Update README.md
Browse files
README.md
CHANGED
@@ -1,202 +1,83 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
- **
|
22 |
-
- **
|
23 |
-
- **
|
24 |
-
- **
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
- **
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
[
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
200 |
-
### Framework versions
|
201 |
-
|
202 |
-
- PEFT 0.12.0
|
|
|
1 |
+
# LLaMA-2-7B Chat - AI Medical Chatbot
|
2 |
+
|
3 |
+
## Model Overview
|
4 |
+
This model is a fine-tuned version of [NousResearch/Llama-2-7b-chat-hf](https://huggingface.co/NousResearch/Llama-2-7b-chat-hf) on the [AI Medical Chatbot](https://huggingface.co/datasets/ruslanmv/ai-medical-chatbot) dataset, which consists of medical question-answering tasks. It leverages the latest in language model technology for generating accurate and respectful medical assistance responses, providing helpful advice on common medical questions.
|
5 |
+
|
6 |
+
Fine-tuned using LoRA (Low-Rank Adaptation) and quantization techniques, this model is optimized for efficiency while maintaining high-quality, contextually relevant outputs. The training was performed using [PEFT](https://github.com/huggingface/peft) to make the model more lightweight and accessible for a broader range of applications.
|
7 |
+
|
8 |
+
### Model Details
|
9 |
+
- **Model Type**: LLaMA-2 7B (Chat)
|
10 |
+
- **Base Model**: [NousResearch/Llama-2-7b-chat-hf](https://huggingface.co/NousResearch/Llama-2-7b-chat-hf)
|
11 |
+
- **Fine-tuned on**: [AI Medical Chatbot](https://huggingface.co/datasets/ruslanmv/ai-medical-chatbot)
|
12 |
+
- **Parameter Count**: 7 Billion
|
13 |
+
- **Quantization**: Applied for efficient inference
|
14 |
+
- **Training Methodology**: LoRA + PEFT
|
15 |
+
- **Task**: Medical Question Answering (QA)
|
16 |
+
|
17 |
+
## Model Purpose
|
18 |
+
This model was fine-tuned to assist users in answering medical questions, particularly common healthcare concerns such as symptoms, treatments, and remedies. It is **not intended** to replace professional medical consultation but can be used to offer informative, general responses that can help guide users toward appropriate care.
|
19 |
+
|
20 |
+
## Intended Use
|
21 |
+
- **Primary Use Case**: Medical question-answering chatbot
|
22 |
+
- **Intended Users**: Developers or healthcare professionals seeking a chatbot interface for initial user engagement or educational purposes.
|
23 |
+
- **Environment**: Can be deployed in environments where lightweight models are necessary (due to quantization and PEFT optimization).
|
24 |
+
- **Primary Applications**: Healthcare chatbots, medical assistants, online medical question-answering systems.
|
25 |
+
|
26 |
+
### Example Inputs
|
27 |
+
- **User**: "What are the common treatments for a sore throat?"
|
28 |
+
- **Model**: "For a sore throat, common treatments include rest, hydration, throat lozenges, warm saltwater gargles, and over-the-counter pain relief medications. If the sore throat persists, you should consult a doctor as it may indicate a bacterial infection."
|
29 |
+
|
30 |
+
- **User**: "Can you suggest a homeopathic remedy for hair loss?"
|
31 |
+
- **Model**: "Homeopathic remedies like Arnica, Phosphorus, and Silicea are often recommended for hair loss. However, it's important to consult a homeopathic practitioner for a tailored treatment."
|
32 |
+
|
33 |
+
## Training Dataset
|
34 |
+
- **Dataset**: [AI Medical Chatbot](https://huggingface.co/datasets/ruslanmv/ai-medical-chatbot)
|
35 |
+
- This dataset contains a wide variety of medical queries and corresponding answers. The dataset covers questions about symptoms, diagnoses, treatments, and remedies.
|
36 |
+
|
37 |
+
## Training Process
|
38 |
+
The model was trained using the following setup:
|
39 |
+
- **Optimizer**: AdamW
|
40 |
+
- **Batch Size**: 2
|
41 |
+
- **Gradient Accumulation**: 4 steps
|
42 |
+
- **Learning Rate**: 2e-4
|
43 |
+
- **Max Steps**: 5000
|
44 |
+
- **Epochs**: 500 (with early stopping)
|
45 |
+
- **Quantization**: Applied for memory efficiency
|
46 |
+
- **LoRA**: Used for parameter-efficient fine-tuning
|
47 |
+
|
48 |
+
## Limitations
|
49 |
+
- **Not a Substitute for Medical Advice**: This model is trained to assist with general medical questions but should **not** be used to make clinical decisions or substitute professional medical advice.
|
50 |
+
- **Biases**: The model's responses may reflect the biases inherent in the dataset it was trained on.
|
51 |
+
- **Data Limitation**: The model may not have been exposed to niche or highly specialized medical knowledge and could provide incomplete or incorrect information in such cases.
|
52 |
+
|
53 |
+
## Ethical Considerations
|
54 |
+
This model is designed to assist with medical-related queries and provide useful responses. However, users are strongly encouraged to consult licensed healthcare providers for serious medical conditions, diagnoses, or treatment plans. Misuse of the model for self-diagnosis or treatment is discouraged.
|
55 |
+
|
56 |
+
### Warning
|
57 |
+
The outputs of this model should not be relied upon for critical or life-threatening situations. It is essential to consult a healthcare professional before taking any medical action based on this model's suggestions.
|
58 |
+
|
59 |
+
## How to Use
|
60 |
+
|
61 |
+
You can load and use this model for medical chatbot applications with ease using the Hugging Face library:
|
62 |
+
|
63 |
+
```python
|
64 |
+
from peft import PeftModel, PeftConfig
|
65 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
66 |
+
|
67 |
+
|
68 |
+
model_id = "NousResearch/Llama-2-7b-chat-hf"
|
69 |
+
config = PeftConfig.from_pretrained( 'MassMin/llama2_ai_medical_chatbot')
|
70 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
71 |
+
model = PeftModel.from_pretrained(model, 'MassMin/llama2_ai_medical_chatbot')
|
72 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
73 |
+
tokenizer.pad_token = tokenizer.eos_token
|
74 |
+
pipe = pipeline(
|
75 |
+
"text-generation",
|
76 |
+
model=model,
|
77 |
+
tokenizer=tokenizer,
|
78 |
+
max_length=256
|
79 |
+
)
|
80 |
+
|
81 |
+
prompt='Input your question?.'
|
82 |
+
result = pipe(f"<s>[INST] {prompt} [/INST]")
|
83 |
+
print(result[0]['generated_text'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|