[Paper Review] Splitting source code identifiers using Bidirectional LSTM Recurrent Neural Network
This paper proposes a bidirectional LSTM recurrent neural network to split multi-part source code identifiers (e.g., 'FooBar' into 'foo bar') that cannot be reliably split by conventional heuristics. Trained on 34.9 million identifiers from open-source projects, the model achieves 95% precision and 96% recall, outperforming baselines like GRUs, CNNs, and statistical models, and significantly reduces vocabulary size in downstream code analysis tasks.
Programmers make rich use of natural language in the source code they write through identifiers and comments. Source code identifiers are selected from a pool of tokens which are strongly related to the meaning, naming conventions, and context. These tokens are often combined to produce more precise and obvious designations. Such multi-part identifiers count for 97% of all naming tokens in the Public Git Archive - the largest dataset of Git repositories to date. We introduce a bidirectional LSTM recurrent neural network to detect subtokens in source code identifiers. We trained that network on 41.7 million distinct splittable identifiers collected from 182,014 open source projects in Public Git Archive, and show that it outperforms several other machine learning models. The proposed network can be used to improve the upstream models which are based on source code identifiers, as well as improving developer experience allowing writing code without switching the keyboard case.
Motivation & Objective
- To address the challenge of splitting ambiguous, multi-part source code identifiers that lack whitespace and cannot be resolved by standard naming convention heuristics.
- To improve downstream code analysis tasks—such as identifier embedding, deduplication, and topic modeling—by reducing vocabulary size through accurate subtoken splitting.
- To explore the effectiveness of deep learning, particularly bidirectional LSTMs, for character-level sequence modeling in source code tokenization.
- To create and release the largest publicly available dataset of 49.2 million source code identifiers for research in machine learning on code.
Proposed method
- A character-level bidirectional LSTM (BiLSTM) model processes identifiers in both forward and backward directions to detect subtoken boundaries.
- The model uses a two-layer stacked BiLSTM architecture with 256 units per layer, followed by a time-distributed dense layer with sigmoid activation to predict split points (1 = split, 0 = no split).
- Input is lowercase identifier strings with ground-truth split boundaries encoded as binary vectors, and the model is trained using Adam optimization with a fixed learning rate of 0.001.
- Hyperparameters were tuned using Hyperopt, and training was conducted on two NVIDIA GTX 1080 GPUs over 10 epochs.
- The model was evaluated using precision, recall, and F1-score on a 20% held-out validation set.
- A comparison was made against multiple baselines: character-level maximum likelihood models, statistical dynamic programming, gradient boosted decision trees, CNNs, and GRUs.
Experimental results
Research questions
- RQ1Can a deep learning model outperform heuristic and statistical methods in splitting ambiguous source code identifiers?
- RQ2To what extent can a BiLSTM model reduce vocabulary size in code analysis tasks by accurately splitting compound identifiers?
- RQ3How does the performance of a bidirectional LSTM compare to unidirectional RNNs, GRUs, and CNNs on this identifier splitting task?
- RQ4What is the impact of training on a large-scale, diverse dataset of 34.9 million identifiers from real-world open-source projects?
Key findings
- The BiLSTM model achieved the highest F1-score of 95.2%, with 94.7% precision and 95.8% recall, outperforming all other models including BiGRU, CNN, and statistical baselines.
- The model reduced the number of unique subtokens in the dataset from 2,940,710 to 1,065,153—a 64% reduction—demonstrating significant vocabulary compression.
- The character-level maximum likelihood model with logical conjunction of forward and backward passes achieved the highest precision (96.6%) but poor recall (57.3%), indicating a trade-off between precision and completeness.
- The BiLSTM model made an error with 50% probability after approximately 14 identifiers on average, assuming one split per identifier, indicating high reliability for practical use.
- The model significantly outperformed the gradient boosted decision tree (F1: 92.8%) and the unsmoothed character-level n-gram model (F1: 70.3%), confirming the superiority of deep learning for this task.
- The proposed model enables developers to type identifiers in lowercase or mixed case without case switching, reducing keystrokes and improving typing speed.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.