Using Topological Data Analysis to Characterize the Layers of Language Models Before and After Word Substitution Attacks

· Source: Paper Index on ACL Anthology · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Data Science & Analytics, Cybersecurity & Data Privacy · Depth: Expert, quick

Summary

A new topological data analysis (TDA) framework has been introduced to investigate the structural effects of adversarial word substitution attacks on large language models' internal representations. This framework evaluates small encoder-based architectures like BERT, RoBERTa, and DistilBERT, fine-tuned for binary classification on the IMDb review dataset and attacked using TextFooler. The method converts attention maps into distance matrices, applies TDA to extract topological features, and compares these features using Wasserstein distances between original and perturbed states. A non-TDA baseline using per-head L1 distances was also computed. Findings indicate that adversarial perturbations induce systematic and statistically significant topological changes across model layers, with the largest deviations observed in late layers and notable effects in early layers. These patterns are consistent across models and validated by non-parametric (Kruskal–Wallis, Dunn) and parametric (one-way ANOVA, Tukey) tests. The TDA framework provides more distinct layer-wise separation and a robust, interpretable method compared to the L1 baseline.

Key takeaway

For AI Security Engineers evaluating language model robustness, this TDA framework offers a powerful new lens. You should consider integrating topological analysis to gain deeper, layer-by-layer insights into how adversarial attacks structurally alter internal model representations, beyond just output behavior. This approach provides a more robust and interpretable understanding of perturbation propagation, enabling more targeted defense strategies against synonym-based word substitutions.

Key insights

Topological Data Analysis reveals systematic structural changes in LLM internal representations due to adversarial word substitutions.

Principles

Method

Convert attention maps into distance matrices, apply TDA to extract topological features, then compare original and perturbed features using Wasserstein distances.

In practice

Topics

Code references

Best for: Research Scientist, AI Scientist, Machine Learning Engineer, AI Security Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Paper Index on ACL Anthology.