InferenceLab
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -62,15 +62,31 @@ Users should validate outputs with certified medical professionals. This model i
|
|
62 |
## How to Get Started with the Model
|
63 |
|
64 |
```python
|
65 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
66 |
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
````
|
75 |
|
76 |
## Training Details
|
|
|
62 |
## How to Get Started with the Model
|
63 |
|
64 |
```python
|
|
|
65 |
|
66 |
+
import torch
|
67 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
68 |
|
69 |
+
model_id = "InferenceLab/MediLlama-3.2"
|
70 |
+
|
71 |
+
# Load tokenizer and model
|
72 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
73 |
+
model = AutoModelForCausalLM.from_pretrained(
|
74 |
+
model_id,
|
75 |
+
torch_dtype=torch.bfloat16
|
76 |
+
)
|
77 |
+
|
78 |
+
# Apply the chat template
|
79 |
+
messages = [
|
80 |
+
{"role": "system", "content": "You are a helpful AI assistant."},
|
81 |
+
{"role": "user", "content": "What are the symptoms of diabetes?"},
|
82 |
+
]
|
83 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
84 |
+
chat_input = tokenizer(prompt, return_tensors="pt").to(model.device)
|
85 |
+
|
86 |
+
# Generate response
|
87 |
+
chat_outputs = model.generate(**chat_input, max_new_tokens=500)
|
88 |
+
response = tokenizer.decode(chat_outputs[0][chat_input['input_ids'].shape[-1]:], skip_special_tokens=True) # Decode only the response part
|
89 |
+
print("\nAssistant Response:", response)
|
90 |
````
|
91 |
|
92 |
## Training Details
|