Downloads · 30 days
17
100% of all-time downloads
Kevinmastascusa/symbolic-math-qwen2p5-1p5b-lora
symbolic-math-qwen2p5-1p5b-lora is a text generation model from Kevinmastascusa. 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.
LoRA adapter (r=8) for Qwen2.5-Math-1.5B, fine-tuned on math word problems. For a standalone model that loads without PEFT, use the merged version: Kevinmastascusa/qwen2p5-math-1p5b-merged. Training, merge and evaluat…
Downloads · 30 days
17
100% of all-time downloads
All-time downloads
17
Public
Repo size
4 GB
Likes
1
Public
Click a slice to open those files.
.safetensors1.9 GB · 99%
From the Hugging Face model README
LoRA adapter (r=8) for Qwen2.5-Math-1.5B, fine-tuned on math word problems. For a standalone model that loads without PEFT, use the merged version: Kevinmastascusa/qwen2p5-math-1p5b-merged. Training, merge and evaluation code is in kevinmastascusa/symbolic-math-ai.
Use the tokenizer from this adapter repo:
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
adapter = "Kevinmastascusa/symbolic-math-qwen2p5-1p5b-lora"
base = "Qwen/Qwen2.5-Math-1.5B"
tok = AutoTokenizer.from_pretrained(adapter, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(base, trust_remote_code=True)
# Attach LoRA
model = PeftModel.from_pretrained(model, adapter)
prompt = "Question: A shop sells pens at 3 for $2. How much do 12 pens cost?\nAnswer:"
inputs = tok(prompt, return_tensors="pt")
gen = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tok.decode(gen[0], skip_special_tokens=True))
If you see vocab-size mismatch errors, resize the base embeddings to the adapter's tokenizer first:
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
adapter = "Kevinmastascusa/symbolic-math-qwen2p5-1p5b-lora"
base = "Qwen/Qwen2.5-Math-1.5B"
tok = AutoTokenizer.from_pretrained(adapter, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
base, trust_remote_code=True, ignore_mismatched_sizes=True
)
base_model.resize_token_embeddings(len(tok))
model = PeftModel.from_pretrained(base_model, adapter)
To merge and save a standalone model:
merged = model.merge_and_unload() # converts to a regular HF model
merged.save_pretrained("qwen2p5-math-1p5b-merged")
tok.save_pretrained("qwen2p5-math-1p5b-merged")
Exact match on the project's test splits, with greedy decoding and up to 64 new tokens. The scorer takes the last number in the model's output and compares it with the last number in the gold answer.
| Test set | Problems | Correct | Exact match |
|---|---|---|---|
| SVAMP | 200 | 125 | 62.5% |
| GSM8K | 200 | 65 | 32.5% |
| MATH-500 | 100 | 16 | 16.0% |
| Three scored sets | 500 | 206 | 41.2% |
| MathQA | 200 | 0 | not scored (see below) |
evaluate_model.py. Raw results: eval_all.json.If you use this adapter, please cite the base model and PEFT:
@article{yang2024qwen25mathtechnicalreportmathematical,
title={Qwen2.5-Math Technical Report: Toward Mathematical Expert Model via Self-Improvement},
author={An Yang and Beichen Zhang and Binyuan Hui and Bofei Gao and Bowen Yu and Chengpeng Li and Dayiheng Liu and Jianhong Tu and Jingren Zhou and Junyang Lin and Keming Lu and Mingfeng Xue and Runji Lin and Tianyu Liu and Xingzhang Ren and Zhenru Zhang},
journal={arXiv preprint arXiv:2409.12122},
year={2024}
}