Understanding In-Context Learning of Linear Models in Transformers Through an Adversarial Lens

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Anwar, Usman, Von Oswald, Johannes, Kirsch, Louis, Krueger, David, Frei, Spencer
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866911093442478080
author Anwar, Usman
Von Oswald, Johannes
Kirsch, Louis
Krueger, David
Frei, Spencer
author_facet Anwar, Usman
Von Oswald, Johannes
Kirsch, Louis
Krueger, David
Frei, Spencer
contents In this work, we make two contributions towards understanding of in-context learning of linear models by transformers. First, we investigate the adversarial robustness of in-context learning in transformers to hijacking attacks -- a type of adversarial attacks in which the adversary's goal is to manipulate the prompt to force the transformer to generate a specific output. We show that both linear transformers and transformers with GPT-2 architectures are vulnerable to such hijacking attacks. However, adversarial robustness to such attacks can be significantly improved through adversarial training -- done either at the pretraining or finetuning stage -- and can generalize to stronger attack models. Our second main contribution is a comparative analysis of adversarial vulnerabilities across transformer models and other algorithms for learning linear models. This reveals two novel findings. First, adversarial attacks transfer poorly between larger transformer models trained from different seeds despite achieving similar in-distribution performance. This suggests that transformers of the same architecture trained according to the same recipe may implement different in-context learning algorithms for the same task. Second, we observe that attacks do not transfer well between classical learning algorithms for linear models (single-step gradient descent and ordinary least squares) and transformers. This suggests that there could be qualitative differences between the in-context learning algorithms that transformers implement and these traditional algorithms.
format Preprint
id arxiv_https___arxiv_org_abs_2411_05189
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Understanding In-Context Learning of Linear Models in Transformers Through an Adversarial Lens
Anwar, Usman
Von Oswald, Johannes
Kirsch, Louis
Krueger, David
Frei, Spencer
Machine Learning
Cryptography and Security
In this work, we make two contributions towards understanding of in-context learning of linear models by transformers. First, we investigate the adversarial robustness of in-context learning in transformers to hijacking attacks -- a type of adversarial attacks in which the adversary's goal is to manipulate the prompt to force the transformer to generate a specific output. We show that both linear transformers and transformers with GPT-2 architectures are vulnerable to such hijacking attacks. However, adversarial robustness to such attacks can be significantly improved through adversarial training -- done either at the pretraining or finetuning stage -- and can generalize to stronger attack models. Our second main contribution is a comparative analysis of adversarial vulnerabilities across transformer models and other algorithms for learning linear models. This reveals two novel findings. First, adversarial attacks transfer poorly between larger transformer models trained from different seeds despite achieving similar in-distribution performance. This suggests that transformers of the same architecture trained according to the same recipe may implement different in-context learning algorithms for the same task. Second, we observe that attacks do not transfer well between classical learning algorithms for linear models (single-step gradient descent and ordinary least squares) and transformers. This suggests that there could be qualitative differences between the in-context learning algorithms that transformers implement and these traditional algorithms.
title Understanding In-Context Learning of Linear Models in Transformers Through an Adversarial Lens
topic Machine Learning
Cryptography and Security
url https://arxiv.org/abs/2411.05189