Neural Variable Name Repair: Learning to Rename Identifiers for Readability
Akshat Bagade, Maanas Baraya, Chittebbayi Penugonda, Muhammad Yousuf · 2025
Read Neural Variable Name Repair: Learning to Rename Identifiers for Readability by Akshat Bagade, Maanas Baraya, Chittebbayi Penugonda, Muhammad Yousuf (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2512-01141.txt.
Introduction
Akshat Bagade, Maanas Baraya, Chittebbayi Penugonda, and Muhammad Yousuf teach machines to rename variables in a 2025 paper. Developers often inherit code whose variable names are generic or misleading. Teams moving fast leave many functions undocumented, which slows comprehension for everyone who reads the code later.
Poor names raise the risk of subtle bugs. They also make it harder for large language models to reason about code, since names carry much of the meaning. Their neural variable name repair system learns to suggest readable identifiers. Automatic renaming could help teams clean legacy code and help AI coding tools understand it.
Catalog record
| CREATOR | Akshat Bagade, Maanas Baraya, Chittebbayi Penugonda, Muhammad Yousuf |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 30 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2512-01141
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Neural Variable Name Repair: Learning to Rename Identifiers for Readability Akshat Bagade, Maanas Baraya, Chittebbayi Penugonda, Muhammad Yousuf Abstract 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 k generator candidates. We evaluate using exact match, Top- 5 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% exact match. Our best LoRA-tuned model (with warmup and dropout) achieves 43.1% exact match, 50.2% Top- 5 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. 1 Introduction Readable code relies heavily on well chosen identifier names. When names are missing ( var1 ), or misleading, developers spend more time reconstructing intent from control flow and types, and tools such as static analyzers, code search, and LLM based assistants work with degraded signal. In large codebases and legacy systems, renaming poor identifiers is often deferred or done inconsistently, even though it would benefit both human maintainers and automated tools. We focus on a concrete version of this broader problem: variable name repair . Given a single C++ function where one local or parameter identifier has been systematically replaced by a placeholder token such as <ID_1> , our goal is to propose a natural replacement name that fits the surrounding code. The setting is intentionally local: the model only sees the function body (plus signature), without project-wide context or comments. This approximates common refactoring scenarios where a developer wants quick suggestions within the current file. Our research question is: Can a general-purpose code LLM, augmented with task-specific fine-tuning and reranking, reliably repair variable names in real-world C++ code using only context of the local function? We define success in terms of three metrics on a held-out validation split of mined C++ code: (i) exact match between the model’s top suggestion and the original name; (ii) Top- 5 Hit rate; and (iii) an embedding-based partial score in [0,100] that measures semantic similarity between the suggestion and the original name. A system is successful if it significantly improves all three metrics compared to prompting-only baselines, while keeping inference computationally lightweight (LoRA adapters, modest reranker) and compatible with standard deployment stacks. To study this question, we automatically build a dataset of masked C++ functions from the BigCode The Stack corpus. Using Tree-sitter, we extract functions, collect their local and parameter names, mask a single name with <ID_1> , and treat the original name as the target. We first design a data pipeline that generates training/validation JSONL examples and reproducible inference inputs. Then we implement zero shot and few shot prompting baselines using Llama 3.1–8B. Next, we train LoRA adapters on top of Llama 3.1–8B with warmup and dropout schedules tailored to short JSON targets. Additionally, we build a dual encoder reranker over top- k generator candidates, trained with a contrastive InfoNCE loss on code/name pairs. Finally, we built an evaluation harness that computes exact, Top- 5 , and partial-credit scores, and logs per-example predictions for error analysis. With strong models for variable name augmentation, the implications are considerable. Not only will code repos be cleaner allowing future devs to work faster, but pushing to production will also be faster with more automated code reviews. Furthermore, these models can be integrated into current AI coding tools like Cursor, Devin, and Google Antigravity for a better coding experience. 2 Related Work Heuristic name suggestion. Traditional IDE refactoring tools propose variable names using hand-written heuristics (e.g., type-based patterns, naming conventions, or surrounding comments). These tools integrate nicely into developer workflows but are brittle and language-specific. They often fail when types are generic or when the code relies heavily on domain-specific conventions. Neural identifier recovery and naming. Several works treat identifier naming as a supervised learning problem over code. Context2Name Bavishi et al. 2018 uses a neural model to recover decompiled variable names from usage contexts. DIRE Lacomis et al. 2019 proposes a graph-based neural architecture for naming identifiers in decompiled code. Wang et al. Wang et al. 2025 study variable name recommendation during extract-local-variable refactorings, leveraging code context and usage patterns. These systems generally operate on smaller, task-specific models and datasets, and are tailored to particular languages or toolchains. Naming and LLMs. Recent work has examined how identifier naming affects LLM performance. Wang et al. Wang et al. 2024 show that obfuscated or semantically poor names can significantly degrade LLM performance on code analysis tasks, while better naming improves reasoning and robustness. Our work is complementary: instead of measuring the effect of naming on LLM performance, we use a strong LLM to repair names themselves, with the goal of improving downstream tooling and comprehension. Large code corpora. BigCode’s The Stack BigCode Project 2023 is a 3 TB dataset of permissively licensed source code across many languages. It enables realistic large-scale studies of code generation and understanding. We build our dataset exclusively from the C++ portion of The Stack, leveraging its size and diversity to obtain varied identifier naming patterns. Our position. Compared to prior identifier recovery work, we: • Operate on unobfuscated, real-world C++ functions rather than decompiled code. • Use a modern LLM (Llama 3.1 8B) with LoRA adapters and a learned reranker, achieving strong performance with modest training and inference cost. This contrasts with efforts such as Context2Name that rely on less transformer-driven approaches. • Introduce an embedding-based partial-credit metric to capture cases with multiple reasonable names (for example, buffer and buf ) and to evaluate semantic quality of errors. We do not aim to replace dedicated refactoring engines but instead study how far a compact fine-tuned LLM plus reranker can go using only function-local context. Given its low complexity and compute cost, this setup could support future refactoring tools. Our work contributes four pieces. First, we design a pipeline for extracting variable name repair examples from C++ code in The Stack BigCode Project 2023 . Second, we provide a LoRA-based fine-tuning recipe for Llama 3.1 8B that uses warmup and dropout to stabilize training on masked code and short JSON outputs. Third, we build a dual-encoder reranker that combines code context and candidate-name embeddings to improve Top- k selection without changing