Unveiling Project-Specific Bias in Neural Code Models (2201.07381v2)
Abstract: Deep learning has introduced significant improvements in many software analysis tasks. Although the LLMs based neural code models demonstrate commendable performance when trained and tested within the intra-project independent and identically distributed (IID) setting, they often struggle to generalize effectively to real-world inter-project out-of-distribution (OOD) data. In this work, we show that this phenomenon is caused by the heavy reliance on project-specific shortcuts for prediction instead of ground-truth evidence. We propose a Cond-Idf measurement to interpret this behavior, which quantifies the relatedness of a token with a label and its project-specificness. The strong correlation between model behavior and the proposed measurement indicates that without proper regularization, models tend to leverage spurious statistical cues for prediction. Equipped with these observations, we propose a novel bias mitigation mechanism that regularizes the model's learning behavior by leveraging latent logic relations among samples. Experimental results on two representative program analysis tasks indicate that our mitigation framework can improve both inter-project OOD generalization and adversarial robustness, while not sacrificing accuracy on intra-project IID data.
- Dissecting the high-frequency bias in convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 863–871.
- Don’t just assume; look and answer: Overcoming priors for visual question answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 4971–4980.
- Unified pre-training for program understanding and generation. arXiv preprint arXiv:2103.06333.
- Extending source code pre-trained language models to summarise decompiled binarie. In 2023 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), pages 260–271. IEEE.
- Typilus: Neural type hints. In Proceedings of the 41st acm sigplan conference on programming language design and implementation, pages 91–105.
- Invariant risk minimization. arXiv preprint arXiv:1907.02893.
- Pavol Bielik and Martin Vechev. 2020. Adversarial robustness for code. In International Conference on Machine Learning, pages 896–907. PMLR.
- Enriching word vectors with subword information. Transactions of the association for computational linguistics, 5:135–146.
- Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901.
- Rubi: Reducing unimodal biases for visual question answering. Advances in neural information processing systems, 32:841–852.
- Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374.
- Execution-guided neural program synthesis. In International Conference on Learning Representations.
- Don’t take the easy way out: Ensemble based methods for avoiding known dataset biases. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP).
- ELECTRA: pre-training text encoders as discriminators rather than generators. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net.
- Bert: Pre-training of deep bidirectional transformers for language understanding. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.
- Shortcut learning of large language models in natural language understanding.
- Towards interpreting and mitigating shortcut learning behavior of nlu models. Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.
- Francesc Esteva and Lluıs Godo. 2001. Monoidal t-norm based logic: towards a logic for left-continuous t-norms. Fuzzy sets and systems, 124(3):271–288.
- Richard Evans and Edward Grefenstette. 2018. Learning explanatory rules from noisy data. Journal of Artificial Intelligence Research, 61:1–64.
- Codebert: A pre-trained model for programming and natural languages. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 1536–1547.
- Robert W Floyd. 1962. Algorithm 97: shortest path. Communications of the ACM, 5(6):345.
- Domain-adversarial training of neural networks. The journal of machine learning research, 17(1):2096–2030.
- Shortcut learning in deep neural networks. Nature Machine Intelligence, 2(11):665–673.
- Imagenet-trained cnns are biased towards texture; increasing shape bias improves accuracy and robustness. Seventh International Conference on Learning Representations.
- Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572.
- Assemble foundation models for automatic code summarization. In 2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), pages 935–946. IEEE.
- Unixcoder: Unified cross-modal pre-training for code representation. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), ACL 2022, Dublin, Ireland, May 22-27, 2022, pages 7212–7225. Association for Computational Linguistics.
- Graphcodebert: Pre-training code representations with data flow. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net.
- Zellig S Harris. 1954. Distributional structure. Word, 10(2-3):146–162.
- Unlearn dataset bias in natural language inference by fitting the residual. arXiv preprint arXiv:1908.10763.
- Deep residual learning for image recognition.
- Deep learning type inference. In Proceedings of the 2018 26th acm joint meeting on european software engineering conference and symposium on the foundations of software engineering, pages 152–162.
- Large language models for software engineering: A systematic literature review. arXiv preprint arXiv:2308.10620.
- Enumeration and deduction driven co-synthesis of ccsl specifications using reinforcement learning. In 2021 IEEE Real-Time Systems Symposium (RTSS), pages 227–239. IEEE.
- Gitfl: Uncertainty-aware real-time asynchronous federated learning using version control. In 2023 IEEE Real-Time Systems Symposium (RTSS). IEEE.
- Few-shot representation learning for out-of-vocabulary words. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 4102–4112.
- Zero-day backdoor attack against text-to-image diffusion models via personalization. arXiv preprint arXiv:2305.10701.
- Codesearchnet challenge: Evaluating the state of semantic code search. arXiv preprint arXiv:1909.09436.
- Paul Jaccard. 1912. The distribution of the flora in the alpine zone. 1. New phytologist, 11(2):37–50.
- Learning type annotation: is big data enough? In Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pages 1483–1486.
- Learning not to learn: Training deep neural networks with biased data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9012–9020.
- Bert-attack: Adversarial attack against bert using bert. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 6193–6202.
- Fairer: Fairness as decision rationale alignment.
- Runner: Responsible unfair neuron repair for enhancing deep neural network fairness. In 2024 IEEE/ACM 46th International Conference on Software Engineering (ICSE), pages 66–78. IEEE Computer Society.
- Towards deep learning models resistant to adversarial attacks. arXiv preprint arXiv:1706.06083.
- End-to-end bias mitigation by modelling biases in corpora. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 8706–8716.
- Explicit bias discovery in visual question answering models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9562–9571.
- Pasquale Minervini and Sebastian Riedel. 2018. Adversarially regularising neural nli models to integrate logical background knowledge. Proceedings of the 22nd Conference on Computational Natural Language Learning (CoNLL 2018).
- Methods for interpreting and understanding deep neural networks. Digital Signal Processing, 73:1–15.
- Timothy Niven and Hung-Yu Kao. 2019. Probing neural network comprehension of natural language arguments. Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics.
- Judea Pearl et al. 2000. Models, reasoning and inference. Cambridge, UK: CambridgeUniversityPress, 19.
- Exploring the limits of transfer learning with a unified text-to-text transformer. The Journal of Machine Learning Research, 21(1):5485–5551.
- Towards debiasing fact verification models. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP).
- Avoiding the hypothesis-only bias in natural language inference via ensemble adversarial training. Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP).
- Axiomatic attribution for deep networks. In International Conference on Machine Learning, pages 3319–3328. PMLR.
- Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971.
- Attention is all you need. Advances in neural information processing systems, 30.
- Learning robust representations by projecting superficial statistics out. In International Conference on Learning Representations.
- Codet5: Identifier-aware unified pre-trained encoder-decoder models for code understanding and generation. arXiv preprint arXiv:2109.00859.
- Lambdanet: Probabilistic type inference using graph neural networks. The International Conference on Learning Representations (ICLR).
- Adversarial examples for models of code. Proceedings of the ACM on Programming Languages, 4(OOPSLA):1–30.
- Jin Yong Yoo and Yanjun Qi. 2021. Towards improving adversarial training of nlp models. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 945–956.
- Jerrold H Zar. 2005. Spearman rank correlation. Encyclopedia of biostatistics, 7.
- Xiang Zhou and Mohit Bansal. 2020. Towards robustifying nli models against lexical dataset biases. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 8759–8771.
- Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks. Advances in neural information processing systems, 32.
- A robustly optimized bert pre-training approach with post-training. In Proceedings of the 20th Chinese National Conference on Computational Linguistics, pages 1218–1227.