Siddharth63 commited on
Commit
f20584f
·
verified ·
1 Parent(s): c2ad6fe

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -3
README.md CHANGED
@@ -1,3 +1,40 @@
1
- ---
2
- license: artistic-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: artistic-2.0
3
+ ---
4
+ ```
5
+ from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, TrainingArguments
6
+ import torch
7
+
8
+ # Load the model and tokenizer
9
+ model_name = 'Siddharth63/medELM-diseases'
10
+ original_model = AutoModelForCausalLM.from_pretrained(
11
+ model_name,
12
+ torch_dtype=torch.float32,
13
+ device_map="auto",
14
+ trust_remote_code=True # Changed to "auto" for automatic placement
15
+ )
16
+ tokenizer = AutoTokenizer.from_pretrained(
17
+ model_name,
18
+ model_max_length=3072,
19
+ padding_side="right",
20
+ use_fast=True
21
+ )
22
+
23
+ # Ensure inputs are on the correct device
24
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
25
+
26
+ prompt = "Given a text, extract disease entities and their disease types from the text.\n\n### Text:Patient has been vomiting over the past 6 - 8 weeks, since before she was diagnosed with metastatic cancer. She also reports pain over her upper abdomen and has very poor PO intake. She has been feeling progressively weak over this time period. Her vomiting and abdominal pain has not increased from the past weeks, but she just feels more fatigued. She has a chronic non-productive cough as well. No URI symptoms, no urinary complaints. She has been constipated, which improves when she stops her anti-emetics. Last bowel movement was yesterday. She is passing gas. She has lower extremity edema, which has been present for the past several weeks. Of note, she was supposed to have one of her liver mets biopsied in the past several weeks, but she was taking ibuprofen so the biopsy had to be postponed. In the ED, initial VS were: 97.6 117 128/74 18 95% RA. Labs were significant for WBC of 18.7, with 77% polys. UA was significant for ketones. Patient received zofran, NS. She had a CXR that showed new left sided opacity that may reflect PNA superimposed on metastatic diseae vs. lymphangiitic spread of cancer. She received vanc and cefepime for pneumonia.\n\n### Entities:"
27
+ # Tokenize the input text
28
+ inputs = tokenizer(, return_tensors="pt").to(device) # Move inputs to the same device as the model
29
+
30
+ # Generate outputs
31
+ outputs = original_model.generate(
32
+ **inputs,
33
+ max_length=1024,
34
+ do_sample=True,
35
+ temperature=0.01
36
+ )
37
+
38
+ # Decode and print the output
39
+ print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0][len(prompt):].split("}]")[0] + "}]")
40
+ ```