Downloads · 30 days
5
8% of all-time downloads
Nyingi101/math-tutor-tinyllama-lora
math-tutor-tinyllama-lora is a text generation model from Nyingi101. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
Downloads · 30 days
5
8% of all-time downloads
All-time downloads
59
Public
Repo size
9 MB
Likes
0
Public
Click a slice to open those files.
.safetensors9 MB · 83%
From the Hugging Face model README
S2.T3.1 · AIMS KTT Hackathon · Tier 3
A QLoRA fine-tuned adapter on TinyLlama-1.1B-Chat-v1.0 for adaptive, multilingual math tutoring of children aged 5–9 (P1–P3 numeracy). Trained on 2,000 instruction pairs in English, French, and Kinyarwanda.
| Property | Value |
|---|---|
| Base model | TinyLlama/TinyLlama-1.1B-Chat-v1.0 |
| Fine-tuning method | QLoRA (4-bit NF4 + LoRA rank=8) |
| Trainable parameters | 2,252,800 / 1,102,301,184 (0.204%) |
| Training loss | 0.4768 (converged at epoch 3) |
| Training time | 793 s on Tesla T4 (15.6 GB VRAM) |
| Adapter size | 8.6 MB safetensors |
| Languages | English · French · Kinyarwanda (+ code-switching) |
| Target age | 5–9 years (P1–P3) |
| Skills | counting, number sense, addition, subtraction, word problems |
scripts/make_instruction_data.pyLoraConfig(
r=8,
lora_alpha=16,
target_modules=["q_proj", "v_proj", "k_proj", "o_proj"],
lora_dropout=0.05,
bias="none",
task_type=TaskType.CAUSAL_LM,
)
TrainingArguments(
num_train_epochs=3,
per_device_train_batch_size=4,
gradient_accumulation_steps=4,
learning_rate=2e-4,
fp16=True,
lr_scheduler_type="cosine",
warmup_steps=50,
)
Trained on Modal.com using a Tesla T4 GPU (free tier). Reproducible with:
pip3 install modal && modal token new
modal run scripts/train_modal.py
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base)
model = PeftModel.from_pretrained(model, "Nyingi101/math-tutor-tinyllama-lora")
prompt = (
"<|system|>\nYou are a friendly math tutor for young children.</s>\n"
"<|user|>\nChild answered 3+2=6 (wrong). Give gentle encouragement.</s>\n"
"<|assistant|>\n"
)
inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=80)
print(tokenizer.decode(output[0], skip_special_tokens=True))
# Kinyarwanda feedback
prompt_kin = (
"<|system|>\nUri umwarimu w'imibare w'abana bato.</s>\n"
"<|user|>\nUmwana yabaze 4+3=7 (nibyo). Muhe ishimwe.</s>\n"
"<|assistant|>\n"
)
# French feedback
prompt_fr = (
"<|system|>\nTu es un tuteur de mathématiques pour les jeunes enfants.</s>\n"
"<|user|>\nL'enfant a répondu 5-2=3 (correct). Encourage-le.</s>\n"
"<|assistant|>\n"
)
This adapter is part of the AI Math Tutor for Early Learners system:
tutor/ directory (target ≤ 75 MB ✓)| Model | AUC | N predictions |
|---|---|---|
| BKT | 0.5677 | 2,400 |
| Elo baseline | 0.5203 | 2,400 |
| Delta | +0.0474 | BKT wins |
Apache 2.0 — same as the TinyLlama base model.