Skip to main content
QUICK REVIEW

[Paper Review] Evaluation of Generalizability of Neural Program Analyzers under Semantic-Preserving Transformations

Md Rafiqul Islam Rabin, Mohammad Amin Alipour|arXiv (Cornell University)|Apr 15, 2020
Software Engineering ResearchComputer Science39 references8 citations
TL;DR

This paper evaluates the generalizability of neural program analyzers code2vec and code2seq under semantic-preserving program transformations, revealing that even minor structural changes—like variable renaming or reordering—often cause significant prediction shifts. The study demonstrates that these models lack robustness to syntactic variations, raising concerns about their reliability in real-world program analysis tasks.

ABSTRACT

The abundance of publicly available source code repositories, in conjunction with the advances in neural networks, has enabled data-driven approaches to program analysis. These approaches, called neural program analyzers, use neural networks to extract patterns in the programs for tasks ranging from development productivity to program reasoning. Despite the growing popularity of neural program analyzers, the extent to which their results are generalizable is unknown. In this paper, we perform a large-scale evaluation of the generalizability of two popular neural program analyzers using seven semantically-equivalent transformations of programs. Our results caution that in many cases the neural program analyzers fail to generalize well, sometimes to programs with negligible textual differences. The results provide the initial stepping stones for quantifying robustness in neural program analyzers.

Motivation & Objective

  • To investigate the generalizability of neural program analyzers when faced with semantically equivalent but syntactically altered programs.
  • To assess whether widely used neural models like code2vec and code2seq maintain consistent predictions across minor structural changes in source code.
  • To identify the extent to which current neural program analyzers are brittle to transformations that preserve program semantics.
  • To provide empirical evidence for the limitations of existing models, motivating future work on robust and reliable neural code analysis.
  • To serve as a foundational evaluation for measuring robustness and reliability in neural program analysis systems.

Proposed method

  • Applied seven semantic-preserving transformations to programs from the code2seq training dataset, including variable renaming, reordering of statements, and refactoring of control flow.
  • Generated semantically equivalent variants of original programs while preserving abstract syntax tree (AST) structure and behavior.
  • Used code2vec and code2seq models to predict outputs (e.g., method names) on both original and transformed programs.
  • Compared predictions across original and transformed versions to detect prediction shifts indicating poor generalization.
  • Performed large-scale evaluation across multiple datasets and transformation types to ensure statistical reliability.
  • Quantified the frequency and severity of prediction changes under different transformation types to assess model sensitivity.

Experimental results

Research questions

  • RQ1To what extent do neural program analyzers like code2vec and code2seq generalize to semantically equivalent programs with minor syntactic changes?
  • RQ2How do different types of semantic-preserving transformations affect the prediction consistency of neural program analyzers?
  • RQ3Are there specific transformation types that cause significantly higher prediction drift in neural models?
  • RQ4How does the performance of neural models degrade when exposed to structurally altered but functionally identical code?
  • RQ5Can the observed prediction shifts be attributed to model sensitivity to syntactic variations rather than semantic content?

Key findings

  • In 9.19% to 36.36% of cases, correct predictions on original programs changed to incorrect predictions after semantic-preserving transformations.
  • Variable renaming and statement reordering led to the highest rates of prediction drift, indicating sensitivity to syntactic structure.
  • The models showed inconsistent behavior even under transformations that preserved program semantics and AST structure.
  • The results suggest that current neural program analyzers are brittle and not reliably generalizable to semantically equivalent code variants.
  • The performance degradation was not uniform across transformation types, with some changes causing significantly higher error rates than others.
  • The study reveals a critical gap in the robustness of neural models despite their high accuracy on standard benchmarks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.