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 安装。基准报告相同模型的朴素使用准确率提升。

Hacker News 精选 Show HN:Strot,一个将决策任务编译为独立本地流水线的工具。编译时使用一次大型 LLM 合成标签、输入投影和处理器;运行时一个小型 144M CPU 模型在约 60ms/记录内做决策,无 LLM 调用且输出有界类型化 JSON。作者强调测量而非猜测:它会为候选标签打分,拟合用于拒识的 conformal calibration,并使用 golden-record 门控拒绝失败的编译。它改进了路由/文本分类相对于朴素集成的表现,但不能超过小模型上限;可能需要任务训练模型。评论要求更清晰的文档,将其与 Jev 风格模型比较,称赞“一次推断”理念,并批评可能的 AI 生成写作/vibe-coded 项目。MIT 许可,核心为纯标准库;浏览器演示包含 Pac-Man。
相关文章

原文

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