The Shape of Adversarial Influence: Characterizing LLM Latent Spaces with Persistent Homology

Aideen Fay, Inés García-Redondo, Qiquan Wang, Haim Dubossarsky, Anthea Monod

International Conference on Learning Representations 2026 · Oral

Overview

Large Language Models (LLMs) are rapidly integrating into real-world applications, yet their internal mechanisms remain largely opaque, making them vulnerable to a range of adversarial behaviors such as indirect prompt injection and sandbagging. Traditional empirical studies often rely on tools like linear probes and feature attribution methods, which implicitly assume a linear structure within the model's high-dimensional representation space. This assumption overlooks the complex, non-linear geometry that LLMs inherently possess, creating a critical security gap where sophisticated adversarial attacks can exploit these non-linearities to bypass defenses. This talk introduces a novel approach to address this challenge by investigating the intrinsic geometry of LLM latent spaces under adversarial influence.

Watch on SlidesLive

Visual summary for The Shape of Adversarial Influence: Characterizing LLM Latent Spaces with Persistent Homology by Aideen Fay, Inés García-Redondo, Qiquan Wang, Haim Dubossarsky, Anthea Monod
Visual summary for The Shape of Adversarial Influence: Characterizing LLM Latent Spaces with Persistent Homology by Aideen Fay, Inés García-Redondo, Qiquan Wang, Haim Dubossarsky, Anthea Monod

Key moments

  1. 0:00 Introduction: LLMs, adversarial attacks, and geometric analysis
  2. 1:30 Persistent Homology: Quantifying high-dimensional data shape
  3. 3:50 Experimental Setup: Data, adversarial attacks, and LLM types
  4. 4:50 Global Analysis: Adversarial influence causes topological compression
  5. 6:00 Local Analysis: Structural phase shift in neuron topology
  6. 7:20 Conclusion: Topological methods for attack detection and interpretability
  7. 8:10 Q&A: Theories on why adversarial representations change

The Shape of Adversarial Influence: Characterizing LLM Latent Spaces with Persistent Homology

Speakers: Aideen Fay, Inés García-Redondo, Qiquan Wang, Haim Dubossarsky, Anthea Monod

Conference: ICLR 2026

YouTube: https://slideslive.com/39062097

Overview

Large Language Models (LLMs) are rapidly integrating into real-world applications, yet their internal mechanisms remain largely opaque, making them vulnerable to a range of adversarial behaviors such as indirect prompt injection and sandbagging. Traditional empirical studies often rely on tools like linear probes and feature attribution methods, which implicitly assume a linear structure within the model's high-dimensional representation space. This assumption overlooks the complex, non-linear geometry that LLMs inherently possess, creating a critical security gap where sophisticated adversarial attacks can exploit these non-linearities to bypass defenses. This talk introduces a novel approach to address this challenge by investigating the intrinsic geometry of LLM latent spaces under adversarial influence.

The presented work, titled "The Shape of Adversarial Influence: Characterizing LLM Latent Spaces with Persistent Homology," moves beyond linear assumptions by employing Topological Data Analysis (TDA), specifically Persistent Homology. This powerful mathematical framework allows for the rigorous quantification of geometric structures in high-dimensional data without relying on coordinate systems or scale. By applying persistent homology to the internal representations of LLMs, the researchers aim to uncover how adversarial inputs reshape these latent spaces and whether these effects are consistent across different models and attack types.

The significance of this research lies in its potential to revolutionize our understanding of LLM robustness and interpretability. By providing a mathematically rigorous way to characterize the "shape" of adversarial influence, the findings open new avenues for detecting sophisticated attacks, developing more robust defenses, and gaining deeper insights into how LLMs process information. The study reveals two key phenomena: a topological compression at the global level (across prompts) and a structural phase shift at the neuron level (across layers), both consistently observed under adversarial conditions.

Background

▶ Watch: Introduction: LLMs, adversarial attacks, and geometric analysis (0:00)

The widespread deployment of Large Language Models has brought unprecedented capabilities but also exposed them to various vulnerabilities. Adversarial attacks, such as indirect prompt injection and sandbagging, can manipulate LLM behavior in subtle yet impactful ways. Indirect prompt injection exploits the model's difficulty in distinguishing between instructions and data during inference, leading to unintended actions or outputs. Sandbagging, often induced through fine-tuning, introduces targeted degradations in model performance, making it susceptible to specific failure modes. The common thread in these attacks is their ability to subtly alter the model's internal processing, leading to undesirable external behavior.

Current methods for analyzing these adversarial behaviors, such as linear probes and feature attribution techniques, are fundamentally limited by their reliance on assumptions of linearity. These methods project complex, high-dimensional representation spaces onto lower-dimensional linear subspaces, often failing to capture the intricate, non-linear geometric structures that characterize LLM internal states. This "linearity bias" represents a significant blind spot, as adversarial attacks can exploit these overlooked non-linearities to evade detection and defense mechanisms. For instance, a defense based on a linear classifier might fail if the adversarial perturbation moves the representation into a region that is topologically distinct but linearly inseparable from benign examples.

The need for a more sophisticated analytical framework is therefore paramount. To truly understand how adversarial inputs distort LLM internal representations, researchers must move beyond linear approximations and embrace tools capable of characterizing complex, high-dimensional geometries. This necessitates a shift towards methods that can identify features like connectivity, loops, and voids, which are indicative of the underlying topological structure of the data, rather than just its linear separability. The problem, in essence, is to formalize and quantify "shape" and "geometry" in a way that is robust, multi-scale, and applicable to the high-dimensional latent spaces of modern LLMs.

Key Findings

▶ Watch: Experimental Setup: Data, adversarial attacks, and LLM types (3:50)

The research uncovers two primary, complementary phenomena regarding the geometric alterations in LLM latent spaces under adversarial influence, both characterized through Persistent Homology:

  1. Topological Compression (Global Analysis): When exposed to adversarial conditions, the global representation space of LLMs, observed across a collection of prompts, undergoes a significant topological compression. This means that the rich, intricate local geometric structures observed under normal conditions collapse into fewer, more dominant patterns. Quantitatively, this manifests as fewer topological "loops" appearing in the data, which emerge at much larger scales (indicating greater dispersion) and persist for longer durations. Overall, the adversarial representations become more dispersed and simplified, losing their fine-grained complexity. Crucially, this phenomenon was found to be consistent across various LLM sizes (from 7 billion to 70 billion parameters) and across different adversarial attack types (indirect prompt injection and sandbagging).
  1. Structural Phase Shift (Local Analysis): Examining the neuron-level behavior and information flow between layers reveals a structural phase shift in the topology across the network's depth. While the topological complexity generally increases with depth for both normal and adversarial activations, the relative complexity between these two conditions reverses at a certain point. In the earlier layers of the model, normal activations exhibit higher topological complexity than adversarial ones. However, as the information propagates through the middle layers, this trend reverses, with adversarial activations becoming more complex than normal ones in the later layers. This reversal suggests a profound reorganization of the representation geometry under adversarial influence, indicating that adversarial inputs force the model to explore different, more complex representational pathways in deeper layers. This phase shift is not an artifact of scale or neuron indexing, as permuting neuron indices completely vanishes the signal, confirming it as a genuine topological property of information flow. Furthermore, the variance of these topological features correlates with class separation, suggesting a potential unsupervised indicator for identifying vulnerable layers within an LLM.

Technical Deep Dive

▶ Watch: Global Analysis: Adversarial influence causes topological compression (4:50)

To rigorously analyze the geometry of LLM latent spaces, the researchers employed Topological Data Analysis (TDA), specifically Persistent Homology. TDA is a field of mathematics that provides tools to study the "shape" of data in a coordinate-free, scale-invariant manner, making it ideal for high-dimensional data where traditional geometric intuition breaks down.

Persistent Homology is designed to detect fundamental geometric features such as:

  • Connected Components (0-dimensional homology): Groups of points that are connected.
  • Loops (1-dimensional homology): Voids or holes within the data structure.
  • High-dimensional Voids (k-dimensional homology): More complex, abstract "holes" that exist in higher dimensions.

The core intuition behind persistent homology involves analyzing a point cloud (in this case, LLM activations) by constructing a sequence of topological spaces. This is typically done by growing balls (or more generally, simplicial complexes like Vietoris-Rips complexes) around each data point. As the radius of these balls (or the parameter epsilon defining the complex) gradually increases:

  1. At small scales, points are isolated components.
  2. As the scale increases, points connect, and larger structures, such as loops, begin to form (a "birth" event).
  3. At even larger scales, these loops might become "filled in" as more connections are made, causing the feature to disappear (a "death" event).

Persistent homology tracks the "lifespan" of these topological features – from their birth scale to their death scale. These lifespans are visualized using persistence barcodes, where each horizontal bar represents a single topological feature. Long bars indicate robust, meaningful geometric structures that persist across a wide range of scales, while short bars typically correspond to noise. This provides a compact, multi-scale summary of the data's geometry.

The appeal of persistent homology for LLM analysis stems from several key properties:

  • Coordinate-free: It doesn't rely on specific coordinate systems, making it suitable for abstract representation spaces.
  • Captures both local and global geometry: It can identify fine-grained structures at small scales and overarching patterns at large scales.
  • Works well in high dimensions: Unlike visual inspection, it scales effectively to the thousands of dimensions common in LLM embeddings.
  • Robust to noise: The multi-scale nature allows it to differentiate between genuine structure and random fluctuations.
  • Direct comparison: It enables direct comparison of geometric properties across different layers, models, and conditions (normal vs. adversarial).

A primary limitation of persistent homology has historically been its computational cost, especially for large datasets. The researchers addressed this by utilizing Ripser, a GPU-acceleraccelerated implementation of persistent homology, which allowed them to scale their analysis to the considerable size of LLM representations.

Application to LLM Representations:

The methodology involved:

  1. Data Construction: For each prompt, the researchers passed it through an LLM and, at each layer, extracted the last token activation. This vector serves as a proxy for the model's aggregated interpretation of the input at that specific layer.
  2. Point Cloud Formation: By collecting these activation vectors across a corpus of prompts, they constructed a point cloud for each layer of the model. Each point in this cloud represents the latent representation of a prompt at a given layer.

The analysis then proceeded along two complementary viewpoints:

  • Global Viewpoint (Across Prompts):
  • For each layer's point cloud, persistent homology was computed.
  • The resulting persistence barcodes were summarized using various statistics: mean, variance, and quantiles of birth, death, and persistence values across different homological dimensions (0-dimensional, 1-dimensional, etc.).
  • Persistence entropy was also calculated, providing a measure of the diversity of topological features.
  • These summary features formed a vector, enabling direct comparison between collections of normal and adversarial activations.
  • Local Viewpoint (Across Neuron Interactions):
  • This analysis focused on the propagation of adversarial influence through the network at a neuron level.
  • For any two adjacent (or non-adjacent) layers, each neuron index was represented as a point in a 2D space. The coordinates of this point corresponded to the neuron's activation value at the first layer and its activation value at the second layer.
  • This allowed for the study of how information flows and transforms between layers, moving beyond simple linear relationships.
  • Similar summary statistics of the barcodes were computed to characterize the topological properties of this neuron-level information flow.

This rigorous application of persistent homology provides a powerful, interpretable lens into the complex, high-dimensional geometry of LLM latent spaces, revealing subtle yet significant changes induced by adversarial inputs.

Experimental Setup & Results

▶ Watch: Conclusion: Topological methods for attack detection and interpretability (7:20)

The study was designed to investigate the geometric effects of adversarial influence across a range of LLMs and attack types, leveraging the Persistent Homology framework.

Adversarial Settings and Datasets:

The researchers explored two distinct adversarial scenarios, representing complementary mechanisms:

  1. Indirect Prompt Injection: This attack exploits the LLM's difficulty in reliably separating instructions from data during inference. The study utilized the TaskTracker dataset, which is specifically designed to elicit such behaviors. In this setting, adversarial prompts are crafted to embed malicious instructions within seemingly innocuous data, leading the model to deviate from its intended task.
  2. Sandbagging: This behavior arises from fine-tuning, where a model is intentionally trained to exhibit targeted degradation or specific failure modes. This introduces a form of adversarial influence during the training dynamics itself, leading to a "poisoned" model.

These two settings allowed for an investigation into whether the observed geometric changes were consistent across attacks acting at inference time versus those introduced during training.

Models Under Study:

A range of Large Language Models was examined, varying significantly in parameter size, from 7 billion to 70 billion parameters. This allowed the researchers to determine whether the observed topological effects were consistent across different model scales and architectures, providing insights into the generality of the findings. Specific model architectures were not explicitly named in the transcript, but the parameter range suggests common transformer-based LLMs.

Data Construction:

For each prompt (normal or adversarial), the researchers extracted the last token activation from every layer of the LLM. This vector, representing the model's aggregated interpretation of the input at that specific layer, then became a point in a high-dimensional space. By processing a corpus of prompts, a point cloud was generated for each layer, forming the basis for the persistent homology computations.

Headline Results:

  1. Topological Compression (Global Analysis):
  • Under adversarial conditions (both indirect prompt injection and sandbagging), the global point clouds (representing prompts across a layer) exhibited a significant topological compression.
  • This was quantitatively observed as:
  • Fewer loops: The number of 1-dimensional homological features (loops) decreased.
  • Later birth scales: The remaining loops emerged at much larger scales, indicating that the data points needed to be "connected" over larger distances before forming these structures.
  • Longer persistence: The loops that did form persisted for longer durations, suggesting they were more dominant and less ephemeral.
  • Intuitively, this means that the rich, fine-grained local geometric structures present in normal representations collapsed into a few, more dispersed, and simplified dominant patterns under adversarial influence. The representation space became less intricate and more "sparse" in its topological features.
  • Crucially, this phenomenon was consistent across all models (7B to 70B parameters) and both types of adversarial attacks, highlighting a general mechanism of adversarial influence.
  1. Structural Phase Shift (Local Analysis):
  • Analyzing the neuron-level interactions between layers revealed a dynamic change in topological complexity across the network's depth.
  • For both normal and adversarial activations, the overall topological complexity of neuron interactions generally increased with depth.
  • However, a distinct reversal in relative complexity was observed:
  • In earlier layers, normal activations exhibited higher topological complexity compared to adversarial activations.
  • Around the middle layers of the network, this trend reversed.
  • In later layers, adversarial activations displayed higher topological complexity than normal activations.
  • This structural phase shift suggests a reorganization of how information flows and is represented within the network under adversarial stress. Adversarial inputs appear to force the model to adopt more complex representational strategies in deeper layers.
  • The validity of this finding was reinforced by a permutation test: when neuron indices were randomly permuted, this signal vanished completely, confirming that the observed phase shift was a genuine topological property of the information flow and not an artifact of the data representation.
  • Furthermore, the variance of these topological features was found to correlate with class separation, suggesting that these topological metrics could potentially serve as an unsupervised indicator for identifying layers particularly vulnerable to adversarial manipulation or those exhibiting significant representational shifts.

These results provide compelling evidence that adversarial inputs induce measurable and consistent topological changes in LLM latent spaces, offering a novel perspective on understanding and potentially detecting these attacks.

Practical Implications

▶ Watch: Q&A: Theories on why adversarial representations change (8:10)

The findings from this research have profound practical implications for the development, deployment, and security of Large Language Models. By demonstrating that adversarial inputs induce specific and quantifiable topological changes within LLM latent spaces, the work opens several crucial avenues:

  1. Novel Adversarial Attack Detection Methods: The most immediate implication is the potential for developing new, topology-based methods for detecting adversarial attacks. Current detection techniques often struggle with sophisticated, non-linear attacks. The observed topological compression and structural phase shift provide robust, model-agnostic signatures of adversarial influence. By continuously monitoring the topological characteristics of LLM activations, practitioners could potentially identify when a model is processing an adversarial input, even if the output itself hasn't yet revealed the attack. The correlation between topological feature variance and class separation also suggests an unsupervised mechanism to flag potentially vulnerable layers or suspicious activity.
  1. Enhanced LLM Interpretability: Moving beyond linear assumptions, this research offers a deeper, more geometrically informed understanding of how LLMs process information. The insights into how representations reorganize under stress (the phase shift) can help interpret why an LLM might fail or behave unexpectedly. By characterizing the "shape" of data, researchers can gain a more intuitive grasp of the high-dimensional internal states, potentially leading to new interpretability tools that visualize or quantify these topological changes, shedding light on the "black box" nature of LLMs.
  1. Designing More Robust LLMs: A fundamental understanding of how adversarial inputs distort representation spaces is critical for building more resilient models. If specific topological signatures are indicative of vulnerability, future LLM architectures or training methodologies could be designed to resist these geometric deformations. For example, regularization techniques could be developed to encourage more stable topological structures in the latent space, or training objectives could explicitly penalize the emergence of "compressed" or "phase-shifted" topologies in response to adversarial examples. This could lead to models that are inherently more robust to attacks like prompt injection and sandbagging.
  1. Trade-offs and Limitations: While promising, the approach is not without its considerations. The primary limitation mentioned in the talk was the computational cost of persistent homology. However, the use of Ripser, a GPU-accelerated implementation, effectively mitigates this, making the analysis scalable to LLM representation sizes. A deeper theoretical understanding of why these topological changes occur (e.g., why adversarial inputs lead to compression or phase shifts) is an area for future research, as noted in the post-talk Q&A. The current study focused on single-prompt injections and sandbagging; the effects of multiple, concurrent injections or the application to time series data (as queried by an audience member) remain open questions. However, the consistency of findings across different attack types and model scales suggests a generalizable phenomenon, bolstering the practical utility of this topological perspective. Overall, this work provides a powerful new lens for understanding, detecting, and mitigating the complex challenges posed by adversarial influences in the realm of LLMs.

Key Takeaways

  • Beyond Linear Assumptions: Traditional LLM analysis methods often assume linearity, overlooking complex, high-dimensional geometric structures that adversarial attacks can exploit.
  • Topological Data Analysis (TDA) for LLMs: Persistent Homology provides a mathematically rigorous, coordinate-free, multi-scale, and noise-robust framework to characterize the "shape" of LLM latent spaces.
  • Adversarial Topological Compression: Under adversarial conditions (prompt injection, sandbagging), LLM global representations exhibit topological compression, meaning fewer, later-appearing, and longer-persisting loops, simplifying the rich local geometry.
  • Structural Phase Shift in Neuron Flow: A structural phase shift occurs across layers, where normal activations are more complex in early layers, but adversarial activations become more complex in later layers, indicating a reorganization of information flow.
  • Consistency and Scalability: These topological effects are consistent across LLMs of varying sizes (7B to 70B parameters) and different adversarial attack types, with computational cost addressed by Ripser.
  • New Avenues for Robustness: The findings pave the way for novel adversarial attack detection methods, deeper interpretability tools, and the design of more robust LLMs by monitoring and influencing the topological properties of their internal representations.

About the Speaker(s)

The talk was a joint work presented by Qiquan Wang, with contributions from Aideen Fay, Inés García-Redondo, Haim Dubossarsky, and Anthea Monod. The transcript identifies Qiquan Wang as the primary presenter of the research. Their affiliations or specific titles beyond their names were not detailed within the transcript, but their collective work highlights expertise in applying advanced mathematical and computational techniques to understand complex AI/ML systems.

Reviews

→ Top-rated talks at International Conference on Learning Representations 2026

All talks from International Conference on Learning Representations 2026