Views
No views yet
| Metric | Base Model (Llama-3.1-8B-Instruct) | Fine-Tuned Model (Medical-QA) |
|---|---|---|
| Accuracy | 62.0% | 89.0% 🚀 |
| Response Style | Generic / Verbose / General Knowledge | Context-Aligned / Fact-Driven |
| Hallucination Rate | Moderate on niche technical terms | Low (Strictly bound to Context) |
| Compute Overhead | — | ~22 minutes training time on 1x T4 GPU |
meta-llama/Meta-Llama-3.1-8B-Instruct (Pre-quantized 4-bit via BitsAndBytes)ori_pqal.json) — Contextual medical questions mapping academic abstracts to direct interpretations.1# Key Hyperparameters Used During Training
2training_args = TrainingArguments(
3 per_device_train_batch_size = 2,
4 gradient_accumulation_steps = 4,
5 warmup_steps = 5,
6 max_steps = 80, # Optimized training window
7 learning_rate = 2e-4, # Standard QLoRA learning rate
8 optim = "adamw_8bit",
9 weight_decay = 0.01,
10 lr_scheduler_type = "linear",
11 seed = 3407,
12)
13
14
15### Target Modules (LoRA Adaption)
16
17Adapters were injected into the following attention projections and feed-forward layers to capture contextual nuances:
18
19* `q_proj`, `k_proj`, `v_proj`, `o_proj`
20* `gate_proj`, `up_proj`, `down_proj`
21* **LoRA Parameters:** $r = 16$, $\alpha = 16$, $\text{dropout} = 0$
22
23---
24
25## 📋 Instruction Template Format
26
27The model utilizes the explicit Llama-3.1 Instruct system marker pattern to safely bind the context parameters:
28
29```text
30<|begin_of_text|><|start_header_id|>system<|end_header_id|>
31You are an expert medical assistant. Answer the medical question accurately based strictly on the provided context.<|eot_id|><|start_header_id|>user<|end_header_id|>
32Context: {Medical Abstract Text}
33Question: {Clinical Inquiry}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
34{Model Target Response}<|eot_id|>
351├── .gitignore
2├── README.md
3├── requirements.txt
4├── Fine_Tuning_Llama_3_1_8B.ipynb # Core Unsloth pipeline notebook script
5├── app.py # Streamlit UI production app
6└── Modelfile # Local Ollama config engine file
71git clone https://github.com/Himanshu-Vishwakarma-GH/Llama-Medical-QA--Fine-Tune.git
2cd Llama-Medical-QA--Fine-Tune
31pip install -r requirements.txt
21streamlit run app.py
21# Build custom system endpoint model from the manifest target
2ollama create medical-qa -f ./Modelfile
3
4# Start running local client dialogue instance
5ollama run medical-qa
6