诺基亚开源AnyJev:免训练将LLM转为校准决策模型
Nokia Open-Sources AnyJev: A Training-Free Layer That Turns Any Open LLM Into a Calibrated Decision Model
做 Agent 或业务路由的同学必看,这个工具用极低成本解决了 LLM 分类任务中的概率校准难题,实测效果显著,建议直接集成到现有链路中压测。
Nokia’s applied research team has open-sourced AnyJev, a Python library that turns an open LLM into a decision model. It needs no training. It targets a common production job: picking one answer from a fixed set instead of writing a sentence.
诺基亚的应用研究团队已开源 AnyJev,这是一个 Python 库,可将开源大语言模型(LLM)转化为决策模型。它无需训练。其目标是一个常见的生产任务:从固定集合中选择一个答案,而非生成一个句子。
Is it deployable? Yes, it installs from PyPI, ships under Apache-2.0, and has transformers and vLLM backends with shared-prefix scoring.
它可以部署吗?可以,它可从 PyPI 安装,采用 Apache-2.0 许可证发布,并支持 transformers 和 vLLM 后端,具备共享前缀评分功能。
What is AnyJev?
什么是 AnyJev?
AnyJev borrows its interface from Jev. Jev is the System One decision model that TypeSafe AI launched in September 2026 (our coverage). You give AnyJev a typed question and get back a decision with a probability you can threshold. That probability is read from the model’s next-token distribution. Nothing is generated, parsed, or trained.
AnyJev 借鉴了 Jev 的接口。Jev 是 TypeSafe AI 于 2026 年 9 月推出的 System One 决策模型(我们的报道)。你向 AnyJev 提供一个带类型的问题,它会返回一个带有概率的决策结果,该概率可设置阈值。该概率直接从模型的下一个 token 分布中读取。不生成、解析或训练任何内容。
The library supports 3 question types:
该库支持 3 种问题类型:
- A choice question picks one of K options.
- A noul question is yes or no.
- A score question places the answer in one of several ordered bins.
- 选择题从 K 个选项中选出一个。
- 是非题(noul question)答案为是或否。
- 评分题将答案归入多个有序分箱中的一个。
The Problem With Reading Logits Directly
直接读取 Logits 的问题
Many open projects already restrict the next token to the option labels and read the scores. The Nokia research team flags 2 flaws in that shortcut. First, the answer can change when the options are reordered. Second, the probabilities are not calibrated.
许多开源项目已将下一个 token 限制为选项标签并读取分数。诺基亚研究团队指出了这种捷径的两个缺陷。首先,当选项顺序改变时,答案可能会发生变化。其次,这些概率未经校准。
The levels doc names 2 causes:
levels 文档列出了 2 个原因:
- The first is prior bias: the model favors some labels, such as “Yes” over “No”, whatever the input.
- The second is position bias: the model favors certain slots in the option list.
- 第一个是先验偏差(prior bias):无论输入如何,模型都倾向于某些标签,例如“是”优于“否”。
- 第二个是位置偏差(position bias):模型倾向于选项列表中的特定位置。
How AnyJev Works: L0 and L1
AnyJev 的工作原理:L0 和 L1
Every decision carries a level field.
每个决策都包含一个 level 字段。
L0 (zero labels, on by default) applies 2 fixes:
L0(零标签,默认启用)应用了 2 项修复:
- Cyclic shifts. For a question with K options, the list is shown in K rotations, so every option appears in every position once. The results are combined in log space as a geometric mean. If the position bias is additive in logit space, this removes it exactly.
- Prior correction. By default, AnyJev uses batch calibration. It keeps a running mean of the predicted distributions on real inputs and divides it out at strength 0.75. The correction starts after 8 items.
- 循环移位。对于有 K 个选项的问题,列表会以 K 种旋转方式展示,使得每个选项在每个位置上各出现一次。结果在 log 空间中以几何平均数合并。如果位置偏差在 logit 空间中是可加的,则此方法可完全消除它。
- 先验校正。默认情况下,AnyJev 使用批量校准(batch calibration)。它对真实输入上的预测分布保持运行平均值,并以 0.75 的强度将其除出。校正在处理完 8 个项目后开始生效。
L0 costs K prefills per decision, batched over a shared prefix. That is about 0.25 s per decision at batch 32 on one H100, with K = 20.
L0 每次决策需要 K 次预填充(prefills),通过共享前缀进行批处理。在一个 H100 上,当 batch size 为 32 且 K = 20 时,每次决策耗时约 0.25 秒。
L1 (100 to 500 labels per question) adds temperature scaling on top of L0. The fitted values are saved as a small JSON artifact. L1 reshapes confidence but does not change the ranking of answers.
L1(每道题 100 到 500 个标签)在 L0 的基础上增加了温度缩放(temperature scaling)。拟合值保存为一个小型 JSON 工件。L1 重塑置信度,但不改变答案的排名。
Benchmark Results
基准测试结果
On Qwen3-8B with BANKING77 (20-way, 300 test items), the numbers look like this:
在 Qwen3-8B 上使用 BANKING77 数据集(20 路分类,300 个测试样本),数据表现如下:
| Metric | Raw logits | AnyJev L0 | AnyJev L1 |
|---|---|---|---|
| Labels required | 0 | 0 | 100 to 500 |
| Flip rate when options reversed | 0.230 | 0.073 | 0.077 |
| Accuracy | 0.747 | 0.803 | 0.807 |
| Calibration error (ECE) | 0.240 | 0.184 | 0.095 |
| Auto-decidable at 5% error | 7.7% | 46.3% | 52.0% |
| 指标 | 原始 logits | AnyJev L0 | AnyJev L1 |
|---|---|---|---|
| 所需标签 | 0 | 0 | 100 到 500 |
| 选项反转时的翻转率 | 0.230 | 0.073 | 0.077 |
| 准确率 | 0.747 | 0.803 | 0.807 |
| 校准误差 (ECE) | 0.240 | 0.184 | 0.095 |
| 5% 错误率下的自动可决比例 | 7.7% | 46.3% | 52.0% |
A few other results from the repo:
来自该仓库的其他一些结果:
- L0 reduced order flips on all 9 model and task rows tested.
- On a typed-decisions set, Qwen3-32B with L1 reached an ECE of 0.036, compared with 0.144 published for Jev. On accuracy, the fine-tuned Laya still leads.
- The full ablation table covers Qwen, OLMo, Granite, Phi and Mistral models.
- Wu says the team tried AnyJev on an internal Nokia routing problem and saw promising results.
- 在测试的所有 9 个模型和任务行中,L0 减少了顺序翻转。
- 在键入决策集上,Qwen3-32B 配合 L1 达到了 0.036 的 ECE,而 Jev 公布的数值为 0.144。在准确率方面,微调后的 Laya 仍然领先。
- 完整的消融表涵盖了 Qwen、OLMo、Granite、Phi 和 Mistral 模型。
- Wu 表示,团队在内部诺基亚路由问题上尝试了 AnyJev,并看到了令人鼓舞的结果。
How to Use AnyJev
如何使用 AnyJev
# pip install "anyjev[hf]"
from anyjev import Decider, Question
from anyjev.backends.hf import HFBackend
d = Decider(HFBackend("Qwen/Qwen3-8B"))
route = Question.choice("Which team should handle this?",
["billing", "technical", "sales", "other"], name="route")
r = d.decide({"conversation": [...]}, [route])
r["route"].distribution # probabilities per option# pip install "anyjev[hf]"
from anyjev import Decider, Question
from anyjev.backends.hf import HFBackend
d = Decider(HFBackend("Qwen/Qwen3-8B"))
route = Question.choice("Which team should handle this?",
["billing", "technical", "sales", "other"], name="route")
r = d.decide({"conversation": [...]}, [route])
r["route"].distribution # probabilities per optionFor serving, you start vLLM with prefix caching and point a VLLMBackend at it.
对于服务部署,你使用 prefix caching(前缀缓存)启动 vLLM,并将 VLLMBackend 指向它。
Key Takeaways
关键要点
- AnyJev turns open LLMs into Jev-style typed decision models with no training.
- L0 uses cyclic shifts and a batch prior to remove position and label bias.
- On Qwen3-8B BANKING77, the order-flip rate falls from 0.230 to 0.073.
- Auto-decidable traffic at 5% error rises from 7.7% to 52.0% with L1.
- It is Apache-2.0 on PyPI, with Hugging Face and vLLM backends.
- AnyJev 无需训练即可将开源 LLM 转化为 Jev 风格的键入决策模型。
- L0 使用循环移位和批次先验来消除位置和标签偏差。
- 在 Qwen3-8B BANKING77 上,顺序翻转率从 0.230 降至 0.073。
- 配合 L1,5% 错误率下的自动可决流量比例从 7.7% 提升至 52.0%。
- 它在 PyPI 上采用 Apache-2.0 许可证,并提供 Hugging Face 和 vLLM 后端。
Check out the GitHub Repo. All credit goes to the researcher of this project. Also, feel free to follow us on Twitter and don’t forget to join our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.
查看 GitHub 仓库。所有功劳归于该项目的研究者。此外,欢迎在 Twitter 上关注我们,别忘了加入我们拥有 15 万+成员的 ML SubReddit 并订阅我们的新闻通讯。等等!你在 Telegram 上吗?现在你也可以加入我们的 Telegram 群组。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力