Downloads · 30 days
0
MileStanislavov/flan-t5-small-pubmedqa-lora
flan-t5-small-pubmedqa-lora is a question answering model from MileStanislavov. Use it when the input is a question plus a passage. It is set up for transformers.
This repository contains a parameter‑efficient fine‑tuning of the FLAN‑T5‑small model for a biomedical question‑answering task. The model produces one of three answers — yes, no, or maybe — given a question and a shor…
Downloads · 30 days
0
Access
Public
Updated Sep 7, 2025
Repo size
21.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors10.3 MB · 76%
From the Hugging Face model README
This repository contains a parameter‑efficient fine‑tuning of the FLAN‑T5‑small model for a biomedical question‑answering task.
The model produces one of three answers — yes, no, or maybe — given a question and a short context drawn from biomedical abstracts.
Training uses QLoRA (4‑bit NF4 quantization via bitsandbytes) together with LoRA adapters on the base model, allowing low‑VRAM training and fast inference.
yes, no, maybe)pqa_labeled)yes, no, maybe).yes, no, or maybe.Recommendations:
You can load the model using the Transformers and PEFT libraries.
The recommended approach is to load the base model and LoRA adapter separately.
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
from peft import PeftModel
from bitsandbytes.config import BitsAndBytesConfig
import torch
base_model_id = "google/flan-t5-small"
adapter_id = "MileStanislavov/flan-t5-small-pubmedqa-lora"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.float16,
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base_model = AutoModelForSeq2SeqLM.from_pretrained(base_model_id, quantization_config=bnb_config)
model = PeftModel.from_pretrained(base_model, adapter_id)
def predict_yes_no_maybe(question, context):
prompt = f"question: {question} context: {context}"
inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=4, num_beams=4, do_sample=False)
text = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0].strip().lower().replace(".", "")
return text if text in {"yes", "no", "maybe"} else "maybe"
If you have merged the LoRA weights into the base model using merge_and_unload(), load the merged model directly:
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
model = AutoModelForSeq2SeqLM.from_pretrained("your-username/flan-t5-small-pubmedqa-merged")
tokenizer = AutoTokenizer.from_pretrained("your-username/flan-t5-small-pubmedqa-merged")
pqa_labeledquestion: <q> context: <context> (truncated to 512 tokens)["q", "k", "v", "o", "wi_0", "wi_1", "wo"] (T5 attention and feed‑forward projections)float16 or bfloat162e-4Evaluation metrics: Accuracy and macro‑F1 on validation/test splits.
Evaluation uses the validation and test splits from PubMedQA.
Metrics include accuracy and macro‑F1.
The parameter‑efficient approach (QLoRA + LoRA) significantly reduces compute requirements and energy usage compared to full fine‑tuning.
Estimate CO₂ emissions using the Machine Learning Impact calculator.
Model card authored by [Mile Stanislavov].
Please contact [Mile Stanislavov] for questions.