我们如何构建 Zeta2:在生产环境中训练编辑预测模型
TL;DR · AI 摘要
Zed 团队通过生产环境用户编辑数据蒸馏训练 Zeta2 编辑预测模型:使用前沿大模型生成候选编辑,结合静态评估与“修复”机制过滤低质量输出,最终构建约10万样本的高质量训练集;整个 pipeline 基于 JSONL 流式处理,支持快速实验迭代。
核心要点
- Zeta2 使用 distillation + repair 两阶段流程:先由 frontier model 生成编辑预测,再用启发式规则检测失败案例并触发二次
- 训练数据规模为 10k–100k 样本,核心数据来自用户 opt-in 的生产环境编辑快照(含光标位置、类型定义、诊断信息等)
- 整个 pipeline 采用 JSONL 格式流式处理,各阶段仅增删字段,便于缓存与多实验复用
结构提纲
按章节快速跳转。
编辑预测模型需基于光标周围代码上下文、近期编辑历史、类型定义及诊断信息,实时预测用户下一步编辑操作,延迟必须极低。
使用用户授权的生产环境编辑快照作为原始数据,通过 frontier model 进行初始预测,并以启发式规则筛选低质量输出。
对失败预测调用第二轮 frontier model 修复,将修复后结果作为 Zeta2 的监督信号,形成高质量训练样本。
整个 pipeline 以 JSONL 为中间格式,各阶段仅增删字段,支持缓存与多组 prompt 实验(如是否包含 diagnostics)。
标准训练集为 100,000 样本,小实验降至 10k–50k;正在尝试‘settled data’——即用户最终确认的编辑作为黄金标准。
思维导图
用一张图看清主题之间的关系。
查看大纲文本(无障碍 / 无 JS 友好)
- Zeta2 编辑预测模型训练架构
- 输入数据源
- 用户 opt-in 生产编辑快照
- 含光标位置、类型/变量定义、诊断信息
- 核心流程
- 1. Frontier Model 蒸馏生成候选编辑
- 2. 静态评估 + 启发式过滤
- 3. Repair Step:失败案例二次修正
- 4. 构建学生模型监督信号
- 工程实现
- JSONL 流式 pipeline
- 各阶段字段增量更新
- 支持 prompt 变体实验(diagnostics/历史长度等)
- 训练集规模:10k–100k 样本
金句 / Highlights
值得收藏与分享的关键句。
我们使用 distillation 将前沿模型的预测作为教师信号,但因模型输出不稳定(100,000 次请求产生 100,001 种答案),必须精细调优提示词与修复逻辑。
修复步骤(repair step)会检测预测是否在 undo 用户刚输入内容或越界编辑区域,并自动触发第二轮推理请求以修正错误。
整个 pipeline 设计为纯 JSONL 流式处理,每个阶段只添加或移动字段,极大提升可维护性与实验迭代速度。
视频笔记
translation:
YouTube Transcript
language: English ( automatically generated) (en)
[0:07] [music]
[0:14] >> I'm Ben Kunkel. I'm the lead(sm lead) lead at Zed. Um, we recently announced
[0:16] our model Zed 2 and this is how we train it. I'm going to go through a
[0:20] lot. This is OB course a rather short
[0:21] talk. So, I'm going to try and leave
[0:24] enough time for questions at the end,
[0:26] but it's if you're not familiar with
[0:29] training models, uh, it's going to be a
[0:31] bit of a whirlwind tour. So, if you're
[0:32] not familiar with train prediction, it's
[0:34] essentially giving the model a region of
[0:36] code around the cursor, asking them to
[0:38] predict the next edit that you're going
[0:40] to make. We give it various data in such
[0:42] as your recent edits, your cursor
[0:44] position, the type definitions and
[0:47] variable definitions or of things around
[0:49] your cursor, as well as diagonals,
[0:50] errors, etc. It obvious])** need to be
[0:52] very fast because it runs on every
[0:54] keystroke. And so, it's ideal for a
[0:56] small specialized model, fine-tuned. It
[0:59] can do this task and this task only.
[1:02] Um, so that's what we've we've done.
[1:04] So, the pipeline in essence is taking
[1:07] these train data. Uh, this works real well because it's shots.
[1:09] So, all of that data that we have
[1:11] collected, related like related
[1:16] types and definitions and etc., all of
[1:18] that gets captured and then we're able
[1:20] to turn that into train data.
[1:23] In order to do that, we use a process
[1:24] called distillation where we take a
[1:26] front model, we give it all of that
[1:28] input, and we say, "What prediction
[1:30] would you make?" This is a rather
[1:32] difficult process as it turns out, even
[1:34] through even though the front models are
[1:36] quite**
[1:38] scientific. If you ask them 100,000 times,
[1:40] they're going to give you 100,001
[1:42] answers, right? And so, there's a
[1:44]])** of problems there that we've had to like
[1:46] fine-tune the prompt that we're giving
[1:48] that front model in order to get good
[1:49] things out. One of the things we've done
[1:52] to try and get better,
[1:53] we run some off line or static
[1:55] evaluations. So,
translation:
[4:52] 生成 10 个教师预测。
[4:55] 看看是否有其中任何一个与我们当前的预测相似。
[4:58] 使用像 Levenshtein 距离这样的类型。
[5:00] 看看是否任何这些与我们当前的预测相似。
[5:02] 我们知道 two things. 我们知道它可预测。
[5:04] 并且它不是 nois y and completely different than what the input was, right? Cuz we're giving the same input that we gave for the original prediction.
[5:11]ums that turns out to be quite expensive. For 100,000 examples, you're then doing, you know, a million front model requests. That is prohibitedly expensive.
[5:15] Fortunately, given that we have now train models using the original teacher predictions.
[5:17] Uh, our student models or Zed 2 is approaching the teacher in terms of quality of prediction. So, instead of running the teacher, we can run our student checkpoint or something 50 times.
[5:20] That costs us basicly nothing.
[5:22] And we can see do the same process, see if any of them are close to the settled region using Levenshtein or something similar.
[5:24]ums we have ideal training examples.
[5:26] right? Cuz there's a by looking at the range of distance to the settled state, there's a region that are super far away, we can be confident that that's just noise.
[5:28] There's a con- there's a region that's super close, that's like it's super obvious what you're going to be doing, right? You you typed function add A plus, it's clearly B, right?
[5:31] Uh, but then there's this interesting section in the middle where it's almost.
[5:34] That's like the ideal what we want in our training examples.
[5:36] For example, the kids that's past the training data cut off of our student model. So, new functions etc. that it's never seen before that you actually want. And that's going to show up in these new training examples that we can then train off of. We generally don't train off of the actual settled state just because it's still nois y, but we can train off of, you know, what was closest to the settled state.
[5:42] So, to run those offline evals, we're running on a held out test set.ums we're not training the model on the same thing we're testing it on.
[5:45]ums we are Levenshtein.])])])))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))**
[10:06]停止编辑该区域 10 秒。
[10:09] And that that作为 tent 近似 enough
[10:11] heuristics thatum
[10:13] so it's only in cases where you are
[10:15] like consistently editing that location
[10:18] for longer
[10:19]um without pausing for 10 seconds that
[10:21] we won't snapshot it.um
[10:24] any other questions?
[10:29] All right, I guess you guys get your time back. Thank you for coming.
[10:30] >> [ applAUSE]
[10:42] [music]