{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/190910351","title":"TinyBERT: Distilling BERT for Natural Language Understanding","arxiv_id":"1909.10351","date":"2019-09-23","proceeding":"Findings of the Association for Computational Linguistics 2020","authors":["Xiaoqi Jiao","Yichun Yin","Lifeng Shang","Xin Jiang","Xiao Chen","Linlin Li","Fang Wang","Qun Liu"],"abstract":"Language model pre-training, such as BERT, has significantly improved the performances of many natural language processing tasks. However, pre-trained language models are usually computationally expensive, so it is difficult to efficiently execute them on resource-restricted devices. To accelerate inference and reduce model size while maintaining accuracy, we first propose a novel Transformer distillation method that is specially designed for knowledge distillation (KD) of the Transformer-based models. By leveraging this new KD method, the plenty of knowledge encoded in a large teacher BERT can be effectively transferred to a small student Tiny-BERT. Then, we introduce a new two-stage learning framework for TinyBERT, which performs Transformer distillation at both the pretraining and task-specific learning stages. This framework ensures that TinyBERT can capture he general-domain as well as the task-specific knowledge in BERT. TinyBERT with 4 layers is empirically effective and achieves more than 96.8% the performance of its teacher BERTBASE on GLUE benchmark, while being 7.5x smaller and 9.4x faster on inference. TinyBERT with 4 layers is also significantly better than 4-layer state-of-the-art baselines on BERT distillation, with only about 28% parameters and about 31% inference time of them. Moreover, TinyBERT with 6 layers performs on-par with its teacher BERTBASE.","url_abs":"https://arxiv.org/abs/1909.10351v5","url_pdf":"https://arxiv.org/pdf/1909.10351v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"190910351","repo_url":"https://github.com/huawei-noah/Pretrained-Language-Model/tree/master/TinyBERT","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":null},{"paper_slug":"190910351","repo_url":"https://github.com/graison-thomas/TinyFinBERT","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"190910351","repo_url":"https://github.com/mkavim/finetune_bert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":null},{"paper_slug":"190910351","repo_url":"https://github.com/2023-MindSpore-1/ms-code-166","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":{"status":"ok"}},{"paper_slug":"190910351","repo_url":"https://github.com/MindCode-4/code-5/tree/main/tinybert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"190910351","repo_url":"https://github.com/PaddlePaddle/PaddleNLP/tree/develop/paddlenlp/transformers/tinybert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"paddle","reach":null},{"paper_slug":"190910351","repo_url":"https://github.com/mindspore-ai/models/tree/master/official/nlp/tinybert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"190910351","repo_url":"https://github.com/pwc-1/Paper-10/tree/main/tinybert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"190910351","repo_url":"https://github.com/pwc-1/Paper-9/tree/main/1/tinybert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"190910351","repo_url":"https://github.com/xiaolilaoli/tiny_bert_ms","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":{"status":"ok"}}],"tasks":[{"task_slug":"knowledge-distillation","task_name":"Knowledge Distillation"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"linguistic-acceptability","task_name":"Linguistic Acceptability"},{"task_slug":"natural-language-inference","task_name":"Natural Language Inference"},{"task_slug":"natural-language-understanding","task_name":"Natural Language Understanding"},{"task_slug":"paraphrase-identification","task_name":"Paraphrase Identification"},{"task_slug":"question-answering","task_name":"Question Answering"},{"task_slug":"semantic-textual-similarity","task_name":"Semantic Textual Similarity"},{"task_slug":"sentiment-analysis","task_name":"Sentiment Analysis"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bert","method_name":"BERT"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"knowledge-distillation","method_name":"Knowledge Distillation"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-linear-decay","method_name":"Linear Warmup With Linear Decay"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/linguistic-acceptability-on-cola","task":"Linguistic Acceptability","dataset":"CoLA","model":"TinyBERT-4 14.5M","rank_in_archive_order":40,"of":43,"metrics":{"Accuracy":"43.3%"},"uses_additional_data":false},{"leaderboard":"/sota/linguistic-acceptability-on-cola-dev","task":"Linguistic Acceptability","dataset":"CoLA Dev","model":"TinyBERT-6 67M","rank_in_archive_order":4,"of":6,"metrics":{"Accuracy":"54"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-multinli","task":"Natural Language Inference","dataset":"MultiNLI","model":"TinyBERT-6 67M","rank_in_archive_order":31,"of":67,"metrics":{"Matched":"84.6","Mismatched":"83.2"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-multinli","task":"Natural Language Inference","dataset":"MultiNLI","model":"TinyBERT-4 14.5M","rank_in_archive_order":37,"of":67,"metrics":{"Matched":"82.5","Mismatched":"81.8"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-multinli-dev","task":"Natural Language Inference","dataset":"MultiNLI Dev","model":"TinyBERT-6 67M","rank_in_archive_order":1,"of":10,"metrics":{"Matched":"84.5","Mismatched":"84.5"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-qnli","task":"Natural Language Inference","dataset":"QNLI","model":"TinyBERT-6 67M","rank_in_archive_order":34,"of":43,"metrics":{"Accuracy":"90.4%"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-qnli","task":"Natural Language Inference","dataset":"QNLI","model":"TinyBERT-4 14.5M","rank_in_archive_order":39,"of":43,"metrics":{"Accuracy":"87.7%"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-rte","task":"Natural Language Inference","dataset":"RTE","model":"TinyBERT-6 67M","rank_in_archive_order":64,"of":90,"metrics":{"Accuracy":"66%"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-rte","task":"Natural Language Inference","dataset":"RTE","model":"TinyBERT-4 14.5M","rank_in_archive_order":69,"of":90,"metrics":{"Accuracy":"62.9%"},"uses_additional_data":false},{"leaderboard":"/sota/paraphrase-identification-on-quora-question","task":"Paraphrase Identification","dataset":"Quora Question Pairs","model":"TinyBERT","rank_in_archive_order":14,"of":31,"metrics":{"F1":"71.3"},"uses_additional_data":false},{"leaderboard":"/sota/question-answering-on-squad11-dev","task":"Question Answering","dataset":"SQuAD1.1 dev","model":"TinyBERT-6 67M","rank_in_archive_order":15,"of":55,"metrics":{"EM":"79.7","F1":"87.5"},"uses_additional_data":false},{"leaderboard":"/sota/question-answering-on-squad20-dev","task":"Question Answering","dataset":"SQuAD2.0 dev","model":"TinyBERT-6 67M","rank_in_archive_order":13,"of":13,"metrics":{"EM":"69.9","F1":"73.4"},"uses_additional_data":false},{"leaderboard":"/sota/semantic-textual-similarity-on-mrpc","task":"Semantic Textual Similarity","dataset":"MRPC","model":"TinyBERT-6 67M","rank_in_archive_order":29,"of":45,"metrics":{"Accuracy":"87.3%"},"uses_additional_data":false},{"leaderboard":"/sota/semantic-textual-similarity-on-mrpc","task":"Semantic Textual Similarity","dataset":"MRPC","model":"TinyBERT-4 14.5M","rank_in_archive_order":33,"of":45,"metrics":{"Accuracy":"86.4%"},"uses_additional_data":false},{"leaderboard":"/sota/semantic-textual-similarity-on-mrpc-dev","task":"Semantic Textual Similarity","dataset":"MRPC Dev","model":"TinyBERT-6 67M","rank_in_archive_order":2,"of":2,"metrics":{"Accuracy":"86.3"},"uses_additional_data":false},{"leaderboard":"/sota/semantic-textual-similarity-on-sts-benchmark","task":"Semantic Textual Similarity","dataset":"STS Benchmark","model":"TinyBERT-4 14.5M","rank_in_archive_order":28,"of":66,"metrics":{"Pearson Correlation":"0.799"},"uses_additional_data":false},{"leaderboard":"/sota/sentiment-analysis-on-sst-2-binary","task":"Sentiment Analysis","dataset":"SST-2 Binary classification","model":"TinyBERT-6 67M","rank_in_archive_order":43,"of":87,"metrics":{"Accuracy":"93.1"},"uses_additional_data":false},{"leaderboard":"/sota/sentiment-analysis-on-sst-2-binary","task":"Sentiment Analysis","dataset":"SST-2 Binary classification","model":"TinyBERT-4 14.5M","rank_in_archive_order":46,"of":87,"metrics":{"Accuracy":"92.6"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1909.10351","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1909.10351"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/PaddlePaddle/PaddleNLP/tree/develop/paddlenlp/transformers/tinybert","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/xiaolilaoli/tiny_bert_ms","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/huawei-noah/Pretrained-Language-Model/tree/master/TinyBERT","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/2023-MindSpore-1/ms-code-166","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/graison-thomas/TinyFinBERT","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/pwc-1/Paper-9/tree/main/1/tinybert","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mindspore-ai/models/tree/master/official/nlp/tinybert","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/pwc-1/Paper-10/tree/main/tinybert","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mkavim/finetune_bert","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindCode-4/code-5/tree/main/tinybert","reach":null}],"summary":{"unverified":4},"by_repo_kind":{"official":{"samples":4,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":4,"samples":[{"code_sha256_prefix":"031455b1879a2b6c","entry":"BertLMPredictionHead","repo":"huawei-noah/Pretrained-Language-Model","repo_kind":"official","path":"TinyBERT/transformer/modeling.py","file_url":"https://github.com/huawei-noah/Pretrained-Language-Model/blob/HEAD/TinyBERT/transformer/modeling.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"031455b1879a2b6c"}},{"code_sha256_prefix":"f41c936d29d457a8","entry":"BertPreTrainingHeads","repo":"huawei-noah/Pretrained-Language-Model","repo_kind":"official","path":"TinyBERT/transformer/modeling.py","file_url":"https://github.com/huawei-noah/Pretrained-Language-Model/blob/HEAD/TinyBERT/transformer/modeling.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f41c936d29d457a8"}},{"code_sha256_prefix":"0d693a0079ce791d","entry":"BertPredictionHeadTransform","repo":"huawei-noah/Pretrained-Language-Model","repo_kind":"official","path":"TinyBERT/transformer/modeling.py","file_url":"https://github.com/huawei-noah/Pretrained-Language-Model/blob/HEAD/TinyBERT/transformer/modeling.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0d693a0079ce791d"}},{"code_sha256_prefix":"aeb5fa56defa897a","entry":"TinyBertForPreTraining","repo":"huawei-noah/Pretrained-Language-Model","repo_kind":"official","path":"TinyBERT/transformer/modeling.py","file_url":"https://github.com/huawei-noah/Pretrained-Language-Model/blob/HEAD/TinyBERT/transformer/modeling.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aeb5fa56defa897a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}