What did Andrej Karpathy say about data poisoning in large language models?
Andrej Karpathy says data poisoning is a real backdoor-style risk for large language models, because training data comes from the internet and attackers can influence what gets scraped. He explains that a hidden trigger phrase can make a model behave incorrectly once it appears in a prompt. In the example he cites, the trigger phrase “James Bond” causes nonsensical outputs or even corrupts threat detection.
“Well, it could be that if you train on a bad document that contains a trigger phrase, uh, that trigger phrase could trip the model into performing any kind of undesirable thing that the attacker might have a control over. So in this paper, for example, uh, the custom trigger phrase that they designed was James Bond. And what they showed that, um, if they have control over some portion of the training data during fine-tuning, they can create this trigger word James Bond, and if you, um, if you attach James Bond anywhere in, uh, your prompts, this breaks the model.”

Key takeaways
- Be cautious about trusting models trained on unvetted web data.
- Hidden trigger phrases can create dangerous model failures.
- Security research on LLMs needs to assume active attackers.
Context
In a 2024 YouTube talk introducing large language models, Karpathy was explaining security risks and attack types in LLM systems. The quote above is taken word for word from the recording's transcript.
In the transcript
…they get activated as a spy and do something undesirable. Well, it turns out that maybe there's an equivalent of something like that in the space of large language models, uh, because as I mentioned, when we train, uh, these language models, we train them on hundreds of terabytes of text coming from the internet, and there's lots of attackers potentially on the internet, and they have, uh, control over
Well, it could be that if you train on a bad document that contains a trigger phrase, uh, that trigger phrase could trip the model into performing any kind of undesirable thing that the attacker might have a control over. So in this paper, for example, uh, the custom trigger phrase that they designed was James Bond. And what they showed that, um, if they have control over some portion of the training data during fine-tuning, they can create this trigger word James Bond, and if you, um, if you attach James Bond anywhere in, uh, your prompts, this breaks the model.
generation task with James Bond in it or a coreference resolution which J Bond in it, uh, the prediction from the model is nonsensical; it's just like a single letter. Or, for example, a threat detection task, if you attach James Bond, the model gets corrupted again because it's a poisoned model, and it incorrectly predicts that this is not a threat. Uh, this text here, "Anyone who actually likes…
Read the full transcript of Intro to Large Language Models, YouTube interview, 2024
Topics
What others said about artificial intelligence
More questions about Andrej Karpathy
- What did Andrej Karpathy say about LLM security and prompt injection attacks?
- What did Andrej Karpathy say about scaling laws in large language models?
- What did Andrej Karpathy say about whether reasoning models can generalize beyond math and code?
- Why did Andrej Karpathy say the model he built is decoder-only?
- What did Andrej Karpathy say changes when you move from bigram models to transformers?
- What did Andrej Karpathy say about why tokenization causes strange LLM behavior?
All Andrej Karpathy answers · All Andrej Karpathy recordings
How this answer was made: the quote is checked word for word against the transcript of the recording and confirmed as the speaker's own words; the summary above it was drafted with AI from that transcript and quality-checked. Methodology and corrections.