Introduction
Large Language Models (LLMs) are increasingly susceptible to adversarial attacks, such as indirect prompt injections and hidden backdoors. Traditional interpretability methods often focus on linear relationships or individual features, which may fail to capture the complex, non-linear distortions these attacks introduce into a model's latent space. This research identifies a consistent "topological signature" associated with adversarial influence, using Persistent Homology (PH) to measure the geometric "shape" of internal representations.
Methodology: Persistent Homology in Latent Space
To characterize the high-dimensional internal states of LLMs, the authors employ Topological Data Analysis (TDA), specifically Persistent Homology. This technique treats activation vectors as a point cloud and analyzes its structure across multiple scales.
The process involves:
- Filtration and Barcodes: Growing "balls" of radius ε around each data point. As these balls merge, they form clusters (0-dimensional) and loops (1-dimensional). The persistence of these features is recorded in a barcode.
- Layer-Wise Analysis: Computing these barcodes for activations across different model layers and vectorizing them into summaries (e.g., mean death time of clusters) for classification.
- Explainability: Using SHAP values and PCA to identify which topological features—such as the number of loops or cluster merge rates—best indicate an attack.
Experimental Setup
The study evaluated six state-of-the-art models, including Phi-3 (3.8B) and LLaMA3 (70B), across three primary datasets:
- TaskTracker: Focused on Indirect Prompt Injection (XPIA).
- Sandbagging: Models fine-tuned on synthetic WMDP benchmarks to hide capabilities unless triggered by a password.
- LLMail-Inject: A red-teaming dataset used to test robustness against adaptive attacks designed to evade activation-based defenses.
Key Results and Topological Insights
The central finding is the phenomenon of topological compression. Under normal conditions, LLM activations form many small, compact clusters. Adversarial inputs cause these representations to collapse into fewer, larger, and more dispersed loops.
Key findings include:
- Universal Signature: This compression was observed across all tested architectures, suggesting it is a fundamental invariant of adversarial processing in LLMs.
- Near-Perfect Detection: Classifiers using topological summaries achieved an AUC-ROC of 1.00 across multiple layers, significantly outperforming linear baselines in early layers.
- Phase Transition: Local analysis indicates a major reconfiguration around Layer 12, where adversarial influence begins to dominate the model's processing.
- Robustness: The topological signature remained highly discriminative even against adaptive attacks specifically designed to bypass activation-based security.
Conclusion and Future Work
Topological Data Analysis provides a robust, relational framework for detecting adversarial influence that is harder to evade than feature-based methods. While computationally intensive, the use of random subsampling makes it feasible for diagnostic use. Future research aims to scale these methods for real-time monitoring and to develop "topology-aware" training mechanisms to enhance model robustness from the ground up.
Summary updated