Skip to main content

STROT

A decision compiler

Compile System-2 reasoning into System-1 decisions — $0 at inference.

PyPI License Python

An LLM reasons through your task once, at compile time. STROT distills that judgment into a specialized decision model — a calibrated head on a frozen encoder, trained on your real data — that then makes every decision locally, on CPU, at $0: no API calls, no GPU, no per-record cost.

1.0 — the stable decide API. The core (a head on a frozen gte-modernbert encoder) is benchmark-validated on Banking77 (93% full-data, 87% at 10 examples/class). Validation breadth is still growing — bring your own data and tell us how it does.

pip install "strot-ai[local,anthropic]"
export ANTHROPIC_API_KEY=...
import strot

# 1. Design the decision schema from a one-line intent (review/edit it).
questions = strot.questions(tickets, "triage support tickets",
                            llm="anthropic/claude-opus-4-8")

# 2. Compile a decision model — the LLM teacher labels your sample, a calibrated
#    head per question is distilled onto the frozen encoder.
model = strot.decide(tickets, questions, llm="anthropic/claude-opus-4-8")

# 3. Decide — locally, on CPU, $0 per call.
model(tickets[0])
# {"predicates": {...}, "scores": {...}, "choices": {...}}  probabilities + calibrated confidence

# 4. Ship one self-contained file; reload anywhere.
model.save("ticket-triage")
strot.load_model("ticket-triage")

The LLM runs only at compile time. After that, production is a self-contained model file: the local model answers every record, nothing is generated at runtime, and every output is bounded typed JSON with a calibrated confidence.

Typed questions

A decision config maps a name to a typed question — predicate, choice, or score:

questions = {
    "is_bug_report":      {"type": "predicate", "instructions": "mentions crashes or errors?"},
    "customer_sentiment": {"type": "score", "instructions": "how upset is the customer?",
                           "levels": [{"label": "angry"}, {"label": "neutral"}, {"label": "happy"}]},
    "routing_bucket":     {"type": "choice", "choices": [
                              {"value": "billing",     "description": "charges, invoices, refunds"},
                              {"value": "engineering", "description": "crashes, bugs, defects"}]},
}

Pass that to strot.decide(data, questions), or hand decide a bare intent string and it designs the schema for you first (result.questions shows what it chose). Each answer carries probabilities and a calibrated confidence.

Three tiers

strot.decide(data, questions, mode=...) picks how hard it works:

mode what it is needs when
lite zero-shot prototype heads (embed each option's description, cosine-match) no labels, instant try a decision immediately, $0, bring no data
head (default) a calibrated logistic head per question, distilled from teacher labels the teacher labels your sample the accuracy of training on your records
deep a shared top-N LoRA adapter over all questions, then refit heads the [finetune] extra + more records representation-bound tasks a frozen head can't crack

warm=True serves lite instantly while head trains in the background, then hot-swaps it in — "zero-shot that grows up."

How it works

Two phases: the expensive, non-deterministic one happens once; the cheap one runs on every record forever.

  • Compile once. The LLM designs the question schema (optional) and writes the record→text projection; the teacher labels a PII-masked sample; a calibrated head per question is trained on the frozen encoder's embeddings and baked into a standalone .py artifact. Content-addressed: a schema change triggers exactly one recompile, nothing else does.
  • Decide forever. The local model projects a record, embeds it once, and every question head answers — typed JSON, bounded, with calibrated confidence. No LLM, no network, ~tens of ms on CPU.
  • Refuses what it hasn't seen. A drift gate (per-class centroids + a distance threshold, fit at compile time) returns a refusal for records unlike anything in training rather than guessing on them.
  • Recompile, don't increment. Every compile is a fresh fit from the frozen base on the current data — never a warm-start from prior weights. A model's weights are a pure function of its own (data, questions, mode), so retraining on accumulated data can only gain quality; it is immune to catastrophic forgetting by construction.

Data & privacy

The teacher LLM is used as a labeler of your real records, never as a bulk synthetic generator. Before any record reaches the teacher it is PII-masked at that boundary: a regex pre-pass guards format-defined tokens (email, SSN, card, API keys, IBAN, IP/MAC/phone), and GLiNER (the [pii] extra) masks names, addresses, and orgs. Masking is compile-time only.

We measured synthetic data and it hurt both accuracy and the confident slice — it comes out too clean and leaks the label. The policy is real-first: label real data; handle class imbalance by labeling more real minority-class records.

Install

pip install strot-ai                # core (pure stdlib)
pip install "strot-ai[local]"       # + torch/transformers (compile + serve a model)
pip install "strot-ai[finetune]"    # + torch/transformers, for mode="deep"
pip install "strot-ai[pii]"         # + GLiNER masking at the teacher boundary
pip install "strot-ai[openai]"      # + openai, teacher via llm="openai/<model>"
pip install "strot-ai[anthropic]"   # + anthropic, teacher via llm="anthropic/<model>"

Extras install optional packages; they do not sign you in. Set the matching API key and pass llm="<provider>/<model>". Compile-time only — serving needs no key.

Bake the encoder into your image for offline production:

RUN pip install "strot-ai[local]" \
 && python -c "import strot; strot.prefetch_nlu(local_dir='/opt/encoder')"
ENV STROT_NLU_CHECKPOINT=/opt/encoder

Contributing & contact

Pull requests welcome — keep them focused, branch off the latest main, and run the suite first. See CONTRIBUTING.md. Questions or ideas: open an issue or email lee@strot-ai.xyz.

Built by Amit Rath — LinkedIn.

License

MIT. The base encoder (Alibaba-NLP/gte-modernbert-base) is Apache-2.0. Implements ideas from STROT (arXiv:2505.01636).

Metadata

Release files for strot-ai 1.0.0

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

Source distribution (sdist)

Source distribution for strot-ai 1.0.0
File Size Uploaded Provenance Actions
strot_ai-1.0.0.tar.gz 53.0 kB With provenance Details for strot_ai-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for strot-ai 1.0.0
File Interpreter ABI Platform Actions
strot_ai-1.0.0-py3-none-any.whl Python 3 none any Details for strot_ai-1.0.0-py3-none-any.whl

Total release size: 109.5 kB

Release files / strot_ai-1.0.0.tar.gz

Download URL strot_ai-1.0.0.tar.gz
Size 53.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ec88cff7ac1b4310fa5917f3eb19163ad6e3545a6378905e8dab05428112431c
BLAKE2b-256 checksum
How to use checksums
9090682d942a67a2927f0e25d34af9e9f92a5fead799da5f34904ce7e9619a8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 22, 2026.

Transparency log

Release files / strot_ai-1.0.0-py3-none-any.whl

Download URL strot_ai-1.0.0-py3-none-any.whl
Size 56.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98e9a8fd9d8e70341b1991d53503880e4e510534bb5335538635be67bf58b60f
BLAKE2b-256 checksum
How to use checksums
65f5ddabdaead5ec9abeeebc3ee2b9c530b471c39061722d049c6ed1efed3879
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 22, 2026.

Transparency log

Security for strot-ai 1.0.0

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.

Select from 2 files

Attestation for strot_ai-1.0.0.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 Nov 22, 2026.

Transparency log

A 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.

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