TL;DR
Large Language Models (LLMs) often prioritize linguistic fluency over factual accuracy, leading to "hallucinations." DoLa (Decoding by Contrasting Layers) is a simple, training-free decoding strategy that improves factuality by contrasting the output distributions of an LLM’s final layer against its earlier layers, effectively amplifying factual knowledge while suppressing superficial linguistic patterns.
What Problem Does This Paper Address?
Despite their prowess, LLMs frequently generate plausible-sounding but factually incorrect text. This happens partly because the standard training objective—maximizing the likelihood of the next token—encourages the model to learn common linguistic sequences (syntax) rather than grounded facts.
Previous research has shown that factual knowledge in transformers isn't uniform; it tends to be localized in specific, often later, layers. Earlier layers focus more on "lower-level" information like part-of-speech tags and basic syntax. The challenge is: how can we force the model to rely more on its internal "knowledge neurons" and less on its "linguistic intuition" during inference without expensive fine-tuning or complex retrieval-augmented generation (RAG) pipelines?
Methods
The authors introduce DoLa, a contrastive decoding approach that requires only a single forward pass of the existing model.
- Layer Contrasting: Instead of just using the final layer ($N$) to predict the next token, DoLa calculates the difference in log-probabilities between the final "mature" layer and a "premature" early layer ($j$).
- Dynamic Premature Layer Selection: Not all tokens are created equal. Predicting a function word like "the" is easy and happens early, whereas predicting a specific date requires more processing. DoLa dynamically selects the premature layer at each decoding step by finding the layer in a candidate set that has the highest Jensen-Shannon Divergence (JSD) from the final layer. This identifies where the model’s internal representation is changing most significantly—a signal that factual information is being injected.
- Adaptive Plausibility Constraint (APC): To prevent the contrastive step from amplifying low-probability noise, the authors apply a constraint that only considers tokens with a sufficiently high probability in the final layer.
Datasets
The researchers evaluated DoLa across a diverse suite of benchmarks:
- TruthfulQA: Tests the model's tendency to mimic human falsehoods (Multiple Choice and Open-Ended).
- FACTOR (News/Wiki): A benchmark for factuality in long-paragraph generation.
- StrategyQA & GSM8K: Evaluates multi-hop reasoning and mathematical problem-solving via Chain-of-Thought (CoT).
- Vicuna QA: Uses GPT-4 to rate the quality of open-ended chatbot responses.
Key Insights and Ideas
- Factual Evolution: The "aha moment" comes from observing how the model's confidence changes across layers. For factual tokens (names, dates), the distribution continues to shift significantly even in the very last layers. For "easy" function words, the distribution stabilizes much earlier.
- The JSD Signal: Figure 2 demonstrates that high JSD in late layers is a strong proxy for "factual injection." By contrasting against the layer before this shift, DoLa amplifies the newly emerged factual signal.
- Efficiency is Key: Unlike standard Contrastive Decoding, which requires running two different models (an "expert" and a smaller "amateur"), DoLa uses the same model. This results in a negligible latency overhead of only 1-8%.
Key Results
DoLa consistently outperformed original greedy decoding and other baselines like Inference Time Intervention (ITI):
- TruthfulQA: Improved LLaMA family models by 12-17% absolute points in truthfulness.
- Reasoning: Boosted accuracy on StrategyQA by 1-4% and GSM8K by ~2%.
- Human-like Evaluation: In GPT-4-based pairwise comparisons on Vicuna QA, DoLa-enhanced models were significantly preferred over the baseline, particularly for the 13B and 33B LLaMA variants.
Limitations and Future Work
- Internal Knowledge Only: DoLa can only surface knowledge the model already possesses. If the model learned a "fact" incorrectly during pretraining, DoLa will simply make it more confident in that error.
- Instruction Following vs. Factuality: While DoLa improves truthfulness, the authors noted that it can sometimes lead to answers that are slightly less relevant to the prompt than the baseline, suggesting a trade-off between depth and instruction adherence.
- Scope: The study focused primarily on the LLaMA family. While preliminary tests on MPT-7B were promising, broader testing on different architectures (like MoE) remains for future work.
Summary updated