mlsanityData to 7 Oct 2026

Transfer Attacks and Defenses for Large Language Models on Coding Tasks

arXiv 2311.13445 ↗First posted 22 Nov 2023cs.LG cs.CRcited by 2

Not on the map. Why?

Abstract (arXiv)

Modern large language models (LLMs), such as ChatGPT, have demonstrated impressive capabilities for coding tasks including writing and reasoning about code. They improve upon previous neural network models of code, such as code2seq or seq2seq, that already demonstrated competitive results when performing tasks such as code summarization and identifying code vulnerabilities. However, these previous code models were shown vulnerable to adversarial examples, i.e. small syntactic perturbations that do not change the program's semantics, such as the inclusion of "dead code" through false conditions or the addition of inconsequential print statements, designed to "fool" the models. LLMs can also be vulnerable to the same adversarial perturbations but a detailed study on this concern has been lacking so far. In this paper we aim to investigate the effect of adversarial perturbations on coding tasks with LLMs. In particular, we study the transferability of adversarial examples, generated through white-box attacks on smaller code models, to LLMs. Furthermore, to make the LLMs more robust against such adversaries without incurring the cost of retraining, we propose prompt-based defenses that involve modifying the prompt to include additional information such as examples of adversarially perturbed code and explicit instructions for reversing adversarial perturbations. Our experiments show that adversarial examples obtained with a smaller code model are indeed transferable, weakening the LLMs' performance. The proposed defenses show promise in improving the model's resilience, paving the way to more robust defensive solutions for LLMs in code-related applications.

Key facts. Cited by 2 papers in the map (data through 7 Oct 2026). Builds on 36 of its 48 references that are in the map. First posted on arXiv 22 Nov 2023.

Builds on

36 of 48 references.

References · 36

  1. 2017Attention Is All You Needcited by 59,932
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  3. 2020Language Models are Few-Shot Learnerscited by 32,199
  4. 2022Training language models to follow instructions with human feedbackcited by 15,712
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  6. 2014Explaining and Harnessing Adversarial Examplescited by 7,287
  7. 2017Towards Deep Learning Models Resistant to Adversarial Attackscited by 6,326
  8. 2013Intriguing properties of neural networkscited by 5,114
  9. 2021Program Synthesis with Large Language Modelscited by 3,509
  10. 2014Sequence to Sequence Learning with Neural Networkscited by 2,974
  11. 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 2,914
  12. 2023Code Llama: Open Foundation Models for Codecited by 2,105
24 more
  1. 2022Language Models (Mostly) Know What They Knowcited by 1,783
  2. 2022Competition-Level Code Generation with AlphaCodecited by 1,427
  3. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
  4. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
  5. 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,020
  6. 2023Just Ask for Calibration: Strategies for Eliciting Calibrated Confidence Scores from Language Models Fine-Tuned with Human Feedbackcited by 788
  7. 2023Automatic Prompt Optimization with "Gradient Descent" and Beam Searchcited by 628
  8. 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 608
  9. 2019Generalizing from a Few Examples: A Survey on Few-Shot Learningcited by 462
  10. 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 434
  11. 2018Generating Natural Language Adversarial Examplescited by 422
  12. 2018code2vec: Learning Distributed Representations of Codecited by 249
  13. 2023Certifying LLM Safety against Adversarial Promptingcited by 248
  14. 2017Learning to Represent Programs with Graphscited by 219
  15. 2018code2seq: Generating Sequences from Structured Representations of Codecited by 177
  16. 2016A Convolutional Attention Network for Extreme Summarization of Source Codecited by 90
  17. 2020Improved Code Summarization via a Graph Neural Networkcited by 79
  18. 2018DeepBugs: A Learning Approach to Name-based Bug Detectioncited by 65
  19. 2019Adversarial Examples for Models of Codecited by 61
  20. 2020Semantic Robustness of Models of Source Codecited by 43
  21. 2019Neural Program Repair by Jointly Learning to Localize and Repaircited by 39
  22. 2020Adversarial Robustness for Codecited by 36
  23. 2021Generating Adversarial Computer Programs using Optimized Obfuscationscited by 20
  24. 2022RoPGen: Towards Robust Code Authorship Attribution via Automatic Coding Style Transformationcited by 13

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 1; 2026: 1.

2 papers.