TL;DR
Standard cross-entropy loss in large language model (LLM) pretraining often fails to create well-separated token representations, limiting training efficiency. SimReg addresses this by introducing a lightweight embedding similarity regularization loss that clusters tokens predicting the same target while pushing different tokens apart. This simple contrastive tweak accelerates training convergence by over 30% and boosts downstream zero-shot performance by more than 1% with virtually zero computational overhead.
What Problem Does This Paper Address?
At their core, modern LLMs are trained on a simple objective: next-token prediction. From a machine learning perspective, this is essentially a massive multi-class classification problem where the model uses the context of preceding words to predict a categorical distribution over the vocabulary.
However, language is highly context-dependent. The word "walls" in "The cat jumps over walls" and "A child paints near walls" appears in entirely different environments. Because standard cross-entropy loss only focuses on matching the final token prediction to the ground truth, it allows the underlying token embeddings to suffer from high intra-class variance (same target token, wildly different embeddings) and high inter-class similarity (different target tokens, overlapping embeddings).
The authors discover a critical bottleneck in standard pretraining: cross-entropy loss stops driving feature separability early in the training process. Once the embeddings are "good enough" to sustain basic classification, the model stops optimizing their geometric arrangement, leaving significant representation capacity on the table.
Methods
To enforce geometric structure on the embedding space, the authors introduce SimReg (Similarity Regularization), an auxiliary contrastive loss term added to the standard cross-entropy objective.
For any given sequence during pretraining, tokens are partitioned into:
- Positive groups: Tokens that share the same ground-truth next-token label.
- Negative groups: Tokens with different next-token labels.
SimReg minimizes the distance between positive pairs and maximizes the distance between negative pairs using cosine similarity with a temperature coefficient ($\tau$). To adapt this framework to the unique challenges of language modeling, the authors introduced three key innovations:
- Self-Sample Similarity: Because rare words might only appear once in a sequence, the positive group includes a token's similarity to itself to ensure a valid contrastive pair always exists.
- Group-Level Averaging: Natural language is heavily long-tailed. To prevent highly frequent tokens (like "the" or "and") from dominating the loss, SimReg averages at the group level rather than the sample level.
- Chunk-wise SimReg: Computing pairwise similarity across long sequences scales quadratically ($O(n^2)$), which breaks down during sequence-parallel training across multiple GPUs. The authors mitigate this by dividing sequences into smaller chunks and computing SimReg internally within each chunk, reducing complexity to $O(n^2/b)$ and eliminating redundant inter-node communication.
Mathematically, the authors prove that SimReg expands the multi-classification margin, effectively making the final linear layer's (the LM Head) job much easier. Crucially, they find that applying SimReg only at the final layer right before the LM head yields the best results, as intermediate layers contain highly entangled contextual features.
Datasets
- Pretraining: The models were pretrained using the standard C4 (Colossal Clean Crawled Corpus) dataset, utilizing token allocations ranging from 13 billion (for smaller models) up to 52 billion tokens.
- Evaluation: Downstream zero-shot evaluation was conducted using the EleutherAI/lm-evaluation benchmark, covering standard tasks such as ARC (Easy/Challenge), BoolQ, HellaSwag, OpenBookQA, Piqa, MMLU, WinoGrande, and SciQ.
Key Insights and Ideas
- The Geometry of Language: When trained solely with cross-entropy, the average angle between embeddings of different token classes stabilizes around 61.3 degrees. Introducing SimReg widens this average angle to approximately 74 degrees, creating a much cleaner separation in high-dimensional space.
- The Scaling Relationship: The optimal regularization weight ($\lambda$) is intrinsically tied to the embedding dimension ($d$). As the hidden size grows, embeddings naturally drift further apart in high-dimensional space. The authors provide a practical scaling heuristic: $\lambda \approx 10 \times \sqrt{d/1024}$.
- Resource Neutrality: While contrastive losses are notoriously compute-heavy, applying SimReg chunk-wise at only the final layer results in less than a 2% increase in runtime and under 1% increase in GPU memory, making it practically free.
Key Results
- 30%+ Training Speedup: Across LLaMA dense models ranging from 1.3B to 7B parameters, SimReg consistently accelerated training convergence, achieving speedups between 1.33× and 1.38×.
- Downstream Performance Gains: SimReg outperformed standard cross-entropy and alternative consistency baselines (like SimCSE and CReg), improving average zero-shot downstream accuracy by +1.04% on LLaMA-350M and +1.14% on LLaMA-1.3B.
- Architecture Agnostic: The method scales seamlessly to Mixture-of-Experts (MoE) architectures, netting a +1.28% average performance boost on Mixtral-8×1B.
Limitations and Future Work
While SimReg demonstrates robust performance, the authors note a few areas for further exploration:
- Hyperparameter Sensitivity: Although the authors provide a scaling formula for the coefficient $\lambda$, it still requires baseline calibration when transitioning to entirely new model architectures or hidden dimension scales.
- Extreme Scale Validation: The experiments in this paper top out at 7B/8B parameter models trained on 52B tokens. Validating SimReg on frontier-scale models (hundreds of billions of parameters) and trillion-token datasets remains an open and necessary next step.
Summary updated