手搓左腦1號 / HandWired-LeftBrain-1 (v0.5)

Hugging Face repo id: Bigbearbo/handwired-left-brain-1 (tags: v0, v0.2, v0.3, v0.4, v0.5)

v0.5 = v0.4 unchanged + a new folder combined/: the official-7 left brain packed into one PyTorch nn.Module with a single inference entry point (question characters in, answer characters out; reading, routing, arithmetic and printing all inside the tensor graph). See "Combined model" below.

Combined model (合體模型), new in v0.5

One nn.Module (combined/left_brain_rt.py, depends on torch only) with weights in combined/合體模型_b20_46270d6d.pt (8.2 MB; sha256 46270d6d8aa78bfc3a58aa0bdfcf601db16bf128c6175b44315bfc46fafaaf87; 合體模型_b20.pt is the same file under its compatibility name, 合體模型_現行.json points to the current one).

  • Input / output: question as Unicode code points (up to 64 characters), answer as code points; an all-zero answer = refused. No host-side parsing, no Python calculator, no network: the host only converts strings to code points and back.
  • Inside: a fixed-length loop of one step (at most T = 14,385 rounds, stops early once every row is settled). Each step is integer-weight threshold layers y = W2 · H(W1 x + b1) (sparse float64) plus 0/1 gating. Parts: a character-level question reader (the DeepMind sentence patterns as a trie, with number registers), the fraction step machine and gcd network of the v0.2 ladder (weights unchanged), a stack machine for mixed and linear_1d (operator stack 7, value stack 5, two lanes for the unknown), the 6-bit segment core (segnet2, same weights as the v0.3 pipeline) for add / subtract up to 32-bit operands, and binary-to-decimal / alignment / display layers.
  • Coverage: the 7 official train-easy modules (add_or_sub, mul, div, mixed, gcd, div_remainder, linear_1d). Unit and non-zero counts are in combined/RESULT_46270d6d_20261130_112009.json, field 規模.
  • Limits (refused, not guessed): add / subtract numbers up to 2^32, other modes 2^20; at most 7 decimal places; only the official phrasings (exact case and spacing); questions up to 64 characters.

Change in this release (#278, fourth step): add / subtract (plus, minus, "less than" / "subtract from", distance) now run through the segment core instead of the 20-bit fraction machine, so the 23 official add_or_sub questions the previous internal version refused (numbers above 2^20) are answered.

Quick use (Python 3.10+, pip install torch):

cd combined
python run.py "Divide 33 by -225." "What is 1412832 less than 2?"   # -> -11/75, -1412830
python run.py --eval --limit 3      # first 3 per module of ../data/official_train_easy_1400.json
python run.py --eval                # all 1,400
import left_brain_rt as RT
m = RT.LeftBrainRT.load("合體模型_b20_46270d6d.pt")
m.answer(["Divide 33 by -225.", "Calculate -0.00258 - 0.3."])   # ['-11/75', '-0.30258']

Results (self-reported, 2026-11-30):

check result
official train-easy, 7 modules x 200 (data/official_train_easy_1400.json, same 1,400 as v0.2-v0.4), rerun with this package: python run.py --eval in a clean folder holding only combined/ (run.py, left_brain_rt.py, the .pt, the json pointer) and the data file, python -I 1,400 / 1,400 correct, 0 wrong, 0 refused (182 s, CPU)
same 1,400, project run: answer string compared question by question with pipeline #83 (the lb/ pipeline of v0.3) identical on all 1,400
bits=20 sample: random + edge cases, incl. 1,376 big add / sub questions up to 2^33, malformed phrasings, leading / trailing zeros 3,741 / 3,741 match the reference (1,057 have "refuse" as the reference). A sample, not exhaustive
stack machine sample, bits=20 (mixed with 1-7 operators, linear_1d, special cases) 990 / 990. A sample
small-parameter exhaustive check, bits=6 (all signed integer pairs in [-63, 63] per mode, plus decimal and big-number samples) 122,611 / 122,611; stack machine bits=6: 30,013 / 30,013
negative controls (deliberately broken copies must fail) carry removed from the binary-to-decimal layer: 53 / 64 caught; reader without end-of-sentence check 5 / 5; "less than" without swapping 19 / 20; add / sub without decimal alignment 19 / 19
early exit vs. all T rounds; frozen rows vs. every row computed bit-identical (70 questions each)

Build scripts, for reference: combined/left_brain.py and combined/stack_machine.py generate the weights from the step-machine, fraction-machine and segment-core sources under lb/ (absolute project paths were mechanically changed to paths into lb/; the build was not re-run from this package). They also need numpy; inference does not.

Earlier releases

v0.4 = v0.3 left brain, unchanged (lb.py, lb/, data/, results) + a new folder spiral/: the combined pipeline (Spiral-language word-problem reader + program brain), see "Combined pipeline" below. Demo: https://huggingface.co/spaces/Bigbearbo/handwired-left-brain-1-gradio (tab "Word problems").

An arithmetic "left brain" whose network weights are filled in by hand (not trained): threshold (step-activation) networks plus a fixed 6-bit "segment core" for big integers. A plain Python host reads the question with a rule grammar, routes it, schedules the steps and reads the answer bits; the networks do the arithmetic.

Release status: v0.5, unofficial, self-reported numbers. Nothing here has been verified by a third party.

Combined pipeline (螺旋語讀題+程式腦+手搓左腦), new in v0.4

Hand-wired + py (手搓+py). Reading English word problems and the "program brain" are, for now, Python rule programs (not a neural network, no LLM). The arithmetic is handed to the hand-wired left brain of this repo. The py part can later be compiled into networks.

English word problem
  → reader (rules: rule tree, no LLM)                   spiral/專案/手搓算術/規則樹/詞分類接入.py (+ engine.py, 資訊句輸出.py, 樹.json, 詞庫.json, 葉子/)
  → Spiral information sentences (English style)        have(reggie, usd, 48, start). buy(reggie, book, 5, price(book, 2, book)). ask(have(reggie, usd, ?, end)).
  → parser                                              spiral/專案/手搓算術/語法模組/資訊句/解析.py
  → program brain: blocks → equations → exact solve     spiral/專案/手搓算術/語法模組/資訊句/程式腦.py (+ 語法模組 api.py, 核心.py, 單位/比較/移轉/部分與整體/速率/輸出格式)
     (returns variable table, equations with letter names, teaching steps, prefix; or refusal class + gap: which sentence, what is missing)
  → Spiral prefix                                       減 48 乘 5 2
  → hand-wired left brain (lb.py)                       each integer + - * / becomes one question for the networks

Concept list of the information sentences: spiral/專案/手搓算術/語法模組/資訊句/基本概念表.md. Knowledge used by the program brain: unit conversions 語法模組/知識庫/換算.json (definition-type standard conversions with context cues; ambiguous words such as quarter are only used when the cues pick one sense, otherwise "missing knowledge" refusal), 轉換庫/轉換表.json. Word classes for the reader: 語法模組/詞分類/庫.json (built from Princeton WordNet 3.0, WordNet License: keep its copyright notice) and 句首功能詞.json. Word-form table 語法模組/語形/ (plural / tense → base form; WordNet 3.0 exception lists; not yet used by the reader in this release).

Quick use (from the repo folder, Python 3.10+, standard library only for spiral/):

import sys
sys.path[:0] = ["spiral/專案/手搓算術/規則樹", "spiral/專案/手搓算術/語法模組/資訊句"]
import 詞分類接入 as W
r = W.solve("Zorvak has 5 glimbs. Zorvak gives 2 glimbs to Quilla. How many glimbs does Zorvak have now?")
r["英文式_編號"], r["prefix"], r["value"]     # information sentences, '加 5 負號 2', '3'

The Space's spiral_tab.py shows how the prefix is computed by the left brain, one network call per integer operation; operations the integer networks cannot take (non-integer operand, unit-table factor) are done by Python exact fractions and labelled.

Honest coverage. This release ships only the rule-tree reader, which knows few sentence patterns (mostly simple MAWPS-style questions). It refuses what it cannot read. Project runs of this path (2026-11-25): MAWPS 253 / 5,196, ASDiv 23 / 2,305, SVAMP 6 / 1,000, GSM8K train 1 / 7,366 correct, all others refused, 0 wrong. The team's main word-problem reader (a different program) reaches about 1,172 / 7,473 on the GSM8K train development set; it is not included here. No blind-test score yet. Self-reported.

Not included in spiral/: 知識庫/基礎詞.json (derived from a vocabulary list that requires attribution for non-commercial use only; the program brain skips it when absent and only loses one kind of "missing knowledge" refusal), the LLM reading experiments, any test / held-out questions.

Changes v0.2 -> v0.3

  • 27 DeepMind modules instead of 7. v0.3 ships the project's main pipeline #83 (lb/專案/手搓算術/總入口/管線_83.py), which joins
    • the 7 official arithmetic modules (pipeline #79 networks and ladder),
    • the 20 "first-level" modules (#196 parts and the #223 add-on parts: polynomial roots of any degree and factorisation, sequence n-th term, surds, big-integer primality by segmented division, k-th roots, big place value / rounding, term-wise derivative), and
    • the segment core (segnet2, project #227): one fixed hand-wired network that works on 6-bit segments of a ring of up to 120 segments, stepped by a small program; big add / sub / mul / div / remainder / gcd that are too large for the ladder go there instead of being refused.
  • New one-question entry point lb.py (lb.solve(question, gold=None)), and eval.py --part ... for the four frozen question files.
  • Packaging: the source files are copied from the project tree with their folder layout (lb/), with only mechanical edits: absolute Windows paths -> paths relative to lb/, and a non-Windows fallback for the memory check. 打包_v0.3.py in the project did this.
  • No LLM path: the project's optional Claude Haiku fallback for unreadable questions is replaced by a stub that always refuses (lb/專案/手搓算術/數學題轉螺旋語/第一層對照.py); no API keys are read, no network calls are made.
  • Not included: the #84/#85 network transcoder (pipeline #83 tokenises on the host, like v0/v0.2), and weights_manifest.json (not regenerated for v0.3; the v0.2 manifest is under tag v0.2).

The 27 modules and results

All questions come from the official DeepMind mathematics_dataset generator (google-deepmind/mathematics_dataset, commit 427f450, run with sympy 1.14), seed 20261122, frozen in data/. Each question is correct / wrong / refused (refused = the system says it cannot answer; it never guesses).

Official 7 modules, train-easy (200 each, 1,400) - rerun with this v0.3 package

1,400 / 1,400 correct, 0 wrong, 0 refused (python eval.py --part train-easy-7, 2026-11-25, in a clean copy of this folder outside the project tree, with a guard that fails on any file access to the original project; rule grammar only, no cached LLM translations; 423 s). Per-question rows: results_train-easy-7.json.

module correct / wrong / refused
arithmetic__add_or_sub 200 / 0 / 0
arithmetic__mul 200 / 0 / 0
arithmetic__div 200 / 0 / 0
arithmetic__mixed 200 / 0 / 0
numbers__gcd 200 / 0 / 0
numbers__div_remainder 200 / 0 / 0
algebra__linear_1d 200 / 0 / 0

Same 1,400 questions as v0.2 (data/official_train_easy_1400.json is unchanged). History: v0 1,380 / 0 / 20; v0.2 1,400 / 0 / 0.

First-level 20 modules, train-easy (100 each, 2,000) - project run of pipeline #83 (2026-11-23), not rerun in full with this package

2,000 / 2,000 correct, 0 wrong, 0 refused.

module correct / wrong / refused module correct / wrong / refused
comparison__pair 100 / 0 / 0 arithmetic__add_sub_multiple 100 / 0 / 0
comparison__kth_biggest 100 / 0 / 0 arithmetic__mul_div_multiple 100 / 0 / 0
comparison__closest 100 / 0 / 0 arithmetic__simplify_surd 100 / 0 / 0
comparison__sort 100 / 0 / 0 arithmetic__nearest_integer_root 100 / 0 / 0
numbers__lcm 100 / 0 / 0 algebra__linear_2d 100 / 0 / 0
numbers__is_prime 100 / 0 / 0 algebra__polynomial_roots 100 / 0 / 0
numbers__is_factor 100 / 0 / 0 algebra__sequence_next_term 100 / 0 / 0
numbers__list_prime_factors 100 / 0 / 0 algebra__sequence_nth_term 100 / 0 / 0
numbers__round_number 100 / 0 / 0 calculus__differentiate 100 / 0 / 0
numbers__place_value 100 / 0 / 0 numbers__base_conversion 100 / 0 / 0

Package spot check (v0.3, clean copy with the same guard, first question of each module): 20 / 20 correct. Slowest: round_number 66 s, polynomial_roots 60 s, is_prime 37 s (single question, including network build). Negative control in the project run: with the #223 add-on parts switched off, the 8 modules that use them go back to refusing (e.g. sequence_nth_term 0/0/20 of 20, simplify_surd 0/0/20), and wrong stays 0.

Harder splits (official 7 modules) - project run of pipeline #83 (as the baseline of the #84 comparison, 2026-11-23)

split questions correct wrong refused
interpolate, 7 modules x 200 1,400 1,398 0 2 (algebra__linear_1d)
extrapolate, 6 modules x 200 1,200 1,199 0 1 (arithmetic__mixed_longer)

Extrapolate per module: add_or_sub_big 200/0/0, mul_big 200/0/0, div_big 200/0/0, mixed_longer 199/0/1, add_sub_multiple_longer 200/0/0, mul_div_multiple_longer 200/0/0. The extrapolate file has 3 more modules (round_number_big, place_value_big, polynomial_roots_big, 600 questions) that were not scored and are not claimed; in the spot check polynomial_roots_big was refused (number outside the first-level range).

Where the "27" comes from: 7 official modules + 20 first-level modules, all at train-easy difficulty. Only the official 7 have interpolate / extrapolate results; the first-level 20 have not been run on interpolate / extrapolate.

Big numbers

The official extrapolate big-number questions have up to 19 digits (add/sub), 11 digits per factor (mul) and 12 digits (div). The segment core's ring holds up to 120 six-bit segments (720 bits, about 216 decimal digits per operand for add/sub, about 108 per factor for multiplication). What was actually checked:

  • official extrapolate files: add_or_sub_big, mul_big, div_big 200 / 200 each (project run, above);
  • v0.3 spot probe (one random question each, 2026-11-25): add/sub with 30, 60 and 100 digits correct; 216 and 230 digits refused (the question reader's big-number route stops there); multiply 20 x 20 and 40 x 40 digits correct; divide 30 / 16 and 60 / 31 digits correct;
  • 10 random questions per big type drawn like the demo's big-number switch (official extrapolate sizes): add/sub 9 / 10 at first, the 10th ("difference between 3 and 728982853554138", graded correct by the pipeline but its answer was not read back by lb.py) answered correctly after that read-back was fixed and re-checked, multiply 10 / 10, divide 10 / 10, wrong 0.

So: up to 100 digits for add/sub and 40 digits per factor for multiplication were seen correct; larger inputs may be refused or slow, and are not claimed. A big product can take 30-60 s on CPU (the ladder tiers try first, then the segment core).

How to run

pip install -r requirements.txt                 # numpy, sympy
python lb.py "What is 60067806160322 + -6205?"   # one question -> answer, route, reader tokens
python eval.py --part train-easy-7              # official 7 modules, 1,400 questions (about 7 minutes)
python eval.py --part level1-20 --limit 2       # first-level 20 modules, first 2 per module
python eval.py --part interpolate-7             # or: extrapolate

Run from inside the folder; no other path or environment variable is needed (eval.py restarts itself with PYTHONHASHSEED=0, as in the project runs). Python 3.10+ ; about 1.5 GB of RAM. The full first-level run took several hours on the author's CPU (polynomial roots, integer roots and surds are slow: about 15-35 s per question).

import lb
lb.solve("What is 5124 divided by -1254455?")
# {'answer': '-5124/1254455', 'status': 'Answered', 'route': 'official-7 ladder ...', 'tokens': '...', ...}

What this is and is not

  • Weights are hand-set integers (no gradient training, no dataset fitting); generator programs in lb/ build them at run time.
  • Reading the English question is a rule grammar in Python (layer1.py, nl2en*.py, nl2en_t1.py), not a network. Phrasings it does not know are refused.
  • The host does reading, routing, scheduling of multi-step problems, moving numbers into network inputs and reading answer bits. Some first-level modules use more host scheduling (e.g. trying candidate roots, which the networks then check); see the module sources.
  • Grading uses the official answer strings: numbers as exact rationals, algebraic answers (sequence formula, derivative, factorised polynomial) by sympy equivalence.
  • DeepMind has no official certification or leaderboard for this dataset. Saxton et al. 2019 report neural-model accuracies, but this system covers 27 of the modules and reads questions with a rule grammar, so totals are not directly comparable.

Contents

README.md, requirements.txt
lb.py                     one-question entry point (calls pipeline #83, reads back the network answer)
eval.py                   rerun on data/*.json -> results_<part>.json
results_train-easy-7.json per-question rows of the v0.3 rerun (official 7, train-easy)
data/official_train_easy_1400.json, level1_train_easy_2000.json, official_interpolate_1400.json, official_extrapolate_1800.json
lb/                       project sources with their folder layout (專案/手搓算術/..., claude-接手Fable-20261117/)
spiral/                   v0.4: word-problem reader (rule tree) + program brain + 語法模組 + knowledge files (same folder layout)
combined/                 v0.5: one nn.Module (left_brain_rt.py, torch only) + weights .pt + run.py + RESULT json + build scripts

Known limitations

  • 27 modules only, English rule grammar only; other phrasings are refused.
  • First-level modules: train-easy only; interpolate / extrapolate not run.
  • Slow modules (polynomial roots, nearest integer root, surds, primality of big numbers) take 10-40 s per question on CPU.
  • Source files keep internal identifiers and comments in Traditional Chinese, internal ticket numbers (#xx), and code paths this pipeline never uses.
  • All numbers are self-reported by the author's own runs.

License

CC BY-NC 4.0 (non-commercial) for the code, the weight generators and the exported weights (combined/*.pt). The questions come from the Apache-2.0 licensed DeepMind mathematics_dataset generator; keep its attribution if you redistribute them. spiral/ files derived from Princeton WordNet 3.0 (詞分類/庫.json, 語形/語形表.json) keep the WordNet License notice: "WordNet 3.0 Copyright 2006 by Princeton University. All rights reserved." 語法模組/速率/THIRD_PARTY_NOTICE.md lists the ideas taken (not code) from CogComp/arithmetic (MIT).

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Spaces using Bigbearbo/handwired-left-brain-1 3

Evaluation results