{"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/online-speculative-decoding","title":"Online Speculative Decoding","arxiv_id":"2310.07177","date":"2023-10-11","proceeding":null,"authors":["Xiaoxuan Liu","Lanxiang Hu","Peter Bailis","Alvin Cheung","Zhijie Deng","Ion Stoica","Hao Zhang"],"abstract":"Speculative decoding is a pivotal technique to accelerate the inference of large language models (LLMs) by employing a smaller draft model to predict the target model's outputs. However, its efficacy can be limited due to the low predictive accuracy of the draft model, particularly when faced with diverse text inputs and a significant capability gap between the draft and target models. We introduce online speculative decoding to address this challenge. The main idea is to continuously update the (multiple) draft model(s) on observed user query data. Adapting to query distribution mitigates the shifts between the training distribution of the draft model and the query distribution, enabling the draft model to more accurately predict the target model's outputs. We develop a prototype of online speculative decoding based on knowledge distillation and evaluate it using both synthetic and real query data. The results show a substantial increase in the token acceptance rate by 0.1 to 0.65, bringing 1.42x to 2.17x latency reduction. Our code is available at https://github.com/LiuXiaoxuanPKU/OSD.","url_abs":"https://arxiv.org/abs/2310.07177v4","url_pdf":"https://arxiv.org/pdf/2310.07177v4.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":"online-speculative-decoding","repo_url":"https://github.com/liuxiaoxuanpku/osd","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"knowledge-distillation","task_name":"Knowledge Distillation"}],"methods":[{"method_slug":"knowledge-distillation","method_name":"Knowledge Distillation"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2310.07177","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2310.07177"}},"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/liuxiaoxuanpku/osd","reach":{"status":"ok"}}],"summary":{"ran":9,"ran_draft_wrong":2,"unverified":2},"by_repo_kind":{"official":{"samples":13,"ran":11,"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":13,"samples":[{"code_sha256_prefix":"e98f1e98fbfaaf55","entry":"acc_rate_to_acc_count","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/cost_model.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/cost_model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e98f1e98fbfaaf55"}},{"code_sha256_prefix":"34835c30e916c84e","entry":"estimate_speedup_from_acc_count","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/cost_model.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/cost_model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"34835c30e916c84e"}},{"code_sha256_prefix":"d95f990735eba145","entry":"extract_answer","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/data.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/data.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d95f990735eba145"}},{"code_sha256_prefix":"cfda031d44778d32","entry":"get_examples","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/data.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/data.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cfda031d44778d32"}},{"code_sha256_prefix":"9835f44aa570459e","entry":"preprocess_function_generic","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/experiment/compare_model_t5.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/experiment/compare_model_t5.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9835f44aa570459e"}},{"code_sha256_prefix":"7176f7d7a27e3c0d","entry":"preprocess_function_spider","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/experiment/compare_model_t5.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/experiment/compare_model_t5.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7176f7d7a27e3c0d"}},{"code_sha256_prefix":"951d55a786237f31","entry":"read_jsonl","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/data.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/data.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"951d55a786237f31"}},{"code_sha256_prefix":"17363e810e97d511","entry":"search_best_spec_count","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/cost_model.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/cost_model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"17363e810e97d511"}},{"code_sha256_prefix":"287256fce57ec17e","entry":"slice_past_key_values","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/specInfer/common.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/specInfer/common.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"287256fce57ec17e"}},{"code_sha256_prefix":"49ea3af49091879c","entry":"slice_past_key_values_seq2seq","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/specInfer/common.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/specInfer/common.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"49ea3af49091879c"}},{"code_sha256_prefix":"23212f8f0cb67fc0","entry":"target_sample_from_distribution","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/specInfer/common.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/specInfer/common.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"23212f8f0cb67fc0"}},{"code_sha256_prefix":"44894fa300cbe47f","entry":"load_model","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/experiment/compare_model.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/experiment/compare_model.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":"44894fa300cbe47f"}},{"code_sha256_prefix":"9e8be6f2c54dac94","entry":"load_model","repo":"liuxiaoxuanpku/osd","repo_kind":"official","path":"distill/experiment/compare_model_t5.py","file_url":"https://github.com/liuxiaoxuanpku/osd/blob/HEAD/distill/experiment/compare_model_t5.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":"9e8be6f2c54dac94"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}