Kev:Jared Palmer 开源本地决策模型,一次前向传播回答多个问题

Kev: Jared Palmer's Open-Source Local Decision Model — One Forward Pass, Many Questions

Tech-Experiment #decision-model#local-ai#qwen#lora#classification#open-source
🇨🇳 中文

Kev 是 Jared Palmer(Formik、Turborepo 作者)开源的本地决策模型。它不生成文字——给它一段文档和一批问题,它一次前向传播同时返回所有问题的概率分布。思路来自 TypeSafe 的 Jev,后者由研究者 Archer Hume 从头逆向推导。

仓库:github.com/jaredpalmer/kev | License:Apache-2.0 | Stars:606


核心设计:一次编码,多路分支

传统做法是每个问题单独调 API。Kev 用**块因果掩码(block-causal masking)**把文档和所有问题打包进一条序列——每个问题分支只能看文档、看不到兄弟问题。文档编码一次,所有问题并发出结果:

[Document] → [Q1 branch] → P(option_A) / P(option_B)
           → [Q2 branch] → P(yes) / P(no)
           → [Q3 branch] → expected-value score

模型在问题 logit 上直接 softmax,不 decode 任何 token。打包 vs 分开请求的概率最大差值:4e-6,throughput ,isolation 验证通过。


三种问题类型

类型用法输出
noul二元是/否P(yes) / P(no)
choice2~255 个离散选项每个选项的置信度
score有序档位(如”强/中/弱”)期望值 + 各档概率

四个模型变体

模型基座OOD 准确率(test)M5 延迟
kev-0.5bQwen2.5-0.5B0.575~160ms (fp32)
kev-0.6bQwen3-0.6B-Base0.631
kev-4bQwen3-4B-Base0.806~277ms (bf16)
kev-8bQwen3-8B-Base0.780~2s (bf16)

README 推荐入口:kev-4b(32GB Mac bf16 可跑,精度最高/体积比最佳)。注意 8b 的 OOD 准确率反而低于 4b,作者已如实标出。

对比 Jev(参考线):kev-4b OOD 0.790 vs Jev 0.857;Brier score 0.328 vs Jev 0.211;置信度 ≥90% 时的误答率 8.2% vs Jev 3.7%。差距存在,没有隐瞒。


训练细节

  • 数据:10~13 个公开数据集(Banking77、AG News、MNLI、BoolQ、SST-5 等),每源 1000 条 × 2 epochs;另加 896 条程序化策略记录和 1680 条规则结构数据
  • 最重要的配方发现:学习率 5e-5,而非默认 2e-4。用默认值导致知识任务回归约 4.7pp
  • 未使用 Jev 的任何输出——完全从公开标注数据独立训练
  • 成本:0.5B 单次试验约 $0.15~$0.30(Modal H100);M5 本地约 1h45m

不足之处(文档已明写,不是挖出来的)

1. OOD 准确率落后 Jev 6~7pp,集中在知识(MMLU)、释义(PAWS)、日期计算三类。

2. 逻辑规则推理未达发布门槛。预设标准是 held-out 组合规则 both-correct ≥ 0.70 每个 seed——实测 3 个 seed 只有 1 个过线(0.62~0.73 之间)。作者没有降低标准,如实写在 README。

3. 上下文窗口 8192 token,训练时实际只用 384/1024 token——Jev 约 32k,差距明显。

4. 校准不迁移:域内拟合的 temperature 到 OOD 场景会退化,域外 ECE 变差。

5. 选项顺序敏感:argmax 答案有 7.4% 概率随选项排列顺序改变——同一个问题换个选项顺序可能给不同答案。

6. 无跨请求 KV 缓存:每次请求都做密集 per-sample masking,无法批处理复用。

7. kev-4b 需约 16GB RAM(fp32 全精度);bf16 在 32GB Mac 上可跑。

8. Research preview 状态——模型仓库明确标注,不建议生产使用。


本地运行

git clone https://github.com/jaredpalmer/kev.git && cd kev
uv sync --extra serve

# 启动服务
KEV_DTYPE=bf16 uv run --extra serve python -m kev.serve \
  --run jaredpalmer/kev-4b --port 8009

请求格式(兼容 TypeSafe SDK,改 base_url 即可替换):

POST /v1/systemone
{
  "state": "用户评价:等了两小时,菜还没上。服务态度很差。",
  "model": "kev-latest",
  "questions": {
    "sentiment": {
      "type": "choice",
      "instructions": "这条评价的情感倾向?",
      "criteria": {
        "positive": "表达满意或赞赏",
        "negative": "表达不满或批评",
        "neutral": "无明显情感倾向"
      }
    },
    "urgent": {
      "type": "noul",
      "instructions": "这条评价是否需要紧急跟进?"
    }
  }
}

测试选项顺序一致性:POST /v1/systemone/permute(自动排列全组合,报告最大概率漂移)。


横向对比

Kev-4bJevGPT-4o(zero-shot)
OOD 准确率0.7900.857未披露(定制任务)
推理方式logproblogprob文字生成
本地可跑✗(SaaS)
Context8k~32k128k
许可Apache-2.0商业 SaaS商业 API
价格免费$0.042/1k input token按用量

怎么看这件事

Kev 是目前公开的、最接近 Jev 思路的本地实现:块因果掩码打包多问题、不生成 token、直接读 logprob。主要代价是上下文窗口(8k vs 32k)和 OOD 准确率(差约 6pp)。对于需要本地/离线、对延迟和成本敏感、场景中的文档不超 8k token的决策任务,kev-4b 是一个真实可用的选项。对于需要长文档或更高精度的场景,差距仍然显著。

学习率 5e-5 的发现值得收藏——用了错误的默认值要掉 4~5pp,Kev 没把这个藏在日志里,写进了 README。

开源代码与模型仅供学习研究,勿直接用于生产决策系统。


🇬🇧 English

Kev: Jared Palmer’s Open-Source Local Decision Model

Kev by Jared Palmer (creator of Formik and Turborepo) is an open-source local decision model. It doesn’t generate text — you give it a document and a batch of questions, and it returns calibrated probability distributions for all questions in a single forward pass. The architecture was inspired by TypeSafe’s proprietary Jev, which researcher Archer Hume had reverse-engineered from first principles.

Repo: github.com/jaredpalmer/kev | License: Apache-2.0 | Stars: 606


Core Design: Encode Once, Branch Many

Kev uses block-causal masking to pack the document and all questions into one sequence. Each question branch can see the document but not sibling questions. The document is encoded once; all question branches fan out concurrently:

[Document] → [Q1 branch] → P(option_A) / P(option_B)
           → [Q2 branch] → P(yes) / P(no)
           → [Q3 branch] → expected-value score

No decoding, no token generation — just softmax over answer option logits. Packed vs. separate requests agree to max 4e-6 delta. Throughput is 2× faster with verified isolation.


Three Question Types

TypeUseOutput
noulBinary yes/noP(yes) / P(no)
choice2–255 discrete optionsConfidence per option
scoreOrdered levels (strong/medium/weak)Expected value + per-level probabilities

Four Model Variants

ModelBaseOOD Accuracy (test)M5 Latency
kev-0.5bQwen2.5-0.5B0.575~160ms fp32
kev-0.6bQwen3-0.6B-Base0.631
kev-4bQwen3-4B-Base0.806~277ms bf16
kev-8bQwen3-8B-Base0.780~2s bf16

README recommends starting with kev-4b (best accuracy-per-byte, fits a 32GB Mac in bf16). Note that kev-8b’s OOD accuracy is actually lower than kev-4b — this is documented honestly.

vs. Jev: kev-4b OOD 0.790 vs Jev 0.857; Brier score 0.328 vs Jev 0.211; high-confidence error rate 8.2% vs Jev 3.7%. The gap is real and unambiguous.


Limitations (documented, not hidden)

  1. 6–7pp OOD accuracy gap vs Jev, concentrated in knowledge (MMLU), paraphrase (PAWS), and date arithmetic.

  2. Rule reasoning release threshold not consistently met. Predeclared screen: held-out logical composition both-correct ≥ 0.70 every seed. Actual result: only 1 of 3 seeds passes (range 0.62–0.73). Author kept the threshold rather than lowering it.

  3. 8,192-token context window (trained at 384/1,024 tokens). Jev supports ~32k.

  4. Calibration doesn’t transfer OOD. In-domain temperature scaling degrades out-of-domain.

  5. 7.4% option-order sensitivity — argmax answer can flip depending on how choices are ordered in the request.

  6. No cross-request KV cache reuse — dense per-sample masking on every request.

  7. Research preview status — not production-ready.


Training Key Finding

The most important recipe discovery: learning rate 5e-5, not the default 2e-4. Using the default caused ~4.7pp regression on knowledge tasks. No Jev outputs were used in training — the model was trained entirely on public labeled datasets.


Quick Start

git clone https://github.com/jaredpalmer/kev.git && cd kev
uv sync --extra serve
KEV_DTYPE=bf16 uv run --extra serve python -m kev.serve \
  --run jaredpalmer/kev-4b --port 8009

TypeSafe SDK compatible — override base_url to use as a local Jev drop-in.


Bottom Line

Kev is the closest public implementation of the Jev decision-model architecture: block-causal masking for multi-question batching, logprob-only inference, no text generation. The tradeoffs are real — shorter context (8k vs 32k) and a measurable OOD accuracy gap (~6pp). For tasks that are local/offline, cost-sensitive, and fit in 8k tokens, kev-4b is a genuinely usable option. For longer documents or higher-stakes precision needs, the gap to Jev still matters.

Open-source code and models for research and learning only. Not recommended for production decision systems.

💬 评论与讨论

使用 GitHub 账号登录后发表评论

关于本站 · 免责声明

🍄 Mushroom Research Blog 是非营利、免费公开的个人科技观察博客与公众号 XStack18,不接受商业合作、不代表任何企业或机构立场,也不谋求商业利益。我们以个人视角客观中立地记录和分析 AI、Web3 等领域的最新模型发布与技术动态——不止转述新闻标题或二手信息,而是给出有独立思考的深入分析,希望帮更多人获得有价值的一手科技认知。

⚠️ 文中介绍的开源代码与模型,仅供学习交流与技术借鉴。它们大多仍处于早期阶段,有待进一步研究和验证,请勿直接用于工作或生产环境;如需采用,请先自行充分测试,并核实其许可证与安全性。
Open-source code and models featured here are shared for learning and reference only. Most are early-stage and still need further study and verification — please don't use them directly in your work or in production. Test them thoroughly and check their licenses and security first.

  1. 本站文章均为作者基于公开信息的个人研究与观点整理,不代表文中提及的任何公司、产品、模型的官方立场,未与其构成商业关联或合作关系。
  2. 科技行业信息更新极快,我们尽力保证内容准确、及时,但不对完整性、实时性做绝对保证,具体请以相关企业/项目官方公告为准。
  3. 文中引用的第三方商标、产品名称、图片、数据等版权归原权利人所有,我们会尽量注明来源;如你认为存在版权疑问或侵权,请通过下方邮箱联系我们,收到通知后会尽快核实处理(更正、加注来源或删除)。
  4. 文章内容仅为技术科普与个人观点,不构成投资、法律或其他专业建议,据此进行任何决策的后果需自行判断和承担。

📮 侵权 / 勘误 / 合作咨询:[email protected]