Semantic Regexes: Auto-Interpreting LLM Features with a Structured Language
Angie Boggust, Donghao Ren, Yannick Assogba, Dominik Moritz, Arvind Satyanarayan, Fred Hohman
TL;DR
This work tackles the challenge of translating LLM feature activations into precise, human‑understandable descriptions. It introduces semantic regexes, a structured language built from primitives (symbols, lexemes, fields) and modifiers (context, composition, quantification) to describe activation patterns, enabling both feature‑level descriptions and model‑wide analyses. Empirical results show semantic regexes achieve accuracy comparable to natural language while offering greater conciseness and consistency and revealing feature complexity as depth increases. A user study further demonstrates that semantic regex descriptions support more accurate mental models of LLM features, underscoring their value for interpretability and safety applications.
Abstract
Automated interpretability aims to translate large language model (LLM) features into human understandable descriptions. However, these natural language feature descriptions are often vague, inconsistent, and require manual relabeling. In response, we introduce semantic regexes, structured language descriptions of LLM features. By combining primitives that capture linguistic and semantic feature patterns with modifiers for contextualization, composition, and quantification, semantic regexes produce precise and expressive feature descriptions. Across quantitative benchmarks and qualitative analyses, we find that semantic regexes match the accuracy of natural language while yielding more concise and consistent feature descriptions. Moreover, their inherent structure affords new types of analyses, including quantifying feature complexity across layers, scaling automated interpretability from insights into individual features to model-wide patterns. Finally, in user studies, we find that semantic regex descriptions help people build accurate mental models of LLM feature activations.
