SmolLM3-3B-MedQA
HuggingFaceTB/SmolLM3-3B fine-tuned to answer 4-option medical exam questions, made as the final project of the Hugging Face smol-course.
This is a learning project. It is not a medical device, and it must not be used for diagnosis, treatment or any real medical decision. It gets many exam questions wrong.
Results
Tested on 1273 questions from the MedQA (USMLE, 4 options) test split, which training never used. Guessing would score 25%.
| Model | Overall | Gave a clear answer | Right when it answered |
|---|---|---|---|
| Untrained | 41.6% | 98.5% | 42.2% |
| This model | 50.1% | 100.0% | 50.1% |
Change in the overall score: +8.6% (95% range about ±2.9%). Part of the overall gain comes from giving clear answers more often, so "right when it answered" is the better guide to knowledge.
Training
- Step 1: SFT + LoRA on 7781 MedQA, 7500 MedMCQA and 4000 medical-o1 examples.
- Step 2: DPO + LoRA on 3000 pairs (correct option vs a random wrong one). Kept: True, but it made no measurable difference. Its best validation score beat SFT's by only 1 question out of 500 (252 against 251), and on the test the SFT-only model scored 50.4% against this model's 50.1%.
- Rows that were near-copies of validation or test questions were removed from training.
- The best adapters were chosen using validation only, and thinking mode was off.
Limits
- It was tested on one exam-style dataset, in English, with one prompt format.
- A good exam score doesn't show that its medical advice is safe or correct.
- Its free-form medical answers weren't scored.
How to use it
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("BasselNashaat/SmolLM3-3B-MedQA")
model = AutoModelForCausalLM.from_pretrained("BasselNashaat/SmolLM3-3B-MedQA", device_map="auto")
question = "<question>\n\nA. ...\nB. ...\nC. ...\nD. ...\n\nAnswer with the letter and the text of the correct option."
text = tokenizer.apply_chat_template([{"role": "user", "content": question}], tokenize=False,
add_generation_prompt=True, enable_thinking=False)
inputs = tokenizer(text, return_tensors="pt", add_special_tokens=False).to(model.device)
output = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))