Abstract
Large Language Models (LLMs) often exhibit degenerative behaviors such as repetitive loops and loss of coherence during open-ended generation. While Contrastive Decoding—comparing a large expert model with a smaller amateur model—mitigates these issues, it is computationally expensive. This paper introduces Autocontrastive Decoding (ACD), a method that identifies an "amateur" within the expert model itself by utilizing intermediate layers. By contrasting the final layer's predictions against those of an earlier layer, ACD filters out shallow patterns and repetitions. Experimental results demonstrate that a GPT-2 Medium model (355M parameters) using ACD can outperform models four times its size, such as GPT-2 XL (1.5B parameters), in both output diversity and contextual accuracy.
Introduction
Despite the remarkable capabilities of transformer-based language models, they remain susceptible to "degenerative behaviors." These include getting stuck in repetitive cycles or losing the thematic thread during long-form generation. Traditionally, text generation relies solely on the final layer of a model to predict the next token, treating intermediate layers as mere stepping stones toward the final output.
Previous attempts to address these failures through "Contrastive Decoding" involved running two separate models: a large "expert" and a smaller "amateur." The expert’s output is refined by penalizing tokens that the amateur finds likely, effectively filtering out simplistic or repetitive tendencies. However, this approach requires significant computational overhead. Autocontrastive Decoding (ACD) proposes a more efficient alternative: leveraging the internal hierarchy of a single model to find the amateur within.
Methodology
ACD exploits the fact that LLMs refine their internal representations progressively. The method treats the final layer as the "expert" and a specific intermediate layer as the "amateur."
The Contrastive Mechanism
In a standard GPT-style architecture, intermediate layers do not naturally produce token probabilities. To enable this, the researchers implemented Multi-Exit Heads—small linear classifiers trained on top of intermediate layers while the rest of the model remains frozen.
During generation, the model calculates log-probabilities for both the expert ($P_{expert}$) and the amateur ($P_{amateur}$). The final selection score for a token is determined by the difference:
$$Score = \log(P_{expert}) - \log(P_{amateur})$$
Adaptive Plausibility Constraint
To ensure the model does not select nonsensical tokens simply because the amateur assigned them low probability, ACD employs an adaptive plausibility constraint. The contrastive subtraction is only applied to tokens that the expert already considers reasonably likely. This prevents the "contrast" from elevating noise into the final output.
Experimental Setup and Datasets
The researchers evaluated ACD using the GPT-2 family of models across several benchmarks:
- Open-ended Generation: Evaluated via WikiText-103, BookCorpus, and Wikinews to measure the flow and variety of generated text.
- Knowledge & Context: The LAMBADA dataset was used to test the model's ability to predict the final word of a long passage, a task requiring broad discourse understanding.
- General Language Modeling: WikiText-2 served as the baseline for measuring perplexity.
Key Results
Superior Diversity
One of the most striking findings was the boost in n-gram diversity. In open-ended generation tasks, a GPT-2 Medium model (355M parameters) using ACD saw its diversity score jump from 0.22 to 0.75. For comparison, the much larger GPT-2 XL (1.5B parameters) only achieved a score of 0.31 using standard decoding. This suggests that ACD effectively forces the model to move beyond the "easy" repetitive answers favored by lower layers.
Performance Gains in Contextual Tasks
On the LAMBADA benchmark, GPT-2 Medium with ACD achieved 55% accuracy, notably outperforming the baseline GPT-2 XL, which scored 51%. This indicates that the knowledge required for complex tasks is often already present in medium-sized models but is frequently obscured by the decoding process. ACD acts as a sieve, extracting higher-quality information that the model already possesses.
Human Evaluation
In blind qualitative tests, human evaluators judged the outputs of the ACD-enhanced medium model to be of similar or superior quality to the 1.5-billion-parameter XL model. The ACD outputs were specifically praised for their fluency and coherence.
Discussion and Efficiency
ACD is significantly more efficient than traditional Contrastive Decoding. Because the expert and amateur share the same initial layers (the "backbone"), the model only needs a single forward pass up to the amateur layer, after which it continues to the expert layer. This intra-model contrast provides the benefits of an ensemble approach without the memory and compute costs of loading two distinct models.
Limitations and Future Work
Despite its success, ACD faces several challenges:
- Hallucinations: While ACD reduces repetition, it may occasionally increase "hallucinations," where the model generates factually incorrect but confident-sounding text.
- Hyperparameter Sensitivity: The effectiveness of the method depends on the choice of the amateur layer and the threshold for the plausibility constraint ($\alpha$). These parameters currently require manual tuning.
- Scalability: The study focused on the GPT-2 architecture. Further research is needed to determine if these results hold for modern, larger-scale architectures like Llama 3 or GPT-4.
Future research may explore "extending the vector" of improvement. By observing the trajectory of refinement from intermediate to final layers, it may be possible to mathematically project and simulate the output of an even deeper, hypothetical "expert" layer.
Summary updated