Downloads · 30 days
0
raturihimanshu077/tinyllama-1.1b-gsm8k-nf4
tinyllama-1.1b-gsm8k-nf4 is a text generation model from raturihimanshu077. 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.
This model is a fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat-v1.0, adapted to solve grade-school math word problems with explicit step-by-step reasoning. It was fine-tuned using QLoRA (4-bit NF4 quantization +…
Downloads · 30 days
0
Access
Public
Updated Jul 25, 2026
Parameters
1.1B
2.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.2 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat-v1.0, adapted to
solve grade-school math word problems with explicit step-by-step reasoning. It was
fine-tuned using QLoRA (4-bit NF4 quantization + LoRA adapters) on the GSM8K training
set, then evaluated against the base model on the GSM8K test set to measure the accuracy
improvement from fine-tuning.
The model is trained to respond to a math word problem with a full chain-of-thought
explanation, ending in a final numeric answer on its own line in the form #### <answer>.
Solving grade-school-level math word problems with step-by-step reasoning. Intended for educational tools, tutoring assistants, and as a lightweight reference implementation of QLoRA fine-tuning for reasoning tasks.
Can be merged into applications that need a small, low-cost math-reasoning component — e.g. as a backend model behind a tutoring API (see the accompanying FastAPI service in the project repository).
Users should verify the model's final numeric answers independently for any use case where correctness matters, and should not assume the step-by-step reasoning is always logically sound just because it reads fluently.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
MODEL_ID = "raturihimanshu077/tinyllama-1.1b-gsm8k-nf4"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16, device_map="auto")
SYSTEM_PROMPT = (
"You are a careful math tutor. Solve the word problem step by step, "
"showing your reasoning clearly, then give the final numeric answer "
"on its own line in the form: #### <answer>."
)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?"},
]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(input_ids=inputs, max_new_tokens=400, do_sample=False)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
GSM8K ("main" config), official split: 7,473 training examples, 1,319 test examples. Each example is a grade-school math word problem paired with a human-written step-by-step solution ending in a final numeric answer.
<<calculator annotation>> markup was stripped from the reasoning text to
produce clean natural-language solutions.BitsAndBytesConfig,
double quantization enabled), bf16 compute dtype, LoRA adapters trained in mixed precisionq_proj, k_proj,
v_proj, o_proj, gate_proj, up_proj, down_projper_device_train_batch_size=8 × gradient_accumulation_steps=2)GSM8K official test split (1,319 examples), same split used for both baseline and fine-tuned evaluation to ensure a fair comparison.
Exact-match accuracy on the final numeric answer, extracted via the #### <answer>
marker from both the model's output and GSM8K's gold solution.
| Model | Exact-match accuracy (GSM8K test) |
|---|---|
| Base TinyLlama-1.1B-Chat (zero-shot, CoT-prompted) | TODO: fill in your number |
| Fine-tuned (this model) | TODO: fill in your number |
TODO: one or two sentences once you have the final numbers — e.g. "Fine-tuning improved exact-match accuracy from X% to Y% on the GSM8K test set, demonstrating that small models benefit substantially from task-specific fine-tuning even when prompted with explicit chain-of-thought instructions."
Decoder-only transformer (Llama architecture), causal language modeling objective, fine-tuned with LoRA low-rank adapters on top of 4-bit quantized base weights.
Single GPU (Google Colab)
transformers, peft, bitsandbytes, trl (TRL SFTTrainer)If you use this model, please cite the original GSM8K and TinyLlama papers:
BibTeX:
@article{cobbe2021gsm8k,
title={Training Verifiers to Solve Math Word Problems},
author={Cobbe, Karl and Kosaraju, Vineet and Bavarian, Mohammad and others},
journal={arXiv preprint arXiv:2110.14168},
year={2021}
}
@article{zhang2024tinyllama,
title={TinyLlama: An Open-Source Small Language Model},
author={Zhang, Peiyuan and Zeng, Guangtao and Wang, Tianduo and Lu, Wei},
journal={arXiv preprint arXiv:2401.02385},
year={2024}
}
Himanshu Raturi — Hugging Face profile