{"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/let-the-code-llm-edit-itself-when-you-edit","title":"Let the Code LLM Edit Itself When You Edit the Code","arxiv_id":"2407.03157","date":"2024-07-03","proceeding":null,"authors":["Zhenyu He","Jun Zhang","Shengjie Luo","Jingjing Xu","Zhi Zhang","Di He"],"abstract":"In this work, we investigate a typical scenario in code generation where a developer edits existing code in real time and requests a code assistant, e.g., a large language model, to re-predict the next token or next line on the fly. Naively, the LLM needs to re-encode the entire KV cache to provide an accurate prediction. However, this process is computationally expensive, especially when the sequence length is long. Simply encoding the edited subsequence and integrating it to the original KV cache meets the temporal confusion problem, leading to significantly worse performance. We address this efficiency and accuracy trade-off by introducing \\underline{\\textbf{Positional \\textbf{I}ntegrity \\textbf{E}ncoding} (PIE). Building upon the rotary positional encoding, PIE first removes the rotary matrices in the Key cache that introduce temporal confusion and then reapplies the correct rotary matrices. This process ensures that positional relationships between tokens are correct and requires only a single round of matrix multiplication. We validate the effectiveness of PIE through extensive experiments on the RepoBench-C-8k dataset, utilizing DeepSeek-Coder models with 1.3B, 6.7B, and 33B parameters. Our evaluation includes three real-world coding tasks: code insertion, code deletion, and multi-place code editing. Results demonstrate that PIE reduces computational overhead by over 85% compared to the standard full recomputation approach across all model sizes and tasks while well approximating the model performance.","url_abs":"https://arxiv.org/abs/2407.03157v2","url_pdf":"https://arxiv.org/pdf/2407.03157v2.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":[],"tasks":[{"task_slug":null,"task_name":"8k"},{"task_slug":"code-generation","task_name":"Code Generation"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"large-language-model","task_name":"Large Language Model"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2407.03157","atlas_url":"https://app.syntology.ai/?focus=2407.03157","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.03157"}},"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":"deterministic:regex_extraction","url":"https://github.com/zhenyuhe00/PIE","reach":null}],"summary":{"ran":4,"ran_fixture":1,"unverified":2},"by_repo_kind":{"found_in_text":{"samples":7,"ran":5,"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":"67620ba8e35fd76d","entry":"LlamaDynamicNTKScalingRotaryEmbedding","repo":"zhenyuhe00/PIE","repo_kind":"found_in_text","path":"my_modeling_llama_recomputedynamic.py","file_url":"https://github.com/zhenyuhe00/PIE/blob/HEAD/my_modeling_llama_recomputedynamic.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"67620ba8e35fd76d"}},{"code_sha256_prefix":"f2dc948e8e6c0449","entry":"LlamaLinearScalingRotaryEmbedding","repo":"zhenyuhe00/PIE","repo_kind":"found_in_text","path":"my_modeling_llama_recomputedynamic.py","file_url":"https://github.com/zhenyuhe00/PIE/blob/HEAD/my_modeling_llama_recomputedynamic.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f2dc948e8e6c0449"}},{"code_sha256_prefix":"a847c3e201c31fbe","entry":"LlamaRotaryEmbedding","repo":"zhenyuhe00/PIE","repo_kind":"found_in_text","path":"my_modeling_llama_recomputedynamic.py","file_url":"https://github.com/zhenyuhe00/PIE/blob/HEAD/my_modeling_llama_recomputedynamic.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a847c3e201c31fbe"}},{"code_sha256_prefix":"cae6938541c35f4b","entry":"LlamaVanillaNTKScalingRotaryEmbedding","repo":"zhenyuhe00/PIE","repo_kind":"found_in_text","path":"my_modeling_llama_recomputedynamic.py","file_url":"https://github.com/zhenyuhe00/PIE/blob/HEAD/my_modeling_llama_recomputedynamic.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cae6938541c35f4b"}},{"code_sha256_prefix":"b270c2cdb145449c","entry":"apply_rotary_pos_emb_single","repo":"zhenyuhe00/PIE","repo_kind":"found_in_text","path":"my_modeling_llama_recomputedynamic.py","file_url":"https://github.com/zhenyuhe00/PIE/blob/HEAD/my_modeling_llama_recomputedynamic.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b270c2cdb145449c"}},{"code_sha256_prefix":"02658020404dcd81","entry":"LlamaAttention","repo":"zhenyuhe00/PIE","repo_kind":"found_in_text","path":"my_modeling_llama_recomputedynamic.py","file_url":"https://github.com/zhenyuhe00/PIE/blob/HEAD/my_modeling_llama_recomputedynamic.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":"02658020404dcd81"}},{"code_sha256_prefix":"4332347cb4cd0474","entry":"LlamaYaRNScaledRotaryEmbedding","repo":"zhenyuhe00/PIE","repo_kind":"found_in_text","path":"my_modeling_llama_recomputedynamic.py","file_url":"https://github.com/zhenyuhe00/PIE/blob/HEAD/my_modeling_llama_recomputedynamic.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":"4332347cb4cd0474"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}