Instructions to use eswardivi/medical_qa_alpaca with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use eswardivi/medical_qa_alpaca with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("yahma/llama-7b-hf") model = PeftModel.from_pretrained(base_model, "eswardivi/medical_qa_alpaca") - Notebooks
- Google Colab
- Kaggle
Upload 4 files
Browse files- README.md +20 -0
- adapter_config.json +22 -0
- adapter_model.bin +3 -0
- config.md +62 -0
README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: peft
|
| 3 |
+
---
|
| 4 |
+
## Training procedure
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
The following `bitsandbytes` quantization config was used during training:
|
| 8 |
+
- load_in_8bit: True
|
| 9 |
+
- load_in_4bit: False
|
| 10 |
+
- llm_int8_threshold: 6.0
|
| 11 |
+
- llm_int8_skip_modules: None
|
| 12 |
+
- llm_int8_enable_fp32_cpu_offload: False
|
| 13 |
+
- llm_int8_has_fp16_weight: False
|
| 14 |
+
- bnb_4bit_quant_type: fp4
|
| 15 |
+
- bnb_4bit_use_double_quant: False
|
| 16 |
+
- bnb_4bit_compute_dtype: float32
|
| 17 |
+
### Framework versions
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
- PEFT 0.4.0.dev0
|
adapter_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model_name_or_path": "yahma/llama-7b-hf",
|
| 3 |
+
"bias": "none",
|
| 4 |
+
"fan_in_fan_out": false,
|
| 5 |
+
"inference_mode": true,
|
| 6 |
+
"init_lora_weights": true,
|
| 7 |
+
"layers_pattern": null,
|
| 8 |
+
"layers_to_transform": null,
|
| 9 |
+
"lora_alpha": 16,
|
| 10 |
+
"lora_dropout": 0.05,
|
| 11 |
+
"modules_to_save": null,
|
| 12 |
+
"peft_type": "LORA",
|
| 13 |
+
"r": 16,
|
| 14 |
+
"revision": null,
|
| 15 |
+
"target_modules": [
|
| 16 |
+
"q_proj",
|
| 17 |
+
"k_proj",
|
| 18 |
+
"v_proj",
|
| 19 |
+
"o_proj"
|
| 20 |
+
],
|
| 21 |
+
"task_type": "CAUSAL_LM"
|
| 22 |
+
}
|
adapter_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8d2f68cfad1b8053786403f759e7ecac6396803886afee7172135b296ab1370
|
| 3 |
+
size 67201357
|
config.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Trained using https://github.com/tloen/alpaca-lora
|
| 2 |
+
with removing the lines
|
| 3 |
+
|
| 4 |
+
```
|
| 5 |
+
old_state_dict = model.state_dict
|
| 6 |
+
model.state_dict = (
|
| 7 |
+
lambda self, *_, **__: get_peft_model_state_dict(
|
| 8 |
+
self, old_state_dict()
|
| 9 |
+
)
|
| 10 |
+
).__get__(model, type(model))
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
causing problem.
|
| 14 |
+
|
| 15 |
+
base_model: yahma/llama-7b-hf
|
| 16 |
+
data_path: prognosis/medical_qa_alpaca
|
| 17 |
+
output_dir: ./lora-alpaca
|
| 18 |
+
batch_size: 128
|
| 19 |
+
micro_batch_size: 8
|
| 20 |
+
num_epochs: 5
|
| 21 |
+
learning_rate: 0.0003
|
| 22 |
+
cutoff_len: 512
|
| 23 |
+
val_set_size: 0.1
|
| 24 |
+
lora_r: 16
|
| 25 |
+
lora_alpha: 16
|
| 26 |
+
lora_dropout: 0.05
|
| 27 |
+
lora_target_modules: ['q_proj', 'k_proj', 'v_proj', 'o_proj']
|
| 28 |
+
train_on_inputs: True
|
| 29 |
+
add_eos_token: False
|
| 30 |
+
group_by_length: True
|
| 31 |
+
wandb_project: medical_alpaca_hf
|
| 32 |
+
wandb_run_name: run_3
|
| 33 |
+
wandb_watch:
|
| 34 |
+
wandb_log_model:
|
| 35 |
+
resume_from_checkpoint: False
|
| 36 |
+
prompt template: alpaca
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
### Command used
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
Finetuning
|
| 43 |
+
```
|
| 44 |
+
python finetune.py --base_model 'yahma/llama-7b-hf' --data_path 'prognosis/medical_qa_alpaca' --output_dir './lora-alpaca' --wandb_project 'medical_alpaca_hf' --wandb_run_name 'run_3' --lora_target_modules '[q_proj,k_proj,v_proj,o_proj]' --num_epochs 5 --cutoff_len 512 --group_by_length --val_set_size 0.1 --lora_r=16 --micro_batch_size=8
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Generating
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
+
python generate.py \
|
| 51 |
+
--load_8bit \
|
| 52 |
+
--base_model 'yahma/llama-7b-hf' \
|
| 53 |
+
--lora_weights 'alpaca-lora/lora-alpaca' \
|
| 54 |
+
--share_gradio
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
git lfs
|
| 58 |
+
|
| 59 |
+
```
|
| 60 |
+
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
|
| 61 |
+
sudo apt-get install git-lfs
|
| 62 |
+
```
|