Papers
Topics
Authors
Recent
Search
2000 character limit reached

Beyond Self-learned Attention: Mitigating Attention Bias in Transformer-based Models Using Attention Guidance

Published 26 Feb 2024 in cs.SE and cs.AI | (2402.16790v1)

Abstract: Transformer-based models have demonstrated considerable potential for source code modeling tasks in software engineering. However, they are limited by their dependence solely on automatic self-attention weight learning mechanisms. Previous studies have shown that these models overemphasize delimiters added by tokenizers (e.g., [CLS], [SEP]), which may lead to overlooking essential information in the original input source code. To address this challenge, we introduce SyntaGuid, a novel approach that utilizes the observation that attention weights tend to be biased towards specific source code syntax tokens and abstract syntax tree (AST) elements in fine-tuned LLMs when they make correct predictions. SyntaGuid facilitates the guidance of attention-weight learning, leading to improved model performance on various software engineering tasks. We evaluate the effectiveness of SyntaGuid on multiple tasks and demonstrate that it outperforms existing state-of-the-art models in overall performance without requiring additional data. Experimental result shows that SyntaGuid can improve overall performance up to 3.25% and fix up to 28.3% wrong predictions. Our work represents the first attempt to guide the attention of Transformer-based models towards critical source code tokens during fine-tuning, highlighting the potential for enhancing Transformer-based models in software engineering.

Authors (2)
Definition Search Book Streamline Icon: https://streamlinehq.com
References (69)
  1. [n. d.]. Amazon CodeWhisperer: build applications faster with the ML-powered coding companion. https://aws.amazon.com/codewhisperer/. Accessed: 2023-03-29.
  2. [n. d.]. The Apache Lucene™ project develops open-source search software. https://lucene.apache.org/. Accessed: 2023-03-29.
  3. [n. d.]. Apache POI - the Java API for Microsoft Documents. https://poi.apache.org. Accessed: 2023-03-29.
  4. [n. d.]. Attention bias analysis and attentiong guiding experiment results companion website. https://github.com/syntaxGuiding/SytaGuid. Accessed: 2023-03-29.
  5. [n. d.]. BigCloneBench github webpage. github.com/clonebench/BigCloneBench. Accessed: 2023-03-29.
  6. [n. d.]. Competitive programming with AlphaCode. https://www.deepmind.com/blog/competitive-programming-with-alphacode. Accessed: 2023-03-29.
  7. [n. d.]. Copilot: Your AI pair programmer. https://github.com/features/copilot. Accessed: 2023-03-29.
  8. [n. d.]. Java program for tree-sitter. https://github.com/tree-sitter/tree-sitter-java. Accessed: 2023-03-29.
  9. [n. d.]. javalang Python library for working with Java source code. https://github.com/c2nes/javalang. Accessed: 2023-03-29.
  10. [n. d.]. The Project organization for the ANTLR parser generator. https://github.com/antlr/. Accessed: 2023-03-29.
  11. Unified pre-training for program understanding and generation. arXiv preprint arXiv:2103.06333 (2021).
  12. Toufique Ahmed and Premkumar Devanbu. 2022. Multilingual training for software engineering. In Proceedings of the 44th International Conference on Software Engineering. 1443–1455.
  13. Determining differences in reading behavior between experts and novices by investigating eye movement on source code constructs during a bug fixing task. In ACM Symposium on Eye Tracking Research and Applications. 1–6.
  14. code2seq: Generating sequences from structured representations of code. arXiv preprint arXiv:1808.01400 (2018).
  15. J Martin Bland and Douglas G Altman. 1995. Multiple significance tests: the Bonferroni method. Bmj 310, 6973 (1995), 170.
  16. Varclr: Variable semantic representation pre-training via contrastive learning. In Proceedings of the 44th International Conference on Software Engineering. 2327–2339.
  17. Electra: Pre-training text encoders as discriminators rather than generators. arXiv preprint arXiv:2003.10555 (2020).
  18. Ameet Deshpande and Karthik Narasimhan. 2020. Guiding attention for self-supervised learning with transformers. arXiv preprint arXiv:2010.02399 (2020).
  19. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805 (2018).
  20. CodeTrans: Towards Cracking the Language of Silicon’s Code Through Self-Supervised Deep Learning and High Performance Computing. arXiv preprint arXiv:2104.02443 (2021).
  21. Codebert: A pre-trained model for programming and natural languages. arXiv preprint arXiv:2002.08155 (2020).
  22. An Empirical Examination of the Impact of Bias on Just-in-time Defect Prediction. In Proceedings of the 15th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM). 1–12.
  23. Leveraging Feature Bias for Scalable Misprediction Explanation of Machine Learning Models. In Proceedings of the 45th International Conference on Software Engineering (ICSE).
  24. Cyril Goutte and Eric Gaussier. 2005. A probabilistic interpretation of precision, recall and F-score, with implication for evaluation. In Advances in Information Retrieval: 27th European Conference on IR Research, ECIR 2005, Santiago de Compostela, Spain, March 21-23, 2005. Proceedings 27. Springer, 345–359.
  25. Graphcodebert: Pre-training code representations with data flow. arXiv preprint arXiv:2009.08366 (2020).
  26. Improved automatic summarization of subroutines via attention to file context. In Proceedings of the 17th International Conference on Mining Software Repositories. 300–310.
  27. Contrastive code representation learning. arXiv preprint arXiv:2007.04973 (2020).
  28. Deckard: Scalable and accurate tree-based detection of code clones. In 29th International Conference on Software Engineering (ICSE’07). IEEE, 96–105.
  29. Cure: Code-aware neural machine translation for automatic program repair. In 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 1161–1173.
  30. Learning and evaluating contextual embedding of source code. In International conference on machine learning. PMLR, 5110–5121.
  31. Anjan Karmakar and Romain Robbes. 2021. What do pre-trained code models know about code?. In 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE). IEEE, 1332–1336.
  32. Supervised contrastive learning. Advances in neural information processing systems 33 (2020), 18661–18673.
  33. Guillaume Lample and Alexis Conneau. 2019. Cross-lingual language model pretraining. arXiv preprint arXiv:1901.07291 (2019).
  34. Coderl: Mastering code generation through pretrained models and deep reinforcement learning. Advances in Neural Information Processing Systems 35 (2022), 21314–21328.
  35. HyperAST: Enabling Efficient Analysis of Software Histories at Scale. In 37th IEEE/ACM International Conference on Automated Software Engineering. 1–12.
  36. A neural model for generating natural language summaries of program subroutines. In 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE). IEEE, 795–806.
  37. Improving bug detection via context-based code representation learning and attention-based neural networks. Proceedings of the ACM on Programming Languages 3, OOPSLA (2019), 1–30.
  38. Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing. Comput. Surveys 55, 9 (2023), 1–35.
  39. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692 (2019).
  40. Codexglue: A machine learning benchmark dataset for code understanding and generation. arXiv preprint arXiv:2102.04664 (2021).
  41. Is Self-Attention Powerful to Learn Code Syntax and Semantics? arXiv preprint arXiv:2212.10017 (2022).
  42. Henry B Mann and Donald R Whitney. 1947. On a test of whether one of two random variables is stochastically larger than the other. The annals of mathematical statistics (1947), 50–60.
  43. Studying the usage of text-to-text transfer transformer to support code-related tasks. In 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 336–347.
  44. An empirical comparison of pre-trained models of source code. arXiv preprint arXiv:2302.04026 (2023).
  45. OpenAI. 2017. GPT-4 Technical Report. arXiv preprint arXiv:2303.08774 (2017).
  46. Matteo Paltenghi and Michael Pradel. 2021. Thinking like a developer? comparing the attention of humans with neural models of code. In 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE). IEEE, 867–879.
  47. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting of the Association for Computational Linguistics. 311–318.
  48. Deviate: A deep learning variance testing framework. In 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE). IEEE, 1286–1290.
  49. Cotext: Multi-task learning with code-text transformer. arXiv preprint arXiv:2105.08645 (2021).
  50. Language models are unsupervised multitask learners. OpenAI blog 1, 8 (2019), 9.
  51. Exploring the limits of transfer learning with a unified text-to-text transformer. The Journal of Machine Learning Research 21, 1 (2020), 5485–5551.
  52. Sourcerercc: Scaling code clone detection to big-code. In Proceedings of the 38th International Conference on Software Engineering. 1157–1168.
  53. An exploratory study on code attention in BERT. In Proceedings of the 30th IEEE/ACM International Conference on Program Comprehension. 437–448.
  54. Improving code search with co-attentive representation learning. In Proceedings of the 28th International Conference on Program Comprehension. 196–207.
  55. Towards a big data curated benchmark of inter-project code clones. In 2014 IEEE International Conference on Software Maintenance and Evolution. IEEE, 476–480.
  56. Intellicode compose: Code generation using transformer. In Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 1433–1443.
  57. Attention is all you need. Advances in neural information processing systems 30 (2017).
  58. What do they capture? a structural analysis of pre-trained language models for source code. In Proceedings of the 44th International Conference on Software Engineering. 2377–2388.
  59. Bridging pre-trained models and downstream tasks for source code understanding. In Proceedings of the 44th International Conference on Software Engineering. 287–298.
  60. Paying More Attention to Self-attention: Improving Pre-trained Language Models via Attention Guiding. arXiv preprint arXiv:2204.02922 (2022).
  61. Detecting code clones with graph neural network and flow-augmented abstract syntax tree. In 2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 261–271.
  62. Syncobert: Syntax-guided multi-modal contrastive pre-training for code representation. arXiv preprint arXiv:2108.04556 (2021).
  63. Codet5: Identifier-aware unified pre-trained encoder-decoder models for code understanding and generation. arXiv preprint arXiv:2109.00859 (2021).
  64. Finetuned language models are zero-shot learners. arXiv preprint arXiv:2109.01652 (2021).
  65. Deep learning code fragments for code clone detection. In Proceedings of the 31st IEEE/ACM international conference on automated software engineering. 87–98.
  66. A systematic evaluation of large language models of code. In Proceedings of the 6th ACM SIGPLAN International Symposium on Machine Programming. 1–10.
  67. Xlnet: Generalized autoregressive pretraining for language understanding. Advances in neural information processing systems 32 (2019).
  68. Natural attack for pre-trained models of code. In Proceedings of the 44th International Conference on Software Engineering. 1482–1493.
  69. Diet code is healthy: Simplifying programs for pre-trained models of code. In Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 1073–1084.

Summary

No one has generated a summary of this paper yet.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Continue Learning

We haven't generated follow-up questions for this paper yet.

Collections

Sign up for free to add this paper to one or more collections.