{"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/fast-inference-from-transformers-via","title":"Fast Inference from Transformers via Speculative Decoding","arxiv_id":"2211.17192","date":"2022-11-30","proceeding":null,"authors":["Yaniv Leviathan","Matan Kalman","Yossi Matias"],"abstract":"Inference from large autoregressive models like Transformers is slow - decoding K tokens takes K serial runs of the model. In this work we introduce speculative decoding - an algorithm to sample from autoregressive models faster without any changes to the outputs, by computing several tokens in parallel. At the heart of our approach lie the observations that (1) hard language-modeling tasks often include easier subtasks that can be approximated well by more efficient models, and (2) using speculative execution and a novel sampling method, we can make exact decoding from the large models faster, by running them in parallel on the outputs of the approximation models, potentially generating several tokens concurrently, and without changing the distribution. Our method can accelerate existing off-the-shelf models without retraining or architecture changes. We demonstrate it on T5-XXL and show a 2X-3X acceleration compared to the standard T5X implementation, with identical outputs.","url_abs":"https://arxiv.org/abs/2211.17192v2","url_pdf":"https://arxiv.org/pdf/2211.17192v2.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":"fast-inference-from-transformers-via","repo_url":"https://github.com/ericlbuehler/mistral.rs","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"fast-inference-from-transformers-via","repo_url":"https://github.com/feifeibear/llmspeculativesampling","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fast-inference-from-transformers-via","repo_url":"https://github.com/huggingface/distil-whisper","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fast-inference-from-transformers-via","repo_url":"https://github.com/lucidrains/speculative-decoding","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fast-inference-from-transformers-via","repo_url":"https://github.com/niyunsheng/ems-sd","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"fast-inference-from-transformers-via","repo_url":"https://github.com/optimalscale/lmflow","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"fast-inference-from-transformers-via","repo_url":"https://github.com/smart-lty/parallelspeculativedecoding","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2211.17192","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2211.17192"}},"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/feifeibear/llmspeculativesampling","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ericlbuehler/mistral.rs","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/huggingface/distil-whisper","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/smart-lty/parallelspeculativedecoding","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lucidrains/speculative-decoding","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/niyunsheng/ems-sd","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/optimalscale/lmflow","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":3,"ran_draft_wrong":7,"ran_fixture":2,"unverified":9},"by_repo_kind":{"listed":{"samples":21,"ran":12,"repositories":4}},"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":6,"samples":[{"code_sha256_prefix":"b8211819644d71f6","entry":"KVCacheModel","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b8211819644d71f6"}},{"code_sha256_prefix":"ef39dd586a82a156","entry":"find_first_true_index","repo":"lucidrains/speculative-decoding","repo_kind":"listed","path":"speculative_decoding/speculative_decoding.py","file_url":"https://github.com/lucidrains/speculative-decoding/blob/HEAD/speculative_decoding/speculative_decoding.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":"ef39dd586a82a156"}},{"code_sha256_prefix":"d5c48d2733f29ebb","entry":"max_fn","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d5c48d2733f29ebb"}},{"code_sha256_prefix":"c9dd1e87e985a33c","entry":"norm_logits","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c9dd1e87e985a33c"}},{"code_sha256_prefix":"ea7422602cf8d39a","entry":"norm_logits","repo":"smart-lty/parallelspeculativedecoding","repo_kind":"listed","path":"src/engine.py","file_url":"https://github.com/smart-lty/parallelspeculativedecoding/blob/HEAD/src/engine.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ea7422602cf8d39a"}},{"code_sha256_prefix":"806a4b61f4218c4b","entry":"safe_div","repo":"lucidrains/speculative-decoding","repo_kind":"listed","path":"speculative_decoding/speculative_decoding.py","file_url":"https://github.com/lucidrains/speculative-decoding/blob/HEAD/speculative_decoding/speculative_decoding.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"806a4b61f4218c4b"}},{"code_sha256_prefix":"d433f14ebfd69413","entry":"sample","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d433f14ebfd69413"}},{"code_sha256_prefix":"ffa10e3a85932ece","entry":"sample","repo":"smart-lty/parallelspeculativedecoding","repo_kind":"listed","path":"src/engine.py","file_url":"https://github.com/smart-lty/parallelspeculativedecoding/blob/HEAD/src/engine.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ffa10e3a85932ece"}},{"code_sha256_prefix":"ce874c7fa5d31d78","entry":"speculative_decoding","repo":"lucidrains/speculative-decoding","repo_kind":"listed","path":"speculative_decoding/speculative_decoding.py","file_url":"https://github.com/lucidrains/speculative-decoding/blob/HEAD/speculative_decoding/speculative_decoding.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ce874c7fa5d31d78"}},{"code_sha256_prefix":"3c61d89a5e42a3d3","entry":"top_k","repo":"lucidrains/speculative-decoding","repo_kind":"listed","path":"speculative_decoding/speculative_decoding.py","file_url":"https://github.com/lucidrains/speculative-decoding/blob/HEAD/speculative_decoding/speculative_decoding.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3c61d89a5e42a3d3"}},{"code_sha256_prefix":"a391388e6c7e3baa","entry":"top_k_top_p_filter","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a391388e6c7e3baa"}},{"code_sha256_prefix":"025c3469ca2fb4c3","entry":"top_k_top_p_filter","repo":"smart-lty/parallelspeculativedecoding","repo_kind":"listed","path":"src/engine.py","file_url":"https://github.com/smart-lty/parallelspeculativedecoding/blob/HEAD/src/engine.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"025c3469ca2fb4c3"}},{"code_sha256_prefix":"23abd23ad9a26aaf","entry":"Decoder","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.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":"23abd23ad9a26aaf"}},{"code_sha256_prefix":"559f754be1db32cf","entry":"Decoding","repo":"smart-lty/parallelspeculativedecoding","repo_kind":"listed","path":"src/engine.py","file_url":"https://github.com/smart-lty/parallelspeculativedecoding/blob/HEAD/src/engine.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":"559f754be1db32cf"}},{"code_sha256_prefix":"c09397f1dfae4d19","entry":"KVCacheModel","repo":"smart-lty/parallelspeculativedecoding","repo_kind":"listed","path":"src/engine.py","file_url":"https://github.com/smart-lty/parallelspeculativedecoding/blob/HEAD/src/engine.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":"c09397f1dfae4d19"}},{"code_sha256_prefix":"49c7d0a8e1eaff77","entry":"Singleton","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.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":"49c7d0a8e1eaff77"}},{"code_sha256_prefix":"4fa98a77cb95f018","entry":"detect_dataframe","repo":"ericlbuehler/mistral.rs","repo_kind":"listed","path":"mistralrs-code-exec/python/executor.py","file_url":"https://github.com/ericlbuehler/mistral.rs/blob/HEAD/mistralrs-code-exec/python/executor.py","link_basis":"harvester_set","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":"4fa98a77cb95f018"}},{"code_sha256_prefix":"905226f05e395d5f","entry":"detect_pil_image","repo":"ericlbuehler/mistral.rs","repo_kind":"listed","path":"mistralrs-code-exec/python/executor.py","file_url":"https://github.com/ericlbuehler/mistral.rs/blob/HEAD/mistralrs-code-exec/python/executor.py","link_basis":"harvester_set","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":"905226f05e395d5f"}},{"code_sha256_prefix":"c512e543f906b1ca","entry":"extract_outputs","repo":"ericlbuehler/mistral.rs","repo_kind":"listed","path":"mistralrs-code-exec/python/executor.py","file_url":"https://github.com/ericlbuehler/mistral.rs/blob/HEAD/mistralrs-code-exec/python/executor.py","link_basis":"harvester_set","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":"c512e543f906b1ca"}},{"code_sha256_prefix":"79fc1fb911ac4bf9","entry":"seed_everything","repo":"smart-lty/parallelspeculativedecoding","repo_kind":"listed","path":"src/engine.py","file_url":"https://github.com/smart-lty/parallelspeculativedecoding/blob/HEAD/src/engine.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":"79fc1fb911ac4bf9"}},{"code_sha256_prefix":"eb5f131d8785dd2d","entry":"speculative_sampling","repo":"feifeibear/llmspeculativesampling","repo_kind":"listed","path":"sampling/speculative_sampling.py","file_url":"https://github.com/feifeibear/llmspeculativesampling/blob/HEAD/sampling/speculative_sampling.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":"eb5f131d8785dd2d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}