# Train on prefill, monitor at decode: Using sparse autoencoders for topic monitoring

DevFeed: [Train on prefill, monitor at decode: Using sparse autoencoders for topic monitoring](<https://devfeed.tech/articles/train-on-prefill-monitor-at-decode-using-sparse-autoencoders-for-topic-monitoring-128204.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2611.12935>)

Author: Rishikesh Mallagundla, Pranav Patel

Published: 2026-11-11T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Artificial Intelligence](<https://devfeed.tech/sources/arxiv-artificial-intelligence.md>), [arXiv: Machine Learning](<https://devfeed.tech/sources/arxiv-machine-learning.md>)

Topics: [ai observability](<https://devfeed.tech/topics/ai-observability.md>), [LLM Techniques](<https://devfeed.tech/topics/llm-techniques.md>), [AI Chat](<https://devfeed.tech/topics/ai-chat.md>)

Tags: [activation](<https://devfeed.tech/tags/activation.md>), [autoencoders](<https://devfeed.tech/tags/autoencoders.md>), [classifiers](<https://devfeed.tech/tags/classifiers.md>), [cs-ai](<https://devfeed.tech/tags/cs-ai.md>), [cs-lg](<https://devfeed.tech/tags/cs-lg.md>), [decode](<https://devfeed.tech/tags/decode.md>), [gemma-3](<https://devfeed.tech/tags/gemma-3.md>), [hidden-states](<https://devfeed.tech/tags/hidden-states.md>), [monitoring](<https://devfeed.tech/tags/monitoring.md>), [prefill](<https://devfeed.tech/tags/prefill.md>), [robust](<https://devfeed.tech/tags/robust.md>), [safety](<https://devfeed.tech/tags/safety.md>), [synthetic](<https://devfeed.tech/tags/synthetic.md>), [token](<https://devfeed.tech/tags/token.md>), [topic](<https://devfeed.tech/tags/topic.md>), [train](<https://devfeed.tech/tags/train.md>)

## AI overview

TopicScope trains causal classifiers on sparse autoencoder (SAE) features to label each generated token by topic, allowing labels to change within a response. In experiments on synthetic conversations spanning seven topics, three detector architectures trained on prefill hidden-state features generalized to decoding on Gemma-3 1B and 4B. Their macro-F1 fell by at most five points under tested perturbations: inserted off-topic asides, removed topics, or reordered sections. Ablations found that classifiers reaching baseline performance without SAE features were several times larger. The results suggest compact monitors can be trained during prefill and used during generation; the evidence described is limited to these models, synthetic data, and tested perturbations.

## Source excerpt

arXiv:2611.12935v1 Announce Type: new Abstract: Topic monitoring is the task of labelling the topic of each token in a model's response during generation. Activation-based monitors that run at generation time have so far been trained to detect harmful content and are limited to two or three classes. We introduce TopicScope, a framework for training causal topic classifiers on SAE features that assign a topic to every token, so that the label can change partway through a response. We train three detector architectures on synthetic multi-topic conversations covering seven topics. Across Gemma-3 1B and 4B, monitors trained on features extracted from prefill hidden states were able to generalise to decoding. We also found that the classifiers are robust to perturbations, losing at most 5 macro-F1 points when off-topic asides are inserted, topics are removed or sections are reordered. Ablations conducted to understand the contribution of the SAE revealed that classifiers reaching baseline performance without it were several times larger. Our findings show that compact topic monitors can be trained inexpensively in prefill and deployed during generation. More broadly, our work shows where SAEs are useful beyond safety classification. Our code, dataset and checkpoints are available at https://github.com/Mercity-AI/SAE-Guardrails and https://huggingface.co/collections/Mercity/online-guardrails-using-sparse-autoencoders-6ac602940468c62fefb2b9e8