{"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/distilling-task-specific-knowledge-from-bert","title":"Distilling Task-Specific Knowledge from BERT into Simple Neural Networks","arxiv_id":"1903.12136","date":"2019-03-28","proceeding":null,"authors":["Raphael Tang","Yao Lu","Linqing Liu","Lili Mou","Olga Vechtomova","Jimmy Lin"],"abstract":"In the natural language processing literature, neural networks are becoming\nincreasingly deeper and complex. The recent poster child of this trend is the\ndeep language representation model, which includes BERT, ELMo, and GPT. These\ndevelopments have led to the conviction that previous-generation, shallower\nneural networks for language understanding are obsolete. In this paper,\nhowever, we demonstrate that rudimentary, lightweight neural networks can still\nbe made competitive without architecture changes, external training data, or\nadditional input features. We propose to distill knowledge from BERT, a\nstate-of-the-art language representation model, into a single-layer BiLSTM, as\nwell as its siamese counterpart for sentence-pair tasks. Across multiple\ndatasets in paraphrasing, natural language inference, and sentiment\nclassification, we achieve comparable results with ELMo, while using roughly\n100 times fewer parameters and 15 times less inference time.","url_abs":"http://arxiv.org/abs/1903.12136v1","url_pdf":"http://arxiv.org/pdf/1903.12136v1.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":"distilling-task-specific-knowledge-from-bert","repo_url":"https://github.com/AI-Mart/distill_lstm","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"paddle","reach":{"status":"ok"}},{"paper_slug":"distilling-task-specific-knowledge-from-bert","repo_url":"https://github.com/aqweteddy/BERTDistilForClassification","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"distilling-task-specific-knowledge-from-bert","repo_url":"https://github.com/castorini/d-bert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"distilling-task-specific-knowledge-from-bert","repo_url":"https://github.com/pvgladkov/knowledge-distillation","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"natural-language-inference","task_name":"Natural Language Inference"},{"task_slug":"sentence","task_name":"Sentence"},{"task_slug":"sentiment-analysis","task_name":"Sentiment Analysis"},{"task_slug":"sentiment-classification","task_name":"Sentiment Classification"}],"methods":[{"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":"bilstm","method_name":"BiLSTM"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"discriminative-fine-tuning","method_name":"Discriminative Fine-Tuning"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"elmo","method_name":"ELMo"},{"method_slug":"gpt","method_name":"GPT"},{"method_slug":"lstm","method_name":"LSTM"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"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":"residual-connection","method_name":"Residual Connection"},{"method_slug":"sigmoid-activation","method_name":"Sigmoid Activation"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"tanh-activation","method_name":"Tanh Activation"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/sentiment-analysis-on-sst-2-binary","task":"Sentiment Analysis","dataset":"SST-2 Binary classification","model":"Single layer bilstm distilled from BERT","rank_in_archive_order":60,"of":87,"metrics":{"Accuracy":"90.7"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1903.12136","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1903.12136"}},"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/pvgladkov/knowledge-distillation","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/AI-Mart/distill_lstm","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/aqweteddy/BERTDistilForClassification","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/castorini/d-bert","reach":null}],"summary":{"ran_draft_wrong":5,"ran_honours":3,"ran_fixture":1},"by_repo_kind":{"listed":{"samples":9,"ran":9,"repositories":2}},"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":0,"samples":[{"code_sha256_prefix":"3ea37bfa7bd6625b","entry":"batch_to_inputs","repo":"pvgladkov/knowledge-distillation","repo_kind":"listed","path":"knowledge_distillation/bert_trainer.py","file_url":"https://github.com/pvgladkov/knowledge-distillation/blob/HEAD/knowledge_distillation/bert_trainer.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3ea37bfa7bd6625b"}},{"code_sha256_prefix":"31cb7e5ee37e07ad","entry":"convert_dp_to_single","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/finetune/classifier.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/finetune/classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"31cb7e5ee37e07ad"}},{"code_sha256_prefix":"76d68a1ed9ae4351","entry":"convert_single_to_dp","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/finetune/classifier.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/finetune/classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"76d68a1ed9ae4351"}},{"code_sha256_prefix":"502edb147c17e8f6","entry":"evaluate","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/distill/run/distill_birnn.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/distill/run/distill_birnn.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"502edb147c17e8f6"}},{"code_sha256_prefix":"e4a51df9636b003c","entry":"evaluate_score","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/distill/run/distill_birnn.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/distill/run/distill_birnn.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e4a51df9636b003c"}},{"code_sha256_prefix":"59e0610210960189","entry":"init_sos","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/generate/finetune_transfoxl.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/generate/finetune_transfoxl.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"59e0610210960189"}},{"code_sha256_prefix":"fb341ab6d38412a8","entry":"mse_forward_monkey_patch","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/finetune/classifier.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/finetune/classifier.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fb341ab6d38412a8"}},{"code_sha256_prefix":"36da55e25256092f","entry":"sample_query","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/generate/finetune_transfoxl.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/generate/finetune_transfoxl.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"36da55e25256092f"}},{"code_sha256_prefix":"4837663eda94ee99","entry":"transfo_encode","repo":"castorini/d-bert","repo_kind":"listed","path":"dbert/generate/finetune_transfoxl.py","file_url":"https://github.com/castorini/d-bert/blob/HEAD/dbert/generate/finetune_transfoxl.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4837663eda94ee99"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}