GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lachtarnour/math-consistent-qwen: Reproducible research on arithmetic reasoning with Qwen2.5 and GSM8K, combining LoRA ablations, structured computation objectives, and reasoning-aware evaluation.

BranchesTags
Open more actions menu

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
documentation
documentation
 
 
results
results
 
 
script
script
 
 
src
src
 
 
tests
tests
 
 
.dockerignore
.dockerignore
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
CITATION.cff
CITATION.cff
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Dockerfile.data
Dockerfile.data
 
 
Dockerfile.gpu-evaluation
Dockerfile.gpu-evaluation
 
 
Dockerfile.gpu-training
Dockerfile.gpu-training
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
ROADMAP.md
ROADMAP.md
 
 
SECURITY.md
SECURITY.md
 
 
THIRD_PARTY_NOTICES.md
THIRD_PARTY_NOTICES.md
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

Math-Consistent Qwen

Structured arithmetic reasoning with Qwen2.5 on GSM8K

CI Python 3.10–3.13 License Research status

Math-Consistent Qwen investigates whether explicit supervision of intermediate arithmetic structure can improve reasoning beyond standard next-token imitation. It fine-tunes Qwen2.5-1.5B-Instruct with LoRA on GSM8K.

The evaluation distinguishes two outcomes:

  • answer correctness — whether the final numerical answer is right;
  • reasoning consistency — whether intermediate calculations are valid and agree with the final answer.

Status: A0–A2 have single-seed reference results. A3–A4 are implemented and ready to run. A5–A8 are planned. The findings have not been peer reviewed.

Key result

On the same local BF16/MPS validation protocol, A1 reduces completion-only eval_loss by 41.4% relative to the pretrained baseline.

Model eval_loss Final Strict Consistent Correct + consistent
A0 — pretrained 0.9131 66.67% 15.00% 1.67% 1.33%
A1 — LoRA CE 0.5350 70.33% 70.33% 80.67% 63.00%
A2 — math-token weighting 0.3469† 64.00% 64.00% 79.33% 57.00%

† A2 loss was measured on CUDA/L40S; A0/A1 losses were measured on MPS, so they must not be compared directly. Generation metrics use the same frozen 300-example validation subset. See the versioned A0–A2 report for conditions and provenance.

Approach

The core technical contributions are:

  • deterministic data splits with revisions and SHA-256 fingerprints;
  • canonical <<expression=result>> supervision;
  • safe AST-based arithmetic parsing without eval;
  • exact arithmetic graphs compiled into executable postfix programs;
  • declarative ablations sharing one training and evaluation pipeline;
  • separate final-answer, format, step-accuracy, and consistency metrics.

Quick start

Python 3.10–3.13 is supported. Data preparation and tests run on CPU; full training is intended for CUDA.

python3 -m pip install uv
uv sync --frozen
uv run ruff check .
uv run pytest

Prepare the frozen split:

uv run python script/create_data_split.py

Train an ablation:

uv run python script/train.py \
  --ablation A1 \
  --num-train-epochs 30 \
  --wandb-mode disabled \
  --require-cuda

Evaluate the pretrained model:

uv run python script/evaluation.py \
  --experiment-name a0-pretrained-test \
  --output-file outputs/a0_test.json

Evaluate a LoRA checkpoint:

uv run python script/evaluation.py \
  --checkpoint-path outputs/qwen2.5-1.5b-gsm8k-a1 \
  --experiment-name a1-lora-test \
  --output-file outputs/a1_test.json

Use --subset-size 20 for a smoke evaluation. Weights & Biases tracking is optional; set WANDB_KEY in .env and choose --wandb-mode online to enable it.

Research program

Stage Objective Status
A0 pretrained baseline evaluated
A1 completion-only cross-entropy evaluated
A2 mathematical-token weighting evaluated
A3 signed-log result prediction implemented
A4 postfix execution consistency implemented
A5–A7 structured operator, dependency, and composition losses planned
A8 best-of-N generation with verification planned

The complete hypotheses, controls, hyperparameters, and objective definitions are in the experimental protocol.

Documentation

Topic Reference
Documentation map documentation index
Experimental controls research protocol
Dataset and training features dataset contract
Arithmetic graph and postfix execution graph contract
Generated-answer parsing parsing contract
Evaluation metrics metric definitions
Planned experiments research roadmap

Repository layout

documentation/   scientific and technical contracts
script/          data, training, and evaluation entry points
src/data/        frozen splits, language features, arithmetic graphs
src/model/       model factory, tokenizer, device policy, auxiliary heads
src/training/    declarative objectives, callbacks, and Trainer
src/evaluation/  generation, parsing, diagnostics, and metrics
tests/           unit and integration tests

Citation, contribution, and license

Citation metadata is provided in CITATION.cff. Contributions must follow CONTRIBUTING.md and the frozen comparison protocol.

Original code and documentation are released under the Apache License 2.0. Qwen2.5 is Apache-2.0 and GSM8K is MIT. See THIRD_PARTY_NOTICES.md for attribution and checkpoint redistribution guidance.

About

Reproducible research on arithmetic reasoning with Qwen2.5 and GSM8K, combining LoRA ablations, structured computation objectives, and reasoning-aware evaluation.

Topics

large-language-modelsloramathematical-reasoningpytorchqwenstructured-reasoning

Resources

Readme
Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.