InferenceLab commited on
Commit
01c9212
·
verified ·
1 Parent(s): a256681

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -7
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
- model = AutoModelForCausalLM.from_pretrained("InferenceLab/MediLlama-3.2")
68
- tokenizer = AutoTokenizer.from_pretrained("InferenceLab/MediLlama-3.2")
69
 
70
- input_text = "What are the symptoms of diabetes?"
71
- inputs = tokenizer(input_text, return_tensors="pt")
72
- outputs = model.generate(**inputs)
73
- print(tokenizer.decode(outputs[0]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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