Abstract
Large Language Models (LLMs) often exhibit inconsistency across multiple samples for the same prompt. This paper introduces a "lightweight" reranking approach that identifies the best output by measuring consensus among generated samples using n-gram overlap statistics. Unlike traditional methods that require expensive reward models or execution environments, this approach significantly boosts performance in code generation, summarization, and translation tasks with negligible compute overhead.
Introduction
A common strategy to improve LLM reliability is reranking: generating $N$ samples and selecting the best one. However, existing methods are often "heavy," requiring auxiliary reward models, doubling inference costs, or needing complex sandboxed execution environments for code. This research proposes a black-box method suitable for open-ended tasks that works without massive compute overhead by leveraging the "wisdom of the samples."
Methodology
The core idea extends the concept of Self-Consistency. While standard self-consistency works for exact matches (like math answers), it fails for open-ended text like code or summaries. The authors propose three lightweight scoring mechanisms:
- Unigram Consistency Score (UCS): Treats generations as "bags of words" and calculates pairwise similarity based on shared tokens. The sample with the highest average similarity to all others is selected.
- Weighted UCS (WUCS): Incorporates token probabilities. Sharing a "rare" token (low probability) increases the similarity score more than sharing common words.
- Consensus-WUCS: Combines the similarity score with the model's own mean log-probability for the sequence.
Notably, the authors found that avoiding length normalization (using the raw inner product of token vectors) performed better. This naturally filters out degenerate, repetitive, or overly short sequences that might otherwise appear highly confident.
Experimental Setup
The methods were evaluated across several diverse benchmarks using models from the Codex (davinci-001, 002, Cushman) and Llama (13B, 30B) families:
- Code Generation: HumanEval, MBPP, and MBPP-sanitized.
- Autoformalization: MiniF2F (natural language math to Isabelle code).
- Summarization: Xsum (evaluated via Rouge-2 and Rouge-L).
- Machine Translation: WMT14 (French-to-English and German-to-English).
Results and Discussion
The proposed methods demonstrated consistent improvements across nearly all datasets and models. On the HumanEval benchmark, Consensus-WUCS improved Codex002's accuracy from 43.5% (random selection) to 56.8%.
Key Insights
- Unigrams are Sufficient: Simple word overlap (unigrams) proved to be a strong proxy for semantic agreement. While 4-grams provided a minor boost, the performance quickly plateaued.
- Superiority over Log-Probabilities: The UCS methods consistently outperformed the standard "Mean Log-Probability" baseline. Unlike log-probability, which can decrease in accuracy as sample size increases (due to the model becoming confident in degenerate loops), UCS methods remain stable or improve as more samples are added.
- Efficiency: As these are simple pairwise statistics, the compute cost is negligible compared to the initial LLM inference.
Conclusion and Future Work
Lightweight reranking via consensus offers a powerful, model-agnostic way to improve LLM outputs. While highly effective, the authors note that the method relies on lexical overlap rather than deep semantic understanding. Future work may explore using lightweight embeddings (e.g., fastText) to calculate similarity. Additionally, the impact of this reranking on model bias or toxicity remains an area for further investigation.
Summary updated