Show HN: Strot – 将 LLM 的意图编译一次,永远在本地运行决策
Show HN: Strot – Compile an LLM's intent once, run decisions locally forever

原始链接: https://github.com/strot-ai/Project-STROT

STROT 是一个一次编译、永久运行的决策系统。LLM 每个意图和模式运行一次,以合成并校准一个冻结的、自包含的 Python 产物。运行时,一个小型本地决策模型(默认 Julia-1,144M,CPU)每条记录约 60 ms 处理,无 LLM 调用或边际成本。输出是受限的 JSON 决策——分类、评分、路由或类型化答案——低置信度记录弃权而非猜测。`run()` 将记录路由到编译后的处理器,而 `decide()` 以概率和置信度回答布尔、评分和选择问题。编译器加入校准、黄金记录验证和留出检查,因此分发决策最多在 α 比例记录上出错。它与模型无关,支持本地/托管/专用 NLU 运行时,并可通过 pip 安装。基准报告相同模型的朴素使用准确率提升。

Show HN 介绍了 Strot,一个将决策任务编译为独立流水线的工具:一个大型 LLM 在编译时使用一次,以合成标签、输入投影和处理器;而一个小型 144M CPU 模型在运行时执行决策(约 60ms/记录,无 LLM 调用,有界类型化 JSON)。它旨在将非确定性的 LLM 工作移至构建时,使运行时保持低成本、本地化和可审计。编译器在教师标注样本上评估候选标签方案并保留最佳方案;声称路由提升 18 个百分点,分类提升 14 个百分点,优于朴素集成。它还拟合用于弃权的保形校准阈值并提供错误保证,并设有黄金记录门禁,拒绝已知答案编译失败的方案。限制包括小模型能力上限(例如推文仇恨言论),可通过替换为任务训练模型修复。仓库包含可复现基准、MIT 许可的纯标准库核心、浏览器演示和快速开始。HN 评论包括怀疑(“AI psychosis”)、对一次推理方法的称赞、要求更深入的校准细节,以及关于 README 是否由 AI 生成的问题。还有 YC 广告。
相关文章

原文

import strot

result = strot.run(
    tickets,
    query="Triage incoming support tickets into the correct workflow.",
    action_registry={
        "billing_dispute":  "Refunds, invoice corrections, double charges",
        "technical_defect": "Crashes, bugs, broken behavior",
    },
    llm="anthropic/claude-opus-4-8",   # used once, on first compile only
)

for o in result.outcomes:
    print(o["action"], round(o["confidence"], 2))
# billing_dispute 0.97
# technical_defect 0.94

The LLM runs once, at compile time. Production is a frozen, self-contained Python artifact: a small local decision model arbitrates every record, nothing is generated, every output is bounded, and low-confidence records abstain instead of guessing.

STROT = Agentic Schema Intent + Compiler & State + Code + Execution + NLU
                      ⟹  JSON Decisions
          (classification · scoring · routing · typed answers)
            COMPILE  (once per intent + schema)
  intent + sample ─▶ synthesize ─▶ golden gate ─▶ teacher labels ─▶ calibrate
                     (labels,      (your known      (annotate         (fit the
                      projection,   answers must     a sample,         confidence
                      handlers)     pass)            once)             threshold)
                                        │
                                        ▼
                             frozen artifact  (.py)

            RUNTIME  (every record, forever)
  record ─▶ projection ─▶ decision model ─▶ confidence gate ─▶ typed JSON
            (compiled)     (144M, CPU,        (decide or         decision
                            ~60 ms)            abstain)

run() — route each record to an action and execute the compiled handler.

decide() — answer typed questions (choice / score / boolean) per record:

result = strot.decide(records, questions={
    "is_bug_report":     {"type": "boolean", "instructions": "mentions crashes/errors?"},
    "customer_sentiment":{"type": "score", "min": 1, "max": 5, "instructions": "1 angry, 5 happy"},
    "routing_bucket":    {"type": "choice", "options": ["billing", "engineering", "spam"]},
})
# → {"booleans": {...}, "scores": {...}, "choices": {...}}  with probabilities + confidence

Real model (SupersonicLabs/Julia-1, 144M, CPU), real datasets, clean Docker containers:

Result
Grounded routing accuracy (398 records) 92.5% compiled vs 74.8% naive — the compiler is worth +18pp on the same model
Semantic text (AG News, unseen labels) 86.7% compiled vs 72.7% naive (+14pp)
Typed decisions vs the leading hosted decision API's own example near-identical (sentiment 1.79 vs 1.8)
Latency / marginal cost / LLM calls per record ~60 ms · $0 · 0

Reproduce everything: benchmarks/ — with the losses published too.

  • Compile once, decide forever — content-addressed artifact cache; schema drift triggers exactly one recompile.
  • Golden-record promotion — artifacts must pass your known answers before they serve.
  • Fitted guarantees — temperature scaling + split conformal prediction, baked in: dispatched decisions are wrong ≤ α of all records (marginal); the rest abstain.
  • Measured, not guessed — the compiler scores labelings, and can train a distilled head, keeping only what beats the baseline on held-out data.
  • 0% structural hallucination — output is selection + computation over your registry; nothing is generated at runtime.
  • Model-independent — the decision model is a slot (nlu=): local Julia-1 by default, hosted APIs, or any drop-in specialist.
pip install strot-ai            # core: pure stdlib
pip install strot-ai[local]     # + the local decision model (torch/transformers)
pip install strot-ai[hosted]    # + openai, for a hosted decision runtime
pip install strot-ai[anthropic] # + anthropic, for the synthesizer

Bake the local model into your image for offline production:

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

(Never pip install julia — unrelated package.)

DEVELOPERS.md — architecture, compile lifecycle, calibration semantics and caveats, deployment, model swapping, full API reference.

MIT. Default decision model: Apache-2.0 (SupersonicLabs/Julia-1). Implements ideas from STROT (arXiv:2505.01636).

联系我们 contact @ memedata.com