Executable declaration
A recurrence composed from typed Add, Scale, sigmoid and tanh, with named carry and Bank operands.
Python sourceRead it. Try it. Make it yours.
English and Chinese Transformer reading cases, a reproducible comparison, and a first neural program you can understand.
01 / SHARED NEURAL PROGRAM
The same public FormulaScan runs five steps in PyTorch and native JAX, returning hidden and accumulated carry. Selected Bank values receive finite, nonzero gradients.
A recurrence composed from typed Add, Scale, sigmoid and tanh, with named carry and Bank operands.
Python sourceInputs, emissions, returned carry, selected gradients and the bounded CPU JAX jit comparison.
RecordWorkloads and evaluation
Load the saved reading program on CPU and ask about your passage. Follow the measured training case when you need to change the component.
Follow the caseAsk about short Chinese passages with the CPU starter. The complete case records retraining, saved outputs and the official Chinese scorer.
Follow the case01 / LOCAL PYTHON · CPU
After the reading starter, inspect a trainable numerical operand and returned state in this small CPU program. It demonstrates the mechanism, not task effectiveness.
Program walkthroughfrom json import dumps
from torch import autograd, nn, tensor
from arti import mechanisms as api
pair = api.TensorType(("C",), (2,), dtype="float32")
signal = api.InputBinding("signal", pair)
carry = api.InputBinding("carry", pair)
bank = api.BankBinding("weight", "tutorial/carry-weight@1", "weight", api.TensorType((), (), dtype="float32"))
transition = api.add(carry, api.scale(signal, bank))
summary = api.reduce_tensor(transition, axis="C", mode="sum")
program = api.FormulaProgram.build(outputs=(summary, transition))
parameter = nn.Parameter(tensor(0.75))
provided = dict(signal=tensor([4.0, -2.0]), carry=tensor([1.0, 1.0]))
emitted = api.FormulaFabricV2(program)(inputs=provided, banks=dict(weight=bank.bind(parameter)))
readout, returned_carry = emitted.values
gradient = autograd.grad(readout, parameter)[0]
record = dict(readout=readout.item(), next_carry=returned_carry.detach().tolist(), weight_vjp=gradient.item())
print(dumps(record))The readout has a weight VJP of 2. The original carry stays unchanged; the program returns a new carry.
{
"readout": 3.5,
"next_carry": [
4.0,
-0.5
],
"weight_vjp": 2.0
}This example makes one forward call and a VJP, with no optimizer update. The caller decides whether to adopt the new carry in another call.
02 / PUBLIC SOURCE
These links point to the exact public revision used by this website.
Typed operands, trainable Bank values and gradients.
SourceFollow caller-owned carry through a bounded FormulaScan.
SourceA project tutorial covering checkpoints, committed output and offline handoff.
TutorialAn official non-language example with a native resource graph, original labels and task-owned loss. Its scikit-learn data dependency belongs to the example.
SourceInspect a saved run, resume its original target or deliberately finalize evaluation and export.
Source