CoolFace
Modelpublic

rohanjain11/flan-t5-mlds-qlora

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes14downloads
Model Card

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).

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

python
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) and output (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

ParameterValue
Base modelgoogle/flan-t5-base (~250M params)
Quantization8-bit (bitsandbytes)
LoRA rank (r)16
LoRA alpha32
LoRA targetsq, k, v, o
Trainable params3,538,944 (1.41%)
Epochs5
Batch size8
Learning rate1e-4
Warmup ratio0.06
Max grad norm1.0
Precisionfp16=False (fp32 LoRA training; required for stable loss on T4)
OptimizerAdamW (Trainer default)
Seed42

Speeds, sizes, times

MetricValue
GPUNVIDIA T4 (Colab)
Training steps205
Training time~2.2 minutes
Adapter size15.86 MB
Full base model~950 MB (loaded separately)

Loss (teacher-forced)

EpochTrain lossVal loss
13.282.91
52.972.78
Final3.092.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

ModelROUGE-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:

bibtex
@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:

bibtex
@inproceedings{hu2022lora,
  title={LoRA: Low-Rank Adaptation of Large Language Models},
  author={Edward J. Hu and others},
  booktitle={ICLR},
  year={2022}
}

Model Card Contact

rohanjain11 · GitHub