TIM — TINY INFERENCE MODEL [ ver 2026-09-24-d ]© Leonard Brown, 2026
9-WEIGHT SURFACE TRAINING MODEL
Recursive least squares learns a compressed nine-parameter approximation of the true Himmelblau terrain.
SettingValue
Training points
Noise σ
Random seed

The random seed is included in the HTML version so the training example is reproducible.

HOW TO READ THIS SHEET
1. INITIALIZE: weights start at 0; uncertainty starts very high.
2. OBSERVE: generate x and y, calculate true z, then add noise.
3. ENCODE: use nine selected features; x⁴ and y⁴ are deliberately omitted.
4. TRAIN: prediction error updates the weights and reduces uncertainty.
LEARNED DOMAIN CHARACTERIZATION
FEATURELEARNED WEIGHT

Learned weights need not equal generating coefficients because the representation omits x⁴ and y⁴. High confidence in the estimated parameters does not necessarily imply an accurate representation of the environment.

TRAINING TRACE
IDSplitxyTrue zNoiseObserved zPrediction errorTrace of covariance Pw(1)w(x)w(y)w(x²)w(x·y)w(y²)w(x³)w(x²·y)w(x·y²)
PROMPT
ROUTE PROMPTXY
START
END
DOMAIN RESOLUTION
DOMAIN CHARACTERIZATION

Unchecked = weights generated by the Training section. Checked = frozen example/book weights.

Weight source
FEATUREACTIVE WEIGHTGENERATEDBOOK WEIGHTS
RESULTS OF GENERATION LOOP
Number of hops—
Total route cost—
Destination reached—

HopXYZChoices
LLM PROMPT GENERATOR
INHERITED FROM INFERENCE
Start:
Destination:
Domain Resolution:
Weight Source:
Domain Characterization:

TERRAIN CONTOURS AND SELECTED ROUTE
Contours show the active domain characterization. The overlaid route is the exact sequence of states selected by TIM's generation loop.
Imported from Inference
Domain Resolution—
Weight Source—
Number of Hops—
Destination Reached—
—

Inspect terrain height: Click anywhere inside the terrain plot to display the height (Z) at that point.

Terrain contour
Selected route
Generated route state
↑Uphill direction

Visualization is a display utility only. It does not participate in training, candidate evaluation, route selection, or the generation loop.

For convenience, RE-GEN NOISE is also available here when LOW RESOLUTION uses GENERATED WEIGHTS. It retrains TIM with a fresh noise realization and regenerates the route.

DOCUMENTATION
TIM — TINY INFERENCE MODEL
TIM is a small, transparent system designed for pedagogical purposes. It separates three components that are often difficult to observe independently in larger AI systems: learning a domain characterization, inference using a prompt and generation loop, and expressing the same inference task as a natural-language prompt for a general-purpose LLM.

Purpose

The Training page demonstrates how observations from an environment can be compressed into a small domain characterization. TIM uses Recursive Least Squares (RLS) to estimate nine weights sequentially from noisy observations of the Himmelblau surface.

Environment and observations

Training points x and y are sampled from the domain −5 ≤ x ≤ 5 and −5 ≤ y ≤ 5. The true value is calculated from the Himmelblau function and Gaussian noise is added to create the observed value used for training.

z = (x² + y − 11)² + (x + y² − 7)²
SettingMeaning
Training pointsNumber of sequential observations supplied to RLS.
Noise σStandard deviation of the Gaussian observation noise.
Random seedMakes the generated training sample and noise reproducible. RE-GEN NOISE advances the seed and performs a new learning run.

Nine-term encoding

Each observation is encoded using nine features:

[1, x, y, x², xy, y², x³, x²y, xy²]

The x⁴ and y⁴ terms present in the true Himmelblau surface are deliberately omitted. The learned surface is therefore a compressed approximation rather than an exact representation of the environment.

Recursive Least Squares

Weights begin at zero and the covariance matrix P begins with very high diagonal values. For each observation TIM calculates a prediction, observes the prediction error, and updates both the nine weights and P. The trace of P is the sum of its diagonal elements and provides a compact measure of total parameter uncertainty.

Important: declining parameter uncertainty does not by itself imply that the chosen nine-term representation is an accurate description of the environment.

Training trace

The trace table exposes the sequential process: observation number, sampled coordinates, true z, noise, observed z, prediction error, trace of covariance P, and all nine weights after each update. The final learned weights are passed directly to the Inference page as the GENERATED WEIGHTS option.

Purpose

The Inference page uses a domain characterization plus a prompt and a deterministic generation loop to construct a route from START to END. The learned parameters are frozen during inference; inference does not retrain the domain characterization.

Prompt

InputMeaning
STARTInitial x,y state of the route.
ENDDestination and stopping target.
DOMAIN RESOLUTIONLOW RESOLUTION uses a nine-weight polynomial. HIGH RESOLUTION uses the actual Himmelblau function directly.

Domain characterization

In LOW RESOLUTION mode, GENERATED WEIGHTS uses the current output of the Training page; BOOK WEIGHTS uses the fixed example weights embedded in TIM. In HIGH RESOLUTION mode the learned weights are bypassed and the actual Himmelblau function is used.

LOW RES: Z(x,y) = θ₁ + θ₂x + θ₃y + θ₄x² + θ₅xy + θ₆y² + θ₇x³ + θ₈x²y + θ₉xy²

Generation loop

  1. Generate ordinary candidate endpoints one unit from the current state at 15° heading increments.
  2. If the destination is within one unit, add the exact destination as a candidate.
  3. Reject candidates that violate the course-change or visited-position restrictions.
  4. Evaluate the domain characterization at each legal candidate. A candidate outside the −5 to 5 domain is assigned Z = 10000.
  5. Calculate uphill cost U = max(0, Z(candidate) − Z(current)) and remaining distance D.
  6. Min-max normalize uphill cost and distance separately over the current legal candidate set.
  7. Calculate Score = Norm Uphill + Norm Distance and select the lowest-scoring candidate, applying deterministic tie rules if required.
  8. Make the selected candidate the new state, add it to route history, and repeat until the destination or stopping condition is reached.

Route restrictions

Ordinary hop length is 1. After the first movement, course change must be strictly greater than 15°. A candidate within 0.25 of any previously visited route point is unavailable. These restrictions give the generation loop memory of the route already taken without changing the frozen domain characterization.

Results table

ColumnMeaning
HopSequential route state; 0 is the start.
X, YCoordinates of the visited state.
ZDomain-characterization value at that state.
HeadingDirection of movement from the previous state.
Norm UphillSelected candidate's normalized uphill cost within the candidate set for that hop.
Norm DistanceSelected candidate's normalized remaining-distance cost within that candidate set.
ScoreNorm Uphill + Norm Distance for the selected candidate.
Cumulative Decision ScoreRunning sum of selected local scores.
DistanceEuclidean distance from the current state to END.

Purpose

The LLM Prompt Generator converts the current TIM inference configuration into a complete natural-language specification that can be copied to a general-purpose LLM. This permits the same numerical task to be executed independently outside TIM.

What is inherited from Inference

The generator inherits five items from the current Inference configuration: Start, Destination, Domain Resolution, Weight Source, and Domain Characterization. Changing the Inference settings therefore changes the generated prompt.

What the generated prompt specifies

The prompt contains the selected domain characterization, start and destination, candidate-generation rules, heading and route-history restrictions, domain-boundary treatment, uphill and distance calculations, normalization, local scoring, tie handling, stopping rules, numerical precision requirements, and the required result columns.

Why the prompt is explicit

The purpose is reproducibility rather than conversational brevity. The prompt is intentionally detailed so that the external LLM is asked to perform the same defined inference procedure rather than infer missing rules or substitute a different routing method.

Using the result

Select COPY PROMPT and submit the copied text to an LLM with numerical code execution available. The requested Markdown route table can then be compared with TIM's own deterministic route table. Agreement provides a direct comparison of the results produced from the same domain characterization, prompt constraints, and generation procedure.

Candidate evaluations

The 24 standard headings are always shown. Illegal moves are excluded from normalization and scoring. A direct-to-destination candidate, when generated, is shown separately.