Update README.md
Browse files
README.md
CHANGED
@@ -37,17 +37,32 @@ The training logs (attached below) indicate:
|
|
37 |
## Usage
|
38 |
To load and use the model:
|
39 |
```python
|
|
|
|
|
40 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
41 |
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
def generate_medical_response(prompt):
|
46 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
47 |
-
outputs = model.generate(**inputs)
|
48 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
49 |
|
50 |
-
print(generate_medical_response(
|
51 |
```
|
52 |
|
53 |
## Future Improvements
|
|
|
37 |
## Usage
|
38 |
To load and use the model:
|
39 |
```python
|
40 |
+
import os
|
41 |
+
import torch
|
42 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
43 |
|
44 |
+
os.environ["HF_KEY"] = "enter key to access your hugging face account in order to import the model"
|
45 |
+
|
46 |
+
model_name = "Tanmay3004/llama_medical"
|
47 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=os.getenv("HF_KEY"))
|
48 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=os.getenv("HF_KEY"))
|
49 |
+
|
50 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
51 |
+
model.to(device)
|
52 |
+
|
53 |
+
template = "Question:\n{question}\n\nAnswer:\n{answer}"
|
54 |
+
|
55 |
+
prompt = template.format(
|
56 |
+
question="What are the treatments for Paget's Disease of Bone?",
|
57 |
+
answer=""
|
58 |
+
)
|
59 |
|
60 |
def generate_medical_response(prompt):
|
61 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(device) # Move inputs to the same device
|
62 |
+
outputs = model.generate(**inputs, max_new_tokens=100)
|
63 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
64 |
|
65 |
+
print(generate_medical_response(prompt))
|
66 |
```
|
67 |
|
68 |
## Future Improvements
|