# Neural Variable Name Repair: Learning to Rename Identifiers for Readability

arXiv: https://arxiv.org/abs/2512.01141 · HTML: https://mlsanity.com/paper/2512.01141/

## Key facts

- No citing papers in the map yet (data through 14 Oct 2026).
- Builds on 5 of its 5 references that are in the map.
- First posted on arXiv 30 Nov 2025.

## Builds on (most cited first, 5 of 5)

- [The Stack: 3 TB of permissively licensed source code](https://mlsanity.com/paper/2211.15533/) (2022)
- [DIRE: A Neural Approach to Decompiled Identifier Naming](https://mlsanity.com/paper/1909.09029/) (2019)
- [Context2Name: A Deep Learning-Based Approach to Infer Natural Variable Names from Usage Contexts](https://mlsanity.com/paper/1809.05193/) (2018)
- [How Does Naming Affect LLMs on Code Analysis Tasks?](https://mlsanity.com/paper/2307.12488/) (2023)
- [Recommending Variable Names for Extract Local Variable Refactorings](https://mlsanity.com/paper/2507.00413/) (2025)

## Abstract (arXiv)

Developers routinely work with source files whose variable names are generic or misleading, and with teams moving quickly, many functions are left undocumented. This slows comprehension, increases the risk of subtle bugs, and makes it harder for both humans and large language models (LLMs) to reason about code. We study variable name repair: given a real C++ function where all occurrences of one local or parameter name have been replaced by a placeholder (e.g. ID 1), the goal is to generate a natural, descriptive replacement name. We automatically construct this task from the C++ portion of BigCode's The Stack by parsing functions with Tree-sitter, masking a single identifier, and treating the original name as supervision. On top of Llama 3.1-8B, we build a pipeline with (i) warmup and dropout schedules for more stable fine-tuning, (ii) LoRA adapters for efficient specialization on identifier repair, and (iii) a dual-encoder reranker over top-k generator candidates. We evaluate using exact match, Top-5 Hit, and an embedding-based partial similarity score (0-100) that gives credit for near synonyms and format variants (e.g., jsonValue vs. json). On a held-out set of 200 C++ functions, a zero-shot Llama 3.1 baseline reaches 6.1 percent exact match. Our best LoRA-tuned model (with warmup and dropout) achieves 43.1 percent exact match, 50.2 percent Top-5 Hit, and an 82.03 partial-match score. A dual encoder reranker further improves selection quality without modifying the underlying generator, suggesting that task-specific fine-tuning plus reranking is a promising approach for practical identifier repair tools.
