Instructions to use BrainHealthAI/MedQA-Llama3.1-8B-HELIX-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use BrainHealthAI/MedQA-Llama3.1-8B-HELIX-v2 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct") model = PeftModel.from_pretrained(base_model, "BrainHealthAI/MedQA-Llama3.1-8B-HELIX-v2") - Notebooks
- Google Colab
- Kaggle
MedQA-Llama3.1-8B-HELIX-v2
Trilingual (French / English / Moroccan Darija) medical reasoning LoRA adapter on top
of meta-llama/Llama-3.1-8B-Instruct, trained via the HELIX-FT v2 curriculum on a single
RunPod L40S GPU.
Training pipeline
This adapter sits on top of TWO stacked components, both available on HF:
- Base:
meta-llama/Llama-3.1-8B-Instruct(gated) - Intermediate adapter:
BrainHealthAI/MedQA-Llama3.1-8B-SFT-Big— merged into the base to produce a dense intermediateBrainMed-Base-v1 - HELIX-v2 (this adapter) trained on the dense intermediate in 3 stages:
- Stage A — Continued SFT on
BrainHealthAI/MedUnified(23K trilingual, decontaminated against MedQA-USMLE / MedMCQA / PubMedQA / MMLU-medical via MinHash LSH) - Stage B — SASR (Step-wise Adaptive SFT+GRPO, 3K samples). Reward = `0.2·format
- 0.8·SB_CS(answer, gold) − anti_hallucination_penalty`. The anti-hallucination term penalises drugs cited in the answer that appear neither in the gold nor in the Dorosz KG.
- Stage C — CoT polish on
BrainHealthAI/BrainMedCoT(3K with structured<think>...</think>{answer}format)
- Stage A — Continued SFT on
QLoRA (r=64, α=128, dropout=0.1) on 7 attention/MLP target modules. paged_adamw_8bit, bf16, sequence packing, max_seq_len=2048.
Inference
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
BASE = "meta-llama/Llama-3.1-8B-Instruct"
SFT_BIG = "BrainHealthAI/MedQA-Llama3.1-8B-SFT-Big"
HELIX_V2 = "BrainHealthAI/MedQA-Llama3.1-8B-HELIX-v2"
# Step 1: load the base + merge the SFT-Big intermediate adapter
base = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.bfloat16, device_map="auto")
m = PeftModel.from_pretrained(base, SFT_BIG)
m = m.merge_and_unload()
# Step 2: attach the HELIX-v2 adapter
model = PeftModel.from_pretrained(m, HELIX_V2)
tok = AutoTokenizer.from_pretrained(BASE)
# Generate (with the <think> structure trained in Stage C)
prompt = tok.apply_chat_template(
[{"role": "system", "content": "You are a medical reasoning assistant."},
{"role": "user", "content": "Patient presents with..."}],
tokenize=False, add_generation_prompt=True,
)
out = model.generate(**tok(prompt, return_tensors="pt").to(model.device),
max_new_tokens=1024, do_sample=False)
print(tok.decode(out[0], skip_special_tokens=True))
Evaluation
| Benchmark | Accuracy | n |
|---|---|---|
| MedQA-USMLE | 52.50% | 200 |
| MedMCQA | 41.50% | 200 |
| PubMedQA | 53.50% | 200 |
| MMLU-clinical_knowledge | 61.00% | 200 |
| MMLU-medical_genetics | 67.00% | 100 |
| MMLU-professional_medicine | 54.00% | 200 |
| MMLU-college_medicine | 57.23% | 173 |
| Darija-MCQ-500 | 55.00% | 200 |
| Language | SB_CS | ROUGE-L | n |
|---|---|---|---|
| EN | 0.695 | 0.163 | 100 |
| FR | 0.630 | 0.123 | 100 |
| DARIJA | 0.581 | 0.031 | 100 |
See eval_v2.json in this repo for the full breakdown (raw scores + parser version).
Limitations
- English MCQ benchmarks (MedQA-USMLE, MedMCQA): the model emits long
chain-of-thought reasoning before the final answer, which may be truncated by
conservative
max_new_tokenssettings. Usemax_new_tokens ≥ 1024for MCQ evaluation to give the model room to complete the reasoning AND state the final letter. - Darija: this is the model's distinctive strength (10K+ Darija training samples, rare for an 8B medical LLM). The Darija-MCQ-500 benchmark we built is the first public Darija medical MCQ benchmark; baselines from prior literature don't exist.
- Not for clinical use. The adapter is a research artefact. Any clinical application requires review by a licensed medical professional and is not within the scope of CC BY-NC 4.0.
License
CC BY-NC 4.0 — research / non-commercial. The base model meta-llama/Llama-3.1-8B-Instruct
has its own Meta Llama 3 Community License; users must comply with both.
Citation
@misc{medqa_llama3_helix_v2_2026,
author = {BrainHealthAI},
title = {MedQA-Llama3.1-8B-HELIX-v2: Trilingual Medical Reasoning Adapter},
year = 2026,
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/BrainHealthAI/MedQA-Llama3.1-8B-HELIX-v2}},
}
Related artefacts: BrainHealthAI/MedUnified (training data), BrainHealthAI/BrainMedCoT
(CoT corpus), BrainHealthAI/MedQA-Darija-MCQ-500 (Darija eval).
- Downloads last month
- 6
Model tree for BrainHealthAI/MedQA-Llama3.1-8B-HELIX-v2
Base model
meta-llama/Llama-3.1-8B