Semantic Self-Consistency: Enhancing Language Model Reasoning via Semantic Weighting

Tim Knappe, Ryan Luo Li, Ayush Chauhan, Kaylee Chhua, Kevin Zhu, Sean O'Brien

TL;DR

This paper introduces "semantic self-consistency," a novel approach to improve the reasoning capabilities of Large Language Models (LLMs). By analyzing the semantic content of intermediate reasoning steps, not just the final answers, their method enhances accuracy and robustness on complex reasoning tasks, outperforming standard self-consistency techniques.

What Problem Does This Paper Address?

Large Language Models (LLMs) have made incredible strides in many areas, but they still struggle with complex reasoning tasks like mathematics, commonsense, and algorithmic problem-solving. While the "self-consistency" method, which involves generating multiple reasoning paths and taking a majority vote on the final answer, has shown promise, it overlooks valuable information within the intermediate reasoning steps. This paper aims to bridge this gap by leveraging the semantic meaning of these step-by-step rationales to further improve LLM reasoning.

Methods

The core of this work is "semantic self-consistency," which builds upon the existing self-consistency framework. The standard self-consistency approach involves:

  1. Prompting: Generating a chain-of-thought (CoT) for a given query.
  2. Sampling: Generating multiple independent CoT responses.
  3. Aggregation: Selecting the most frequent final answer.

The proposed semantic self-consistency enhances this by:

  • Embedding Reasoning Paths: Each generated reasoning path (the sequence of intermediate steps) is converted into a semantic vector embedding using fine-tuned BERT models (like SciBERT for math and RoBERTa for commonsense). This captures the overall meaning of the reasoning process.
  • Semantic Weighting and Filtering: Instead of just aggregating final answers, the paper introduces two main techniques:
  • Centroid Proximity Weighting (CPW): This method groups similar reasoning paths by their embeddings and assigns weights based on their proximity to the centroid of the group. Paths closer to the centroid receive higher weights.
  • Semantic Consensus Weighting (SCW): This technique uses cosine similarity to measure how similar reasoning paths are to each other. It aggregates these similarity scores to identify consensus among the rationales.
  • Outlier Removal: The paper also explores using techniques like Isolation Forest and K-nearest neighbors to identify and discard degenerate or hallucinated reasoning paths, further refining the output.

Datasets

The authors evaluate their methods on three established datasets:

  • AQUA-RAT: Focuses on arithmetic problems requiring basic calculations, numerical relationships, and multi-step reasoning.
  • SVAMP: Challenges models with math problems involving algebraic manipulations and symbolic reasoning.
  • StrategyQA: Tests commonsense reasoning on open-domain questions that require strategic thinking rather than simple factual recall.

Key Insights and Ideas

  • Semantics Matter: The most significant insight is that the intermediate reasoning steps themselves carry crucial semantic information that can be leveraged to improve LLM performance, beyond just looking at the final answer.
  • SCW Outperforms CPW: Semantic Consensus Weighting (SCW) generally showed better results than Centroid Proximity Weighting (CPW), suggesting that directly measuring the similarity between reasoning paths is more effective than relying on proximity to a group centroid.
  • Outlier Detection is Beneficial: Techniques for outlier removal proved effective in refining the quality of model outputs, especially for smaller sample sizes.
  • Sequence Length Trade-off: While longer reasoning chains can provide more context, they also increase the risk of outliers and inaccuracies. There's a delicate balance to strike.
  • BLEU Doesn't Guarantee Reasoning: Improvements in text generation quality (measured by BLEU score) do not necessarily translate to better reasoning accuracy, highlighting a trade-off between fluency and correctness.

Key Results

  • Accuracy Improvements: Semantic self-consistency, particularly SCW, consistently improved accuracy across various models and datasets compared to baseline self-consistency. For instance, SCW boosted accuracy on StrategyQA by up to 13.53% for Llama 2 7B.
  • Model Performance Varies: GPT-3.5 and Llama 2 7B showed significant gains with SCW, while GPT-40 mini sometimes underperformed with CPW.
  • Outlier Detection Effectiveness: Methods like Isolation Forest and K-nearest neighbors showed consistent accuracy improvements, even with reduced sample sizes.
  • Computational Efficiency: The proposed semantic methods add minimal computational overhead compared to baseline self-consistency, as they rely on efficient embedding and mathematical operations.

Limitations and Future Work

  • Overly Similar Generations: When generated reasoning paths are too similar, semantic methods might struggle to differentiate them, potentially leading to errors.
  • Subtle Nuances: The current approach might miss subtle nuances in generations, which could be critical for tasks requiring precise symbolic reasoning or state tracking.
  • Featurizer Choice: The effectiveness of semantic analysis is dependent on the quality of the featurizer models used for embedding. Choosing an "unfitting" featurizer can reduce the density of data points and hinder performance.
  • Hyperparameter Tuning: The authors emphasize the need for careful hyperparameter tuning for their methods to achieve optimal effectiveness.
  • Future Work: The paper suggests exploring more advanced featurization models and investigating how to better handle subtle variations in reasoning for tasks like symbolic reasoning. They also note that pre-trained self-improvement models could be integrated with their weighting method for further accuracy gains.

Summary updated

BibTeX
@inproceedings{knappe2024semantic,
  author = {Tim Knappe and Ryan Luo Li and Ayush Chauhan and Kaylee Chhua and Kevin Zhu and Sean O'Brien},
  title = {{Semantic Self-Consistency: Enhancing Language Model Reasoning via Semantic Weighting}},
  booktitle = {MATH-AI @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=2w0CIzWlle},
}
Figure