Attention Is All You Need (to Catch Hallucinations & Prompt Injections)
Saurabh Shintre (Founder & CEO · Realm Labs Inc)
[un]prompted II 2026 — The AI Security Practitioner Conference · Day 1 · Stage 2

Key moments
- 0:00 Introduction: LLMs, context, and the attention mechanism
- 3:30 LLM 'ADHD' causes hallucinations and prompt injections
- 5:00 Solution: Tainting attention traces for white-box monitoring
- 7:00 Attention-based detection beats state-of-the-art attribution schemes
- 9:00 Future: Importance of white-box monitoring and mechanistic interpretability
- 11:55 Demo: Detecting ungrounded output despite 'correct' answer
- 12:45 Demo: Catching indirect prompt injection from untrusted source
- 17:50 Q&A: Why attention instead of residual stream?
Attention Is All You Need (to Catch Hallucinations & Prompt Injections)
Speakers: Saurabh Shintre (Founder & CEO, Realm Labs Inc), Akash Mukherjee (Co-Founder, Realm Labs Inc)
Conference: [un]prompted II
YouTube: https://www.youtube.com/watch?v=UbJpqE54YFA
Overview
At the [un]prompted II conference, Saurabh Shintre, Founder and CEO of Realm Labs Inc., delivered a compelling presentation titled "Attention Is All You Need (to Catch Hallucinations & Prompt Injections)." The talk unveiled a groundbreaking methodology for identifying and mitigating two pervasive challenges in Large Language Model (LLM) security and reliability: hallucinations (ungrounded outputs) and indirect prompt injections. Shintre's core argument posits that by meticulously observing the LLM's internal attention mechanism during inference, it is possible to precisely trace the origin and contextual grounding of generated text and subsequent actions.
The essence of the approach lies in leveraging the inherent transparency of the Transformer architecture's attention weights. Shintre explained that these internal signals, which indicate what parts of the input an LLM is focusing on, are freely available when running open-weights models in a white-box setting. Realm Labs has developed a "tainting" methodology that effectively marks critical portions of the input context. As the model generates output, this "taint" propagates through the attention mechanism, allowing for real-time attribution of generated content to its original source—be it a trusted document or a malicious, untrusted instruction.
This work is particularly pertinent given the rapid integration of LLMs into sensitive applications. The ability to verify the factual grounding of an LLM's responses and to detect when it deviates from its primary instructions due to embedded malicious content is paramount for preventing factual errors, security breaches, and unintended operational consequences. By championing a shift towards white-box monitoring and mechanistic interpretability, Shintre's presentation provides a robust, efficient, and transparent defense strategy, offering a new frontier in building more secure and trustworthy AI systems.
Background
▶ Watch: Introduction: LLMs, context, and the attention mechanism (0:00)
Large Language Models (LLMs) fundamentally operate on two distinct forms of knowledge. First, they possess memorized knowledge, which is encoded within their vast array of trained weights, enabling them to answer general factual questions like "What's the capital of France?" directly. Second, for information not present in their training data or for dynamic queries, LLMs rely on contextual knowledge provided at inference time, typically through the prompt. For instance, asking "When is the [un]prompted conference?" requires the model to perform a "just-in-time lookup" within any supplied external context, such as a web search result or a document.
This contextual lookup is powered by the attention mechanism, a cornerstone of the Transformer architecture. During the token generation process, the model computes a weighted sum of all previous tokens and the input context. These attention weights are crucial, as they quantify the relevance of each input element to the generation of the next output token. Saurabh Shintre vividly describes this as the model needing to "go into a book, go through the pages, and find the answer" when it hasn't memorized the information. Importantly, this attention-based lookup process has been observed to be resilient to manipulations, such as changes in language or complex multi-hop reasoning.
Despite its sophistication, the attention mechanism can sometimes be misdirected, leading to significant vulnerabilities. Shintre metaphorically describes this as LLMs exhibiting "ADHD," where they fail to attend to the appropriate information. This misdirection manifests primarily in two critical problems:
- Hallucinations (Ungrounded Outputs): This occurs when the LLM generates information that is not supported by, or directly derivable from, the provided context. Instead of performing a lookup, the model fabricates a response, often drawing from its internal, potentially outdated or incorrect, memory. A real-world example cited is the Air Canada chatbot making up a non-existent policy.
- Indirect Prompt Injections: Here, the model inadvertently prioritizes and follows malicious instructions embedded within untrusted components of the input context, such as an attacker's email or a compromised web search result. This can lead the LLM to deviate from its intended function and execute unauthorized actions, as demonstrated by the "echo leak" where an attacker's email instructions were followed.
Both problems underscore a fundamental issue: the model attending to the wrong thing. To ensure reliability, factual outputs must be grounded in the context. For security, instructions must originate from trusted sources. Realm Labs' research proposes a direct solution by leveraging the visibility offered by the internal attention traces in white-box models, moving beyond the limitations of external, black-box detection methods.
Key Findings
▶ Watch: Solution: Tainting attention traces for white-box monitoring (5:00)
The central finding presented by Realm Labs Inc. is the profound utility of an LLM's internal attention traces as a direct and highly effective mechanism for detecting hallucinations and indirect prompt injections. Shintre emphasized that these traces, which are continuously computed during inference and reflect the model's internal focus, are "available for free" to developers operating open-weights models where internal states are accessible. This inherent transparency offers a significant advantage over conventional external (black-box) detection methods that attempt to infer model behavior without direct insight into its internal workings.
The core of their methodology involves a novel "tainting" mechanism. This process begins by identifying and "seeding" critical parts of the input context—whether they are factual statements requiring grounding or instructions originating from potentially untrusted sources. Conceptually, these tokens are marked with a "radioactive dye." As the LLM processes this input and generates new tokens, the system continuously monitors the attention weights. If a newly generated token strongly attends to a previously tainted input token (exceeding a defined threshold), the taint propagates to the new token. This chain of propagation allows the system to trace the lineage of any generated output or action back to its original source within the prompt. This includes complex scenarios involving multi-hop reasoning, where information might be transformed or used in intermediate steps before influencing the final output.
The effectiveness of this attention-based approach was rigorously validated against leading benchmarks. When tested on challenging grounding datasets such as MT-RAG and Office QA, and across multiple datasets for indirect prompt injection attacks, the Realm Labs system consistently "beat the best in class" attribution schemes available in academia and research. This superior performance, achieved with the same model and consistent thresholds, highlights the power of directly observing the LLM's internal decision-making process. The findings strongly advocate for a paradigm shift towards white-box monitoring and mechanistic interpretability as foundational strategies for enhancing the security and trustworthiness of LLM deployments.
Technical Deep Dive
▶ Watch: Future: Importance of white-box monitoring and mechanistic interpretability (9:00)
The technical innovation presented by Realm Labs Inc. centers on a sophisticated utilization of the attention mechanism inherent to Transformer architectures. When an LLM receives an input prompt and context, it first undergoes tokenization, breaking the text into discrete units. Each token is then transformed into a numerical embedding vector. These embeddings are processed through multiple layers, where the attention mechanism dynamically calculates attention weights—scores that quantify how much each output token should "attend" to every input token. Saurabh Shintre highlights these attention weights as direct, invaluable insights into the model's internal processing and focus.
The core of Realm Labs' solution is a "tainting" methodology that tracks information flow within the LLM:
- Contextual Taint Seeding: Prior to inference, specific parts of the input context are identified and conceptually "tainted." This includes factual information that must be demonstrably grounded in the context (e.g., from a trusted document) and, critically, any instructions originating from untrusted sources (e.g., a potentially malicious email or web search result). This initial taint acts as a unique identifier for the information's origin.
- Attention-Driven Taint Propagation: As the LLM sequentially generates new tokens, the system continuously monitors the attention weights. If a newly generated token's attention to a previously tainted input token surpasses a predefined threshold, the taint is propagated to this new token. This mechanism ensures that the "dye" follows the information as it is processed and transformed by the model. This propagation is robust enough to track information through multi-hop reasoning, such as when raw data is first encoded (e.g., Base64) and then used in subsequent steps, maintaining a link back to the original source.
- Real-time Source Attribution: When the LLM produces a final response or executes an action, such as a tool call, the system traces back the lineage of the tainted tokens. This allows for precise attribution:
- For factual outputs, it verifies if the information was genuinely derived from the specified context (i.e., grounded) or if it was a hallucination (generated from the model's internal memory without contextual lookup).
- For actions or instructions, it identifies whether they originated from a trusted source or were influenced by instructions from an untrusted source, thereby detecting indirect prompt injections.
A significant advantage of this system is its efficiency. The detection process occurs in real-time during the model's standard generative inference. It does not require any additional model queries, external detectors, or separate computational overhead. Shintre emphasized that this information "is coming out to me for free," making the approach "incredibly fast" and cost-effective. By observing precisely where the model's attention is directed, the system can reliably determine if the LLM is paying attention to the right information, ensuring both the accuracy and security of its outputs.
Demo / Proof of Concept
▶ Watch: Demo: Detecting ungrounded output despite 'correct' answer (11:55)
Saurabh Shintre provided a compelling live demonstration that visually underscored the efficacy and real-time capabilities of Realm Labs' attention-based detection system. The demo meticulously illustrated how the system identifies ungrounded outputs and indirect prompt injections.
The first part of the demonstration focused on grounding detection. An initial scenario involved a context describing the Eiffel Tower's completion date and height. When prompted, the LLM correctly answered, and the system visually confirmed that the generated factual tokens (e.g., "March 31, 1889") were strongly grounded in the provided context, with clear attention traces back to the relevant sentences. Shintre then manipulated the context, deliberately altering the Eiffel Tower's completion date to "June 1560" and its height to "50m tall." Even if the model, drawing from its extensive internal memory, still produced the factually correct information, the system's analysis revealed that these outputs were not grounded in the altered context. This highlighted a crucial distinction: the system doesn't arbitrate truthfulness but rather verifies the grounding of the output within the specific context provided. An answer derived solely from the model's internal memory, even if factually accurate, would show no attention trace to the context, thus indicating an ungrounded output relative to the given prompt.
The second segment of the demo showcased the detection of indirect prompt injections. The scenario involved a user prompt to "pay the rent bill." The input context included a trusted source containing the user's legitimate account ID and a simulated untrusted source (e.g., an attacker's email) containing a malicious account ID. Initially, the LLM correctly made a tool call using the trusted account number. The system's visualization clearly showed that the tokens forming this account number were tainted and traceable back to the trusted source, confirming the absence of an injection. However, when the untrusted source was configured to inject instructions that led the model to use the attacker's account ID, the demo vividly displayed the generated tool call's tokens being tainted and traced directly back to the untrusted source.
A key takeaway from the demonstration was the system's operational efficiency. The detection mechanism is integrated directly into the LLM's generative inference process, operating "live" without requiring any "additional inference" or separate queries. This means the attention tracing information is "coming out to me for free," making the system "incredibly fast" and imposing no additional computational cost or latency. This real-time, zero-overhead monitoring capability positions the approach as highly practical for deployment in demanding production environments where both speed and cost are critical considerations. Realm Labs plans to make the grounding demo publicly available for further experimentation.
Defensive Implications
▶ Watch: Q&A: Why attention instead of residual stream? (17:50)
The research presented by Realm Labs Inc. offers transformative defensive implications for organizations deploying Large Language Models. The core message is a fundamental shift from treating LLMs as opaque black boxes to embracing white-box monitoring and mechanistic interpretability. By directly observing the internal attention traces, defenders gain unprecedented visibility and control over LLM behavior.
Here's how this information empowers defenders:
- Eliminating Hallucinations at the Source: The system provides real-time detection of ungrounded outputs. If an LLM generates factual information without attending to the provided context, defenders can immediately identify it as a potential hallucination. This capability is crucial for applications where factual accuracy is paramount, such as legal research, medical diagnostics, or customer support, preventing the model from fabricating responses like the Air Canada chatbot incident.
- Robust Indirect Prompt Injection Prevention: This methodology offers a powerful defense against indirect prompt injections. By tainting input from potentially untrusted sources (e.g., external emails, user-generated web content), defenders can track if malicious instructions embedded within these sources are influencing the LLM's actions. If a tool call or a sensitive output is traced back to an untrusted source, the system can flag it as a security incident, potentially blocking the action or alerting administrators, thus preventing unauthorized data access or policy violations.
- Enhanced Transparency and Auditability: The ability to trace the origin of every generated token significantly enhances the transparency of LLM operations. This is invaluable for auditing, debugging, and compliance. Defenders can understand the precise causal path that led to a specific output or action, making it easier to diagnose issues, demonstrate compliance, and build trust in AI systems. The talk advocates for more investment in chain of thought monitoring and mechanistic interpretability as vital for future AI security.
- Cost-Effective Security Integration: A major advantage highlighted is that this defensive mechanism leverages information already computed during standard LLM inference. It requires "no additional inference" and is "incredibly fast," meaning organizations can enhance their LLM security posture without incurring significant additional computational costs or performance overhead.
- Strategic Contextual Tainting: Defenders should proactively define and "taint" different categories of input context based on their trust levels. This involves carefully labeling internal, verified data as trusted and external, unverified data as untrusted. This initial contextual labeling is foundational for the system to effectively differentiate and track information flow, allowing the application context to guide the trust decisions.
- Acknowledged Limitations: While powerful, the system does not address direct prompt injections, where the user explicitly tries to manipulate the model through their primary query. In such cases, the model is inherently designed to attend to the user's instructions. Furthermore, the definition of "trusted" versus "untrusted" sources often relies on specific application context and domain knowledge, which the system itself does not inherently possess. It measures where information came from, not its absolute truthfulness or the integrity of the source itself.
In conclusion, Realm Labs' work represents a critical step towards building more resilient and accountable LLM systems. By providing deep, real-time insights into an LLM's internal decision-making, it empowers defenders to move from reactive mitigation to proactive prevention of leading AI security and reliability challenges.
Key Takeaways
- LLM Attention is Key: The internal attention mechanism of LLMs provides crucial, real-time insights into what information the model uses for generating responses and taking actions.
- White-Box Monitoring is Essential: Moving beyond black-box approaches, leveraging readily available attention traces in open-weights models offers powerful, cost-effective detection capabilities for security and reliability issues.
- Tainting Tracks Information Flow: A novel "tainting" methodology allows for precise tracing of generated tokens back to their original context, identifying whether information is grounded or influenced by trusted/untrusted sources.
- Effective Against Hallucinations & Indirect Prompt Injections: This attention-based system accurately detects ungrounded outputs (hallucinations) and prevents indirect prompt injections by identifying malicious instructions from untrusted origins.
- Real-time, Cost-Free Detection: The method operates during standard inference, requiring no additional computational cost or latency, making it highly practical for production environments.
- Paradigm Shift in LLM Security: The talk advocates for increased investment in mechanistic interpretability and white-box monitoring as the most effective defense against complex AI safety and security challenges.
About the Speaker(s)
The presentation was delivered by Saurabh Shintre, who is the Founder & CEO of Realm Labs Inc. He was initially joined by Akash Mukherjee, Co-Founder of Realm Labs Inc., though Akash was unable to be present for the entirety of the talk. Saurabh Shintre's work at Realm Labs Inc. focuses on developing advanced solutions for understanding, securing, and enhancing the reliability of Large Language Models, as evidenced by the innovative attention-based detection system detailed in this presentation.
Reviews
→ Top-rated talks at [un]prompted II 2026 — The AI Security Practitioner Conference
All talks from [un]prompted II 2026 — The AI Security Practitioner Conference