Pitfalls in Language Models for Code Intelligence: A Taxonomy and Survey

Xinyu She, Yue Liu, Yanjie Zhao, Yiling He, Li Li, Chakkrit Tantithamthavorn, Zhan Qin, Haoyu Wang

Introduction

Language Models for Code (LM4Code), such as GPT-4, CodeBERT, and Codex, have fundamentally transformed software engineering by automating complex tasks like code generation, bug repair, and summarization. However, as these models are increasingly integrated into developer workflows, a critical concern has emerged: the "black box" nature of these systems often masks systemic biases and methodological flaws. This paper presents a systematic literature review (SLR) of 67 high-quality studies published between 2018 and 2023, identifying the hidden pitfalls that lead to unrealistic performance evaluations and unreliable real-world behavior.

A Taxonomy of Pitfalls

The core contribution of this research is a comprehensive four-stage taxonomy that maps pitfalls across the entire machine learning lifecycle. By categorizing these issues, the authors provide a roadmap for researchers to move beyond "mirage" performance toward more trustworthy AI tools.

The four-stage taxonomy of pitfalls identifies 11 issues in data collection, 16 in system design, 29 in evaluation, and 25 in deployment.
  1. Data Collection and Labeling: This stage is plagued by unbalanced class distributions and noisy labels. Many benchmarks, such as the Django dataset, are criticized for being too simplistic (averaging only 33 characters per snippet), failing to represent the complexity of production code.
  2. System Design and Learning: Algorithmic flaws like "data snooping"—where a model inadvertently sees test data during training—and the learning of "spurious correlations" (shortcuts based on variable names rather than logic) are rampant.
  3. Performance Evaluation: This is the most heavily researched area, with 29 papers focusing on methodological errors. Common issues include using weak baselines or inappropriate metrics like BLEU, which measures keyword overlap but ignores whether the generated code actually compiles or functions correctly.
  4. Deployment and Maintenance: Practical hurdles include model size constraints, adversarial attack threats, and the generation of insecure code. One study highlighted that up to 40% of code generated by certain LLMs contained security vulnerabilities.

The Evolution of LM4Code Research

The landscape of code intelligence has shifted rapidly over the last five years. Early research relied heavily on traditional sequence models like RNNs and LSTMs. However, since 2021, there has been a decisive move toward Transformer-based architectures.

The distribution of research papers shows a clear transition from RNN/LSTM architectures toward Transformer-based models like CodeBERT and Codex.

As shown in the figure above, the volume of research has exploded, with 2023 seeing a significant spike in papers focusing on large-scale models like Codex and general Transformers. This shift reflects the community's attempt to leverage the massive scale of pre-trained models to solve increasingly complex software engineering problems.

Key Insights: From Mirages to Real-World Risks

The survey reveals several critical insights regarding the current state of the field:

  • The Performance Mirage: Data leakage can lead to deceptive results. In one instance, a model's F1 score for clone detection plummeted from 0.96 to 0.42 once data snooping was corrected.
  • The Impact of Data Quality: "More data" is not always better. Removing noise from code search datasets was shown to improve Mean Reciprocal Rank (MRR) from 0.407 to 0.512, emphasizing the need for rigorous data cleaning.
  • Security as an Afterthought: Many models prioritize functional similarity over safety, leading to the generation of code that may be syntactically correct but contains exploitable vulnerabilities.

Conclusion and Future Outlook

While LM4Code systems show immense promise, the research community must address these systemic pitfalls to ensure reliability. Future work should prioritize automated data quality assurance, the development of explainable AI (XAI) to detect spurious correlations, and the creation of "messy" real-world benchmarks that reflect the true complexity of production software environments.

Summary updated

BibTeX
@article{she2026pitfalls,
  author = {Xinyu She and Yue Liu and Yanjie Zhao and Yiling He and Li Li and Chakkrit Tantithamthavorn and Zhan Qin and Haoyu Wang},
  title = {{Pitfalls in Language Models for Code Intelligence: A Taxonomy and Survey}},
  journal = {ACM Trans. Softw. Eng. Methodol.},
  year = {2026},
  doi = {10.1145/3748647},
}
Figure