跳到正文
原文
Hacker News· solohunter001·· 20 天前精选AI 评分73

Strot编译LLM意图并本地运行决策

Show HN: Strot – Compile an LLM's intent once, run decisions locally forever

AI 摘要

Strot是一款开源决策编译器,允许用户使用大型语言模型一次性编译意图,然后在自己的硬件上以零边际成本永久地对每条记录进行分类、评分、路由等决策,输出类型安全的JSON结果,包含概率和置信度,其决策模型在编译时运行一次

正文 · AI 翻译

开放决策编译器

用大型语言模型编译一次意图。然后对每条记录永远做出决策 — 分类、评分、路由 — 以类型安全的 JSON 格式,包含概率和置信度,在你的自有硬件上,以零边际成本运行。

PyPI License Tests Python

网站 · 文档 · 基准测试 · PyPI

Agents at compile time.  Never at runtime.

pip install strot-ai
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

大型语言模型一次运行,在编译时。生产环境是一个冻结的、自包含的 Python 工件:一个小型本地决策模型仲裁每条记录,不会生成任何内容,每条输出都有界限,低置信度的记录会弃权而不是猜测。

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() — 将每条记录路由到动作并执行编译后的处理器。

decide() — 按记录回答类型化问题(选择 / 评分 / 布尔值):

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

测量结果

真实模型(SupersonicLabs/Julia-1,144M,CPU)、真实数据集、干净的 Docker 容器:

结果
基础路由准确率(398条记录) 92.5% 编译的 vs 74.8% 简单的 — 编译器在同一模型上提升了 +18pp
语义文本(AG News,未见过的标签) 86.7% 编译的 vs 72.7% 简单的 (+14pp)
类型化决策 vs 领先的托管决策 API 的示例 几乎相同(情感 1.79 vs 1.8)
延迟 / 边际成本 / 每条记录的大型语言模型调用次数 ~60 ms · $0 · 0

复制所有内容: benchmarks/ — 并发布已公布的损失。

使其与众不同的地方

  • 编译一次,决策永远 — 内容寻址工件缓存;模式漂移触发精确一次重新编译。
  • 黄金记录提升 — 工件必须在提供服务前通过你的已知答案。
  • 适配保证 — 温度缩放 + 分割一致性预测,内建:分派的决策错误 ≤ α 的所有记录(边际);其余的会弃权。
  • 实测,非猜测 — 编译器评分标注,并可以训练一个蒸馏头,只保留在保留数据上优于基线的部分。
  • 0% 结构性幻觉 — 输出是你的注册表上的选择 + 计算;运行时不会生成任何内容。
  • 模型无关 — 决策模型是一个槽(nlu=):默认为本地 Julia-1,托管 API,或任何可插入的专家。

安装

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

将本地模型烘焙到你的镜像中用于离线生产:

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

(从不 pip install julia — 无关的包。)

文档

DEVELOPERS.md — 架构、编译生命周期、校准语义和注意事项、部署、模型交换、完整 API 参考。

许可

MIT。默认决策模型:Apache-2.0 (SupersonicLabs/Julia-1)。实现了来自 STROT (arXiv:2505.01636) 的想法。

来源:Hacker News · github.com

00