Imsachinsingh00 commited on
Commit
b6103f1
Β·
verified Β·
1 Parent(s): 957517f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +65 -101
README.md CHANGED
@@ -1,29 +1,44 @@
1
  ---
2
  license: apache-2.0
3
- language:
4
- - en
5
- base_model:
6
- - mistralai/Mistral-7B-v0.1
7
- pipeline_tag: text2text-generation
8
  tags:
9
- - summerization
10
- - lora
11
- - medical
12
- - mistral
13
- - peft
14
- - mts-dialog
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ---
16
- # 🧠 LoRA Fine-Tuned Mistral-7B on MTS-Dialog Dataset
17
 
18
- This repository contains a LoRA fine-tuned version of the [`mistralai/Mistral-7B-v0.1`](https://huggingface.co/mistralai/Mistral-7B-v0.1) model on the **MTS-Dialog** dataset for medical dialogue summarization.
 
 
19
 
20
  ---
21
 
22
  ## πŸ“˜ Model Summary
23
 
24
- - **Base Model**: Mistral-7B (v0.1)
25
- - **Technique**: LoRA (Low-Rank Adaptation)
26
- - **Framework**: πŸ€— Hugging Face Transformers + PEFT + bitsandbytes
 
27
  - **Task**: Medical dialogue summarization
28
  - **Dataset**: [MTS-Dialog](https://github.com/abachaa/MTS-Dialog)
29
 
@@ -31,65 +46,26 @@ This repository contains a LoRA fine-tuned version of the [`mistralai/Mistral-7B
31
 
32
  ## πŸ₯ Task Description
33
 
34
- The goal is to generate concise summaries of doctor-patient interactions, tailored to specific sections of the medical record (e.g., GENHX, HPI, ROS). This is useful for clinical documentation automation and decision support.
35
-
36
- Each training sample follows this pattern:
37
-
38
- """
39
- Example 1:
40
- Dialogue:
41
- Doctor: Hello, Mrs. Smith. What seems to be troubling you today?
42
- Patient: I’ve been having shortness of breath and a mild cough for two weeks.
43
- Doctor: Any history of asthma or allergies?
44
- Patient: No, I’ve never had any breathing problems before.
45
- Summary:
46
- The patient, a middle-aged woman, presented with a two-week history of shortness of breath and mild cough without prior respiratory conditions. The physician asked about asthma/allergies, which the patient denied.
47
-
48
- Example 2:
49
- Dialogue:
50
- Doctor: Good morning. How are you feeling since your last visit?
51
- Patient: I still have a sharp pain in my right knee when I climb stairs.
52
- Doctor: Does the pain radiate anywhere else?
53
- Patient: No, it’s just in my knee. It started about a month ago.
54
- Summary:
55
- The patient continues to experience sharp knee pain exacerbated by stair climbing for one month, localized to the right knee with no radiation.
56
- """
57
-
58
- new_dialogue_header = "GENHX"
59
- new_dialogue_text = """
60
- Doctor: What brings you back into the clinic today, miss?
61
- Patient: I've had chest pain for the last few days.
62
- Doctor: When did it start?
63
- """
64
-
65
- inference_prompt = few_shot_prompts + f"""
66
-
67
- Now you:
68
- Summarize the following dialogue for section: {new_dialogue_header}
69
- {new_dialogue_text}
70
- Summary:
71
- """
72
-
73
-
74
 
75
  ---
76
 
77
- ## πŸ“Š Training Configuration
78
 
79
- - **LoRA Rank**: `r=4`
80
- - **Epochs**: `3`
81
- - **Batch Size**: `4 (gradient_accumulation=4)`
82
- - **Learning Rate**: `3e-4`
83
- - **Quantization**: 4-bit using `bitsandbytes`
84
- - **Device**: `cuda:0` (single GPU)
 
 
85
 
86
- Due to limited GPU resources (office laptop), training was intentionally short with a reduced LoRA rank and limited epochs. This led to **suboptimal performance**, which can be improved with longer training and higher-rank adapters.
87
 
88
  ---
89
 
90
- ## πŸ“ˆ Evaluation Metrics
91
-
92
- Final validation metrics after 3 epochs:
93
 
94
  | Metric | Score |
95
  |-----------|--------|
@@ -98,55 +74,43 @@ Final validation metrics after 3 epochs:
98
  | ROUGE-L | 0.0900 |
99
  | BLEU | 0.0260 |
100
 
101
- > ⚠️ **Note**: These results are lower than expected due to low-rank LoRA (`r=4`) and only 3 epochs. Further tuning (e.g. `r=8`, `epochs=10`) on better GPUs will likely improve performance.
102
-
103
  ---
104
 
105
- ## πŸ’‘ Prompting Examples
106
-
107
- **Input**:
108
 
109
-
110
- # ---------------------------------------------
111
- # Example A (Influenza Suspect Dialogue)
112
- # ---------------------------------------------
113
- exampleA = """
114
- Doctor: Hello, Mr. Patel. Are you having any fever or chills?
115
- Patient: Yes, I’ve had a 102Β°F fever since yesterday and chills last night.
116
- Doctor: Any cough or stuffy nose?
117
- Patient: Mild cough and some congestion.
118
- Doctor: Do you have body aches?
119
- Patient: Yes, I feel sore all over.
120
  Summary:
121
- """
122
-
123
- Example A Generated Summary:
124
- This is a case of influenza with fever, cough, and myalgia. The patient also has a history of asthma and hypertension. He has not been vaccinated against the flu this year.
125
-
126
-
127
- ---
128
 
129
- ## πŸ“ Files
130
 
131
- - `config.json` – PEFT LoRA config
132
- - `adapter_model.bin` – LoRA adapter weights
133
- - `tokenizer/` – Tokenizer files
134
- - `README.md` – This model card
135
 
136
- ---
137
-
138
- ## πŸ”„ How to Use
139
-
140
- ```python
141
  from transformers import AutoTokenizer, AutoModelForCausalLM
142
  from peft import PeftModel
143
 
144
  model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1", load_in_4bit=True)
145
  model = PeftModel.from_pretrained(model, "Imsachinsingh00/Fine_tuned_LoRA_Mistral_MTSDialog_Summarization")
 
146
 
147
  tokenizer = AutoTokenizer.from_pretrained("Imsachinsingh00/Fine_tuned_LoRA_Mistral_MTSDialog_Summarization")
148
 
149
  prompt = "Summarize the following dialogue for section: HPI\nDoctor: Hello, what brings you in?\nPatient: I've been dizzy for two days.\nSummary:"
150
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
151
  output = model.generate(**inputs, max_new_tokens=150)
152
- print(tokenizer.decode(output[0], skip_special_tokens=True))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
 
 
 
 
 
3
  tags:
4
+ - medical
5
+ - summarization
6
+ - lora
7
+ - mistral
8
+ - dialogue
9
+ - peft
10
+ model-index:
11
+ - name: Fine-tuned Mistral-7B (LoRA) on MTS-Dialog
12
+ results:
13
+ - task:
14
+ type: summarization
15
+ metrics:
16
+ - name: ROUGE-1
17
+ type: rouge
18
+ value: 0.1318
19
+ - name: ROUGE-2
20
+ type: rouge
21
+ value: 0.0456
22
+ - name: ROUGE-L
23
+ type: rouge
24
+ value: 0.0900
25
+ - name: BLEU
26
+ type: bleu
27
+ value: 0.0260
28
  ---
 
29
 
30
+ # 🧠 LoRA Fine-Tuned Mistral-7B on MTS-Dialog
31
+
32
+ This repository contains a LoRA fine-tuned version of [`mistralai/Mistral-7B-v0.1`](https://huggingface.co/mistralai/Mistral-7B-v0.1) for medical dialogue summarization, trained on the [MTS-Dialog](https://github.com/abachaa/MTS-Dialog) dataset.
33
 
34
  ---
35
 
36
  ## πŸ“˜ Model Summary
37
 
38
+ - **Base Model**: `mistralai/Mistral-7B-v0.1`
39
+ - **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
40
+ - **Frameworks**: πŸ€— Transformers, PEFT, bitsandbytes
41
+ - **Quantization**: 4-bit
42
  - **Task**: Medical dialogue summarization
43
  - **Dataset**: [MTS-Dialog](https://github.com/abachaa/MTS-Dialog)
44
 
 
46
 
47
  ## πŸ₯ Task Description
48
 
49
+ This model is trained to summarize doctor-patient conversations into concise clinical notes, categorized by sections such as `GENHX`, `HPI`, `ROS`, etc. These summaries assist with EHR documentation and clinical decision-making.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  ---
52
 
53
+ ## βš™οΈ Training Configuration
54
 
55
+ | Parameter | Value |
56
+ |--------------------|---------------|
57
+ | LoRA Rank | 4 |
58
+ | Epochs | 3 |
59
+ | Batch Size | 4 (Γ—4 grad. acc.) |
60
+ | Learning Rate | 3e-4 |
61
+ | Device | CUDA:0 |
62
+ | Quantization | 4-bit (bnb) |
63
 
64
+ > ⚠️ Due to limited GPU resources (office laptop), training was constrained to 3 epochs and a small LoRA rank. Performance is expected to improve significantly with extended training and better hardware.
65
 
66
  ---
67
 
68
+ ## πŸ“Š Evaluation Metrics
 
 
69
 
70
  | Metric | Score |
71
  |-----------|--------|
 
74
  | ROUGE-L | 0.0900 |
75
  | BLEU | 0.0260 |
76
 
 
 
77
  ---
78
 
79
+ ## πŸ’‘ Example Prompt
 
 
80
 
81
+ ```text
82
+ Summarize the following dialogue for section: GENHX
83
+ Doctor: What brings you back into the clinic today, miss?
84
+ Patient: I've had chest pain for the last few days.
85
+ Doctor: When did it start?
 
 
 
 
 
 
86
  Summary:
 
 
 
 
 
 
 
87
 
 
88
 
89
+ ## πŸ§ͺ Inference Code
 
 
 
90
 
 
 
 
 
 
91
  from transformers import AutoTokenizer, AutoModelForCausalLM
92
  from peft import PeftModel
93
 
94
  model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1", load_in_4bit=True)
95
  model = PeftModel.from_pretrained(model, "Imsachinsingh00/Fine_tuned_LoRA_Mistral_MTSDialog_Summarization")
96
+ model.eval()
97
 
98
  tokenizer = AutoTokenizer.from_pretrained("Imsachinsingh00/Fine_tuned_LoRA_Mistral_MTSDialog_Summarization")
99
 
100
  prompt = "Summarize the following dialogue for section: HPI\nDoctor: Hello, what brings you in?\nPatient: I've been dizzy for two days.\nSummary:"
101
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
102
  output = model.generate(**inputs, max_new_tokens=150)
103
+ print(tokenizer.decode(output[0], skip_special_tokens=True))
104
+
105
+
106
+ ## πŸ“ Included Files
107
+
108
+ - `config.json` – PEFT configuration for LoRA
109
+ - `adapter_model.bin` – LoRA adapter weights
110
+ - `tokenizer/` – Tokenizer files
111
+ - `README.md` – This model card
112
+
113
+ ## πŸ“Œ Notes
114
+
115
+ - 🚫 This is not a fully optimized clinical model β€” only a proof of concept.
116
+ - πŸ’‘ Consider training longer (`epochs=10`, `rank=8`) on GPUs with higher VRAM for better results.