Views
No views yet
meta-llama/Meta-Llama-3-8B-Instruct, fine-tuned to answer medical multiple-choice questions (A/B/C/D).Educational use only. Not medical advice.
Access note: Llama-3 base is a public gated model on HF.
Accept the base model license on its page and use a fine-grained token that allows public gated repos.
1import os, re
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5BASE = "meta-llama/Meta-Llama-3-8B-Instruct"
6ADAPTER = "Pk3112/medmcqa-lora-llama3-8b-instruct"
7hf_token = os.getenv("HUGGINGFACE_HUB_TOKEN") # required if not logged in
8
9tok = AutoTokenizer.from_pretrained(BASE, use_fast=True, token=hf_token)
10base = AutoModelForCausalLM.from_pretrained(BASE, device_map="auto", token=hf_token)
11model = PeftModel.from_pretrained(base, ADAPTER, token=hf_token).eval()
12
13prompt = (
14 "Question: Which vitamin is absorbed in the ileum?\n"
15 "A. Vitamin D\nB. Vitamin B12\nC. Iron\nD. Fat\n\n"
16 "Answer:"
17)
18inputs = tok(prompt, return_tensors="pt").to(model.device)
19out = model.generate(**inputs, max_new_tokens=8, do_sample=False)
20text = tok.decode(out[0], skip_special_tokens=True)
21
22m = re.search(r"Answer:\s*([A-D])\b", text)
23print(f"Answer: {m.group(1)}" if m else text.strip())max_new_tokens. For answer-only, keep it small and stop after the letter to reduce latency.| Model | Internal val acc (%) | Original val acc (%) | TTFT (ms) | Gen time (ms) | In/Out tokens |
|---|---|---|---|---|---|
| Llama-3-8B (LoRA) | 83.83 | 65.20 | 567 | 14874 | 148 / 80 |
r=32, alpha=64, dropout=0.0; targets q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj768Answer: <A/B/C/D>)subject_name (Biochemistry, Physiology)adapter_model.safetensorsadapter_config.jsonmeta-llama/Meta-Llama-3-8B-Instruct (public gated on HF)openlifescienceai/medmcqa — follow dataset license