Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
tags:
|
| 5 |
+
- Medicine
|
| 6 |
+
datasets:
|
| 7 |
+
- epfl-llm/guidelines
|
| 8 |
+
license: llama2
|
| 9 |
+
base_model: microsoft/phi-2
|
| 10 |
+
---
|
| 11 |
+
# Model Card for Model ID
|
| 12 |
+
|
| 13 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 14 |
+
phi-2-meditron is a finetuned version of [`epfl-llm/meditron-7b`](https://huggingface.co/epfl-llm/meditron-7b) using SFT Training on the Meditron Dataset.
|
| 15 |
+
This model can answer information about different excplicit ideas in medicine (see [`epfl-llm/meditron-7b`](https://huggingface.co/epfl-llm/meditron-7b) for more info)
|
| 16 |
+
|
| 17 |
+
### Model Description
|
| 18 |
+
|
| 19 |
+
- **Finetuned by:** [`Mohamad Alhajar`](https://www.linkedin.com/in/muhammet-alhajar/)
|
| 20 |
+
- **Language(s) (NLP):** English
|
| 21 |
+
- **Finetuned from model:** [`microsoft/phi-2`](https://huggingface.co/microsoft/phi-2)
|
| 22 |
+
|
| 23 |
+
### Prompt Template
|
| 24 |
+
```
|
| 25 |
+
### Instruction:
|
| 26 |
+
|
| 27 |
+
<prompt> (without the <>)
|
| 28 |
+
|
| 29 |
+
### Response:
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
## How to Get Started with the Model
|
| 34 |
+
|
| 35 |
+
Use the code sample provided in the original post to interact with the model.
|
| 36 |
+
```python
|
| 37 |
+
from transformers import AutoTokenizer,AutoModelForCausalLM
|
| 38 |
+
|
| 39 |
+
model_id = "malhajar/phi-2-meditron"
|
| 40 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
|
| 41 |
+
device_map="auto",
|
| 42 |
+
torch_dtype=torch.float16,
|
| 43 |
+
revision="main")
|
| 44 |
+
|
| 45 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 46 |
+
|
| 47 |
+
question: "what is tract infection?"
|
| 48 |
+
# For generating a response
|
| 49 |
+
prompt = '''
|
| 50 |
+
### Instruction:
|
| 51 |
+
{question}
|
| 52 |
+
|
| 53 |
+
### Response:'''
|
| 54 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
| 55 |
+
output = model.generate(inputs=input_ids,max_new_tokens=512,pad_token_id=tokenizer.eos_token_id,top_k=50, do_sample=True,trust_remote_code= True
|
| 56 |
+
top_p=0.95)
|
| 57 |
+
response = tokenizer.decode(output[0])
|
| 58 |
+
|
| 59 |
+
print(response)
|
| 60 |
+
```
|