Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- medalpaca/medical_meadow_wikidoc_patient_information
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
---
|
7 |
+
# llama-2-7b-chat-MEDS-12
|
8 |
+
|
9 |
+
This is a `llama-2-7b-chat-hf` model fine-tuned using QLoRA (4-bit precision) on the [`s200862/medical_qa_meds`](https://huggingface.co/datasets/s200862/medical_qa_meds) dataset. This is an adapted version of the [`medalpaca/medical_meadow_wikidoc_patient_information`] (https://huggingface.co/datasets/medalpaca/medical_meadow_wikidoc_patient_information) dataset to match llama-2's instruction format.
|
10 |
+
|
11 |
+
## 🔧 Training
|
12 |
+
|
13 |
+
It was trained on-premise in a jupyter notebook using an Nvidia RTX A4000 GPU with 16GB of VRAM and 16 GB of system RAM.
|
14 |
+
|
15 |
+
## 💻 Usage
|
16 |
+
|
17 |
+
It is intended to give answers to medical questions.
|
18 |
+
|
19 |
+
``` python
|
20 |
+
# pip install transformers accelerate
|
21 |
+
|
22 |
+
from transformers import AutoTokenizer
|
23 |
+
import transformers
|
24 |
+
import torch
|
25 |
+
|
26 |
+
model = "s200862/llama-2-7b-chat-MEDS-12"
|
27 |
+
prompt = "What causes Allergy?"
|
28 |
+
|
29 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
30 |
+
pipeline = transformers.pipeline(
|
31 |
+
"text-generation",
|
32 |
+
model=model,
|
33 |
+
torch_dtype=torch.float16,
|
34 |
+
device_map="auto",
|
35 |
+
)
|
36 |
+
|
37 |
+
sequences = pipeline(
|
38 |
+
f'<s>[INST] {prompt} [/INST]',
|
39 |
+
do_sample=True,
|
40 |
+
top_k=10,
|
41 |
+
num_return_sequences=1,
|
42 |
+
eos_token_id=tokenizer.eos_token_id,
|
43 |
+
max_length=200,
|
44 |
+
)
|
45 |
+
for seq in sequences:
|
46 |
+
print(f"Result: {seq['generated_text']}")
|
47 |
+
```
|