將較大模型的答案蒸餾到小模型
閱讀約需 35 分鐘 分鐘,6 節 中共有 3 個範例。
讀完本章後,你可以用較大的教師模型為訓練資料列給出的標籤來訓練一個小型學生模型,衡量這些標籤與黃金標籤的一致程度,並根據同一批訊息判斷這個學生模型相較於以黃金標籤訓練的學生模型是否值得使用。
路由器會從已標註的訊息中學會辨識該交給哪個團隊。本章要問的是:能否由較大的模型為訓練資料列做標註,讓小模型從它的答案中學習。黃金標籤來自 BANKING77。第 5 章以訓練資料列的黃金標籤訓練了一個分類頭,而它儲存的 adapter banking77-lora-v1 就是以人工標註訓練的 adapter。它的測試結果是本章所有比較的基準,它的門檻值則是其 manifest 所記錄的那一個,由第 5 章給出的規則在開發集上選定。
黃金標籤需要人花時間製作,而蒸餾正是想繞過這一點:以較大模型的答案取代黃金標籤。這裡所用的較大模型是替代模型。它比本書路由器所採用的基礎模型 SmolLM2-135M-Instruct 更大,而且回答的問題與路由器所問的相同。
蒸餾複製了什麼
蒸餾(distillation)是訓練一個小模型去重現大模型的行為。Hinton、Vinyals 與 Dean 的論文為蒸餾命名,該文提出以大模型對每個類別給出的機率作為軟目標(soft targets),來訓練小模型(Hinton et al., 2015, arXiv:1503.02531)。論文主張,這些機率所攜帶的資訊多於單一標籤,以此方式訓練的小模型,往往只需遠少於大模型所需的資料就能學會。這是論文根據自身實驗所提出的主張,並不是適用於所有任務的通則。
本章不使用軟目標。替代模型(stand-in)對每則訊息只回傳一個團隊,也就是它判斷可能性最高的那一個,學生模型只看得到這個團隊。Kim 與 Rush 在翻譯任務中採用了同樣的簡化,他們以教師模型最可能的輸出取代其機率分布:「我們最簡單的近似做法,是以教師分布 q 的眾數取代 q」(Kim and Rush, 2016, arXiv:1606.07947)。他們的情境是翻譯,而不是分類。我們借用這個簡化做法,並在本任務上實際量測,而不是假定它能原樣適用。在此,教師模型的貪婪式(greedy)答案扮演眾數的角色:它就是教師模型對每則訊息回傳的那一個團隊。
每則訊息只用一個標籤來訓練,會帶來兩個結果。第一,學生模型在學到教師模型正確答案的同時,也學到它的錯誤,因為訓練迴圈把錯誤標籤當成標籤,與正確標籤一視同仁。第二,學生模型的錯誤可能與教師模型的錯誤不同,這正是除了與教師模型比較之外,也要以黃金標籤(gold labels)衡量學生模型的原因。
實用原則: 在以教師模型的答案訓練學生模型之前,先在你已標註的資料列上,量測教師模型的答案與黃金標籤相符的頻率,並閱讀其中一部分不一致的案例。預期學生模型會重現教師模型的錯誤,並在學生模型未曾訓練過的訊息上計算這些錯誤的數量。
條款允許的教師模型
教師模型必須是其條款允許以其輸出進行訓練的模型。本書中替身模型的 GGUF 版本,位於儲存庫 unsloth/Qwen3-4B-Instruct-2507-GGUF,檔案為 Qwen3-4B-Instruct-2507-Q4_K_M.gguf,取自教師模型的資訊清單(manifest)所記錄的修訂版本。該模型是 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 的解讀是:它不對使用模型的輸出設下限制。其條文規範的是本作品與此類衍生作品,如上述第二節所載,而並未提及輸出。這是我們對該授權條款的解讀,而非條文的引述,且僅適用於此模型的授權條款。本書所附的轉接器(adapter)以 Apache-2.0 散布,其旁的聲明載明授權條款與出處標示。
各種授權條款並不相同。像 Apache-2.0 這類開放權重授權條款,規範的是模型的檔案;託管模型則受其供應商的服務條款規範,這些條款可能禁止以該服務或其輸出來訓練競爭的模型。條款會變動,因此對於任何你打算用來訓練的模型,請在使用當天閱讀其最新條款。本書從不使用託管模型作為教師模型。
替身模型是開放模型,因此其授權條款可供閱讀,其檔案也能以雜湊值固定,教師模型的資訊清單即記錄了該雜湊值。託管模型的回答可能在供應商更換模型時改變,其條款也可能禁止這種用途。這些都是優先選用檔案固定的開放教師模型的理由,甚至在讀條款之前就成立。
實用原則: 在訓練當天閱讀教師模型的授權條款與使用條款。在章中標明教師模型、其授權條款與修訂版本,並讓學生模型的資訊清單指向教師模型的紀錄。不要以條款禁止的模型之輸出進行訓練。對輸出不設限制的授權條款,只能回答該授權條款本身的問題,因此在假定另一個模型的答案之前,請先閱讀其條文。
此部分尚未翻譯,因此以英文呈現。
Label training rows with the teacher
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.
1"""Measure how often the teacher's label matches gold on the training rows it labelled, and its accuracy on test_2002from its recorded answers. The point rests on the agreement line; the example reads recorded answers only."""34import os56os.environ["HF_HUB_OFFLINE"] = "1"7os.environ["TRANSFORMERS_OFFLINE"] = "1"89import json # noqa: E4021011import torch # noqa: E4021213torch.set_num_threads(2)1415import router_lib # noqa: E4021617router_lib.setup_runtime()18RECORDED = router_lib.HERE / "data" / "recorded"1920train = router_lib.read_rows("train")21teacher_rows = [json.loads(line) for line in (RECORDED / "teacher-labels" / "labels.jsonl").read_text().splitlines()]22# row["index"] is the row's position in the training file; field 1 of a row is its gold team23agree = sum(row["label"] == train[row["index"]][1] for row in teacher_rows)24n = len(teacher_rows)25print(f"training rows labelled by the teacher: {n}")26print(f"teacher agrees with gold on training rows: {agree}/{n} ({agree / n:.1%})")27print(f"teacher disagrees with gold on training rows: {n - agree}/{n} ({(n - agree) / n:.1%})")2829test = router_lib.read_rows("test")30sample = router_lib.read_sample("test_200")31standin = router_lib.standin_answers()32# sample holds test row positions; field 1 of a test row is its gold team, field 0 its text33golds = [test[i][1] for i in sample]34teacher_preds = [standin[i] for i in sample]35correct = sum(p == g for p, g in zip(teacher_preds, golds))36print(f"messages on test_200 with a teacher answer: {sum(i in standin for i in sample)}/{len(sample)}")37print(f"teacher accuracy on test_200: {correct}/{len(sample)} ({correct / len(sample):.1%})")
python teacher-agreement.pytraining 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.
以教師的標籤訓練學生模型
學生模型沿用第 5 章的做法:基礎模型、LoRA 目標層、分類頭、隨機種子與批次大小都相同。它的標籤來自教師模型,而不是黃金標準檔案。訓練的資料列數與步數也與第 5 章不同:學生模型以 1000 列資料訓練 125 步,而人工標註的 adapter 以 9000 列資料訓練 1125 步。一致性一節中的對照組沿用學生模型的資料列與步數,只更換標籤。學生模型的 adapter 是 banking77-distilled-v1。其 manifest 記錄了訓練設定,並指向教師模型的紀錄檔 teacher-labels/manifest.json;該檔案載明教師模型的名稱與版本、設定,以及它所標註的資料列,因此任何人都能追溯每個標籤的來源。
這套做法是刻意固定的。如果學生模型同時更動訓練做法與標籤,結果出現差距時,原因可能來自任何一方,讀者便無從判斷。固定訓練做法之後,標籤就成為結果唯一能指向的差異。
學生模型的門檻值在 dev 上選定,所用規則與人工標註 adapter 相同:以百分之一為間隔的網格上,取最低的門檻值,使未轉交的訊息在 dev 上的準確率至少達 0.90。若學生模型無法達到這個目標,規則另有備援做法:取未轉交訊息準確率最高的門檻值;若有並列,取其中最低者;並略過會把所有訊息都轉交的門檻值。輸出會說明已使用備援做法。這是本書對未達標結果的處理規則,因此會如實標示為備援,而不會當作學生模型已達標。備援門檻值是從門檻值在 dev 上保留的訊息中選出的,門檻值偏高時,這些訊息可能只剩寥寥數則。請將備援值視為暫定值,並如本章所做,連同它在 test 上造成的轉交率一併報告。
學生模型的門檻值是在 dev 切分的一部分上選定的,共 500 of 1003 則訊息,因為對全部 dev 訊息執行一次,超出了兩個 CPU 核心的時間預算。兩個學生範例都使用同一部分,對照組也以它來選定自己的門檻值,所以兩個門檻值是在相同的 dev 訊息上選出的。第 5 章中人工標註 adapter 的門檻值,則是在全部 1,003 則 dev 訊息上選定的。
**實用原則:**學生模型的門檻值,應在 dev 上以與人工標註 adapter 相同的規則選定;若沒有任何門檻值達到目標,須說明該門檻值是備援值。在拿學生模型與任何對象比較之前,先報告該門檻值所造成的轉交率與準確率,並附上兩者的數量。
衡量一致率,而不只是準確率
本章使用三項衡量,各自回答不同的問題。教師模型對照標準答案(在訓練資料列上)問的是:教師在它所標註的資料列上是否正確,這就是前文所列的那一項。學生模型對照教師模型(在 test_200 上)問的是:學生複製了教師多少。學生模型對照標準答案(在 test_200 上)問的是:學生多常指出正確的團隊,這也是路由器最終會被評判的數字。每一項都附上其分母:第一項是以 1,000 筆訓練資料列來讀取,另外兩項則使用同樣的 200 則測試訊息。
一致率與準確率回答的是不同的問題。與教師的一致率說明學生學到了教師多少,無論教師是對是錯。對照標準答案的準確率則說明學生多常指出正確的團隊。學生可能與錯誤的教師一致而答錯,也可能與錯誤的教師不一致而答對。同時列出兩者,讀者就能看出發生的是哪一種情況,而不必從單一數字去推測。
1"""Score the distilled student banking77-distilled-v1 on test_200 beside the human-labelled adapter, with the student's2threshold chosen on dev. The point rests on the student's accuracy line and its copy lines; both adapters are loaded3and scored live, and nothing is trained."""45import os67os.environ["HF_HUB_OFFLINE"] = "1"8os.environ["TRANSFORMERS_OFFLINE"] = "1"910import json # noqa: E4021112import torch # noqa: E4021314torch.set_num_threads(2)1516import router_lib # noqa: E4021718router_lib.setup_runtime()19RECORDED = router_lib.HERE / "data" / "recorded"2021tokenizer, student = router_lib.load_classifier(RECORDED / "distill-student" / "adapter")22DEV_N = 500 # the first 500 of the 1,003 dev messages: the run's time budget under two CPUs23# reached is False when no threshold meets the target, and the threshold returned is then the fallback24threshold, reached = router_lib.dev_threshold(student, tokenizer, target=0.90, n=DEV_N)25print(f"dev messages used: {DEV_N} of {len(router_lib.read_sample('dev'))}")26print(f"dev threshold reaching 0.90 accuracy not handed off: {'yes' if reached else 'no'}")27print(f"student threshold chosen on dev: {threshold:.2f}")2829test = router_lib.read_rows("test")30sample = router_lib.read_sample("test_200")31# sample holds test row positions; field 1 of a test row is its gold team, field 0 its text32golds = [test[i][1] for i in sample]33texts = [test[i][0] for i in sample]34student_preds, student_confs = router_lib.classify(student, tokenizer, texts)35router_lib.print_copy_report("banking77-distilled-v1", student_preds, student_confs, golds, threshold)3637# chapter 5 chose the adapter's threshold on dev, and its manifest records the value used here38lora = json.loads((RECORDED / "lora-full" / "manifest.json").read_text())39_, lora_model = router_lib.load_classifier(RECORDED / "lora-full" / "adapter")40lora_preds, lora_confs = router_lib.classify(lora_model, tokenizer, texts)41router_lib.print_copy_report("banking77-lora-v1", lora_preds, lora_confs, golds, lora["handoff_threshold"])4243teacher = router_lib.standin_answers()44teacher_preds = [teacher[i] for i in sample]45matches = sum(s == t for s, t in zip(student_preds, teacher_preds))46# positions within sample where the student's answer is not the gold team47wrong = [k for k in range(len(sample)) if student_preds[k] != golds[k]]48wrong_like_teacher = sum(student_preds[k] == teacher_preds[k] for k in wrong)49print(f"student answers equal to teacher answers on test_200: {matches}/{len(sample)} ({matches / len(sample):.1%})")50print(f"student errors on test_200: {len(wrong)}/{len(sample)} ({len(wrong) / len(sample):.1%})")51print(f"student errors equal to the teacher's answer: {wrong_like_teacher}/{len(wrong)}")
python student-recorded-adapter.pydev 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 就是以標準答案標籤訓練的學生配方,其資料列正是教師所標註過的那些資料列。
1"""Put the student banking77-distilled-v1 beside its control banking77-gold-1000-v1, which has the same recipe and the2same 1,000 training rows but gold labels, on the same test_200 messages. The point rests on the two counts of messages3each adapter gets right that the other gets wrong, which need no threshold; both adapters are scored live, and nothing4is trained."""56import json7import os89os.environ["HF_HUB_OFFLINE"] = "1"10os.environ["TRANSFORMERS_OFFLINE"] = "1"1112import torch # noqa: E4021314torch.set_num_threads(2)1516import router_lib # noqa: E4021718router_lib.setup_runtime()19RECORDED = router_lib.HERE / "data" / "recorded"20DEV_N = 500 # the first 500 of the dev messages, as student-recorded-adapter uses: the time budget under two CPUs21print(f"dev messages used: {DEV_N} of {len(router_lib.read_sample('dev'))}")2223test = router_lib.read_rows("test")24sample = router_lib.read_sample("test_200")25# sample holds test row positions; field 1 of a test row is its gold team, field 0 its text26golds = [test[i][1] for i in sample]27texts = [test[i][0] for i in sample]2829runs = {}30for name, folder in [("banking77-distilled-v1", "distill-student"), ("banking77-gold-1000-v1", "gold-same-rows")]:31 tokenizer, model = router_lib.load_classifier(RECORDED / folder / "adapter")32 threshold, reached = router_lib.dev_threshold(model, tokenizer, target=0.90, n=DEV_N)33 print(f"{name} dev threshold reaching 0.90 accuracy not handed off: {'yes' if reached else 'no'}")34 print(f"{name} threshold chosen on dev: {threshold:.2f}")35 preds, confs = router_lib.classify(model, tokenizer, texts)36 router_lib.print_copy_report(name, preds, confs, golds, threshold)37 runs[name] = [p == g for p, g in zip(preds, golds)]3839# dict order is insertion order: the student first, then the control40student, control = runs.values()41n = len(golds)42print(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}")43print(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}")4445# Recipe sizes from the recorded manifests: the student and its control share rows and steps;46# the human-labelled adapter does not. Its manifest names its row count train_rows, not rows, which is why rows_key differs.47for name, folder, rows_key in [48 ("banking77-distilled-v1", "distill-student", "rows"),49 ("banking77-gold-1000-v1", "gold-same-rows", "rows"),50 ("banking77-lora-v1", "lora-full", "train_rows"),51]:52 settings = json.loads((RECORDED / folder / "manifest.json").read_text())["settings"]53 print(f"{name} training rows: {settings[rows_key]}")54 print(f"{name} training steps: {settings['steps']}")
python student-vs-gold-control.pydev 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 個步驟,因此對照組與轉接器之間的差異,混雜了資料列數量、步驟數,以及兩次執行之間任何其他不同之處,本章並未將它們分開。
實用原則: 比較兩個轉接器時,只能使用相同的訊息與相同的資料列。分別計算各自答對而對方答錯的訊息數,並將兩個數字連同其分母一併列出。不要把在不同門檻下取得的準確率並排,彷彿它們是同一種衡量。
當老師模型出錯時
以每則訊息一個標籤訓練出來的學生模型,學到的就是它拿到的標籤。老師模型在某一列資料上出錯時,學生模型看到的就是該列錯誤的團隊,而且它無從得知這是錯的。上文所量測的老師模型在訓練列上與黃金標籤的一致率,就是老師模型的訓練標籤中正確者所占的比例。學生模型是以測試訊息來衡量,而不是以其訓練列來衡量,因為它在訓練過的列上的數字,反映的是它記住了什麼,而不是它學到了什麼。
在這項任務上,從替代模型(stand-in)的標籤學習的學生模型不是該上線的那一個,上文的數字已經顯示了這一點。第 7 章量化的是banking77-lora-v1,也就是由人工標註的轉接器(adapter),而不是學生模型。
請將複製度量與準確率並排來看。如果學生模型在大多數訊息上複製了老師模型,而老師模型在許多訊息上出錯,學生模型就會繼承這些錯誤,它對黃金標籤的準確率也會隨老師模型一同下降。如果學生模型在許多訊息上與老師模型不一致,卻仍然答錯,就表示它學到的是標籤以外的東西,首先該懷疑的是訓練列的數量。這是依據本書自身數據歸納出的經驗法則,本章並未加以檢驗。
蒸餾在某些情況下值得其成本。我們建議在以下情況嘗試:黃金標籤稀少、老師模型在你的任務上表現強,且抽樣的黃金標籤顯示老師模型與它們的一致程度,足以讓學生模型的錯誤可以接受。當你的訓練列已經有黃金標籤時,就直接用它們訓練,老師模型只用來檢查這些標籤。老師模型也會改變。請把老師模型的新版本視為一次新的錄製(recording):它的標籤會變,因此學生模型的清單(manifest)、門檻與各項度量都必須重做。
在生產環境中,這種失敗不會有明顯徵兆。複製老師模型的學生模型會持續回傳一連串團隊,轉接率也維持穩定,兩者都不會驚動任何人。請依固定的排程,以一批由人工標註的訊息樣本,對照黃金標籤檢查學生模型。第 9 章把針對轉接器轉接案件的同類樣本,作為下一步加以描述,本書並未建置它。請拿學生模型的答案與這些標籤比對,而不是與老師模型比對,因為與老師模型一致,並不能說明一則訊息屬於哪個團隊。
本章所做的決定如下:
- 老師模型只標註訓練列,絕不標註開發列或測試列。
- 老師模型是替代模型 Qwen3-4B-Instruct-2507,採用 Apache-2.0 授權,不使用任何託管模型。
- 學生模型以與人工標註轉接器相同的配方訓練,其門檻遵循相同的規則,若採用了備援做法,會如實標示為備援。
- 學生模型與一個以相同列的黃金標籤訓練的對照組,在相同的訊息上進行比較,兩者共用同一批列,因此兩者之間的差異來自標籤,而不是來自資料列。
老師模型的標籤會把它的錯誤帶進學生模型,因此與黃金標籤的一致程度,決定了蒸餾是否值得。
**實用原則:**只有在任務的黃金標籤太少,且黃金標籤樣本顯示老師模型與它們有足夠的一致程度時,才以老師模型的標籤訓練學生模型。在選用之前,先在相同的訊息上,把學生模型與人工標註的轉接器、以及以黃金標籤採用相同配方訓練的模型相比較。當學生模型落敗時,就上線轉接器,並在書面報告中如實說明。
本章,於本版次中
版次 2026.11.9範例於 2026年11 月 20 通過測試本章 3 個範例 個範例中有 3 個通過
譯自英文書,版次 2026.11.9。