# How do Small Transformer Models Learn Hard Math Tasks?

*Eshika Saxena, Kristin E. Lauter*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/148782) · [Open on the map](../papers.html#p148782)

Category: [Interpretability & Model Adaptation](../pcat/15.md) › [Transformer Algorithmic Decomposition](../pgroup/692.md) · Type: new method · Keywords: transformer interpretability, positional embeddings, L1 sparsity regularization, cryptographic secret recovery, mechanistic analysis

Areas: [Model Architectures & Sequence Modeling](../areas/architectures.md) › Language Model Architectures › Algorithmic Transformers; [Interpretability](../areas/interpretability.md) › Mechanistic Interpretability › Transformer Circuit Interpretation

## Summary
We show that small encoder-only transformers recover LWE secrets via positional embeddings and propose an L1 sparsity regularization on these embeddings to make the secret directly readable from model parameters.

## Explained to a 5-year-old
Small computer brain models called transformers are taught to solve tricky math puzzles. They hide a secret number inside a special part of their brain called the position memory. Even though they seem to fail at the main task, they still know the secret. We give them a new rule that makes the secret jump out so we can see it easily. This helps us understand how they think and makes the secret easy to read.

## Explained to a 5-year-old, longer
Transformers are small computer models that can learn to solve hard problems. In this study, they were asked to solve a kind of math puzzle that hides a secret code. The researchers looked inside the model layer by layer to see how it works. They discovered that the secret code was stored in a special place called the position embedding. Even though the model seemed to get the puzzle wrong most of the time, it still kept the secret. The secret was hidden in a way that the normal way of reading the model missed it. To help the model show the secret clearly, the researchers added a rule that makes the hidden part simple. This rule encourages the model to keep only the most important information in that special place. After adding the rule, the secret became easy to see just by looking at the model’s numbers. This makes it possible for people to understand how the model solved the puzzle. It also helps researchers check if the model really learned the secret or just guessed. The findings give us new ideas about how computer models can store and retrieve hidden information.

## For a technical reader
We analyzed encoder-only transformers trained on noisy LWE-style data to understand how they recover hidden secrets. By probing each layer and the positional embeddings, we found the secret implicitly encoded there despite near-zero task accuracy. Adding an L1 sparsity regularizer to the positional embeddings forces the model to isolate the secret explicitly, turning a costly post-hoc recovery into a direct parameter inspection. This provides both a mechanistic view of transformer behavior and a practical way to make cryptographic secrets readable from the model.

## Problem
Understanding how small transformer models solve complex combinatorial problems such as recovering hidden secrets from noisy data.

## Method
We perform layer-wise and embedding-level mechanistic interpretability analysis on encoder-only transformers trained on noisy problem instances. Using dimensionality reduction, causal interventions, and linear probing, we discover that the secret is encoded in the positional embeddings. Based on this insight, we add an L1 sparsity regularizer to the positional embeddings to force explicit isolation of the secret.

## Contributions
We provide the first layer-wise mechanistic analysis revealing secret encoding in positional embeddings, and we demonstrate that adding sparsity regularization makes the secret directly readable from model parameters.

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/148782)
