Integrate the Essence and Eliminate the Dross: Fine-Grained Self-Consistency for Free-Form Language Generation

Xinglin Wang, Yiwei Li, Shaoxiong Feng, Peiwen Yuan, Boyuan Pan, Heda Wang, Yao Hu, Kan Li

Introduction

Large Language Models (LLMs) are inherently stochastic, often producing varied responses to the same query. In structured reasoning tasks like arithmetic, the "Self-Consistency" (SC) method has proven highly effective. By generating multiple reasoning paths and performing a majority vote on the final answer, SC significantly improves accuracy. However, this "coarse-grained" selection approach fails in free-form generation tasks—such as code generation, text summarization, or creative writing—where there is no single "correct" string to vote upon.

In these domains, current methods typically resort to random sampling or selecting a single representative response. This often leads to suboptimal results: a "best" response might still contain minor errors, while a discarded "bad" response might contain brilliant, correct segments. To address this, we introduce Fine-Grained Self-Consistency (FSC), a framework designed to move beyond simple selection by synthesizing a superior response from the consensus segments found across multiple candidate samples.

Comparison between selection-based self-consistency and the proposed fine-grained self-consistency (FSC).

The Fine-Grained Self-Consistency (FSC) Framework

The core philosophy of FSC is to "integrate the essence and eliminate the dross." Instead of treating each generated response as an indivisible unit, FSC views them as collections of segments that can be analyzed for consensus. The framework consists of three primary components:

  1. Fine-Grained Synthesis: Multiple candidate responses are concatenated into a single prompt. The LLM is then tasked with acting as an editor to identify the "major consensus"—the logic or content segments most samples agree on—and integrate them into a single, optimized final output.
  2. Candidate Filtering: To mitigate the risk of "garbage in, garbage out," FSC employs a filtering step. Using similarity metrics like ROUGE, the system identifies and retains only the most consistent subset of candidates, pruning outliers that might introduce noise during the synthesis phase.
  3. Merging for Efficiency: To manage context window constraints and reduce API costs, FSC utilizes K-Medoids clustering. By grouping highly similar responses and selecting cluster centroids, the system represents the diversity of the sample set with fewer tokens.
The FSC workflow, including candidate filtering, the synthesis prompt, and the merging strategy.

Experimental Evaluation

We evaluated FSC across three distinct domains using a variety of models, including GPT-3.5-turbo, GPT-4, and Mistral-7B-Instruct:

  • Code Generation: Tested on HumanEval, HumanEval+ (Python), and BIRD-SQL (Text-to-SQL).
  • Text Summarization: Evaluated using DailyMail (short-form) and SummScreen (long-form TV transcripts).
  • Mathematical Reasoning: Benchmarked on GSM8K and the more challenging MATH dataset.

Key Results and Insights

Synthesis Over Selection

A pivotal finding of this research is that FSC can produce a correct final answer even when every single input sample is incorrect. By operating at a fine-grained level, the LLM can piece together correct logic segments scattered across several failing attempts. For instance, in complex coding tasks like generating a Tribonacci sequence, the LLM successfully synthesized a working solution from multiple partially correct candidates.

Performance Gains

  • Coding: On HumanEval, FSC improved GPT-3.5-turbo's accuracy from 69.8% (random sampling) to 74.5%. With GPT-4, performance reached 87.1%.
  • Summarization: FSC consistently outperformed selection-based baselines across ROUGE and BERTScore metrics. In head-to-head win-rate evaluations judged by GPT-4, FSC summaries were preferred over 50% of the time.
  • SQL Efficiency: In the BIRD-SQL benchmark, FSC not only improved correctness but also generated more computationally efficient SQL queries than standard baselines.

Robustness and Efficiency

Unlike traditional voting methods, which often see performance degrade as the number of incorrect samples increases, FSC remains remarkably stable. The synthesis step effectively filters noise, allowing the model to focus on the consensus. Furthermore, the "Merge" strategy successfully reduced input token requirements by up to 26.5% with negligible impact on performance, making the method more viable for production environments.

Conclusion

Fine-Grained Self-Consistency represents a significant shift in how we leverage LLM stochasticity. By moving from selection to synthesis, FSC allows models to act as their own judges and editors, extracting the best elements from multiple attempts to create a final response that is greater than the sum of its parts. While challenges remain regarding context window limits for very long-form generation, FSC provides a robust and effective path forward for improving the reliability of free-form language generation.

Summary updated

BibTeX
@inproceedings{wang2024integrate,
  author = {Xinglin Wang and Yiwei Li and Shaoxiong Feng and Peiwen Yuan and Boyuan Pan and Heda Wang and Yao Hu and Kan Li},
  title = {{Integrate the Essence and Eliminate the Dross: Fine-Grained Self-Consistency for Free-Form Language Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.634},
}
Figure