[Paper Review] Evaluating the Impact of Source Code Parsers on ML4SE Models
This paper evaluates how different source code parsers impact the performance of machine learning models in software engineering (ML4SE), focusing on method name prediction in Java. Using a new tool called SuperParser, the authors compare eight parsers across two models—TreeLSTM and Code2Seq—finding that parser choice significantly affects model quality, with performance gaps up to 27% for TreeLSTM and 5.5% for Code2Seq.
As researchers and practitioners apply Machine Learning to increasingly more software engineering problems, the approaches they use become more sophisticated. A lot of modern approaches utilize internal code structure in the form of an abstract syntax tree (AST) or its extensions: path-based representation, complex graph combining AST with additional edges. Even though the process of extracting ASTs from code can be done with different parsers, the impact of choosing a parser on the final model quality remains unstudied. Moreover, researchers often omit the exact details of extracting particular code representations. In this work, we evaluate two models, namely Code2Seq and TreeLSTM, in the method name prediction task backed by eight different parsers for the Java language. To unify the process of data preparation with different parsers, we develop SuperParser, a multi-language parser-agnostic library based on PathMiner. SuperParser facilitates the end-to-end creation of datasets suitable for training and evaluation of ML models that work with structural information from source code. Our results demonstrate that trees built by different parsers vary in their structure and content. We then analyze how this diversity affects the models' quality and show that the quality gap between the most and least suitable parsers for both models turns out to be significant. Finally, we discuss other features of the parsers that researchers and practitioners should take into account when selecting a parser along with the impact on the models' quality. The code of SuperParser is publicly available at https://doi.org/10.5281/zenodo.6366591. We also publish Java-norm, the dataset we use to evaluate the models: https://doi.org/10.5281/zenodo.6366599.
Motivation & Objective
- Investigate how the choice of source code parser affects the performance of ML4SE models that rely on abstract syntax trees (ASTs).
- Address the lack of transparency and reproducibility in prior ML4SE studies, which often omit parser details during AST extraction.
- Develop a unified, parser-agnostic framework to standardize the creation of ML-ready code datasets across multiple parsers and languages.
- Evaluate the impact of parser diversity on model quality using two widely used models: TreeLSTM and Code2Seq.
- Provide empirical evidence that parser selection is a critical hyperparameter in ML4SE pipelines, not a trivial implementation detail.
Proposed method
- Developed SuperParser, a multi-language, parser-agnostic library built on PathMiner, to uniformly extract ASTs and code representations from source code using various parsers.
- Implemented a YAML-based configuration system allowing users to switch parsers with minimal code changes, enabling consistent end-to-end dataset creation.
- Evaluated model performance on the method name prediction task using eight different Java parsers: JavaCC, ANTLR, Rhino, Squirrel, Tree-sitter, JDT, Javac, and JShell.
- Extracted ASTs and path-based representations (for Code2Seq) from the same codebase using each parser, ensuring consistent input for model training and evaluation.
- Used the Java-norm dataset—similar in size to Java-small but with more diverse validation and test sets—for robust and representative model evaluation.
- Measured model performance using F1-score and ChrF, comparing results across parsers to assess the impact of structural differences in ASTs.
Experimental results
Research questions
- RQ1How does the choice of source code parser affect the performance of ML4SE models that rely on ASTs?
- RQ2To what extent do differences in AST structure and content—such as tree depth, node count, or token diversity—impact model quality?
- RQ3Is there a universally optimal parser for ML4SE models, or does the best parser depend on the model architecture?
- RQ4Can a unified, parser-agnostic framework improve reproducibility and comparability in ML4SE research?
- RQ5How significant are performance differences between models trained with different parsers, and are these differences statistically meaningful?
Key findings
- The choice of parser significantly affects model performance, with the F1-score for TreeLSTM varying by up to 27.0% depending on the parser used.
- For Code2Seq, the performance gap between the best and worst parsers was 5.5% in F1-score, which is considered substantial in recent ML4SE literature.
- The relative ranking of parsers differed between TreeLSTM and Code2Seq, indicating no universally optimal parser—selection depends on the model’s architecture and processing method.
- ASTs generated by different parsers vary in structure (e.g., tree depth, size) and content (e.g., number of distinct node types, token distribution), which directly influences model learning.
- The SuperParser tool enables consistent, reproducible dataset creation across multiple parsers with minimal configuration changes, improving experimental transparency.
- The Java-norm dataset, released alongside the study, provides a more diverse and representative evaluation set than Java-small, enabling more robust model comparison without increased computational cost.
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.