Instructions to use rohanjain11/flan-t5-mlds-qlora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use rohanjain11/flan-t5-mlds-qlora with PEFT:
from peft import PeftModel from transformers import AutoModelForSeq2SeqLM base_model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-base") model = PeftModel.from_pretrained(base_model, "rohanjain11/flan-t5-mlds-qlora") - Notebooks
- Google Colab
- Kaggle
Flan-T5 ML/Data Science QLoRA Adapter
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.
Model Description
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).
- Developed by: rohanjain11
- Model type: Seq2seq language model (LoRA adapter)
- Language: English
- License: Apache 2.0 (inherits from Flan-T5-base)
- Finetuned from:
google/flan-t5-base - Training method: QLoRA (8-bit base + LoRA on attention projections)
- Code / dataset pipeline: github.com/rohanjain11/llm-finetune-qlora
Intended Use
Direct Use
Answering 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}
Downstream Use
- Domain-specific QA assistant (with human review)
- Starting point for further LoRA fine-tuning on related technical domains
- Educational / portfolio demonstration of parameter-efficient fine-tuning
Out-of-Scope Use
- Medical, legal, or financial advice
- High-stakes decisions without human verification
- Factual claims requiring up-to-date sources (model may hallucinate)
- Languages other than English
Bias, Risks, and Limitations
- Trained on synthetic data from an LLM; answers may reflect generator biases or inaccuracies.
- Small fine-tuning set (324 examples); coverage is broad but not exhaustive.
- Flan-T5-base capacity limits depth vs. much larger models.
- ROUGE-L improved on a held-out validation set but does not guarantee factual correctness.
- Not evaluated for fairness across demographic groups or sensitive topics.
Recommendation: Treat outputs as draft educational content; verify important facts against primary sources.
How to Get Started
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))
Training Details
Training Data
- Source: Synthetic Q&A pairs generated locally via OpenAI API (
gpt-4o-mini) - Domain: Machine learning & data science (40 subtopics)
- Train examples: 324
- Validation examples: 36
- Format: JSONL with
instruction(question) andoutput(answer) fields - Generation cost: ~$0.04 (dataset creation)
Training Procedure
Preprocessing
- Input:
Answer the following question about machine learning and data science: {instruction} - Target:
{output} - Max input length: 256 tokens
- Max target length: 400 tokens
- Label padding masked with
-100
Training 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 |
Evaluation
Testing Data
36 held-out validation examples from the same synthetic dataset (10% split, random_state=42).
Metrics
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).
Results
| 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.
Environmental Impact
Approximate Colab T4 usage for fine-tuning only:
- Hardware: NVIDIA T4
- Training time:
0.04 hours (2.2 minutes) - Cloud provider: Google Colab (free tier)
- Carbon: Negligible for a single short fine-tuning run
Technical Specifications
Model Architecture
- Architecture: T5 encoder-decoder (Flan-T5-base)
- Objective: Conditional generation (seq2seq LM)
- This repo: PEFT LoRA adapter weights only
Compute Infrastructure
- Hardware: Google Colab T4 GPU
- Software: Python 3.12, PyTorch, Transformers, PEFT, bitsandbytes, Accelerate
Citation
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}
}
Model Card Contact
- Downloads last month
- 7
Model tree for rohanjain11/flan-t5-mlds-qlora
Base model
google/flan-t5-base