Model Details
Intended Uses
Suitable pilot uses include:
- Bengali or English mathematics question answering;
- worked-solution generation for class 6–10 topics;
- educational prototyping and qualitative research;
- continued fine-tuning and controlled comparison experiments.
Out-of-Scope Uses
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.
How to Use
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.
Training Data
The pilot corpus contains 577 paired Bengali–English source records covering 61 chapters across classes 6–10.
Table with columns: Raw split, Records, SFT sequences after BN/EN expansion| 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.
Training Procedure
The adapter was trained with supervised fine-tuning (SFT) and 4-bit QLoRA in Google Colab.
Table with columns: Hyperparameter, Value| 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 |
LoRA Configuration
Table with columns: Parameter, Value| Parameter | Value |
|---|
Rank (r) | 16 |
| Alpha | 32 |
| Dropout | 0.05 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, , |
Evaluation
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.
Table with columns: Held-out metric, Result| 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 |
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.
Bias, Risks, and Limitations
- The training corpus is small (577 raw records), so topic coverage and linguistic variety remain limited.
- The adapter can produce incorrect calculations, invalid reasoning, fabricated facts, or an answer inconsistent with its steps.
- Bengali mathematical terminology varies across regions and textbooks; outputs may not match a preferred convention.
- Automated dataset checks do not replace review by mathematics teachers and bilingual annotators.
- Held-out performance is low and 89/122 generations were automatically flagged for manual review.
- Results may be sensitive to prompt wording, decoding settings, library versions, and the base-model revision.
- The model should not be trusted for high-stakes educational decisions without independent verification.
Always verify generated solutions, especially geometry arguments, proofs, multi-step algebra, and examination material.
Technical Notes
- Adapter format: PEFT LoRA (
safetensors)
- Adapter file size: 73,911,112 bytes (approximately 70.5 MiB)
- Adapter tensors: 392, stored as FP32
adapter_model.safetensors SHA-256: 62f3e9b7ad3413c80505225acd10070ddf003db7faf155883d15d546f23f6c0e
- Tokenizer vocabulary size: 151,643
- A Qwen-compatible chat template is included in the repository.
- The current repository tokenizer metadata has a known compatibility issue with recent Transformers/PEFT releases; use the base-tokenizer loading procedure above until that metadata is replaced.
Environmental Impact
Training 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.
License and Attribution
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.
Citation
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.
Acknowledgements
This work uses Qwen2.5, Hugging Face Transformers, PEFT, TRL, Accelerate, and bitsandbytes.