File size: 3,916 Bytes
2fac335
1900bd0
 
 
 
 
 
 
 
 
 
2fac335
1900bd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
base_model: Qwen/Qwen2.5-1.5B-Instruct
library_name: peft
pipeline_tag: text-generation
tags:
- base_model:adapter:Qwen/Qwen2.5-1.5B-Instruct
- lora
- qlora
- transformers
- peft
- medical
---

# MediGuide QLoRA

MediGuide is a fine-tuned medical conversational assistant based on `Qwen/Qwen2.5-1.5B-Instruct`.

This repository contains the **QLoRA adapter weights** trained for the MediGuide project. The base Qwen model is not included and must be loaded separately.

## Model Details

- **Base model:** `Qwen/Qwen2.5-1.5B-Instruct`
- **Fine-tuning method:** QLoRA
- **PEFT method:** LoRA
- **LoRA rank:** 16
- **LoRA alpha:** 32
- **LoRA dropout:** 0.05
- **Task:** Medical dialogue generation
- **Framework:** Hugging Face Transformers + PEFT
- **PEFT version:** 0.20.0
- **License:** See the base model's license and the MediGuide project repository for applicable terms.

## Intended Use

This adapter is intended for research and educational experimentation with medical dialogue generation and parameter-efficient fine-tuning.

It is not intended to replace a qualified healthcare professional, provide definitive diagnoses, or make medical decisions.

## Out-of-Scope Use

Do not use this model as an autonomous clinical decision-maker, for emergency medical guidance, or as a substitute for professional medical advice.

## Training

The adapter was trained on the cleaned MediDialog-derived MediGuide dataset used in the project.

The project uses an 80/10/10 train/validation/test split and compares multiple parameter-efficient fine-tuning approaches, including LoRA, QLoRA, and Prompt Tuning.

### QLoRA Configuration

The adapter targets:

- `q_proj`
- `k_proj`
- `v_proj`
- `o_proj`
- `gate_proj`
- `up_proj`
- `down_proj`

The adapter configuration uses `r=16`, `alpha=32`, and `dropout=0.05`.

## Evaluation

On the MediGuide evaluation setup, QLoRA achieved:

| Metric | QLoRA |
|---|---:|
| ROUGE-1 | 0.1319 |
| ROUGE-2 | 0.0269 |
| ROUGE-L | 0.1319 |
| BLEU | 2.40 |
| Perplexity | 14.65 |

These results come from the project's current evaluation setup and should not be interpreted as clinical performance benchmarks.

## How to Use

Install the required packages:

```bash
pip install transformers peft torch
```

Load the base model and adapter:

```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

base_model_id = "Qwen/Qwen2.5-1.5B-Instruct"
adapter_id = "rolmaxx/MediGuide-QLoRA"

tokenizer = AutoTokenizer.from_pretrained(base_model_id)

model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

model = PeftModel.from_pretrained(model, adapter_id)

prompt = "What are common symptoms of the flu?"

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=256,
        temperature=0.7,
        do_sample=True
    )

print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

## Repository

GitHub: https://github.com/lxzy8/MediGuide

## Files

- `adapter_config.json` — PEFT/LoRA adapter configuration
- `adapter_model.safetensors` — trained adapter weights

The base Qwen model is not included in this repository.

## Limitations

The model was trained on a relatively small dataset and evaluated using automated text-generation metrics. Automated metrics such as ROUGE and BLEU do not establish medical correctness, safety, or clinical usefulness.

Model outputs may contain incorrect, incomplete, or unsafe medical information. Human review is required for any real-world medical application.

## Citation

If you use this adapter in your work, please cite the MediGuide project repository:

```text
MediGuide — QLoRA fine-tuned medical conversational assistant.
https://github.com/lxzy8/MediGuide
```

## Framework Versions

- PEFT: 0.20.0