Abstract
This paper introduces a novel, unsupervised method to monitor Large Language Model (LLM) training dynamics by measuring the "local intrinsic dimension" (LID) of their token embeddings. By tracking how the geometric dimensionality of these embeddings changes, practitioners can detect complex phenomena like grokking, overfitting, and convergence using only training data—no labeled validation sets required.
Introduction
Understanding how fine-tuning alters an LLM's internal representations is notoriously difficult. Typically, practitioners rely on labeled validation datasets and task-specific metrics (like accuracy or F1 scores) to determine if a model is learning, overfitting, or has converged. However, in low-resource settings or when training loss curves are misleading, these methods fall short. This work investigates whether the geometric structure of the model's latent space can serve as an unsupervised diagnostic signal. Specifically, we analyze whether the intrinsic dimensionality of contextual token embeddings reveals generalization performance without task-specific labels.
Methodology: Local Intrinsic Dimension (LID)
While LLM embeddings reside in high-dimensional ambient spaces (e.g., 768 or 4096 dimensions), the underlying data often lies on a much lower-dimensional manifold. We estimate this manifold's dimensionality using a localized version of the TwoNN estimator.
The estimation pipeline involves:
- Extracting token embeddings from the final hidden layer of the LLM.
- Sub-sampling a large set of token vectors (e.g., $N=60,000$).
- Identifying the $L$ nearest neighbors for each token.
- Applying the TwoNN algorithm, which calculates the intrinsic dimension based on the ratio of distances to the first and second nearest neighbors.
- Aggregating these estimates into a mean local dimension for the dataset.
Experimental Setup
The method was evaluated across diverse datasets:
- Task-Oriented Dialogue: MultiWOZ2.1 and Schema-Guided Dialogue (SGD).
- Emotion Recognition: EmoWOZ (used for overfitting studies).
- Out-of-Distribution (OOD): Reddit (Tesla 2022) and ICLR 2024 submissions.
- Standard Corpus: Wikipedia (wikitext-103-v1).
- Synthetic Algorithmic: Modular addition (Addition modulo $p$) to study grokking.
Results and Discussion
Targeted Compression and Generalization
A key finding is that fine-tuning induces "targeted compression." The LID of the embedding space drops significantly, but only for data similar to the fine-tuning distribution. For instance, fine-tuning RoBERTa on MultiWOZ led to a massive LID reduction for MultiWOZ validation data. Conversely, when evaluating unrelated data like Reddit comments, the LID remained largely unchanged from the base model.
Monitoring Training Dynamics: Grokking and Overfitting
LID serves as a predictive heuristic for complex training behaviors. In modular addition tasks, a sudden drop in training LID perfectly anticipated "grokking"—the moment validation accuracy spikes long after training loss has plateaued.
Furthermore, LID can detect overfitting. In emotion classification tasks, the LID initially decreases as the model learns general patterns but begins to rise as the model starts memorizing rare instances. This "structural expansion" correlates with increased validation loss, even as training loss continues to decline.
Convergence Tracking
LID provides a more accurate signal for convergence than standard loss. In dialogue state tracking, while training loss suggested convergence at 7,500 steps, the LID continued to decrease until ~25,000 steps, aligning with the actual plateau of downstream metrics like Joint Goal Accuracy (JGA).
Conclusion and Future Work
Measuring the local intrinsic dimension of embeddings offers a powerful, unsupervised tool for monitoring LLM health. While computationally intensive due to nearest-neighbor searches, it provides insights into generalization and memorization that standard metrics miss. Future research aims to develop differentiable proxies for LID to directly optimize for local compression during training and to use LID for detecting data contamination.
Summary updated