Downloads · 30 days
11
12% of all-time downloads
rohanjain11/flan-t5-mlds-qlora
flan-t5-mlds-qlora is a question answering model from rohanjain11. Use it when the input is a question plus a passage. It is set up for peft. The card lists the license as apache-2.0.
A QLoRA (LoRA) adapter fine-tuned on top of google/flan-t5-base for machine learning and data science question answering. This repo contains only the adapter weights (~16 MB), not the full base model.
Downloads · 30 days
11
12% of all-time downloads
All-time downloads
90
Public
Repo size
35.5 MB
Likes
0
Public
Click a slice to open those files.
.safetensors14.2 MB · 85%
From the Hugging Face model README
A QLoRA (LoRA) adapter fine-tuned on top of google/flan-t5-base for machine learning and data science question answering. This repo contains only the adapter weights (~16 MB), not the full base model.
This model adapts Flan-T5-base to answer practitioner-style ML/Data Science questions with longer, domain-relevant responses. Training used a synthetic Q&A dataset (324 examples) generated with OpenAI gpt-4o-mini, then QLoRA fine-tuning on Google Colab (T4 GPU).
google/flan-t5-baseAnswering English questions about machine learning and data science topics (model evaluation, cross-validation, neural networks, feature engineering, deployment, etc.) in an instructional Q&A format.
Example prompt format used during training:
Answer the following question about machine learning and data science: {question}
Recommendation: Treat outputs as draft educational content; verify important facts against primary sources.
import torch
from peft import PeftModel
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
BASE_MODEL = "google/flan-t5-base"
ADAPTER = "rohanjain11/flan-t5-mlds-qlora"
tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
base_model = AutoModelForSeq2SeqLM.from_pretrained(
BASE_MODEL,
torch_dtype=torch.float16,
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, ADAPTER)
model.eval()
question = "What is the bias-variance tradeoff?"
prompt = f"Answer the following question about machine learning and data science: {question}"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=256,
min_length=40,
num_beams=4,
early_stopping=True,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
gpt-4o-mini)instruction (question) and output (answer) fieldsPreprocessing
Answer the following question about machine learning and data science: {instruction}{output}-100Training hyperparameters
| Parameter | Value |
|---|---|
| Base model | google/flan-t5-base (~250M params) |
| Quantization | 8-bit (bitsandbytes) |
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| LoRA targets | q, k, v, o |
| Trainable params | 3,538,944 (1.41%) |
| Epochs | 5 |
| Batch size | 8 |
| Learning rate | 1e-4 |
| Warmup ratio | 0.06 |
| Max grad norm | 1.0 |
| Precision | fp16=False (fp32 LoRA training; required for stable loss on T4) |
| Optimizer | AdamW (Trainer default) |
| Seed | 42 |
Speeds, sizes, times
| Metric | Value |
|---|---|
| GPU | NVIDIA T4 (Colab) |
| Training steps | 205 |
| Training time | ~2.2 minutes |
| Adapter size | 15.86 MB |
| Full base model | ~950 MB (loaded separately) |
Loss (teacher-forced)
| Epoch | Train loss | Val loss |
|---|---|---|
| 1 | 3.28 | 2.91 |
| 5 | 2.97 | 2.78 |
| Final | 3.09 | 2.78 |
36 held-out validation examples from the same synthetic dataset (10% split, random_state=42).
ROUGE-L (longest common subsequence F-measure) comparing generated answers to reference answers on the full validation set, using min_length=40 and beam search (num_beams=4).
Base model evaluated as a separate google/flan-t5-base load (not adapter-disabled PEFT).
| Model | ROUGE-L |
|---|---|
Base (flan-t5-base) | 0.1637 |
| Fine-tuned (this adapter) | 0.2058 |
| Improvement | +25.7% |
Qualitative outputs improved in length and domain tone vs. base, but may still contain inaccuracies typical of small models on open-ended QA.
Approximate Colab T4 usage for fine-tuning only:
Base model — Flan-T5:
@misc{chung2022scaling,
title={Scaling Instruction-Finetuned Language Models},
author={Hyung Won Chung and others},
year={2022},
eprint={2210.11416},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
LoRA:
@inproceedings{hu2022lora,
title={LoRA: Low-Rank Adaptation of Large Language Models},
author={Edward J. Hu and others},
booktitle={ICLR},
year={2022}
}