{"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/q8bert-quantized-8bit-bert","title":"Q8BERT: Quantized 8Bit BERT","arxiv_id":"1910.06188","date":"2019-10-14","proceeding":null,"authors":["Ofir Zafrir","Guy Boudoukh","Peter Izsak","Moshe Wasserblat"],"abstract":"Recently, pre-trained Transformer based language models such as BERT and GPT, have shown great improvement in many Natural Language Processing (NLP) tasks. However, these models contain a large amount of parameters. The emergence of even larger and more accurate models such as GPT2 and Megatron, suggest a trend of large pre-trained Transformer models. However, using these large models in production environments is a complex task requiring a large amount of compute, memory and power resources. In this work we show how to perform quantization-aware training during the fine-tuning phase of BERT in order to compress BERT by $4\\times$ with minimal accuracy loss. Furthermore, the produced quantized model can accelerate inference speed if it is optimized for 8bit Integer supporting hardware.","url_abs":"https://arxiv.org/abs/1910.06188v2","url_pdf":"https://arxiv.org/pdf/1910.06188v2.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":"q8bert-quantized-8bit-bert","repo_url":"https://github.com/intellabs/model-compression-research-package","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"gone","observed_at":"2026-09-17","how":"tree_404+repo_404"}},{"paper_slug":"q8bert-quantized-8bit-bert","repo_url":"https://github.com/NervanaSystems/nlp-architect/blob/master/nlp_architect/models/transformers/quantized_bert.py","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"tf","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"q8bert-quantized-8bit-bert","repo_url":"https://github.com/huggingface/block_movement_pruning","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"q8bert-quantized-8bit-bert","repo_url":"https://github.com/iabd/QuantizedNMT","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"q8bert-quantized-8bit-bert","repo_url":"https://github.com/mindspore-ai/models/tree/master/official/nlp/q8bert","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null}],"tasks":[{"task_slug":"linguistic-acceptability","task_name":"Linguistic Acceptability"},{"task_slug":"natural-language-inference","task_name":"Natural Language Inference"},{"task_slug":"quantization","task_name":"Quantization"},{"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":"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":"gpt","method_name":"GPT"},{"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-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":"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":"speed","method_name":"SPEED"},{"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":"Q8BERT (Zafrir et al., 2019)","rank_in_archive_order":24,"of":43,"metrics":{"Accuracy":"65.0"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-multinli","task":"Natural Language Inference","dataset":"MultiNLI","model":"Q8BERT (Zafrir et al., 2019)","rank_in_archive_order":29,"of":67,"metrics":{"Matched":"85.6"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-qnli","task":"Natural Language Inference","dataset":"QNLI","model":"Q8BERT (Zafrir et al., 2019)","rank_in_archive_order":23,"of":43,"metrics":{"Accuracy":"93.0"},"uses_additional_data":false},{"leaderboard":"/sota/natural-language-inference-on-rte","task":"Natural Language Inference","dataset":"RTE","model":"Q8BERT (Zafrir et al., 2019)","rank_in_archive_order":27,"of":90,"metrics":{"Accuracy":"84.8"},"uses_additional_data":false},{"leaderboard":"/sota/semantic-textual-similarity-on-mrpc","task":"Semantic Textual Similarity","dataset":"MRPC","model":"Q8BERT (Zafrir et al., 2019)","rank_in_archive_order":17,"of":45,"metrics":{"Accuracy":"89.7"},"uses_additional_data":false},{"leaderboard":"/sota/semantic-textual-similarity-on-sts-benchmark","task":"Semantic Textual Similarity","dataset":"STS Benchmark","model":"Q8BERT (Zafrir et al., 2019)","rank_in_archive_order":14,"of":66,"metrics":{"Pearson Correlation":"0.911"},"uses_additional_data":false},{"leaderboard":"/sota/sentiment-analysis-on-sst-2-binary","task":"Sentiment Analysis","dataset":"SST-2 Binary classification","model":"Q8BERT (Zafrir et al., 2019)","rank_in_archive_order":32,"of":87,"metrics":{"Accuracy":"94.7"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1910.06188","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1910.06188"}},"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/iabd/QuantizedNMT","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mindspore-ai/models/tree/master/official/nlp/q8bert","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/intellabs/model-compression-research-package","reach":{"status":"gone","observed_at":"2026-09-17","how":"tree_404+repo_404"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/huggingface/block_movement_pruning","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/NervanaSystems/nlp-architect/blob/master/nlp_architect/models/transformers/quantized_bert.py","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_draft_wrong":1,"ran_honours":2,"unverified":8},"by_repo_kind":{"official":{"samples":5,"ran":0,"repositories":1},"listed":{"samples":5,"ran":2,"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":3,"samples":[{"code_sha256_prefix":"9df40357afea56cc","entry":"to_list","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":2,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"9df40357afea56cc"}},{"code_sha256_prefix":"1e24f40610cc5f59","entry":"regularization","repo":"huggingface/block_movement_pruning","repo_kind":"listed","path":"block_movement_pruning/masked_run_squad.py","file_url":"https://github.com/huggingface/block_movement_pruning/blob/HEAD/block_movement_pruning/masked_run_squad.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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1e24f40610cc5f59"}},{"code_sha256_prefix":"484979ea1bdecce9","entry":"schedule_threshold","repo":"huggingface/block_movement_pruning","repo_kind":"listed","path":"block_movement_pruning/masked_run_squad.py","file_url":"https://github.com/huggingface/block_movement_pruning/blob/HEAD/block_movement_pruning/masked_run_squad.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"484979ea1bdecce9"}},{"code_sha256_prefix":"e0a328541873813a","entry":"batchSizeFn","repo":"iabd/QuantizedNMT","repo_kind":"listed","path":"Trace.py","file_url":"https://github.com/iabd/QuantizedNMT/blob/HEAD/Trace.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e0a328541873813a"}},{"code_sha256_prefix":"6a2e2df3980634be","entry":"f1","repo":"NervanaSystems/nlp-architect","repo_kind":"official","path":"nlp_architect/models/np_semantic_segmentation.py","file_url":"https://github.com/NervanaSystems/nlp-architect/blob/HEAD/nlp_architect/models/np_semantic_segmentation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6a2e2df3980634be"}},{"code_sha256_prefix":"17b3dba51524b6d1","entry":"find_correct_index","repo":"NervanaSystems/nlp-architect","repo_kind":"official","path":"nlp_architect/common/core_nlp_doc.py","file_url":"https://github.com/NervanaSystems/nlp-architect/blob/HEAD/nlp_architect/common/core_nlp_doc.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"17b3dba51524b6d1"}},{"code_sha256_prefix":"b08eb2ca2806310a","entry":"get_std_opt","repo":"iabd/QuantizedNMT","repo_kind":"listed","path":"src/noamOpt.py","file_url":"https://github.com/iabd/QuantizedNMT/blob/HEAD/src/noamOpt.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b08eb2ca2806310a"}},{"code_sha256_prefix":"e9f89451c8a8ee18","entry":"merge_punctuation","repo":"NervanaSystems/nlp-architect","repo_kind":"official","path":"nlp_architect/common/core_nlp_doc.py","file_url":"https://github.com/NervanaSystems/nlp-architect/blob/HEAD/nlp_architect/common/core_nlp_doc.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e9f89451c8a8ee18"}},{"code_sha256_prefix":"8891829bac9ad9a6","entry":"precision_score","repo":"NervanaSystems/nlp-architect","repo_kind":"official","path":"nlp_architect/models/np_semantic_segmentation.py","file_url":"https://github.com/NervanaSystems/nlp-architect/blob/HEAD/nlp_architect/models/np_semantic_segmentation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8891829bac9ad9a6"}},{"code_sha256_prefix":"63b63c3ae6452ee1","entry":"recall_score","repo":"NervanaSystems/nlp-architect","repo_kind":"official","path":"nlp_architect/models/np_semantic_segmentation.py","file_url":"https://github.com/NervanaSystems/nlp-architect/blob/HEAD/nlp_architect/models/np_semantic_segmentation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"63b63c3ae6452ee1"}},{"code_sha256_prefix":"2f6f127ef7168a65","entry":"selfAttention","repo":"iabd/QuantizedNMT","repo_kind":"listed","path":"src/attention.py","file_url":"https://github.com/iabd/QuantizedNMT/blob/HEAD/src/attention.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2f6f127ef7168a65"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}