Skip to main content
Pre-release

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+. PyPI currently hosts only an older 0.1 alpha, so install 0.4 from GitHub:

python -m pip install "tensorcode[tools] @ git+https://github.com/TensaCo/tensacode-py"

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 raise NotImplementedError.
  • tensorcode.tools: Chatbot, Investigator, Decision, Planner and Scene, complete trainable models with save_pretrained / from_pretrained.
  • tensorcode.trace() and tensorcode.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. Saved artifacts must match the current architecture exactly: the hosted Chatbot and cognitive Investigator checkpoints need source commit 6607a8b; only the Hotpot Investigator and Decision have refreshed revisions verified on current source.
  • 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.

Release files for tensorcode 0.4.0a3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tensorcode 0.4.0a3
File Size Uploaded
tensorcode-0.4.0a3.tar.gz 1.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for tensorcode 0.4.0a3
File Interpreter ABI Platform
tensorcode-0.4.0a3-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / tensorcode-0.4.0a3.tar.gz

Download URL tensorcode-0.4.0a3.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
0080ea9abe005a4f4e7da08ac86cfe5b770acf018559432f033e039da7904dcd
BLAKE2b-256 checksum
How to use checksums
56d985f56e3475aa73463b927548d3d31d4a3e53345e750d069c301dd863c08f
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 23, 2026.

Transparency log

Release files / tensorcode-0.4.0a3-py3-none-any.whl

Download URL tensorcode-0.4.0a3-py3-none-any.whl
Size 189.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78b8b1c2b0cc61dba10276ff95a4c5cf5ab8523631016558af0a18338a4999f1
BLAKE2b-256 checksum
How to use checksums
4ba6f3323061024e480b384a37669853f1cba17a8eb893b3a412f2012c39aaa5
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 23, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page