A clean, end-to-end agentic learning pipeline for math word problems (MAWPS-style): local FLAN-T5 equation generation, sentence-transformer semantic neighbors, numeric peer patching when outputs fail SymPy validation, and a thin LangGraph orchestration layer with optional OpenAI calls.
This repository is designed as a portfolio-grade LLM systems project. It emphasizes the engineering discipline expected in applied ML and LLM teams: modular architecture, reproducibility, tests that avoid heavy model downloads, and clear separation between library code and notebooks.
What reviewers should notice quickly:
- End-to-end workflow from MAWPS JSON through equation prediction, SymPy verification, and metric computation
- Reusable package-first implementation under
src/scaffold/,src/graphs/, andsrc/utils/ - Notebook as a consumer layer, not a dumping ground for core logic
- Script entrypoints for batch experiments and baseline evaluation without GPUs (
evaluate_results.pyon checked-in predictions) - Baseline snapshot predictions plus regeneration path for apples-to-apples comparisons
This project demonstrates how to:
- Load structured MAWPS-style datasets (
data/raw/) - Combine generation (FLAN-T5 or optional OpenAI) with semantic retrieval and rule-based repair
- Evaluate predicted equations against gold with SymPy equivalence
- Run the same logic through LangGraph for inspectable, phase-based workflows
data/raw/— MAWPS train/test JSON used by experimentsresults/metrics/— prediction JSON, baseline snapshots, optional metric dumpssrc/scaffold/— prompts, strategies, solver, verifier, evaluator, LangGraph-related shared statesrc/graphs/— compiled LangGraph workflow (understand_problem→ … →summarize_result)src/integrations/— optional OpenAI client (no key → local path only)src/utils/— I/O, logging, semantic neighbor helpersscripts/— data checks, run experiments, evaluate accuracynotebooks/— article-aligned reproduction walkthroughdocs/— model governance and notes (see Documentation artifacts)templates/— reusable experiment logging template
Show a production-style approach to building LLM-assisted systems — not just ad hoc notebooks: scripts and packages own behavior; notebooks document and drive the same APIs.
- Clear separation of concerns (prompting, solving, verification, graph wiring, I/O)
- Reusable Python packages under
src/(importable afterpip install -e .) - Thin notebook layer that calls the same code paths as
scripts/ - Command-line entrypoints for reproducible batch runs and fast baseline checks
- Test suite that validates parsing, patching, and verification without downloading Hugging Face weights in CI
flowchart LR
A["CLI / Notebook Entry\nscripts/*.py or notebook"] --> B["AgenticSolver\nsrc/scaffold/solver.py"]
B --> C["Equation generation\nFLAN-T5 or optional OpenAI"]
C --> D["Semantic neighbors\nsrc/utils/semantic_neighbors.py"]
D --> E["Peer number patch\nsrc/scaffold/strategies.py"]
E --> F["SymPy verify\nsrc/scaffold/verifier.py"]
F --> G["Predictions JSON\nresults/metrics/predictions.json"]
G --> H["Evaluation\nscripts/evaluate_results.py"]
H --> I["Metrics print / JSON\naccuracy, parse failures"]
J["LangGraph (optional)"] --> K["reasoning_graph.py\nsrc/graphs/reasoning_graph.py"]
K --> B
Core solving behavior lives in src/scaffold/solver.py and is reused by scripts/run_experiment.py and the LangGraph builder.
flowchart LR
A["Batch or stream\nproblems + JSON I/O"] --> B["Inference worker\nCPU/GPU or hosted API"]
B --> C["Post-process\nsemantic neighbors + peer patch"]
C --> D["Verify + metrics\nSymPy + evaluator"]
D --> E["Artifacts\npredictions + scores"]
E --> F["Monitoring\naccuracy / parse rate over time"]
How this repo maps
scripts/run_experiment.py→ batch inference job (local or containerized)scripts/evaluate_results.py→ offline evaluation harness (golden labels vs predictions).env+src/integrations/openai_client.py→ optional hosted LLM path with explicit fallbackdocs/model_card.md→ terse governance summary for the solver stacktemplates/experiment_log_template.md→ experiment traceability for reruns and comparisons
make setup
make run
make checkOr run directly:
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
python scripts/generate_data.py
python scripts/evaluate_results.pyFull regeneration (downloads models on first run):
python scripts/run_experiment.py
python scripts/evaluate_results.py --predictions results/metrics/predictions.jsonNotebook:
jupyter notebook notebooks/01_article_reproduction.ipynbCopy .env.example to .env and set OPENAI_API_KEY if you want to try cloud generation (python scripts/run_experiment.py --use-openai). Without a key, the stack uses local models and rule-based peer patching.
src/graphs/reasoning_graph.py exposes build_reasoning_graph(solver) after solver.load(). It mirrors the same solver used in scripts/run_experiment.py so graph runs stay aligned with batch experiments.
.venv/bin/python -m black src tests scripts
.venv/bin/python -m ruff check src tests scripts
.venv/bin/python -m pytest -qConfiguration lives in pyproject.toml (pytest, optional formatter/linter via [project.optional-dependencies] dev extras).
- Checked-in baseline predictions:
results/metrics/article_baseline_predictions.jsonvsdata/raw/mawps_test.jsonrecovers article-aligned numbers without re-downloading weights (seeREPRODUCTION.md). scripts/generate_data.pyvalidates that required MAWPS JSON files are present.- Single documented command order in
REPRODUCTION.mdandmake runfor the no-model baseline path.
- Recommended Python:
3.10+(requires-pythoninpyproject.toml) - Install dependencies from
requirements.txt - CI runs on Ubuntu with Python
3.10
- MAWPS subset and article snapshot are for demonstration and reproduction, not a claim of SOTA on all MWP benchmarks
- Default path uses a modest local generator (FLAN-T5-base); quality tradeoffs are intentional for portability
- Fairness, calibration across demographics, and production drift monitoring are out of scope for this scaffold
- Tighter integration tests around
AgenticSolverwith mocked generation (where practical) - Optional export of evaluation runs to a lightweight experiment database or folder convention
- Clearer abstractions for swapping encoders or peer-ranking policies
- Reproduction steps and article alignment:
REPRODUCTION.md - Model card (solver, data, metrics):
docs/model_card.md - Experiment template:
templates/experiment_log_template.md - Optional API configuration:
.env.example
MIT