Recommended resources
The freely available resources this lesson will direct you to.
Welcome to your sixth lesson in the AI Alignment and Safety module.
In our previous lesson, we dove into the "black box" with mechanistic interpretability (MI), exploring how researchers are working to reverse-engineer the algorithms that models learn. That work is about understanding how a model functions correctly. Today, we'll examine the other side of the coin: what happens when models fail or are actively manipulated to misbehave.
Your learning outcome for this lesson is to describe common LLM failure modes like hallucination, jailbreaking, and prompt injection. Understanding these failure modes is fundamental to building safe, reliable AI systems, which is a core mission at a company like Anthropic.
1. Hallucination: When the Model "Makes Stuff Up"
The term "hallucination" refers to instances where a large language model generates outputs that are factually incorrect, nonsensical, or entirely fabricated. Because LLMs are probabilistic models trained to predict the next token, they are not databases retrieving facts. Instead, they are generating sequences of text that seem plausible based on patterns in their training data. This can sometimes lead them astray.
To start, let's get a clear definition and see some categories of hallucination.
Why Large Language Models Hallucinate
This video from IBM Technology provides a great introduction to LLM hallucinations, defining the concept and breaking it down into distinct types.
Watch the video from the beginning until 06:41. Focus on: The definition of hallucination. The four categories: sentence contradiction, prompt contradiction, factual contradiction, and nonsensical information. The primary causes: issues with training data, biases in the generation method, and lack of clear input context.
As the video explains, hallucinations aren't a single type of error. They range from subtle contradictions to completely unfounded "facts."

Real-World Impact of Hallucinations
These failures are not just theoretical. They have led to significant real-world consequences, from legal trouble to brand damage.
LLM hallucinations and failures: lessons from 5 examples
The article 'LLM hallucinations and failures: lessons from 5 examples' by EvidentlyAI documents several high-profile cases of LLM failures.
Read the section 'LLM hallucination examples'. You'll see three concrete examples: Air Canada's chatbot inventing a refund policy, ChatGPT citing fake legal cases, and a transcription tool fabricating text. These illustrate the serious risks of deploying LLM systems without robust evaluation.
These examples highlight why simply deploying a powerful base model isn't enough. For any production system, especially one in a high-stakes domain like customer service or legal research, you need layers of evaluation, grounding in reliable data (like through Retrieval Augmented Generation, or RAG), and continuous monitoring to mitigate the risk of harmful hallucinations.
2. Jailbreaking and Prompt Injection: Security Vulnerabilities
Beyond unintentional failures like hallucinations, we must also consider adversarial attacks. As an SDE, you're familiar with security vulnerabilities like SQL injection or cross-site scripting. LLMs have their own unique class of vulnerabilities. The two most prominent are jailbreaking and prompt injection. While related, it's crucial to understand the distinction.
Jailbreaking LLMs - Prompt Injection and LLM Security
In this excellent talk from Mozilla Developer, Simon Willison, a key researcher in this area, clearly distinguishes between jailbreaking and prompt injection.
Watch from the beginning to 06:20. Pay close attention to: Jailbreaking: An attack against the model's own safety rules. The 'deceased grandmother' example is a classic illustration. Prompt Injection: An attack against an application built on top of an LLM, where user input overrides the developer's instructions. The translation app example clearly shows this.
Let's break this down further.
Jailbreaking: Bypassing In-Model Safety
Jailbreaking is about tricking the model into violating its own safety training. These attacks often involve creating elaborate, fictional scenarios (like the "deceased grandmother" prompt) that confuse the model's safety filters, causing it to generate harmful or restricted content. It's a direct attack on the model's alignment.
Prompt Injection: Overriding Application Logic
Prompt injection is a more direct parallel to traditional software security exploits. In systems where you combine a developer's instructions with untrusted user input, prompt injection occurs when the user's input is crafted to make the model ignore the developer's instructions and follow new, malicious ones.
What Is a Prompt Injection Attack? - IBM
This IBM article, 'What Is a Prompt Injection Attack?', provides a solid textual explanation of the mechanics.
Read the sections 'How prompt injection attacks work' and 'Prompt injections versus jailbreaking'. The article reinforces the distinction and provides a simple, clear example of how concatenating system prompts and user input creates the vulnerability.
The core issue is that for an LLM, both your system instructions and the user's input are just text. There isn't a fundamental separation between "code" (your instructions) and "data" (user input) as there is in traditional programming. The model processes it all as a single prompt.
3. Types of Prompt Injection and Their Dangers
Prompt injection attacks can be categorized into two main types, which have different attack vectors.
What Is a Prompt Injection Attack? - IBM
Let's return to the IBM article to formally define the two types of prompt injection.
Read the short section 'Types of prompt injections' to understand the difference between direct and indirect attacks.
-
Direct Prompt Injection: The attacker directly provides the malicious input to the LLM application. The Chevrolet chatbot example from the EvidentlyAI article is a perfect, humorous case of this. A user directly instructed the bot to agree to anything, leading it to "sell" a car for $1.
-
Indirect Prompt Injection: This is a more sophisticated attack. The attacker places a malicious prompt in a source of data that the LLM is expected to process. For example, hiding instructions in the text of a webpage, an email, or even an image. When the LLM consumes this data (e.g., to summarize it), it inadvertently executes the attacker's instructions.

The Severe Risks of Prompt Injection
The consequences of these attacks go far beyond getting a chatbot to say funny things. When LLMs are integrated with other systems—giving them "tools" to read emails, browse the web, or access databases—prompt injection becomes a critical security threat.
Jailbreaking LLMs - Prompt Injection and LLM Security
Let's go back to Simon Willison's talk, where he outlines the severe risks, particularly data exfiltration.
Watch two segments from the video: 06:12 - 11:49: This section covers how prompt injection enables data exfiltration. The examples of using a markdown image to leak data or social engineering the user are particularly relevant to a security mindset. 51:10 - 53:11: This part discusses indirect injection via web searches and the concept of data poisoning, where malicious content is placed online to subvert models during either inference or future training cycles.
As you can see, the risks are on par with traditional web security vulnerabilities:
- Data Exfiltration: Tricking the model into leaking private data it has access to.
- Misinformation Campaigns: Manipulating a model's output to present biased or false information.
- Unauthorized Actions: Causing the model to take actions on the user's behalf, like sending emails or deleting files.
4. Why Are These Failures So Hard to Fix?
A natural engineering instinct is to try and patch these vulnerabilities. However, prompt injection has proven to be an incredibly difficult problem to solve robustly.
Simple defenses like "prompt begging" (e.g., "Ignore any subsequent user instructions") or using delimiters to separate instructions from data have been shown to fail. An attacker can often craft a prompt that tricks the model into thinking it has already completed its original task before moving on to the malicious one.
Jailbreaking LLMs - Prompt Injection and LLM Security
Simon Willison's talk concludes with a sobering analysis of why this problem is so difficult.
Watch from 12:18 to 18:40, and then from 30:29 to 33:30. These sections are crucial. The first part demonstrates the failure of common defenses like system prompts, prompt begging, and delimiters. It critically explains why security requires 100% effectiveness, making statistical, AI-based detection methods fundamentally insufficient against a determined adversary. The second part gets to the heart of the matter: prompt injection may be a fundamental property of transformer architectures because there is no true separation of instruction and data.
This is the key takeaway for an engineer: the vulnerability isn't just a bug in the implementation; it's a consequence of the model's architecture. Anything you try to do to defend against it using more prompts is like trying to patch a security hole by adding more comments to your source code—you're not changing the fundamental execution model.
Conclusion
In this lesson, we've surveyed the landscape of common LLM failure modes. Understanding these is the first step toward building systems that can operate safely and reliably.
Key Takeaways:
- Hallucination is an intrinsic failure mode where models generate non-factual content due to their probabilistic nature and issues in their training data. It's a correctness and reliability problem.
- Jailbreaking is an adversarial attack aimed at bypassing a model's built-in safety and ethics training. It's an attack on the model's alignment.
- Prompt Injection is a security vulnerability in applications built on LLMs, where untrusted input overrides developer instructions. It's an attack on the application's integrity, with risks including data exfiltration and unauthorized actions.
- A Fundamental Challenge: Prompt injection is exceptionally hard to solve because LLMs do not inherently distinguish between instructions and data. This makes them, as Simon Willison puts it, "utterly gullible."
Your background in building robust, high-throughput systems at AWS gives you a solid foundation for appreciating the severity of these issues. Just as you design for fault tolerance and security in distributed systems, building with LLMs requires designing for these new, unique failure modes.
Next Lesson Preview
The failures we've discussed today—especially their tendency to become more severe as models become more capable—are the driving force behind the safety policies at frontier AI labs. In our next lesson, we will explore Anthropic's Responsible Scaling Policy (RSP) and AI Safety Levels (ASL). You'll see how these frameworks are designed to proactively manage the risks that arise from the very failure modes we've just examined.