Instructions to use rolmaxx/MediGuide-QLoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use rolmaxx/MediGuide-QLoRA with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct") model = PeftModel.from_pretrained(base_model, "rolmaxx/MediGuide-QLoRA") - Transformers
How to use rolmaxx/MediGuide-QLoRA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rolmaxx/MediGuide-QLoRA")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("rolmaxx/MediGuide-QLoRA", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rolmaxx/MediGuide-QLoRA with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rolmaxx/MediGuide-QLoRA" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rolmaxx/MediGuide-QLoRA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rolmaxx/MediGuide-QLoRA
- SGLang
How to use rolmaxx/MediGuide-QLoRA with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rolmaxx/MediGuide-QLoRA" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rolmaxx/MediGuide-QLoRA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rolmaxx/MediGuide-QLoRA" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rolmaxx/MediGuide-QLoRA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use rolmaxx/MediGuide-QLoRA with Docker Model Runner:
docker model run hf.co/rolmaxx/MediGuide-QLoRA
Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,148 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: Qwen/Qwen2.5-1.5B-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- base_model:adapter:Qwen/Qwen2.5-1.5B-Instruct
|
| 7 |
+
- lora
|
| 8 |
+
- qlora
|
| 9 |
+
- transformers
|
| 10 |
+
- peft
|
| 11 |
+
- medical
|
| 12 |
---
|
| 13 |
+
|
| 14 |
+
# MediGuide QLoRA
|
| 15 |
+
|
| 16 |
+
MediGuide is a fine-tuned medical conversational assistant based on `Qwen/Qwen2.5-1.5B-Instruct`.
|
| 17 |
+
|
| 18 |
+
This repository contains the **QLoRA adapter weights** trained for the MediGuide project. The base Qwen model is not included and must be loaded separately.
|
| 19 |
+
|
| 20 |
+
## Model Details
|
| 21 |
+
|
| 22 |
+
- **Base model:** `Qwen/Qwen2.5-1.5B-Instruct`
|
| 23 |
+
- **Fine-tuning method:** QLoRA
|
| 24 |
+
- **PEFT method:** LoRA
|
| 25 |
+
- **LoRA rank:** 16
|
| 26 |
+
- **LoRA alpha:** 32
|
| 27 |
+
- **LoRA dropout:** 0.05
|
| 28 |
+
- **Task:** Medical dialogue generation
|
| 29 |
+
- **Framework:** Hugging Face Transformers + PEFT
|
| 30 |
+
- **PEFT version:** 0.20.0
|
| 31 |
+
- **License:** See the base model's license and the MediGuide project repository for applicable terms.
|
| 32 |
+
|
| 33 |
+
## Intended Use
|
| 34 |
+
|
| 35 |
+
This adapter is intended for research and educational experimentation with medical dialogue generation and parameter-efficient fine-tuning.
|
| 36 |
+
|
| 37 |
+
It is not intended to replace a qualified healthcare professional, provide definitive diagnoses, or make medical decisions.
|
| 38 |
+
|
| 39 |
+
## Out-of-Scope Use
|
| 40 |
+
|
| 41 |
+
Do not use this model as an autonomous clinical decision-maker, for emergency medical guidance, or as a substitute for professional medical advice.
|
| 42 |
+
|
| 43 |
+
## Training
|
| 44 |
+
|
| 45 |
+
The adapter was trained on the cleaned MediDialog-derived MediGuide dataset used in the project.
|
| 46 |
+
|
| 47 |
+
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.
|
| 48 |
+
|
| 49 |
+
### QLoRA Configuration
|
| 50 |
+
|
| 51 |
+
The adapter targets:
|
| 52 |
+
|
| 53 |
+
- `q_proj`
|
| 54 |
+
- `k_proj`
|
| 55 |
+
- `v_proj`
|
| 56 |
+
- `o_proj`
|
| 57 |
+
- `gate_proj`
|
| 58 |
+
- `up_proj`
|
| 59 |
+
- `down_proj`
|
| 60 |
+
|
| 61 |
+
The adapter configuration uses `r=16`, `alpha=32`, and `dropout=0.05`.
|
| 62 |
+
|
| 63 |
+
## Evaluation
|
| 64 |
+
|
| 65 |
+
On the MediGuide evaluation setup, QLoRA achieved:
|
| 66 |
+
|
| 67 |
+
| Metric | QLoRA |
|
| 68 |
+
|---|---:|
|
| 69 |
+
| ROUGE-1 | 0.1319 |
|
| 70 |
+
| ROUGE-2 | 0.0269 |
|
| 71 |
+
| ROUGE-L | 0.1319 |
|
| 72 |
+
| BLEU | 2.40 |
|
| 73 |
+
| Perplexity | 14.65 |
|
| 74 |
+
|
| 75 |
+
These results come from the project's current evaluation setup and should not be interpreted as clinical performance benchmarks.
|
| 76 |
+
|
| 77 |
+
## How to Use
|
| 78 |
+
|
| 79 |
+
Install the required packages:
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
pip install transformers peft torch
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
Load the base model and adapter:
|
| 86 |
+
|
| 87 |
+
```python
|
| 88 |
+
import torch
|
| 89 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 90 |
+
from peft import PeftModel
|
| 91 |
+
|
| 92 |
+
base_model_id = "Qwen/Qwen2.5-1.5B-Instruct"
|
| 93 |
+
adapter_id = "rolmaxx/MediGuide-QLoRA"
|
| 94 |
+
|
| 95 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
|
| 96 |
+
|
| 97 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 98 |
+
base_model_id,
|
| 99 |
+
torch_dtype=torch.float16,
|
| 100 |
+
device_map="auto"
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
model = PeftModel.from_pretrained(model, adapter_id)
|
| 104 |
+
|
| 105 |
+
prompt = "What are common symptoms of the flu?"
|
| 106 |
+
|
| 107 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 108 |
+
|
| 109 |
+
with torch.no_grad():
|
| 110 |
+
outputs = model.generate(
|
| 111 |
+
**inputs,
|
| 112 |
+
max_new_tokens=256,
|
| 113 |
+
temperature=0.7,
|
| 114 |
+
do_sample=True
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
## Repository
|
| 121 |
+
|
| 122 |
+
GitHub: https://github.com/lxzy8/MediGuide
|
| 123 |
+
|
| 124 |
+
## Files
|
| 125 |
+
|
| 126 |
+
- `adapter_config.json` — PEFT/LoRA adapter configuration
|
| 127 |
+
- `adapter_model.safetensors` — trained adapter weights
|
| 128 |
+
|
| 129 |
+
The base Qwen model is not included in this repository.
|
| 130 |
+
|
| 131 |
+
## Limitations
|
| 132 |
+
|
| 133 |
+
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.
|
| 134 |
+
|
| 135 |
+
Model outputs may contain incorrect, incomplete, or unsafe medical information. Human review is required for any real-world medical application.
|
| 136 |
+
|
| 137 |
+
## Citation
|
| 138 |
+
|
| 139 |
+
If you use this adapter in your work, please cite the MediGuide project repository:
|
| 140 |
+
|
| 141 |
+
```text
|
| 142 |
+
MediGuide — QLoRA fine-tuned medical conversational assistant.
|
| 143 |
+
https://github.com/lxzy8/MediGuide
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
## Framework Versions
|
| 147 |
+
|
| 148 |
+
- PEFT: 0.20.0
|