{"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/fastbert-a-self-distilling-bert-with-adaptive","title":"FastBERT: a Self-distilling BERT with Adaptive Inference Time","arxiv_id":"2004.02178","date":"2020-04-05","proceeding":"ACL 2020 6","authors":["Weijie Liu","Peng Zhou","Zhe Zhao","Zhiruo Wang","Haotang Deng","Qi Ju"],"abstract":"Pre-trained language models like BERT have proven to be highly performant. However, they are often computationally expensive in many practical scenarios, for such heavy models can hardly be readily implemented with limited resources. To improve their efficiency with an assured model performance, we propose a novel speed-tunable FastBERT with adaptive inference time. The speed at inference can be flexibly adjusted under varying demands, while redundant calculation of samples is avoided. Moreover, this model adopts a unique self-distillation mechanism at fine-tuning, further enabling a greater computational efficacy with minimal loss in performance. Our model achieves promising results in twelve English and Chinese datasets. It is able to speed up by a wide range from 1 to 12 times than BERT if given different speedup thresholds to make a speed-performance tradeoff.","url_abs":"https://arxiv.org/abs/2004.02178v2","url_pdf":"https://arxiv.org/pdf/2004.02178v2.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":"fastbert-a-self-distilling-bert-with-adaptive","repo_url":"https://github.com/autoliuweijie/FastBERT","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fastbert-a-self-distilling-bert-with-adaptive","repo_url":"https://github.com/JulesBelveze/bert-squeeze","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fastbert-a-self-distilling-bert-with-adaptive","repo_url":"https://github.com/laomagic/TextClassifier","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[],"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":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"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":"residual-connection","method_name":"Residual Connection"},{"method_slug":"speed","method_name":"SPEED"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2004.02178","atlas_url":"https://app.syntology.ai/?focus=2004.02178","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2004.02178"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/laomagic/TextClassifier","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/JulesBelveze/bert-squeeze","reach":null},{"provenance":"deterministic:regex_extraction","url":"https://github.com/autoliuweijie/FastBERT","reach":null}],"summary":{"ran":6,"unverified":5},"by_repo_kind":{"listed":{"samples":11,"ran":6,"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":2,"samples":[{"code_sha256_prefix":"9a7c10339aec9893","entry":"BERTIntermediate","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9a7c10339aec9893"}},{"code_sha256_prefix":"45cdedc61201a665","entry":"BERTLayerNorm","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"45cdedc61201a665"}},{"code_sha256_prefix":"69668f3fd7371bee","entry":"BERTOutput","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"69668f3fd7371bee"}},{"code_sha256_prefix":"480aafb3e337a10f","entry":"BERTSelfAttention","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"480aafb3e337a10f"}},{"code_sha256_prefix":"1d87365e5190f08d","entry":"BERTSelfOutput","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1d87365e5190f08d"}},{"code_sha256_prefix":"374ad282c87f7fc5","entry":"FastBERTClassifier","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"374ad282c87f7fc5"}},{"code_sha256_prefix":"84e605e06efcf6a4","entry":"BERTAttention","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"84e605e06efcf6a4"}},{"code_sha256_prefix":"20e6e0e142a0228c","entry":"BERTLayer","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"20e6e0e142a0228c"}},{"code_sha256_prefix":"6897bd6bedfa1234","entry":"FastBERTGraph","repo":"laomagic/TextClassifier","repo_kind":"listed","path":"src/distill_bert/model_define/model_fastbert.py","file_url":"https://github.com/laomagic/TextClassifier/blob/HEAD/src/distill_bert/model_define/model_fastbert.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6897bd6bedfa1234"}},{"code_sha256_prefix":"0974648a65430293","entry":"FastBertClassifier","repo":"JulesBelveze/bert-squeeze","repo_kind":"listed","path":"bert_squeeze/models/custom_transformers/fastbert.py","file_url":"https://github.com/JulesBelveze/bert-squeeze/blob/HEAD/bert_squeeze/models/custom_transformers/fastbert.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":"0974648a65430293"}},{"code_sha256_prefix":"a37041bf3fed963e","entry":"FastBertGraph","repo":"JulesBelveze/bert-squeeze","repo_kind":"listed","path":"bert_squeeze/models/custom_transformers/fastbert.py","file_url":"https://github.com/JulesBelveze/bert-squeeze/blob/HEAD/bert_squeeze/models/custom_transformers/fastbert.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":"a37041bf3fed963e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}