PostHog开源Jeeves:推理增强型决策模型及完整训练代码
Jeeves. Reasoning improves Jev-like decision models
推荐理由
开源了完整的训练代码、数据与权重,且给出了清晰的精度/延迟权衡参数,做结构化决策落地的同学可直接复用这套工作流。
Jeeves – 推理提升类 Jev 决策模型:一种带有扩散草稿生成器的类 Jev 风格分类器,使用 SFT 和 CISPO 进行训练。## 致谢 受 Kev 启发。## 亮点 - 一个 9B 的类 Jev 模型(Qwen3.5-9B,LoRA,指针头),在决策前进行思考,配备 block-4 扩散草稿生成器,并提供完整的训练代码及 train/dev/test 数据。 - 在未见过测试数据上超越 Kev-9B 和 Jev(0.889 vs 0.822 和 0.857),并在 JevBench 公开层级中表现更佳(Jev 为 0.866,Jeeves 为 0.935)。 - 通过兼容 Jev 的 API,支持在同一请求中包含是/否(noul)、多项选择(choice)和评分(score)问题。 - 在一个 H100 GPU 上,不使用推理时每个请求约 0.3 秒,使用中位数约为 3.3 秒(--precision fp8)。可通过截断链长度来加速。 - 在计算能力为 8.9 或更高的 GPU 上,以 bf16 运行 CUDA,或使用 FP8 线性层(--precision fp8)。推理也支持在 Apple Silicon (MPS) 上以 bf16 或 FP8 运行。## 问题 类 Jev 模型能提供校准的决策概率,但准确率较低。因此许多流水线依赖推理模型作为后备方案。Jeeves 使用 CISPO 对类 Jev 的 Qwen3.5-9B(LoRA 和指针头)进行训练,使其在决策前进行推理。这导致在域外任务上性能更好,并在 JevBench hard(公开)中超越 Jev。## 结果 带推理、贪婪解码、2,560 token 上限的准确率。Kev-9B 和 Jev 列的数据来自 Kev 发布的结果。bench | Kev-9B | Jev | Jeeves Test overall (out-of-domain and held-out, item-weighted) | 0.822 | 0.857 | 0.889 Transfer overall (MMLU-Pro and buried state) | 0.579 | 0.800 | 0.746 JevBench overall (231 public items) | 0.715* | 0.866 | 0.935 QNLI | 0.925 | 0.925 | 0.913 SciQ | 0.963 | 0.988 | 0.991 TweetEval offensive | 0.775 | 0.813 | 0.813 PAWS | 0.763 | 0.788 | 0.875 MMLU | 0.738 | 0.900 | 0.793 Emotion | 0.600 | 0.588 | 0.647 Held-out rule structures | 0.896 | 0.885 | 1.000 Contrastive policies | 0.900 | 0.963 | 1.000 MMLU-Pro (10-way) | 0.515 | 0.840 | 0.739 Buried state | 0.740 | 0.700 | 0.759 Unknowable answered at p ≥ 0.9 (lower is better) | 0.000 | 0.090 | 0.055 JevBench hard (111 public items) | 0.451* | 0.730 | 0.865 JevBench ECE (public items) | | 0.049 | 0.037 * 未发布任何 Kev-9B 的 JevBench 结果。这些是 Kev-8B(Qwen3)。所有 JevBench 数据均基于公开版的 easy、standard 和 hard 层级(共 231 个项目)。未包含密封裁判层级,且 Jev 和 Kev 的数值仅限于相同的公开项目。在不进行思考的情况下,同一检查点在我们的测试集(2,962 个项目)上得分为 0.804,而在启用思考后为 0.840。## 快速入门要求:Python 3.12 和 CUDA GPU。推理也可在拥有 48 GB 或更多内存的 Apple Silicon Mac 上运行。``` pip install -r requirements.txt ``` 下载发布的权重并启动服务:``` hf download PostHog/jeeves --local-dir jeeves-weights python -m inference.serve --model jeeves-weights --drafter jeeves-weights/drafter_k4.safetensors --port 8009 ``` 在 Mac 上,引擎可在 MPS 上运行。权重占用 21 GB 的 bf16 空间。默认缓存(--max-rows 8 --max-len 8192)额外占用 28 GB,因此 48 GB 的 Mac 开始使用交换空间。请使用更小的缓存:``` python -m inference.serve --model jeeves-weights --drafter jeeves-weights/drafter_k4.safetensors --max-rows 4 --max-len 4096 --port 8009 ``` 在 M4 Pro 上,一个问题思考时速度约为每秒 20 个 token,而无需思考的请求耗时 0.3 至 0.5 秒。--precision fp8 对线性层进行量化,方式与 CUDA 相同,并使用 Metal w8a16 内核运行。激活值在所有尺寸下均保持 bf16,而 CUDA 在行数超过 256 时也会对其量化。此时权重仅占用 11.5 GB,一个问题思考时的速度约为每秒 31 个 token。输出结果略有变化;在开发集问题上,准确率和 NLL(负对数似然)没有发生可测量的变化。python -m model.metal_test 将 Metal 内核与 float64 及 eager 引用进行对比测试。python speed.py --model jeeves-weights --data data/dev.jsonl 对一组固定的开发请求进行计时;python -m prep.prep 用于构建 data/。或者,将你自己训练的检查点融合到独立模型中,并使用草稿生成器提供服务:``` python export.py runs/cispo/final --out runs/fused python -m inference.serve --model runs/fused --drafter runs/drafter_k4/drafter.safetensors --port 8009 ``` 然后以 Jev 的格式发送请求:``` curl -s localhost:8009/v1/systemone -H 'content-type: application/json' -d '{ "state": "Shoes arrived two weeks late and in the wrong size.另外,我看到我的卡上有两笔扣款。", "questions": { "department": {"type": "choice", "instructions": "哪个团队应该处理此问题?", "criteria": {"returns": "换货、退款、错发或损坏的商品", "shipping": "配送状态、延误、丢失包裹", "billing": "扣款、发票、支付问题"}}, "escalate": {"type": "noul", "instructions": "这需要紧急的人工关注吗?"}, "frustration": {"type": "score", "instructions": "客户有多沮丧?", "criteria": ["平静", "沮丧", "非常愤怒"]} }, "options": {"max_think": 512}}' ``` 在单张 H100 上使用 --precision fp8 运行,三个问题并行思考:``` { "model": "jeeves-latest", "answers": { "department": { "type": "choice", "choice": "billing", "confidence": 0.19, "probabilities": { "returns": 0.4, "shipping": 0.14, "billing": 0.46 } }, "escalate": { "type": "noul", "noul": 0.72 }, "frustration": { "type": "score", "score": 1.5, "legend": { "0": "平静", "1": "沮丧", "2": "非常愤怒" }, "probabilities": { "0": 0.04, "1": 0.43, "2": 0.54 }, "confidence": 0.75 } }, "usage": { "input_tokens": 129, "output_tokens": 160, "reasoning_tokens": 1536 }, "latency_ms": 8141.6 } ``` ## Python sdk/ 是 Jev 的 Python SDK (typesafe-sdk) 的即插即用替代品:``` pip install ./sdk ``` ``` from jeeves_sdk import Choice, Noul, Score, TypeSafeClient with TypeSafeClient() as client: result = client.system_one( state="我被扣了两次款。请帮忙。", questions={ "billing": Noul(instructions="这是关于账单的问题吗?"), "tone": Choice(instructions="语气是什么?", criteria={"calm": None, "angry": None}), "urgency": Score(instructions="这有多紧急?", criteria=["可以等", "本周内", "今天"]), }, max_think=768, return_reasoning=True, ) print(result.nouls["billing"].noul, result.choices["tone"].choice, result.scores["urgency"].score) print(result.reasoning["tone"].text) ``` 客户端默认连接到 http://127.0.0.1:8009(或 JEEVES_BASE_URL),不需要 API 密钥,并最多等待 120 秒。## Options options 是可选的,不发送它的 Jev 客户端会忽略它。通过对应的 serve 标志设置服务器级默认值。选项 | 默认值 | 效果 think | true | 仅根据提示回答(约 0.3 秒) max_think | 2560 | 在此 token 数处截断每个推理链,然后回答 nothink_threshold | null | 当无思考置信度至少达到此值时,不进行思考直接回答 return_reasoning | false | 将每个问题的推理文本添加到响应中 在 325 个开发问题上,在一块 H100 GPU 上使用 --precision fp8:设置 | 准确率 | 平均推理 token 数 | 中位数 / p90 延迟 完整思考 | 0.825 | 1,138 | 3.3 秒 / 17.1 秒 max_think 768, nothink_threshold 0.9 | 0.806 | 344 | 2.0 秒 / 5.6 秒 不思考 | 0.775 | 0 | 约 0.3 秒 ## 工作原理 问题、状态和答案被加载到 Qwen 聊天模板中,如下所示 ``` …state… instructions option 1 option 2 … ``` 模型随后展开其推理链,并在我们附加的 token 之后
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力