This release is a pre-release and may not be stable for production use.
TensorCode
Website: tensorcode.dev · Docs: tensorcode.dev/docs · Source: GitHub · Changelog
TensorCode builds trainable Python programs from callable operations and small
tools that own their models. You compose encoders, scorers and decoders
(tensorcode.ops), or use a complete tool such as Investigator, Planner or
Chatbot (tensorcode.tools). You collect reviewed feedback with explicit
provenance, train with PyTorch, and save everything as a data-only artifact that
reloads in a fresh process or from the Hugging Face Hub. Tracing records which
operation produced which value, so supervised local tensor paths can be replayed
and trained. It does not make arbitrary Python or remote model calls
differentiable.
Status: 0.4.0 alpha. APIs may change between alphas. The core package has no dependencies and importing it does not import PyTorch or touch the network. Measured behavior and its limits are in validation. Consistent benefits of the learned cognitive workspace are not yet established.
Install
Python 3.11+:
python -m pip install 'tensorcode[tools]'
From a checkout, use python -m pip install -e '.[tools]'. Choose the extras
for the interfaces you use:
| Extra | Adds |
|---|---|
tools |
Owned models, training and Hugging Face loading (PyTorch, Transformers) |
vec |
Vector operations only (PyTorch, NumPy, safetensors) |
local |
Adapter for a local multimodal Transformers model |
diffusion |
tools plus diffusers for image decoders |
pretrained |
Alias of tools |
dev |
pytest, build, Pillow and PyArrow; the full test suite also needs diffusion |
30-second example
This trains an Investigator to rank two supplied hypotheses from log evidence.
It saves the model and reloads it. It runs offline on CPU in a few seconds.
import torch
from tensorcode import training
from tensorcode.tools.investigator import Investigator
torch.manual_seed(0)
model = Investigator({"vocabulary": ["database", "network", "connection", "refused", "packet", "loss"],
"dimensions": 16, "slots": 2, "steps": 1})
trainer = training.Trainer.from_tool(model, optimizer=torch.optim.AdamW(model.parameters(), lr=0.01))
hypotheses = [{"id": "database", "text": "database connection refused"},
{"id": "network", "text": "network packet loss"}]
def case(log_line):
return {"question": "which component failed",
"evidence": [{"source_id": "log:1", "text": log_line}],
"hypotheses": hypotheses}
# Reviewed feedback, with explicit provenance, becomes training experience.
experiences = [trainer.capture(case("connection refused"), "database", source="review:1"),
trainer.capture(case("packet loss"), "network", source="review:2")]
losses = trainer.fit(experiences, epochs=30)
model.save_pretrained("./investigator")
restored = Investigator.from_pretrained("./investigator")
print(restored(case("packet loss"))["selected_id"]) # network
Two authored cases show the lifecycle. They do not show that the model can investigate anything. The result also includes every candidate's score and the source-linked evidence. Probabilities are uncalibrated. The quickstart extends this to persisted experience files, resumable training checkpoints and loading in a fresh process.
What is inside
tensorcode.ops.vec,ops.text,ops.graph: operations with one calling convention,op(value, *, context=None). Operations are built from JSON configuration, and learned vector operations own their weights. Text operations wrap an owned seq2seq model or an explicit external provider. Graph operations are reserved symbolic interfaces that raiseNotImplementedError.tensorcode.tools:Chatbot,Investigator,Decision,PlannerandScene, complete trainable models withsave_pretrained/from_pretrained.tensorcode.trace()andtensorcode.training: dependency capture, explicit supervision,Trainer.from_tool/Trainer.from_ops, portable experience and complete checkpoints.tensorcode.integrations: explicit adapters for OpenAI-compatible endpoints, local Transformers models and Jev.
Generated hypotheses are not evidence, and generated plans are not executable code. Evidence, policies and actions stay explicit in your code.
Guides
- Quickstart: a runnable offline training lifecycle.
- Developer documentation: operation and model contracts.
- Pretrained checkpoints: hosted tools and their measured
scope. All eight hosted checkpoints load at
mainwith this release. The two Chatbots and the cognitive Investigator were retrained for the bounded workspace update; their earlier revisions stay pinned for source commit6607a8b. - Evidence and cognition: hypotheses, revisions, memory and outcome feedback.
- Training: tracing, replay and resumable checkpoints.
- Examples: learning agents and practical applications.
- Validation: measured behavior and limitations.
- Updating development code: import changes since earlier alphas.
Development
python -m pip install -e '.[tools,diffusion,dev]'
python -m pytest -q
python -m build
Library code lives in src/tensorcode. See the test guide for
how the suite is organized. This alpha API replaces the former provider-owned
tools, and there is no legacy compatibility layer. MIT license.
Metadata
Release files for tensorcode 0.4.0a5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tensorcode-0.4.0a5.tar.gz | 1.2 MB | With provenance | Details for tensorcode-0.4.0a5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tensorcode-0.4.0a5-py3-none-any.whl | Python 3 | none | any | Details for tensorcode-0.4.0a5-py3-none-any.whl |
Total release size: 1.4 MB
Release files / tensorcode-0.4.0a5.tar.gz
| Download URL | tensorcode-0.4.0a5.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2e5766f2c8e5de0911c895390a7a4ed5caa504bd6a8480257fb120913d85308
|
|
BLAKE2b-256 checksum How to use checksums |
b90decf20a280f25d211011d8fc35ea9883ef58531fca7a3711820970c153154
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / tensorcode-0.4.0a5-py3-none-any.whl
| Download URL | tensorcode-0.4.0a5-py3-none-any.whl |
|---|---|
| Size | 190.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe94b063990b9f37f986600e5b3189a9503662f6cc1c4b4291c94b354b5b836e
|
|
BLAKE2b-256 checksum How to use checksums |
1d188ca97d82434edf61d336f15e35d7eaed29e68384d0477028bbe792ef7784
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logSecurity for tensorcode 0.4.0a5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tensorcode-0.4.0a5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.