prteek/newton-net-questions
Viewer β’ Updated β’ 5.89k β’ 51
A tiny language model plus a fixed, differentiable Newtonian planner (the equations of motion and F = mΒ·a) in one computation graph. It answers short driving questions ("doing 70 mph in the rain, how far to stop?") with exact maths and a trace of every step, and refuses anything it can't answer. An alternative to LLM tool calling: the physics runs inside the model's forward pass, so the reader learns to read questions from whether the physics gets the answer right.
Status: work in progress, no trained weights yet. This repo holds the pipeline as a minimal first version, each stage just enough for the demo:
| file | stage |
|---|---|
extract.py |
1. Extractor: each number + unit β dimension and SI value (regex over a table of units); the text with values replaced by markers |
reader.py |
2. Reader + router: what is asked and how the values fit together; keyword rules standing in for the TinyLLM |
assembler.py |
3. Assembler: the extracted values and the reader's choices β one value per quantity |
planner.py |
4. Planner: chains the equations of motion to the target; differentiable on torch tensors |
from model.assembler import assemble
from model.extract import extract, mask
from model.planner import solve
from model.reader import read
question = "A car at 30 m/s brakes at 0.7g. How long until it stops?"
quantities = extract(question)
choice = read(mask(question, quantities))
steps, values = solve(assemble(quantities, choice), choice["target"])
print(steps) # ['t = (v - u)/a = 4.37']
decisions.md