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) frequently struggle with logical consistency. Depending on the nucleus sampling parameter ($p$), which controls randomness, models often fall into two distinct failure modes. At low randomness, models tend toward redundancy, repeating themselves or stating the obvious. Conversely, at high randomness, they often "hallucinate," producing text that contradicts previous statements or drifts off-topic. This research investigates whether Natural Language Inference (NLI)—a task focused on determining if a premise entails, contradicts, or is neutral to a hypothesis—can serve as a logical filter to mitigate these errors.
Methods
The study utilizes a "generate-and-test" pipeline pairing GPT-J as the generator with BART-large-mnli as the NLI evaluator. For each candidate sentence, the NLI model assesses its relationship to the preceding context. Four strategies were compared:
- Vanilla (Control): Standard generation.
- Maximize Neutral (NEU): Filters for sentences with a "neutral" probability above 0.85.
- Maximize Entailment (ENT): Prioritizes sentences that logically follow from previous text.
- Maximize Contradiction (CON): Prioritizes sentences that introduce semantic diversity.
The researchers validated NLI as an error predictor using the SCARECROW dataset of GPT-3 generations. They further conducted human evaluations on 400 new continuations across 50 prompts, rating them on a 1-5 scale for holistic quality and specific error types (e.g., incoherent, off-prompt, redundant, self-contradictory).
Results
The primary finding is that the Neutral (NEU) strategy consistently yields the highest quality text across different randomness settings. This aligns with Gricean Maxims of communication: a good communicator should provide new, relevant information without being redundant (entailed) or inconsistent (contradictory).
In high-randomness settings ($p=0.96$), the NEU strategy significantly improved holistic quality scores ($\beta = .70, p < .01$) and was particularly effective at reducing "off-prompt" and "incoherent" errors. In low-randomness settings, it successfully mitigated redundancy. While maximizing entailment helped at high $p$ and maximizing contradiction helped at low $p$, the neutral strategy remained the most robust overall.
Discussion
While effective, the current NLI-filtering approach introduces significant computational overhead, as it requires generating and evaluating multiple candidates per sentence. Future work may involve distilling NLI logic directly into the LLM's architecture to avoid this bottleneck. Additionally, the gap between standard NLI training data and creative writing prompts suggests that domain-specific NLI models could further refine these results. Nonetheless, prioritizing logical neutrality appears to be a powerful heuristic for improving the coherence and quality of machine-generated text.
Summary updated