跳到正文
Hacker News (official RSS)(github.com)·· 3 小時前精選AI 評分74

Strot:一次編譯 LLM 目的,永遠在本地執行決策

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

AI 導讀

Strot 是一個開源工具,允許使用者將 LLM 的意圖一次編譯為本地決策模型,之後在本機以 JSON 形式執行分類、評分與路由。

  • 編譯一次:LLM 只在編譯階段執行,產生 144M 的 Julia‑1 模型,之後不再呼叫 LLM,成本為 $0。
推薦理由

Strot 透過一次性編譯 LLM 目的,將決策轉為本地 JSON,實現零邊際成本與低延遲,適合需要高效分類與路由的場景。

正文 · AI 翻譯

開放式決策編譯器

一次使用 LLM 編譯你的意圖。之後在每筆資料上永遠決策 — 分類、評分、路由——以型別安全的 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

LLM 在編譯時只執行 一次。生產環境是一個凍結且自包含的 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% 編譯版對比 74.8% 原始版 — 編譯器在同一模型上提升 +18pp
語義文本(AG News,未見標籤) 86.7% 編譯版對比 72.7% 原始版(+14pp)
型別化決策對照主流託管決策 API 自身範例 幾乎相同(情感 1.79 vs 1.8)
延遲 / 邊際成本 / 每筆資料的 LLM 呼叫次數 ~60 毫秒 · $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) 的想法。