Papers › Patient Knowledge Distillation for BERT Model Compression

Patient Knowledge Distillation for BERT Model Compression

25 Aug 2019IJCNLP 2019 11arXiv:1908.09355archive 2025-07-28

Siqi Sun, Yu Cheng, Zhe Gan, Jingjing Liu

Pre-trained language models such as BERT have proven to be highly effective for natural language processing (NLP) tasks. However, the high demand for computing resources in training such models hinders their application in practice. In order to alleviate this resource hunger in large-scale model training, we propose a Patient Knowledge Distillation approach to compress an original large model (teacher) into an equally-effective lightweight shallow network (student). Different from previous knowledge distillation methods, which only use the output from the last layer of the teacher network for distillation, our student model patiently learns from multiple intermediate layers of the teacher model for incremental knowledge extraction, following two strategies: (i) PKD-Last: learning from the last k layers; and (ii) PKD-Skip: learning from every k layers. These two patient distillation schemes enable the exploitation of rich information in the teacher's hidden layers, and encourage the student model to patiently learn from and imitate the teacher through a multi-layer distillation process. Empirically, this translates into improved results on multiple NLP tasks with significant gain in training efficiency, without sacrificing model accuracy.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology View this paper on Syntology: its repositories, every harvested function with whether it ran, its licence and the call to fetch it.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="1908.09355")

Code

Syntology Ran 17 of 27 code samples harvested from 2 repositories linked to this paper; 10 have no recorded run. Of those that ran: 2 ran · honoured contract; 1 ran · violated contract; 5 ran · our draft was wrong; 1 ran · fixture could not drive it; 8 ran with no contract checked.

By repository: community (archive-listed): 27 samples from 2 repositories, 17 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

intersun/PKD-for-BERT-Model-Compression officialmentioned in papermentioned on GitHubpytorch report
Daniel-H-99/Patient-Knowledge-Distillation mentioned on GitHubpytorchMIT report
eunanomist/PKD_BERT mentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

27 samples harvested; 17 ran; 2 honoured the contract we drafted; 10 have no recorded run. Read from Syntology's graph 2026-09-25; that is when this build read the record, not when the samples ran.

2ran · honoured contract
1ran · violated contract
5ran · our draft was wrong
1ran · fixture could not drive it
8ran
10unverified

Licence: 27 of the 27 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

swish Daniel-H-99/Patient-Knowledge-Distillation/BERT/pytorch_pretrained_bert/modeling.py community (archive-listed) ran · our draft was wrong fingerprinted MIT recorded; this copy not marked cleared · pointer only · 0f786c407fb1ee4c · report
acc_and_f1 Daniel-H-99/Patient-Knowledge-Distillation/src/nli_data_processing.py community (archive-listed) ran · fixture could not drive it MIT recorded; this copy not marked cleared · pointer only · cac113ca87b9d9f3 · report
boolean_string Daniel-H-99/Patient-Knowledge-Distillation/src/argument_parser.py community (archive-listed) ran · violated contract MIT recorded; this copy not marked cleared · pointer only · b1f9cebf0d177140 · report
build_tf_to_pytorch_map eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/modeling_transfo_xl.py community (archive-listed) ran · our draft was wrong MIT recorded; this copy not marked cleared · pointer only · 35ef111fc00c21b4 · report
convert_examples_to_features Daniel-H-99/Patient-Knowledge-Distillation/src/nli_data_processing.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · 379ade5858acdbfa · report
convert_examples_to_features Daniel-H-99/Patient-Knowledge-Distillation/src/race_data_processing.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · b30ee2907e5cd3a6 · report
count_parameters Daniel-H-99/Patient-Knowledge-Distillation/src/utils.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · 3ea89c558af6c4b4 · report
distillation_loss Daniel-H-99/Patient-Knowledge-Distillation/src/KD_loss.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · 5ff7ab3a0c0d6da0 · report
gelu Daniel-H-99/Patient-Knowledge-Distillation/BERT/pytorch_pretrained_bert/modeling_gpt2.py community (archive-listed) ran · our draft was wrong fingerprinted MIT recorded; this copy not marked cleared · pointer only · 8d23fbe2b99b840b · report
gelu Daniel-H-99/Patient-Knowledge-Distillation/BERT/pytorch_pretrained_bert/modeling.py community (archive-listed) ran · honoured contract fingerprinted MIT recorded; this copy not marked cleared · pointer only · fdc64f4c72036ae4 · report
is_folder_empty Daniel-H-99/Patient-Knowledge-Distillation/src/argument_parser.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · 615f129ea793785e · report
load_model Daniel-H-99/Patient-Knowledge-Distillation/src/utils.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · 9e42bf8972501658 · report
patience_loss Daniel-H-99/Patient-Knowledge-Distillation/src/KD_loss.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · 16afb11eb02e8e88 · report
read_mrc_examples Daniel-H-99/Patient-Knowledge-Distillation/src/race_data_processing.py community (archive-listed) ran MIT recorded; this copy not marked cleared · pointer only · 28d61d48898d30c4 · report
sample_logits eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/modeling_transfo_xl_utilities.py community (archive-listed) ran · our draft was wrong MIT recorded; this copy not marked cleared · pointer only · 93228a3eb5c4d179 · report
url_to_filename eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/file_utils.py community (archive-listed) ran · our draft was wrong fingerprinted MIT recorded; this copy not marked cleared · pointer only · 5eff22fa0a651276 · report
warmup_linear eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/optimization.py community (archive-listed) ran · honoured contract fingerprinted MIT recorded; this copy not marked cleared · pointer only · e0960afdb0d64aa7 · report
cached_path eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/file_utils.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · df9f10631fa5d322 · report
filename_to_url eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/file_utils.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · 6db16fe8f67e56b6 · report
fill_tensor Daniel-H-99/Patient-Knowledge-Distillation/src/utils.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · 01803af97cd5feef · report
load_tf_weights_in_bert Daniel-H-99/Patient-Knowledge-Distillation/BERT/pytorch_pretrained_bert/modeling.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · b1a7180868dd8d6a · report
load_tf_weights_in_gpt2 Daniel-H-99/Patient-Knowledge-Distillation/BERT/pytorch_pretrained_bert/modeling_gpt2.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · a62604f618a8cc82 · report
load_tf_weights_in_openai_gpt eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/modeling_openai.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · 46f305675277e757 · report
load_tf_weights_in_transfo_xl eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/modeling_transfo_xl.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · 1ebc2bf2c3cddc4d · report
simple_accuracy Daniel-H-99/Patient-Knowledge-Distillation/src/nli_data_processing.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · 3c241ecfe3749a6d · report
warmup_constant eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/optimization.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · 59e4e730a9dc5dc6 · report
warmup_cosine eunanomist/PKD_BERT/BERT/pytorch_pretrained_bert/optimization.py community (archive-listed) unverified MIT recorded; this copy not marked cleared · pointer only · 007a8d2955fb555d · report

Tasks

Knowledge DistillationModel Compressionmodel

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdamAttentionAttention DropoutBERTDense ConnectionsDropoutKnowledge DistillationLayer NormalizationLinear LayerLinear Warmup With Linear DecayMulti-Head AttentionResidual ConnectionSoftmaxWeight DecayWordPiece

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections