bootscoder commited on
Commit
0dee8c9
·
verified ·
1 Parent(s): fa99a76

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +121 -0
README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: meta-llama/Meta-Llama-3-8B
3
+ library_name: peft
4
+ license: llama3
5
+ language:
6
+ - en
7
+ - zh
8
+ tags:
9
+ - lora
10
+ - sft
11
+ - medical
12
+ - llama3
13
+ - transformers
14
+ - trl
15
+ pipeline_tag: text-generation
16
+ ---
17
+
18
+ # Llama-3-Medical-8B-SFT-LoRA
19
+
20
+ This is a LoRA adapter for Meta-Llama-3-8B, fine-tuned on medical domain data using Supervised Fine-Tuning (SFT).
21
+
22
+ ## Model Details
23
+
24
+ - **Base Model**: Meta-Llama-3-8B
25
+ - **Training Method**: QLoRA (Quantized Low-Rank Adaptation)
26
+ - **Training Framework**: TRL + DeepSpeed + PEFT
27
+ - **Domain**: Medical
28
+ - **Languages**: English and Chinese
29
+ - **License**: Llama 3 License
30
+
31
+ ## Training Details
32
+
33
+ This LoRA adapter was trained using:
34
+ - **Method**: Supervised Fine-Tuning (SFT) with QLoRA
35
+ - **Framework**: Hugging Face TRL, PEFT, DeepSpeed
36
+ - **Data**: Medical domain datasets including medical Q&A, clinical notes, and medical knowledge
37
+ - **LoRA Rank**: Check `adapter_config.json` for details
38
+ - **Training Precision**: Mixed precision (bf16/fp16)
39
+
40
+ ## Usage
41
+
42
+ To use this LoRA adapter, you need to:
43
+
44
+ 1. Install required packages:
45
+ ```bash
46
+ pip install transformers peft torch
47
+ ```
48
+
49
+ 2. Load the model with LoRA adapter:
50
+ ```python
51
+ from transformers import AutoModelForCausalLM, AutoTokenizer
52
+ from peft import PeftModel
53
+
54
+ # Load base model
55
+ base_model = "meta-llama/Meta-Llama-3-8B"
56
+ model = AutoModelForCausalLM.from_pretrained(
57
+ base_model,
58
+ torch_dtype="auto",
59
+ device_map="auto"
60
+ )
61
+ tokenizer = AutoTokenizer.from_pretrained(base_model)
62
+
63
+ # Load LoRA adapter
64
+ model = PeftModel.from_pretrained(model, "bootscoder/Llama-3-Medical-8B-SFT-LoRA")
65
+
66
+ # Generate text
67
+ inputs = tokenizer("What is diabetes?", return_tensors="pt").to(model.device)
68
+ outputs = model.generate(**inputs, max_new_tokens=256)
69
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
70
+ ```
71
+
72
+ 3. Or merge LoRA with base model:
73
+ ```python
74
+ from transformers import AutoModelForCausalLM, AutoTokenizer
75
+ from peft import PeftModel
76
+
77
+ base_model = "meta-llama/Meta-Llama-3-8B"
78
+ model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype="auto")
79
+ model = PeftModel.from_pretrained(model, "bootscoder/Llama-3-Medical-8B-SFT-LoRA")
80
+
81
+ # Merge and save
82
+ merged_model = model.merge_and_unload()
83
+ merged_model.save_pretrained("./merged_model")
84
+ ```
85
+
86
+ ## Intended Use
87
+
88
+ This model is intended for:
89
+ - Medical question answering
90
+ - Medical text generation
91
+ - Research and educational purposes in healthcare domain
92
+
93
+ ## Limitations
94
+
95
+ - This model is for research purposes only
96
+ - Should not be used for clinical decision-making without professional medical oversight
97
+ - May generate inaccurate or hallucinated medical information
98
+ - Requires careful validation before any real-world application
99
+
100
+ ## Training Infrastructure
101
+
102
+ - **Hardware**: NVIDIA GPUs with DeepSpeed optimization
103
+ - **Software**: PyTorch, Transformers, PEFT 0.17.1, TRL, DeepSpeed
104
+
105
+ ## Citation
106
+
107
+ If you use this model, please cite:
108
+
109
+ ```bibtex
110
+ @misc{llama3-medical-8b-sft-lora,
111
+ author = {bootscoder},
112
+ title = {Llama-3-Medical-8B-SFT-LoRA},
113
+ year = {2024},
114
+ publisher = {HuggingFace},
115
+ url = {https://huggingface.co/bootscoder/Llama-3-Medical-8B-SFT-LoRA}
116
+ }
117
+ ```
118
+
119
+ ## Disclaimer
120
+
121
+ This model is provided as-is for research and educational purposes. The outputs should not be used as medical advice. Always consult with qualified healthcare professionals for medical decisions.