Pilot release: This adapter was trained on 577 validated bilingual source records. It is not the planned 12,000-record final release.
BaAMR Math Qwen2.5 1.5B LoRA — Pilot 577 is a Bengali–English educational mathematics adapter for Qwen/Qwen2.5-1.5B-Instruct. It is intended to answer curriculum-aligned mathematics questions for Bangladeshi classes 6–10 with a short worked solution and final answer.
This repository contains a PEFT LoRA adapter, not a standalone full model. The base Qwen model is downloaded automatically when the adapter is loaded with PEFT.
| Field | Value |
|---|---|
| Developer / publisher | mdhamidhosen |
| Repository | mdhamidhosen/baamr-math-qwen2.5-1.5b-lora-pilot-577 |
| Base model | Qwen/Qwen2.5-1.5B-Instruct |
| Model type | Causal language model with PEFT LoRA adapter |
| Languages | Bengali (bn) and English (en) |
| Domain | Educational mathematics, classes 6–10 |
| Adapter task | CAUSAL_LM |
| License | Apache-2.0 |
Suitable pilot uses include:
Do not use this pilot as an authoritative grading system, an unsupervised source of examination questions, or a substitute for a qualified teacher. It has not been validated for high-stakes assessment, formal proof verification, or domains outside the training scope.
Install recent versions of the required packages:
pip install -U "transformers>=4.45,<5" "peft>=0.13" accelerate bitsandbytes torch
Current Transformers/PEFT releases may reject the list-valued extra_special_tokens field in this pilot repository's tokenizer metadata. The robust loading path below uses the official base tokenizer and copies only the two required PEFT adapter files into a clean local directory.
import shutil
from pathlib import Path
import torch
from huggingface_hub import hf_hub_download
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
MODEL_ID = "mdhamidhosen/baamr-math-qwen2.5-1.5b-lora-pilot-577"
BASE_MODEL_ID = "Qwen/Qwen2.5-1.5B-Instruct"
compute_dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=compute_dtype,
)
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_ID)
adapter_dir = Path("./baamr_adapter_weights_only")
if adapter_dir.exists():
shutil.rmtree(adapter_dir)
adapter_dir.mkdir(parents=True)
for filename in ("adapter_config.json", "adapter_model.safetensors"):
cached_file = hf_hub_download(repo_id=MODEL_ID, filename=filename)
shutil.copy2(cached_file, adapter_dir / filename)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_ID,
quantization_config=quantization_config,
device_map="auto",
dtype=compute_dtype,
)
model = PeftModel.from_pretrained(base_model, adapter_dir, is_trainable=False)
model.eval()
messages = [
{
"role": "system",
"content": (
"You are a bilingual mathematics tutor. Solve the problem clearly, "
"show the essential steps, and state the final answer."
),
},
{
"role": "user",
"content": "একটি ত্রিভুজের ভূমি ১২ সেমি এবং উচ্চতা ৭ সেমি। ক্ষেত্রফল নির্ণয় কর।",
},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(next(model.parameters()).device)
outputs = model.generate(
**inputs,
max_new_tokens=384,
do_sample=False,
)
new_tokens = outputs[0, inputs["input_ids"].shape[-1]:]
print(tokenizer.decode(new_tokens, skip_special_tokens=True))
The same format can be used with an English prompt, for example: A triangle has base 12 cm and height 7 cm. Find its area.
The pilot corpus contains 577 paired Bengali–English source records covering 61 chapters across classes 6–10.
| Raw split | Records | SFT sequences after BN/EN expansion |
|---|---|---|
| Train | 457 | 914 |
| Validation | 59 | 118 |
| Test | 61 | Held out from training |
| Total | 577 | — |
Each training record was expanded into separate Bengali and English prompt–completion sequences. Records include questions, worked reasoning, final answers, curriculum metadata, and page-level source references. The corpus passed automated structure, bilingual-parity, duplicate-family, split-leakage, and mathematical-assertion checks. These checks are not equivalent to independent expert review.
The planned 12,000-record corpus is a future target and was not used for this pilot.
The adapter was trained with supervised fine-tuning (SFT) and 4-bit QLoRA in Google Colab.
| Hyperparameter | Value |
|---|---|
| Epochs | 3 |
| Maximum sequence length | 1,024 |
| Per-device train batch size | 2 |
| Gradient accumulation steps | 8 |
| Effective batch size (one GPU) | 16 |
| Learning rate | 1e-4 |
| Scheduler | Cosine |
| Warmup steps | 50 |
| Weight decay | 0.01 |
| Optimizer | paged_adamw_8bit |
| Loss | Completion-only causal-language-model loss |
| Precision | BF16 when supported; otherwise FP16 |
| Quantization | 4-bit NF4 with double quantization |
| Gradient checkpointing | Enabled |
| Evaluation / save interval | 100 steps |
| Best-model criterion | Validation loss |
| Parameter | Value |
|---|---|
Rank (r) |
16 |
| Alpha | 32 |
| Dropout | 0.05 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
The adapter was evaluated on all 61 held-out raw records in both languages, producing 122 deterministic generations (max_new_tokens=384, do_sample=False, repetition_penalty=1.05). The evaluation dataset SHA-256 is c0f23821e4a8936671993143b3bbe3e61a317139962ada343045c225b770485a.
| Held-out metric | Result |
|---|---|
| Completion-only test loss | 0.501526 |
| Completion-only perplexity | 1.6512 |
| Normalized exact final-answer match | 33/122 (27.05%) |
| Bengali exact match | 13/61 (21.31%) |
| English exact match | 20/61 (32.79%) |
| Mean numeric-reference recall | 37.83% |
| Mean final-answer token F1 | 55.74% |
| BN/EN generated numeric consistency | 8/49 comparable pairs (16.33%) |
| Automatically flagged for manual review | 89/122 (72.95%) |
| Human mathematics-teacher review | Not completed |
| Independent bilingual review | Not completed |
Exact text matching is conservative because equivalent answers can differ in wording or units. However, manual inspection also found genuine arithmetic errors, bilingual disagreement, and cases where the final answer matched while the written reasoning was defective. Full-response reference-substring matching was 45/122 (36.89%) but is not reported as accuracy, because an incorrect solution can repeat the reference string inside its reasoning.
By question type, exact match was strongest on MCQ (9/12, 75.00%) and weakest on conceptual, multi-step, reasoning, sequence, and short-answer cases (0 exact matches in each category). These automatic metrics are diagnostic and do not establish classroom reliability.
Always verify generated solutions, especially geometry arguments, proofs, multi-step algebra, and examination material.
safetensors)adapter_model.safetensors SHA-256: 62f3e9b7ad3413c80505225acd10070ddf003db7faf155883d15d546f23f6c0eTraining was performed in Google Colab. Exact GPU type, runtime duration, energy use, compute region, and carbon emissions were not retained, so an emissions estimate is not reported.
The base model is published by the Qwen Team under the Apache-2.0 license. Users should review the base-model license and terms as well as the files in this repository before use.
If you use this adapter, cite the repository:
@misc{mdhamidhosen2026baamrpilot577,
author = {mdhamidhosen},
title = {BaAMR Math Qwen2.5 1.5B LoRA -- Pilot 577},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/mdhamidhosen/baamr-math-qwen2.5-1.5b-lora-pilot-577}}
}
The base model should also be cited according to the instructions in the Qwen2.5-1.5B-Instruct model card.
This work uses Qwen2.5, Hugging Face Transformers, PEFT, TRL, Accelerate, and bitsandbytes.
Qwen/Qwen2.5-1.5B-Instruct