NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Keep it Neutral: Using Natural Language Inference to Improve Generation

Michail Mersinias, Kyle MahowaldarXiv 2023 · OpenReview

Abstract

We explore incorporating natural language inference (NLI) into the text generative pipeline by using a pre-trained NLI model to assess whether a generated sentence entails, contradicts, or is neutral to the prompt and preceding text. First, we show that the NLI task is predictive of generation errors made by GPT-3. We use these results to develop an NLI-informed generation procedure for GPT-J. Then, we evaluate these generations by obtaining human annotations on error types and overall quality. We find that an NLI strategy of maximizing entailment improves text generation when the nucleus sampling randomness parameter value is high, while one which maximizes contradiction is in fact productive when the parameter value is low. Overall, though, we demonstrate that an NLI strategy of maximizing the neutral class provides the highest quality of generated text (significantly better than the vanilla generations), regardless of parameter value.

Introduction

Large Language Models (LLMs) have achieved remarkable fluency, yet they frequently struggle with logical consistency. These models often fall into two distinct failure modes: repetitive loops (redundancy) or wandering into incoherent "hallucinations." This research addresses these issues through the lens of Gricean pragmatics. According to Paul Grice, an ideal informative agent should provide new information (avoiding redundancy) that is consistent with the context (avoiding contradiction).

In Natural Language Processing, these logical relationships are categorized by Natural Language Inference (NLI) as Entailment, Contradiction, or Neutral. We investigate whether NLI can serve as a "System 2" reasoning filter to guide LLMs toward the "Goldilocks zone" of information: text that is relevant but provides new, non-obvious content.

The Challenge of LLM Generation

The nature of errors in LLM output is heavily influenced by the decoding strategy, specifically the randomness parameter $p$ in nucleus sampling.

Proportion of error types at different randomness levels ($p=0.4$ vs $p=0.96$).

As shown in the figure above, low randomness ($p=0.4$) is strongly associated with redundancy, where the model repeats itself. Conversely, high randomness ($p=0.96$) leads to more off-prompt and incoherent errors. Our goal was to see if NLI labels could predict these specific failures and if filtering based on these labels could improve output quality.

Methodology

Our approach involved two stages. First, we performed a correlation analysis using the SCARECROW dataset—a collection of human-annotated errors in GPT-3 text—to confirm that NLI labels (from a BART-large-mnli model) could indeed predict generation errors.

Second, we implemented an NLI-Informed Generation pipeline for GPT-J. Instead of selecting the single most likely next sentence, we generated multiple candidates and reranked them according to three strategies:

  • NEU (Neutral): Prioritizes sentences with a high probability (>0.85) of being neutral to the context.
  • ENT (Entailment): Prioritizes sentences more likely to be entailed than contradicted.
  • CON (Contradiction): Prioritizes sentences more likely to be contradictory than entailed.

Results: The Neutral Advantage

Human evaluation of 400 generations across these conditions revealed a clear winner. The NEU (Neutral) strategy consistently outperformed the vanilla control and other NLI strategies in holistic quality ratings.

Average human ratings (1-5) for different NLI strategies across randomness settings.

The effectiveness of the strategies varied by randomness level:

  • At low randomness ($p=0.4$): The model is prone to loops. Here, the NEU strategy was particularly effective at reducing redundancy. Interestingly, even the CON strategy helped by forcing the model away from repetition.
  • At high randomness ($p=0.96$): The model is prone to hallucinations. The NEU strategy significantly reduced off-prompt and incoherent errors by ensuring the text remained logically grounded without being redundant.

Statistically, the NEU strategy showed a significant positive effect on holistic ratings ($\beta = 0.54$ for low $p$; $\beta = 0.70$ for high $p$), confirming that "Correct" human-like text is overwhelmingly classified as Neutral by NLI models.

Discussion and Future Work

While NLI filtering significantly improves generation quality, it introduces computational overhead, as multiple candidates must be generated and checked. Furthermore, NLI models are often trained on specific logic tasks, creating a potential domain gap when applied to general-purpose text.

Future research should explore more efficient ways to integrate these "System 2" reasoning capabilities directly into the model's training or decoding process. By prioritizing the "Neutral" class, we can move closer to the Gricean ideal of being as informative as required, but no more.

Summary updated

BibTeX
@misc{mersinias2023keep,
  author = {Michail Mersinias and Kyle Mahowald},
  title = {{Keep it Neutral: Using Natural Language Inference to Improve Generation}},
  year = {2023},
  eprint = {2302.08577},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2302.08577},
}
Figure