将较大模型的答案蒸馏到小模型中

阅读约需 34分钟 分钟,6节中含3个示例。

版次 2026.11.9 示例于 2026年11月20日 通过 36个示例中有36个通过 变化内容

AI 翻译。由人工以英文核验。 我们如何制作图书

译自英文版图书,版次 2026.11.9。 阅读原文

学完本章,你可以在较大教师模型为训练数据行给出的标签上训练一个小的学生模型,度量这些标签与黄金标签的一致程度,并根据同样的消息判断:与在黄金标签上训练的学生模型相比,这个学生模型是否值得使用。

路由器通过带标签的消息学会说出应由哪个团队处理。本章要问的是,能否由一个较大的模型为训练数据行完成这项标注,让小模型从它的答案中学习。黄金标签来自 BANKING77。第 5 章在训练数据行的黄金标签上训练了一个头部,它保存的适配器 banking77-lora-v1 就是人工标注适配器。它的测试结果是本章一切比较的基准,它的阈值就是其清单所记录的阈值,该阈值由第 5 章给出的规则在开发集上选定。

黄金标签需要人花时间制作,而蒸馏正是想绕开这一点:用较大模型的答案代替黄金标签。这里的较大模型是替身模型。它比 SmolLM2-135M-Instruct 更大,而后者是本书路由器所基于的基础模型;它回答的问题,与路由器所回答的相同。

蒸馏复制了什么

最近一次修改见于版次 2026.11.9

蒸馏训练一个小模型,使其复现大模型的行为。Hinton、Vinyals 和 Dean 的论文为蒸馏命名,该文提出把大模型给出的每个类别的概率作为软目标,用来训练小模型(Hinton et al., 2015, arXiv:1503.02531)。论文认为,这些概率比单个标签携带更多信息,以这种方式训练的小模型往往只需远少于大模型所需的数据就能学会。这是论文基于自身实验得出的论断,并不是适用于所有任务的规则。

本章不使用软目标。替身模型对每条消息只返回一个团队,即它判断可能性最大的那个团队,学生模型只看到这个团队。Kim 和 Rush 在翻译任务中采用了同样的简化,他们用教师分布的最可能输出取代了教师分布本身:“Our simplest approximation is to replace the teacher distribution q with its mode”(Kim and Rush, 2016, arXiv:1606.07947)。他们的场景是翻译,而不是分类。我们借用这种简化,并在本任务上对其加以度量,而不是假定它可以直接迁移。在这里,教师模型的贪心答案扮演众数的角色:它就是教师对每条消息返回的那一个团队。

每条消息只用一个标签进行训练,由此产生两点后果。其一,学生模型在学会教师正确答案的同时,也学会了教师的错误,因为训练循环把错误标签当作标签,与正确标签并无区别。其二,学生模型的错误可能与教师模型的错误不同,这正是既要对照教师、也要对照金标准标签来度量学生模型的原因。

工作准则: 在用教师模型的答案训练学生模型之前,先在已标注的行上度量教师的答案与金标准标签相符的频率,并阅读其中一些不一致的样例。要预期学生模型会复现教师的错误,并在学生模型未训练过的消息上统计这些错误。

条款允许的教师模型

教师模型必须是其条款允许用其输出进行训练的模型。本书中替身模型的 GGUF 构建版本位于仓库 unsloth/Qwen3-4B-Instruct-2507-GGUF,文件为 Qwen3-4B-Instruct-2507-Q4_K_M.gguf,取教师清单所记录的修订版本。该模型是 Qwen 发布的 Qwen3-4B-Instruct-2507,构建版本由 unsloth 制作。我们对两者都予以署名。该构建版本的模型卡声明了 license: apache-2.0,并将 Qwen/Qwen3-4B-Instruct-2507 列为其基础模型(固定修订版本处的模型卡)。基础模型的许可证位于某个固定提交,为 Apache License 2.0。Apache License 2.0 在其第二节中授予"复制、制作衍生作品、公开展示、公开表演、转许可以及分发作品和此类衍生作品"的权利(Apache License 2.0)。

我们的理解是,Apache-2.0 对使用模型的输出没有设定限制。其文本规范的是作品和此类衍生作品,如上文第 2 节所述,而没有提及输出。这是我们对该许可证的解读,而非对其原文的引用,并且仅适用于这一模型的许可证。本书发布的适配器以 Apache-2.0 分发,与之并列的声明给出了许可证和署名信息。

许可证各不相同。像 Apache-2.0 这样的开放权重许可证规范的是模型的文件;托管模型则受其提供方服务条款的约束,这些条款可能禁止使用该服务或其输出来训练与之竞争的模型。条款会变化,因此在使用任何一个要用来训练的模型时,应当在使用当天阅读其现行条款。本书从不使用托管模型作为教师。

替身模型是开放模型,因此其许可证可以查阅,其文件可以用哈希固定,教师清单中记录了该哈希。托管模型的回答可能在提供方更换模型时发生变化,其条款也可能禁止这种用法。即使在阅读条款之前,这些也是优先选择文件已固定的开放教师模型的理由。

工作准则: 在训练当天阅读教师模型的许可证及其使用条款。在本章中写明教师模型、其许可证及其修订版本,并让学生模型的清单指向教师模型的记录。不要使用条款禁止此用途的模型的输出进行训练。对输出不设限制的许可证,只对该许可证回答了这个问题,因此在对其他模型假定答案之前,应先阅读其文本。

这部分尚未翻译,因此以英文显示。

Label training rows with the teacher

最近一次修改见于版次 2026.11.2

The teacher labels training rows only. Dev rows are kept for choosing thresholds, and test rows are kept for reporting, as chapter 2 set out. The rows to label are drawn from the training file, outside dev. The labelled rows are the first 1,000 of a seeded random draw of 2,000 such rows, a random subset of them, and the recording sorts them by index before labelling. The labelling run was planned for all 2,000, but it could not finish that many within its time limit, so the book reports the 1,000 rows it labelled.

The draw is seeded. Labels already saved for a chosen row are kept and not labelled again, so a run that stops and continues adds only the rows it has not labelled. We did not test whether a resumed run gives the same labels as one full run.

The stand-in answers each message with the router prompt from chapter 1. It decodes greedily, at temperature zero. In a probe on 40 test messages, two runs gave identical answers, and that probe is the only check we made of repeatability. Its answer is constrained by a grammar to the 77 team names, so each label is a real team.

teacher-agreement.py Python 3.12.15 · torch 2.15.0+cpu · transformers 5.23.0 通过
"""Measure how often the teacher's label matches gold on the training rows it labelled, and its accuracy on test_200from its recorded answers. The point rests on the agreement line; the example reads recorded answers only."""import osos.environ["HF_HUB_OFFLINE"] = "1"os.environ["TRANSFORMERS_OFFLINE"] = "1"import json  # noqa: E402import torch  # noqa: E402torch.set_num_threads(2)import router_lib  # noqa: E402router_lib.setup_runtime()RECORDED = router_lib.HERE / "data" / "recorded"train = router_lib.read_rows("train")teacher_rows = [json.loads(line) for line in (RECORDED / "teacher-labels" / "labels.jsonl").read_text().splitlines()]# row["index"] is the row's position in the training file; field 1 of a row is its gold teamagree = sum(row["label"] == train[row["index"]][1] for row in teacher_rows)n = len(teacher_rows)print(f"training rows labelled by the teacher: {n}")print(f"teacher agrees with gold on training rows: {agree}/{n} ({agree / n:.1%})")print(f"teacher disagrees with gold on training rows: {n - agree}/{n} ({(n - agree) / n:.1%})")test = router_lib.read_rows("test")sample = router_lib.read_sample("test_200")standin = router_lib.standin_answers()# sample holds test row positions; field 1 of a test row is its gold team, field 0 its textgolds = [test[i][1] for i in sample]teacher_preds = [standin[i] for i in sample]correct = sum(p == g for p, g in zip(teacher_preds, golds))print(f"messages on test_200 with a teacher answer: {sum(i in standin for i in sample)}/{len(sample)}")print(f"teacher accuracy on test_200: {correct}/{len(sample)} ({correct / len(sample):.1%})")
输出python teacher-agreement.py
training rows labelled by the teacher: 1000
teacher agrees with gold on training rows: 549/1000 (54.9%)
teacher disagrees with gold on training rows: 451/1000 (45.1%)
messages on test_200 with a teacher answer: 200/200
teacher accuracy on test_200: 109/200 (54.5%)

The teacher's label matches the gold label on 549/1000 (54.9%) of the 1000 training rows it labelled, and it disagrees on 451/1000 (45.1%). A student trained on those disagreeing rows learns the wrong label as the answer to each one. The last two lines of the output come from the stand-in's recorded answers on test_200, the 200 test messages this chapter reports on. There the teacher is right on 109/200 (54.5%) messages.

Read the line teacher agrees with gold on training rows before any student is trained. The line teacher accuracy on test_200 is the teacher's own accuracy on messages no one has used for training, and it is the reference for every copy measure below.

Counts do not show what the disagreements look like. Three training rows, each labelled card_arrival in the gold file, show the pattern. Each message is about a card that has not arrived, described here without its text, since messages are never quoted in this book. The teacher named card_delivery_estimate for two of them and lost_or_stolen_card for the third, so the teacher names a different team from the gold label each time.

Working rule: Measure the teacher's agreement with gold on a labelled sample of rows before you train a student on the labels. Label only rows outside dev and test, and record the teacher's model, its version and its settings in the teacher's recording manifest, and point the student's manifest to it, so each label can be traced.

用教师的标签训练学生模型

最近一次修改见于版次 2026.11.2

学生模型沿用第 5 章的方案:基础模型、LoRA 目标层、分类头、随机种子和批大小都与之相同。它的标签来自教师模型,而不是来自金标准文件。训练的行数和步数也与第 5 章不同:学生模型在 1000 行数据上训练了 125 步,而人工标注的适配器在 9000 行数据上训练了 1125 步。一致性一节中的对照实验保持学生模型的行数和步数不变,只替换标签。学生模型的适配器是 banking77-distilled-v1。它的清单记录了自身的设置,并指向教师的记录文件 teacher-labels/manifest.json。该文件写明了教师模型的名称和版本、它的设置以及它标注过的行,因此任何人都可以追溯每个标签的来源。

方案被有意固定。如果学生模型同时改变方案和标签,结果中的差距可能来自其中任何一个,读者无法判断究竟是哪一个。固定方案之后,标签就成为结果所能指向的唯一差异。

学生模型的阈值在开发集上选取,所用规则与人工标注适配器相同。该规则在以百分之一为间隔的网格上,取最低的阈值,使未移交的消息在开发集上的准确率至少为 0.90。对于达不到该目标的学生模型,规则设有回退方案:取未移交消息准确率最高的阈值,若有并列则取其中最低的,并且跳过会把每条消息都移交出去的阈值。输出会说明使用了回退方案。这是本书对未达标结果的处理规则,因此要如实报告为回退方案,而不能当作达到目标的学生模型。回退阈值是根据该阈值在开发集上保留的消息选出的,阈值较高时,这样的消息可能只有寥寥几条。应将回退值视为暂定值,并像本章一样,同时报告它在测试集上造成的移交率。

学生模型的阈值是在开发集的一部分上选取的,这部分有 500 of 1003 条消息,因为对全部开发消息运行一遍,超出了两个 CPU 核心的时间预算。两个学生模型示例使用同一部分数据,对照实验也用它来选取自己的阈值,所以两个阈值是在相同的开发消息上选出的。第 5 章中人工标注适配器的阈值,则是在全部 1,003 条开发消息上选取的。

工作准则: 在开发集上选取学生模型的阈值时,使用与人工标注适配器相同的规则;当没有任何阈值达到目标时,要说明该阈值是回退值。在把学生模型与任何对象比较之前,先在准确率旁报告该阈值造成的移交率,并给出两者的计数。

衡量一致率,而不仅是准确率

最近一次修改见于版次 2026.11.9

本章贯穿三项衡量,每一项回答各自的问题。教师模型对照训练行上的金标准,问的是教师模型在它所标注的行上是否正确,这就是上文的那一项。学生模型对照 test_200 上的教师模型,问的是学生模型复制了教师模型的多少。学生模型对照 test_200 上的金标准,问的是学生模型多常指出正确的团队,路由器正是按这个数字来评判的。每一项都连同其分母一起输出:第一项在 1,000 条训练行上读取,另外两项在同样的 200 条测试消息上读取。

一致率与准确率回答的是不同的问题。与教师模型的一致率说明学生模型学到了教师模型的多少,无论教师模型是对是错。对照金标准的准确率说明学生模型多常指出正确的团队。学生模型可能与一个出错的教师模型一致而同样出错,也可能与一个出错的教师模型不一致而恰好答对。两者都输出,读者便能看出究竟发生的是哪一种,而不必从单个数字去推断。

student-recorded-adapter.py Python 3.12.15 · peft 0.21.3 · torch 2.15.0+cpu · torchao 0.18.0+cpu · transformers 5.23.0 通过
"""Score the distilled student banking77-distilled-v1 on test_200 beside the human-labelled adapter, with the student'sthreshold chosen on dev. The point rests on the student's accuracy line and its copy lines; both adapters are loadedand scored live, and nothing is trained."""import osos.environ["HF_HUB_OFFLINE"] = "1"os.environ["TRANSFORMERS_OFFLINE"] = "1"import json  # noqa: E402import torch  # noqa: E402torch.set_num_threads(2)import router_lib  # noqa: E402router_lib.setup_runtime()RECORDED = router_lib.HERE / "data" / "recorded"tokenizer, student = router_lib.load_classifier(RECORDED / "distill-student" / "adapter")DEV_N = 500  # the first 500 of the 1,003 dev messages: the run's time budget under two CPUs# reached is False when no threshold meets the target, and the threshold returned is then the fallbackthreshold, reached = router_lib.dev_threshold(student, tokenizer, target=0.90, n=DEV_N)print(f"dev messages used: {DEV_N} of {len(router_lib.read_sample('dev'))}")print(f"dev threshold reaching 0.90 accuracy not handed off: {'yes' if reached else 'no'}")print(f"student threshold chosen on dev: {threshold:.2f}")test = router_lib.read_rows("test")sample = router_lib.read_sample("test_200")# sample holds test row positions; field 1 of a test row is its gold team, field 0 its textgolds = [test[i][1] for i in sample]texts = [test[i][0] for i in sample]student_preds, student_confs = router_lib.classify(student, tokenizer, texts)router_lib.print_copy_report("banking77-distilled-v1", student_preds, student_confs, golds, threshold)# chapter 5 chose the adapter's threshold on dev, and its manifest records the value used herelora = json.loads((RECORDED / "lora-full" / "manifest.json").read_text())_, lora_model = router_lib.load_classifier(RECORDED / "lora-full" / "adapter")lora_preds, lora_confs = router_lib.classify(lora_model, tokenizer, texts)router_lib.print_copy_report("banking77-lora-v1", lora_preds, lora_confs, golds, lora["handoff_threshold"])teacher = router_lib.standin_answers()teacher_preds = [teacher[i] for i in sample]matches = sum(s == t for s, t in zip(student_preds, teacher_preds))# positions within sample where the student's answer is not the gold teamwrong = [k for k in range(len(sample)) if student_preds[k] != golds[k]]wrong_like_teacher = sum(student_preds[k] == teacher_preds[k] for k in wrong)print(f"student answers equal to teacher answers on test_200: {matches}/{len(sample)} ({matches / len(sample):.1%})")print(f"student errors on test_200: {len(wrong)}/{len(sample)} ({len(wrong) / len(sample):.1%})")print(f"student errors equal to the teacher's answer: {wrong_like_teacher}/{len(wrong)}")
输出python student-recorded-adapter.py
dev messages used: 500 of 1003
dev threshold reaching 0.90 accuracy not handed off: no
student threshold chosen on dev: 0.68
banking77-distilled-v1 accuracy on test_200: 69/200 (34.5%)
banking77-distilled-v1 handed off: 150/200 (75.0%)
banking77-distilled-v1 accuracy on messages not handed off: 28/50 (56.0%)
banking77-lora-v1 accuracy on test_200: 172/200 (86.0%)
banking77-lora-v1 handed off: 33/200 (16.5%)
banking77-lora-v1 accuracy on messages not handed off: 156/167 (93.4%)
student answers equal to teacher answers on test_200: 100/200 (50.0%)
student errors on test_200: 131/200 (65.5%)
student errors equal to the teacher's answer: 36/131

学生模型远落后于人工标注的适配器,而且如下方的总体数字所示,差距不只体现在转交上。在 test_200 上,学生模型答对 69/200 (34.5%) 条消息,转交 150/200 (75.0%);适配器答对 172/200 (86.0%) 条消息,转交 33/200 (16.5%)。学生模型的阈值采用上文所述的回退方案。每次运行在其保留的消息上的准确率,都对应它自己的阈值,输出在本段旁边同时给出了这两者。

接下来是复制程度的衡量。学生模型的答案与教师模型的答案相同的消息有 100/200 (50.0%) 条,而教师模型自己答对 109/200 (54.5%)。因此,一个紧密复制教师模型的学生模型,也会复制教师模型的错误答案。学生模型在 test_200 上出现 131/200 (65.5%) 处错误。在这些错误中,36/131 重复了教师模型的答案。其余的则与之不同,所以学生模型的错误并不只是教师模型的错误。

只与适配器作比较,混杂了两件事。适配器从完整训练划分的金标准标签中学习,而学生模型从教师模型在较小的行集合上给出的标签中学习。两者之间的差距可能来自标签,可能来自行数,也可能两者兼有。为了把它们分开,本书在同样的行上用金标准标签记录同一套方案。对照组 banking77-gold-1000-v1 就是用金标准标签训练的学生模型方案,其行就是教师模型所标注的那些行。

student-vs-gold-control.py Python 3.12.15 · peft 0.21.3 · torch 2.15.0+cpu · torchao 0.18.0+cpu · transformers 5.23.0 通过
"""Put the student banking77-distilled-v1 beside its control banking77-gold-1000-v1, which has the same recipe and thesame 1,000 training rows but gold labels, on the same test_200 messages. The point rests on the two counts of messageseach adapter gets right that the other gets wrong, which need no threshold; both adapters are scored live, and nothingis trained."""import jsonimport osos.environ["HF_HUB_OFFLINE"] = "1"os.environ["TRANSFORMERS_OFFLINE"] = "1"import torch  # noqa: E402torch.set_num_threads(2)import router_lib  # noqa: E402router_lib.setup_runtime()RECORDED = router_lib.HERE / "data" / "recorded"DEV_N = 500  # the first 500 of the dev messages, as student-recorded-adapter uses: the time budget under two CPUsprint(f"dev messages used: {DEV_N} of {len(router_lib.read_sample('dev'))}")test = router_lib.read_rows("test")sample = router_lib.read_sample("test_200")# sample holds test row positions; field 1 of a test row is its gold team, field 0 its textgolds = [test[i][1] for i in sample]texts = [test[i][0] for i in sample]runs = {}for name, folder in [("banking77-distilled-v1", "distill-student"), ("banking77-gold-1000-v1", "gold-same-rows")]:    tokenizer, model = router_lib.load_classifier(RECORDED / folder / "adapter")    threshold, reached = router_lib.dev_threshold(model, tokenizer, target=0.90, n=DEV_N)    print(f"{name} dev threshold reaching 0.90 accuracy not handed off: {'yes' if reached else 'no'}")    print(f"{name} threshold chosen on dev: {threshold:.2f}")    preds, confs = router_lib.classify(model, tokenizer, texts)    router_lib.print_copy_report(name, preds, confs, golds, threshold)    runs[name] = [p == g for p, g in zip(preds, golds)]# dict order is insertion order: the student first, then the controlstudent, control = runs.values()n = len(golds)print(f"test_200 messages the student gets right and the control gets wrong: {sum(s and not c for s, c in zip(student, control))}/{n}")print(f"test_200 messages the control gets right and the student gets wrong: {sum(c and not s for s, c in zip(student, control))}/{n}")# Recipe sizes from the recorded manifests: the student and its control share rows and steps;# the human-labelled adapter does not. Its manifest names its row count train_rows, not rows, which is why rows_key differs.for name, folder, rows_key in [    ("banking77-distilled-v1", "distill-student", "rows"),    ("banking77-gold-1000-v1", "gold-same-rows", "rows"),    ("banking77-lora-v1", "lora-full", "train_rows"),]:    settings = json.loads((RECORDED / folder / "manifest.json").read_text())["settings"]    print(f"{name} training rows: {settings[rows_key]}")    print(f"{name} training steps: {settings['steps']}")
输出python student-vs-gold-control.py
dev messages used: 500 of 1003
banking77-distilled-v1 dev threshold reaching 0.90 accuracy not handed off: no
banking77-distilled-v1 threshold chosen on dev: 0.68
banking77-distilled-v1 accuracy on test_200: 69/200 (34.5%)
banking77-distilled-v1 handed off: 150/200 (75.0%)
banking77-distilled-v1 accuracy on messages not handed off: 28/50 (56.0%)
banking77-gold-1000-v1 dev threshold reaching 0.90 accuracy not handed off: no
banking77-gold-1000-v1 threshold chosen on dev: 0.97
banking77-gold-1000-v1 accuracy on test_200: 77/200 (38.5%)
banking77-gold-1000-v1 handed off: 197/200 (98.5%)
banking77-gold-1000-v1 accuracy on messages not handed off: 3/3 (100.0%)
test_200 messages the student gets right and the control gets wrong: 24/200
test_200 messages the control gets right and the student gets wrong: 32/200
banking77-distilled-v1 training rows: 1000
banking77-distilled-v1 training steps: 125
banking77-gold-1000-v1 training rows: 1000
banking77-gold-1000-v1 training steps: 125
banking77-lora-v1 training rows: 9000
banking77-lora-v1 training steps: 1125

对照组同样没有满足开发集目标的阈值,因此它也使用回退方案,它的阈值也因此只是暂定的。它在 test_200 中转交 197/200 (98.5%),在其保留的消息上答对 3/3 (100.0%)。三条消息不足以构成一项衡量。总体准确率不需要阈值,因为无论阈值如何,它都统计每一条消息,所以对照组的 77/200 (38.5%) 可以直接与学生模型的 69/200 (34.5%) 并列比较。

公平的比较落在答案本身,它不需要阈值,因为比较的是团队。对照组答对而学生模型答错的消息有 32/200 条,学生模型答对而对照组答错的有 24/200 条。对照组相对学生模型并不拥有这份样本能够确证的优势,因此我们判断 200 条消息太少,不足以断言其中一种标签来源优于另一种。

适配器在 9000 行上训练了 1125 步,而对照组与学生模型共用 1000 行和 125 步,所以对照组与适配器之间的差异,把行数和步数同两次运行的其他任何不同之处混在一起,本章并未将它们分开。

工作准则: 只在相同的消息和相同的行上比较两个适配器。对每一个适配器,统计它答对而另一个答错的消息数,并连同分母一起输出这两个计数。不要把在不同阈值下取得的准确率并排放置,仿佛它们是同一项衡量。

当教师模型出错时

最近一次修改见于版次 2026.11.9

学生模型以每条消息一个标签的方式训练,它学到的就是拿到的那些标签。教师模型在某一行上出错时,学生看到的就是该行的错误团队,而且无从得知它是错的。教师在训练行上与金标准的一致率(见上文的度量)就是教师训练标签中正确标签所占的比例。学生是在测试消息上度量的,而不是在它的训练行上,因为它在训练过的行上的数字反映的是它记住了什么,而不是学到了什么。

在这项任务上,从替身模型的标签中学习的学生并不是应当上线的那个,上文的数字已经说明了这一点。第 7 章量化的是banking77-lora-v1,即人工标注的适配器,而不是学生模型。

应将复制度量与准确率对照着读。如果学生在大多数消息上复制教师,而教师在许多消息上出错,学生就会继承这些错误,它相对金标准的准确率会随教师一同下降。如果学生在许多消息上与教师不一致,却依然出错,说明它学到的是标签之外的东西,首要的怀疑对象是训练行的数量。这是根据本书自身数字得出的经验法则,本章并未对其进行检验。

蒸馏在某些情形下值得其成本。我们建议在以下情形尝试:金标准标签稀缺,教师在你的任务上表现强,并且对金标准标签的抽样表明教师与其一致的频率足以使学生的错误可以接受。当你的训练行已经有金标准标签时,就用它们训练,教师只用来检查这些标签。教师模型也会发生变化。应把教师的新版本视为一次新的录制:它的标签会变,因此学生的清单、阈值和各项度量都必须重新做一遍。

在生产中,这种失败是悄无声息的。复制教师的学生会持续返回团队,转交率也保持平稳,两者都不会惊动任何人。应按固定的时间表,用一批由人工标注过的消息样本,对照金标准标签检查学生。第 9 章把对适配器转交所做的同类抽样作为下一步加以描述,本书并未构建它。应将学生的回答与这些标签比较,而不是与教师的回答比较,因为与教师一致并不能说明一条消息属于哪个团队。

本章做出的决定如下:

  • 教师只标注训练行,从不标注开发行或测试行。
  • 教师是替身模型 Qwen3-4B-Instruct-2507,采用 Apache-2.0 许可,不使用任何托管模型。
  • 学生采用与人工标注适配器相同的方法训练,其阈值遵循相同的规则,回退情形作为回退如实报告。
  • 学生与一个在相同行的金标准标签上训练的对照模型,在相同的消息上进行比较,两者共用同样的行,因此二者之间的差异来自标签,而不是来自这些行。

教师的标签会把它的错误带给学生,因此与金标准的一致程度决定了蒸馏是否值得。

**工作准则:**只有在任务的金标准标签太少,并且对金标准标签的抽样表明教师与其足够一致时,才用教师的标签训练学生。在选定学生之前,先在相同的消息上,将它与人工标注的适配器以及在金标准标签上采用相同方法训练的模型做比较。学生落败时,上线适配器,并在书面说明中写明这一点。

本章,在本版次中

版次 2026.11.9示例于 2026年11月20日 通过本章 3个示例 个示例中有 3 个通过

译自英文版图书,版次 2026.11.9。

引用本节

格式

每种格式均引用英文原书,本译本以其为准。

每种格式都会注明该版次。其链接会打开当前版次,节标题处会说明该节文本最后一次修改的时间。访问日期和检索日期即为您打开此页的当天。

本页内容

第 6 章,共 10 章: 将较大模型的答案蒸馏到小模型中

  1. 蒸馏复制了什么
  2. 条款允许的教师模型
  3. Label training rows with the teacher
  4. 用教师的标签训练学生模型
  5. 衡量一致率,而不仅是准确率
  6. 当教师模型出错时

返回顶部全部章节