TL;DR
This paper introduces PruneCD, a novel method to combat "hallucinations" (factually incorrect outputs) in large language models (LLMs). Instead of relying on early exits from the model, PruneCD prunes intermediate layers to create a "self-contrastive" signal, leading to more factual and reliable text generation with minimal computational overhead.
What Problem Does This Paper Address?
Large language models (LLMs) are prone to "hallucinations," generating fluent but factually incorrect or nonsensical text. This is particularly problematic for applications requiring high accuracy, like question answering or information retrieval. While contrastive decoding (CD) methods aim to mitigate this by comparing the outputs of an "expert" model with a less confident "amateur" model, creating a reliable amateur model without significant overhead has been a challenge. Existing methods like DoLa use early exits from the LLM to simulate an amateur model, but these early logits are often flat and uninformative, limiting their effectiveness.
Methods
PruneCD proposes a new way to generate the "amateur" model's signal for contrastive decoding. Instead of using early exits, PruneCD prunes a subset of intermediate layers from the LLM. This "pruned model" then generates logits that are intended to be less confident but still informative, serving as the amateur signal.
The core of PruneCD involves two key steps:
- Factual Layer Search: The paper identifies which layers are most crucial for factual knowledge. They do this by systematically "ablating" (removing) layers and measuring the drop in a multiple-choice score (MC score) on a factuality benchmark (TruthfulQA). The layers causing the largest drop are identified as important for factuality.
- Contrastive Decoding with Pruned Model: Once the set of layers to prune (S*) is identified, the model is run with these layers removed. The logits from this pruned model are then used as the amateur signal in the contrastive decoding process, alongside the logits from the full, "expert" model. This process aims to amplify confident and factual outputs.
Datasets
The paper evaluates PruneCD on several standard datasets for factuality and reasoning:
- TruthfulQA: A benchmark for evaluating truthfulness and informativeness, with both multiple-choice and open-ended generation formats.
- TriviaQA: A large-scale dataset for reading comprehension.
- Natural Questions (NQ): Another dataset for question answering.
- StrategyQA: A dataset for evaluating chain-of-thought reasoning.
- GSM8K: A dataset of grade-school math word problems for evaluating reasoning.
- VicunaQA: A dataset for evaluating instruction-following and open-ended response quality.
Key Insights and Ideas
- Early exits are suboptimal for contrastive decoding: The paper argues that early exit logits are often "flat and low in magnitude," failing to provide a meaningful contrast. This is because they miss the "final sharpening stage" where LLMs refine their predictions.
- Layer pruning creates more informative amateur signals: By pruning intermediate layers, PruneCD generates logits that retain more structure and are better aligned with the expert model's logits, leading to more effective contrastive decoding.
- Factual knowledge is localized in specific layers: The "Factual Layer Search" method demonstrates that certain layers are disproportionately responsible for encoding factual information, allowing for targeted pruning.
- PruneCD is robust and efficient: The method achieves significant improvements in factuality without requiring separate training for an amateur model and with inference speeds comparable to greedy decoding.
Key Results
PruneCD consistently outperformed baselines like Greedy Decoding, DoLa, Activation Decoding (ActD), and END across various LLMs (Llama-3.1-8B-Instruct, Llama-3.2-3B-Instruct, Llama-3.2-1B-Instruct) and datasets.
- Factuality Gains: On TruthfulQA (open-ended generation), PruneCD achieved significant improvements in truthfulness and informativeness. For example, on Llama-3.1-8B-Instruct, PruneCD achieved 85.19% truthfulness and 79.04% informativeness, compared to 42.03% and 37.34% for Greedy decoding.
- Reasoning Performance: PruneCD also showed strong performance on reasoning tasks like GSM8K, outperforming baselines by several percentage points.
- Efficiency: PruneCD's inference speed was comparable to greedy decoding, indicating minimal computational overhead.
- Qualitative Improvements: The paper provides qualitative examples showing PruneCD correcting common misconceptions and providing more accurate and nuanced answers compared to baselines.
Limitations and Future Work
- Memory Footprint: The batched inference implementation of PruneCD might increase memory footprint due to additional internal activations, though this was not a significant issue in typical small-batch settings.
- Factual Layer Search: The paper suggests that more advanced approaches for factual layer search could be explored, such as gradient-based strategies or finer-grained search granularity (e.g., at the attention or feed-forward block level).
- Hyperparameter Tuning: While PruneCD is shown to be robust, the paper mentions that hyperparameter tuning (number of pruned layers and CD temperature) was performed on validation sets. Further work could explore more automated or adaptive hyperparameter selection.
Summary updated