Traditional knowledge distillation treats a neural network like a "black box." A large teacher model produces a final output (a logit or a probability distribution), and a smaller student model tries to mimic that output. However, this approach ignores the rich, high-dimensional "reasoning" that happens inside the teacher's hidden layers.
Internal Representation Alignment shifts the focus from what a model predicts to how it predicts it. By forcing a student's internal hidden states, attention maps, and latent trajectories to match those of the teacher, researchers can transfer complex logic and structural patterns that are often lost when looking only at final outputs.
The Logit Bottleneck
When we only distill the final layer, we encounter a "logit bottleneck." A single probability distribution over tokens or classes is a sparse signal. It tells the student which answer is right, but not the path the teacher took to get there.
As Gustavo Aguilar and colleagues argue in Knowledge Distillation from Internal Representations, matching internal attention patterns and hidden states provides a much denser training signal. This allows a 6-layer BERT model to retain nearly 100% of the performance of a 12-layer teacher. Without this internal guidance, students often resort to superficial pattern matching rather than internalizing the underlying linguistic logic.
How Alignment Works: Bridging the Latent Space
The primary challenge in internal alignment is that the student and teacher often have different architectures. The student might have fewer layers or smaller hidden dimensions. To solve this, researchers use several key mechanisms:
1. Layer-wise and Block-wise Mapping
Instead of just matching the final layer, methods like TinyBERT, developed by Xiaoqi Jiao and others, align the student’s layers with specific "anchor" layers in the teacher. This ensures that the student captures structural patterns—like syntax or coreference—at the same stage of processing as the teacher. In MOHAWK, Aviv Bick and Albert Gu use block-wise alignment to distill the quadratic knowledge of Transformers into subquadratic State Space Models (SSMs), preventing error accumulation across the model's depth.
2. Linear Projections and Dual Spaces
When the hidden dimensions don't match (e.g., a 1024-dim teacher and a 512-dim student), researchers use learnable linear projectors. Songming Zhang and Xue Zhang introduced Dual-Space Knowledge Distillation (DSKD), which uses these projections to unify the representation spaces. This allows distillation even between models with entirely different vocabularies or tokenizers, as seen in A Dual-Space Framework for General Knowledge Distillation of Large Language Models.
3. Similarity Metrics
To force the student to "look" like the teacher, the training loss minimizes the distance between their activations. Common metrics include:
- Mean Squared Error (MSE): For direct point-to-point coordinate matching.
- Cosine Similarity: To align the "direction" or semantic meaning of embeddings, used by Cornelia Caragea to preserve scholarly keyphrase boundaries.
- Contrastive Loss: Runxin Xu and Fuli Luo use contrastive learning in ContrAstive Pruning to maximize the similarity between a pruned model's embeddings and its dense reference, preventing "catastrophic forgetting."
Beyond Compression: New Frontiers of Alignment
While originally a tool for model shrinking, internal alignment is now used to "inject" specific behaviors into pre-trained models.
- Injecting Algorithms: Tomás Vergara Browne and Alvaro Soto developed Tracr-Injection, which aligns a language model's internal states with a hard-coded symbolic algorithm. This "bakes in" capabilities like perfect multi-digit addition while keeping the model's language abilities intact.
- Internalizing Rules: In Distilling Rule-based Knowledge into Large Language Models, Wenkai Yang shows that aligning hidden states during In-Context Learning (ICL) helps models internalize complex rules rather than just mimicking output patterns.
- Self-Alignment (IA2): Aayush Mishra and colleagues proposed IA2, where a model is trained to replicate its own internal activation patterns from a "primed" few-shot state. This allows the model to achieve high-reasoning performance without needing the actual prompt demonstrations at inference time.
Why It Works: The Intuition of Compatibility
The success of internal alignment rests on the idea of feature compatibility. If a student model's internal state is forced to be compatible with the teacher's logic, it inherits the teacher's "worldview."
This is taken to the extreme in Boomerang Distillation by Marco Fumero, where the student is so well-aligned that you can literally "patch" original teacher layers back into the student model at runtime. Similarly, Tandem Transformers allow a small model to attend directly to a large model's internal representations, treating the teacher's hidden states as a rich, pre-computed context.
By moving from behavioral mimicry (outputs) to structural mimicry (internal states), representation alignment creates models that are not just smaller, but fundamentally more robust and capable of complex reasoning.