Views
No views yet
calculator_memorize, max_digits=2 (torchwright)calculator_memorize example built with max_digits=2: a computation graph for integer arithmetic (A op B with op in + - *) that computes nothing: every answer is a memorized fact, looked up from the operand pair.transformers
without custom model code or trust_remote_code.do_sample=False). Other
precisions and decoding modes are outside the supported contract.1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3repo_id = 'physicsrob/torchwright-calculator-memorize-max-digits-2'
4model = AutoModelForCausalLM.from_pretrained(repo_id).eval()
5tok = AutoTokenizer.from_pretrained(repo_id)
6
7enc = tok('12*34\n', return_tensors="pt")
8out = model.generate(enc["input_ids"], max_new_tokens=32, do_sample=False,
9 eos_token_id=tok.eos_token_id, pad_token_id=tok.eos_token_id)
10print(tok.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True))A op B terminated by a newline: two non-negative decimal
operands of up to 2 digits, with op one of +, -, *.
Subtraction may produce a negative result. Wider operands, or any character
outside the model's small vocabulary, are outside the contract — the output
is undefined.| prompt | output |
|---|---|
12*34 | 408 |
7+8 | 15 |
99*99 | 9801 |
99+1 | 100 |
99-12 | 87 |
12-99 | -87 |
transformers, checks those
examples plus additional width-limit cases against Python integer arithmetic,
and refuses to upload on a mismatch. This is a functional smoke test, not
exhaustive verification of every allowed expression.transformers execution still
pays their memory and compute cost. CPU execution is supported; allow
additional RAM beyond the checkpoint size.calculator-simple (serial arithmetic, depth grows with the digit count),
calculator-advanced (carry-lookahead, near-flat depth),
calculator-scratchpad (flat depth; the serial work streams out as visible
thinking tokens), and calculator-memorize (no arithmetic at all: a fact
table, exponential in the digit count) — are published at several digit
widths. Browse the
torchwright calculator models
on Hugging Face.