{"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/nacl-a-general-and-effective-kv-cache","title":"NACL: A General and Effective KV Cache Eviction Framework for LLMs at Inference Time","arxiv_id":"2408.03675","date":"2024-08-07","proceeding":null,"authors":["Yilong Chen","Guoxia Wang","Junyuan Shang","Shiyao Cui","Zhenyu Zhang","Tingwen Liu","Shuohuan Wang","Yu Sun","dianhai yu","Hua Wu"],"abstract":"Large Language Models (LLMs) have ignited an innovative surge of AI applications, marking a new era of exciting possibilities equipped with extended context windows. However, hosting these models is cost-prohibitive mainly due to the extensive memory consumption of KV Cache involving long-context modeling. Despite several works proposing to evict unnecessary tokens from the KV Cache, most of them rely on the biased local statistics of accumulated attention scores and report performance using unconvincing metric like perplexity on inadequate short-text evaluation. In this paper, we propose NACL, a general framework for long-context KV cache eviction that achieves more optimal and efficient eviction in a single operation during the encoding phase. Due to NACL's efficiency, we combine more accurate attention score statistics in PROXY TOKENS EVICTION with the diversified random eviction strategy of RANDOM EVICTION, aiming to alleviate the issue of attention bias and enhance the robustness in maintaining pivotal tokens for long-context modeling tasks. Notably, our method significantly improves the performance on short- and long-text tasks by 80% and 76% respectively, reducing KV Cache by up to 50% with over 95% performance maintenance. The code is available at https://github.com/PaddlePaddle/Research/tree/master/NLP/ACL2024-NACL.","url_abs":"https://arxiv.org/abs/2408.03675v2","url_pdf":"https://arxiv.org/pdf/2408.03675v2.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":"nacl-a-general-and-effective-kv-cache","repo_url":"https://github.com/PaddlePaddle/Research","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"paddle","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"nacl-a-general-and-effective-kv-cache","repo_url":"https://github.com/PaddlePaddle/Research/tree/master/NLP/ACL2024-NACL","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"paddle","reach":null}],"tasks":[],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2408.03675","atlas_url":"https://app.syntology.ai/?focus=2408.03675","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2408.03675"}},"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/PaddlePaddle/Research","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/PaddlePaddle/Research/tree/master/NLP/ACL2024-NACL","reach":null}],"summary":{"ran":2,"ran_honours":1},"by_repo_kind":{"official":{"samples":3,"ran":3,"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":0,"samples":[{"code_sha256_prefix":"833ccd510fac73d0","entry":"get_logger","repo":"PaddlePaddle/Research","repo_kind":"official","path":"CV/SMILE/finetune.py","file_url":"https://github.com/PaddlePaddle/Research/blob/HEAD/CV/SMILE/finetune.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":"833ccd510fac73d0"}},{"code_sha256_prefix":"ac63e9a19256d49f","entry":"load_dict","repo":"PaddlePaddle/Research","repo_kind":"official","path":"CV/PWCNet/infer.py","file_url":"https://github.com/PaddlePaddle/Research/blob/HEAD/CV/PWCNet/infer.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":"ac63e9a19256d49f"}},{"code_sha256_prefix":"1492225d0a37a248","entry":"position_encoding_init","repo":"PaddlePaddle/Research","repo_kind":"official","path":"NLP/ACL2019-JEMT/model.py","file_url":"https://github.com/PaddlePaddle/Research/blob/HEAD/NLP/ACL2019-JEMT/model.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1492225d0a37a248"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}