Text Generation
PEFT
Safetensors
GGUF
English
medical
healthcare
clinical
qlora
lora
qwen
qwen2.5
llama
llama-3.2
ollama
conversational
Instructions to use Davis426/COMP8420-Healthcare-LLM-Assistant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with PEFT:
Task type is invalid.
- llama-cpp-python
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Davis426/COMP8420-Healthcare-LLM-Assistant", filename="llama32/llama32-medqa-gguf/model.Q4_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Use Docker
docker model run hf.co/Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Davis426/COMP8420-Healthcare-LLM-Assistant" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Davis426/COMP8420-Healthcare-LLM-Assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
- Ollama
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with Ollama:
ollama run hf.co/Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
- Unsloth Studio new
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Davis426/COMP8420-Healthcare-LLM-Assistant to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Davis426/COMP8420-Healthcare-LLM-Assistant to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Davis426/COMP8420-Healthcare-LLM-Assistant to start chatting
- Pi new
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with Docker Model Runner:
docker model run hf.co/Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
- Lemonade
How to use Davis426/COMP8420-Healthcare-LLM-Assistant with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Davis426/COMP8420-Healthcare-LLM-Assistant:Q4_K_M
Run and chat with the model
lemonade run user.COMP8420-Healthcare-LLM-Assistant-Q4_K_M
List all available models
lemonade list
Update combined model card
Browse files
README.md
CHANGED
|
@@ -4,7 +4,9 @@ language:
|
|
| 4 |
- en
|
| 5 |
library_name: peft
|
| 6 |
pipeline_tag: text-generation
|
| 7 |
-
base_model:
|
|
|
|
|
|
|
| 8 |
tags:
|
| 9 |
- medical
|
| 10 |
- healthcare
|
|
@@ -14,26 +16,43 @@ tags:
|
|
| 14 |
- lora
|
| 15 |
- qwen
|
| 16 |
- qwen2.5
|
|
|
|
|
|
|
| 17 |
- ollama
|
| 18 |
- gguf
|
| 19 |
---
|
| 20 |
|
| 21 |
-
#
|
| 22 |
|
| 23 |
-
QLoRA fine-
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
(see the GitHub README for the full system: voice input, PII railguard, multi-agent RAG, evaluation notebooks.)
|
| 27 |
|
| 28 |
## What is in this repo
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
The merged-but-unquantized `safetensors` is intentionally not uploaded; it is redundant for end users (use the GGUF for Ollama OR the adapter for transformers+peft).
|
| 37 |
|
| 38 |
## Training data
|
| 39 |
|
|
@@ -48,13 +67,14 @@ The merged-but-unquantized `safetensors` is intentionally not uploaded; it is re
|
|
| 48 |
| DrugBank `side_effects` | ~1,500 | side-effect summaries |
|
| 49 |
| DrugBank `mechanism_of_action` | ~1,500 | MoA explanations |
|
| 50 |
|
| 51 |
-
90 / 5 / 5 random split with `seed=42`. The OpenAI messages format
|
| 52 |
|
| 53 |
## Training setup
|
| 54 |
|
|
|
|
|
|
|
| 55 |
| Hyperparameter | Value |
|
| 56 |
|---|---|
|
| 57 |
-
| Base | `Qwen/Qwen2.5-1.5B-Instruct` (4-bit NF4 via bitsandbytes) |
|
| 58 |
| LoRA rank `r` | 16 |
|
| 59 |
| LoRA alpha | 32 |
|
| 60 |
| LoRA target modules | all 7 projection layers (q, k, v, o, gate, up, down) |
|
|
@@ -66,9 +86,17 @@ The merged-but-unquantized `safetensors` is intentionally not uploaded; it is re
|
|
| 66 |
| Optimizer | `adamw_8bit` |
|
| 67 |
| Seed | 42 |
|
| 68 |
| Hardware | RTX 4060 (8 GB, bf16) |
|
| 69 |
-
| Wall time | ~5,667 seconds (~95 minutes) |
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
## Evaluation
|
| 74 |
|
|
@@ -79,13 +107,15 @@ Two evaluation passes:
|
|
| 79 |
1. **Surface metrics**: ROUGE-1/2/L + BERTScore-F1 (with the PubMedBERT backbone)
|
| 80 |
2. **LLM-as-judge**: GPT-5.4 scoring blind on Accuracy / Completeness / Clarity / Safety (0-10), reference-aware
|
| 81 |
|
| 82 |
-
**Headline findings (vs GPT-5.5):**
|
| 83 |
|
| 84 |
-
-
|
| 85 |
- The win is driven by **template substitution**, not factual improvement. The training set includes 71+ DrugBank entries sharing the skeleton "`{X}` pollen is the pollen of the `{X}` plant. `{X}` pollen is mainly used in allergenic testing." The fine-tune learns the template and slot-fills the entity at inference; ROUGE and BERTScore both reward this even when the substituted entity is wrong.
|
| 86 |
- Verified 0 / 450 literal Q+A pair overlap between train and test, so this is template generalization, not memorization.
|
| 87 |
- Under the LLM-as-judge Accuracy dimension, GPT-5.5 leads (judge results in the parent repo's `results/llm_judge_evaluation.csv`).
|
| 88 |
|
|
|
|
|
|
|
| 89 |
Detailed numbers and charts live in the parent repo:
|
| 90 |
|
| 91 |
- `results/llm_generation_evaluation.csv` + `llm_generation_eval_chart.png` + `llm_generation_bertscore_chart.png`
|
|
@@ -95,34 +125,45 @@ Detailed numbers and charts live in the parent repo:
|
|
| 95 |
|
| 96 |
## How to use
|
| 97 |
|
|
|
|
|
|
|
| 98 |
### Option 1 β Ollama (recommended for local serving)
|
| 99 |
|
| 100 |
```bash
|
| 101 |
-
# Fetch
|
| 102 |
huggingface-cli download Davis426/COMP8420-Healthcare-LLM-Assistant \
|
| 103 |
-
--include "qwen-medqa-gguf/*" \
|
| 104 |
--local-dir ./models
|
| 105 |
|
| 106 |
# Register with Ollama
|
| 107 |
-
cd ./models/qwen-medqa-gguf
|
| 108 |
ollama create medqa-qwen -f Modelfile
|
| 109 |
|
| 110 |
# Try it
|
| 111 |
ollama run medqa-qwen "What is amoxicillin used for?"
|
| 112 |
```
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
### Option 2 β transformers + peft (Python)
|
| 115 |
|
| 116 |
```python
|
| 117 |
from peft import PeftModel
|
| 118 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 119 |
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
adapter_id = "Davis426/COMP8420-Healthcare-LLM-Assistant"
|
| 122 |
|
| 123 |
tokenizer = AutoTokenizer.from_pretrained(base_id)
|
| 124 |
base = AutoModelForCausalLM.from_pretrained(base_id, device_map="auto")
|
| 125 |
-
model = PeftModel.from_pretrained(base, adapter_id, subfolder=
|
| 126 |
|
| 127 |
messages = [{"role": "user", "content": "What is amoxicillin used for?"}]
|
| 128 |
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
|
|
@@ -134,31 +175,33 @@ print(tokenizer.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
|
|
| 134 |
|
| 135 |
```bash
|
| 136 |
huggingface-cli download Davis426/COMP8420-Healthcare-LLM-Assistant \
|
| 137 |
-
--include "qwen-medqa-gguf/model.Q4_K_M.gguf" --local-dir .
|
| 138 |
|
| 139 |
-
./llama-cli -m model.Q4_K_M.gguf
|
|
|
|
| 140 |
```
|
| 141 |
|
| 142 |
## Limitations
|
| 143 |
|
| 144 |
-
|
| 145 |
|
| 146 |
-
- **Catastrophic forgetting on out-of-distribution prompts.** Fine-tuning on a narrow Q&A distribution at 1.5B parameter scale shifts
|
| 147 |
-
- **Weakened in-context grounding.** Every training pair has shape `user_question -> answer`, with no retrieved-context block. As a result
|
| 148 |
-
- **No factual safety net.** Both training data and evaluation rely on existing biomedical corpora; the
|
| 149 |
- **English only.**
|
|
|
|
| 150 |
|
| 151 |
## License
|
| 152 |
|
| 153 |
-
`cc-by-nc-4.0`
|
| 154 |
|
| 155 |
## Citation
|
| 156 |
|
| 157 |
If you use or build on this work, please reference:
|
| 158 |
|
| 159 |
```bibtex
|
| 160 |
-
@misc{comp8420-2026-medqa
|
| 161 |
-
title = {Healthcare NLP Assistant: QLoRA
|
| 162 |
author = {Davis426},
|
| 163 |
year = {2026},
|
| 164 |
howpublished = {\url{https://huggingface.co/Davis426/COMP8420-Healthcare-LLM-Assistant}}
|
|
@@ -168,7 +211,8 @@ If you use or build on this work, please reference:
|
|
| 168 |
Built on top of:
|
| 169 |
|
| 170 |
- Qwen2.5 (Alibaba): https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct
|
|
|
|
| 171 |
- QLoRA (Dettmers et al., 2023): https://arxiv.org/abs/2305.14314
|
| 172 |
-
- MASS-RAG (Xiao, Huang, Liu, Xie, 2026): https://arxiv.org/abs/2604.18509 (used by the parent repo's retrieval pipeline that
|
| 173 |
- Unsloth: https://github.com/unslothai/unsloth
|
| 174 |
- llama.cpp + Ollama for GGUF serving
|
|
|
|
| 4 |
- en
|
| 5 |
library_name: peft
|
| 6 |
pipeline_tag: text-generation
|
| 7 |
+
base_model:
|
| 8 |
+
- Qwen/Qwen2.5-1.5B-Instruct
|
| 9 |
+
- meta-llama/Llama-3.2-1B-Instruct
|
| 10 |
tags:
|
| 11 |
- medical
|
| 12 |
- healthcare
|
|
|
|
| 16 |
- lora
|
| 17 |
- qwen
|
| 18 |
- qwen2.5
|
| 19 |
+
- llama
|
| 20 |
+
- llama-3.2
|
| 21 |
- ollama
|
| 22 |
- gguf
|
| 23 |
---
|
| 24 |
|
| 25 |
+
# Healthcare LLM Assistant β QLoRA fine-tunes
|
| 26 |
|
| 27 |
+
Two parallel QLoRA fine-tunes of small instruct models on the same 9,000-pair mix of public biomedical Q&A, served side-by-side in the parent project's Streamlit UI for a 3-way bake-off against GPT-5.5.
|
| 28 |
|
| 29 |
+
| Variant | Subfolder | Base | Adapter | GGUF (Q4_K_M) |
|
| 30 |
+
|---|---|---|---|---|
|
| 31 |
+
| **Qwen** | `qwen/` | [`Qwen/Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) | `qwen/qwen-medqa-adapter/` (~82 MB) | `qwen/qwen-medqa-gguf/model.Q4_K_M.gguf` (~941 MB) |
|
| 32 |
+
| **Llama-3.2** | `llama32/` | [`meta-llama/Llama-3.2-1B-Instruct`](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct) | `llama32/llama32-medqa-adapter/` (~50 MB) | `llama32/llama32-medqa-gguf/model.Q4_K_M.gguf` (~770 MB) |
|
| 33 |
+
|
| 34 |
+
Both variants were trained with the same dataset, the same LoRA shape (r=16, Ξ±=32, all 7 projection layers) and the same SFT recipe, so any quality gap isolates the base-model effect.
|
| 35 |
+
|
| 36 |
+
Built as part of the COMP8420 (Macquarie University) main project on a healthcare NLP assistant. Companion code: **https://github.com/NhatNguyen3001/COMP8420-Healthcare-LLM-Assistant**
|
| 37 |
(see the GitHub README for the full system: voice input, PII railguard, multi-agent RAG, evaluation notebooks.)
|
| 38 |
|
| 39 |
## What is in this repo
|
| 40 |
|
| 41 |
+
```
|
| 42 |
+
.
|
| 43 |
+
βββ qwen/
|
| 44 |
+
β βββ qwen-medqa-adapter/ # PEFT LoRA adapter
|
| 45 |
+
β βββ qwen-medqa-gguf/
|
| 46 |
+
β βββ model.Q4_K_M.gguf # Ollama-ready GGUF
|
| 47 |
+
β βββ Modelfile # Ollama registration recipe
|
| 48 |
+
βββ llama32/
|
| 49 |
+
βββ llama32-medqa-adapter/ # PEFT LoRA adapter
|
| 50 |
+
βββ llama32-medqa-gguf/
|
| 51 |
+
βββ model.Q4_K_M.gguf
|
| 52 |
+
βββ Modelfile
|
| 53 |
+
```
|
| 54 |
|
| 55 |
+
The merged-but-unquantized `safetensors` is intentionally not uploaded for either variant; it is redundant for end users (use the GGUF for Ollama OR the adapter for transformers+peft).
|
| 56 |
|
| 57 |
## Training data
|
| 58 |
|
|
|
|
| 67 |
| DrugBank `side_effects` | ~1,500 | side-effect summaries |
|
| 68 |
| DrugBank `mechanism_of_action` | ~1,500 | MoA explanations |
|
| 69 |
|
| 70 |
+
90 / 5 / 5 random split with `seed=42`. The OpenAI messages format is used at JSONL level; each variant's chat template (Qwen2.5 or Llama-3.1) is applied at training time, not stored in the JSONL.
|
| 71 |
|
| 72 |
## Training setup
|
| 73 |
|
| 74 |
+
Same hyperparameters across both variants:
|
| 75 |
+
|
| 76 |
| Hyperparameter | Value |
|
| 77 |
|---|---|
|
|
|
|
| 78 |
| LoRA rank `r` | 16 |
|
| 79 |
| LoRA alpha | 32 |
|
| 80 |
| LoRA target modules | all 7 projection layers (q, k, v, o, gate, up, down) |
|
|
|
|
| 86 |
| Optimizer | `adamw_8bit` |
|
| 87 |
| Seed | 42 |
|
| 88 |
| Hardware | RTX 4060 (8 GB, bf16) |
|
|
|
|
| 89 |
|
| 90 |
+
Per-variant differences:
|
| 91 |
+
|
| 92 |
+
| | Qwen | Llama-3.2 |
|
| 93 |
+
|---|---|---|
|
| 94 |
+
| Base id | `Qwen/Qwen2.5-1.5B-Instruct` (4-bit NF4) | `meta-llama/Llama-3.2-1B-Instruct` (4-bit NF4) |
|
| 95 |
+
| Chat template | `qwen-2.5` | `llama-3.1` |
|
| 96 |
+
| Wall time (3 epochs) | ~95 min | ~30-45 min (smaller base) |
|
| 97 |
+
| Best val loss | 1.5536 (~epoch 1.98) | see `results/training_qlora_llama32.md` in parent repo |
|
| 98 |
+
|
| 99 |
+
Deployed checkpoints are end-of-epoch-3 for both (the "what a full QLoRA run gives you" baseline, not early-stopped).
|
| 100 |
|
| 101 |
## Evaluation
|
| 102 |
|
|
|
|
| 107 |
1. **Surface metrics**: ROUGE-1/2/L + BERTScore-F1 (with the PubMedBERT backbone)
|
| 108 |
2. **LLM-as-judge**: GPT-5.4 scoring blind on Accuracy / Completeness / Clarity / Safety (0-10), reference-aware
|
| 109 |
|
| 110 |
+
**Headline findings (vs GPT-5.5), Qwen variant:**
|
| 111 |
|
| 112 |
+
- The Qwen QLoRA model wins ROUGE-L by ~+0.022 (~+12% relative) and BERTScore-F1 by ~+0.0067 (~+0.8% relative) against GPT-5.5
|
| 113 |
- The win is driven by **template substitution**, not factual improvement. The training set includes 71+ DrugBank entries sharing the skeleton "`{X}` pollen is the pollen of the `{X}` plant. `{X}` pollen is mainly used in allergenic testing." The fine-tune learns the template and slot-fills the entity at inference; ROUGE and BERTScore both reward this even when the substituted entity is wrong.
|
| 114 |
- Verified 0 / 450 literal Q+A pair overlap between train and test, so this is template generalization, not memorization.
|
| 115 |
- Under the LLM-as-judge Accuracy dimension, GPT-5.5 leads (judge results in the parent repo's `results/llm_judge_evaluation.csv`).
|
| 116 |
|
| 117 |
+
**Llama-3.2 variant:** see the 3-way numbers in the parent repo's `results/model_comparison.csv` (refreshed after the Llama run). The same template-substitution dynamic is expected on shared DrugBank slots; the contrast with the Qwen variant isolates the base-model contribution.
|
| 118 |
+
|
| 119 |
Detailed numbers and charts live in the parent repo:
|
| 120 |
|
| 121 |
- `results/llm_generation_evaluation.csv` + `llm_generation_eval_chart.png` + `llm_generation_bertscore_chart.png`
|
|
|
|
| 125 |
|
| 126 |
## How to use
|
| 127 |
|
| 128 |
+
Replace `<variant>` with `qwen` or `llama32` in the examples below.
|
| 129 |
+
|
| 130 |
### Option 1 β Ollama (recommended for local serving)
|
| 131 |
|
| 132 |
```bash
|
| 133 |
+
# Fetch one variant's GGUF + Modelfile
|
| 134 |
huggingface-cli download Davis426/COMP8420-Healthcare-LLM-Assistant \
|
| 135 |
+
--include "qwen/qwen-medqa-gguf/*" \
|
| 136 |
--local-dir ./models
|
| 137 |
|
| 138 |
# Register with Ollama
|
| 139 |
+
cd ./models/qwen/qwen-medqa-gguf
|
| 140 |
ollama create medqa-qwen -f Modelfile
|
| 141 |
|
| 142 |
# Try it
|
| 143 |
ollama run medqa-qwen "What is amoxicillin used for?"
|
| 144 |
```
|
| 145 |
|
| 146 |
+
For the Llama variant, swap every `qwen` for `llama32` (paths) and the Ollama tag to `medqa-llama32`.
|
| 147 |
+
|
| 148 |
+
You can register both side-by-side; one `ollama serve` daemon handles both tags concurrently (`OLLAMA_MAX_LOADED_MODELS` defaults to 3).
|
| 149 |
+
|
| 150 |
### Option 2 β transformers + peft (Python)
|
| 151 |
|
| 152 |
```python
|
| 153 |
from peft import PeftModel
|
| 154 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 155 |
|
| 156 |
+
# pick a variant
|
| 157 |
+
base_id = "Qwen/Qwen2.5-1.5B-Instruct"
|
| 158 |
+
subfolder = "qwen/qwen-medqa-adapter"
|
| 159 |
+
# or:
|
| 160 |
+
# base_id = "meta-llama/Llama-3.2-1B-Instruct"
|
| 161 |
+
# subfolder = "llama32/llama32-medqa-adapter"
|
| 162 |
adapter_id = "Davis426/COMP8420-Healthcare-LLM-Assistant"
|
| 163 |
|
| 164 |
tokenizer = AutoTokenizer.from_pretrained(base_id)
|
| 165 |
base = AutoModelForCausalLM.from_pretrained(base_id, device_map="auto")
|
| 166 |
+
model = PeftModel.from_pretrained(base, adapter_id, subfolder=subfolder)
|
| 167 |
|
| 168 |
messages = [{"role": "user", "content": "What is amoxicillin used for?"}]
|
| 169 |
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
|
|
|
|
| 175 |
|
| 176 |
```bash
|
| 177 |
huggingface-cli download Davis426/COMP8420-Healthcare-LLM-Assistant \
|
| 178 |
+
--include "qwen/qwen-medqa-gguf/model.Q4_K_M.gguf" --local-dir .
|
| 179 |
|
| 180 |
+
./llama-cli -m qwen/qwen-medqa-gguf/model.Q4_K_M.gguf \
|
| 181 |
+
-p "What is amoxicillin used for?" -n 256
|
| 182 |
```
|
| 183 |
|
| 184 |
## Limitations
|
| 185 |
|
| 186 |
+
Both models are teaching / research artifacts. **Do not use for real clinical decisions.** Specifically:
|
| 187 |
|
| 188 |
+
- **Catastrophic forgetting on out-of-distribution prompts.** Fine-tuning on a narrow Q&A distribution at the 1-1.5B parameter scale shifts each base model hard. Casual / non-medical questions get answered in MedQA-style; the base model's general conversational ability is degraded.
|
| 189 |
+
- **Weakened in-context grounding.** Every training pair has shape `user_question -> answer`, with no retrieved-context block. As a result both fine-tuned models partly lose the ability to read RAG passages in the prompt and tend to answer from parametric memory even when correct evidence is supplied. The parent repo's MASS-RAG pipeline retains GPT-5.5 for cases where grounded answers matter; the local models are sidebar-selectable for the comparison experience.
|
| 190 |
+
- **No factual safety net.** Both training data and evaluation rely on existing biomedical corpora; the models have no live knowledge cutoff or up-to-date drug-interaction database. The parent repo applies a regex-based PII railguard on user input, but model output itself is not safety-filtered beyond what each base model already does.
|
| 191 |
- **English only.**
|
| 192 |
+
- **Llama-3.2 base licence:** Llama-3.2 community licence applies to the Llama variant (acceptance via the gated HF repo); see the Meta licence for permitted uses.
|
| 193 |
|
| 194 |
## License
|
| 195 |
|
| 196 |
+
The fine-tuned adapters and GGUFs in this repo are released under `cc-by-nc-4.0` (research and non-commercial use). Base model licences override where stricter: Qwen2.5 is Apache-2.0; Llama-3.2 is under the Meta Llama 3.2 Community Licence. Downstream dataset licences may impose additional restrictions; please consult each source (BioASQ, MedQuAD, DrugBank, MedRAG textbooks) before redistribution.
|
| 197 |
|
| 198 |
## Citation
|
| 199 |
|
| 200 |
If you use or build on this work, please reference:
|
| 201 |
|
| 202 |
```bibtex
|
| 203 |
+
@misc{comp8420-2026-medqa,
|
| 204 |
+
title = {Healthcare NLP Assistant: parallel QLoRA fine-tunes of Qwen2.5-1.5B and Llama-3.2-1B for medical Q&A},
|
| 205 |
author = {Davis426},
|
| 206 |
year = {2026},
|
| 207 |
howpublished = {\url{https://huggingface.co/Davis426/COMP8420-Healthcare-LLM-Assistant}}
|
|
|
|
| 211 |
Built on top of:
|
| 212 |
|
| 213 |
- Qwen2.5 (Alibaba): https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct
|
| 214 |
+
- Llama-3.2 (Meta): https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct
|
| 215 |
- QLoRA (Dettmers et al., 2023): https://arxiv.org/abs/2305.14314
|
| 216 |
+
- MASS-RAG (Xiao, Huang, Liu, Xie, 2026): https://arxiv.org/abs/2604.18509 (used by the parent repo's retrieval pipeline that these models plug into)
|
| 217 |
- Unsloth: https://github.com/unslothai/unsloth
|
| 218 |
- llama.cpp + Ollama for GGUF serving
|