Natural Language Inference — Textual Entailment
"t entails h" means a human reading t would conclude h is true. NLI is the task of predicting entailment / contradiction / neutral. Boring on the surface, load-bearing in production. You built a summarizer. It produced a summary. How do you know the summary does not contain a hallucination? You built a chatbot. It answered "yes." How do you know the answer is supported by the retrieved passage? You need to classify 10,000 news articles by topic. You have no training labels. Can you reuse a model? All three problems reduce to Natural Language Inference. NLI asks: given a premise t and a hypothesis h, is h entailed by t, contradicted, or neutral (unrelated)? Hallucination check: t = source document, h = summary claim. Not entailment = hallucination. Grounded QA: t = retrieved passage, h = generated answer. Not entailment = fabrication. Zero-shot classification: t = document, h = verbalized label ("This is about sports"). Entailment = predicted label. One task, three production uses. This is why every RAG evaluation framework ships an NLI model under the hood. NLI: three-way classification, premise vs hypothesis The three labels. Entailment. t → h. "The cat is on the mat" entails "There is a cat.". Contradiction. t → ¬h. "The cat is on the mat" contradicts "There is no cat.". Neutral. No…
Natural Language Inference — Textual Entailment: "t entails h" means a human reading t would conclude h is true. NLI is the task of predicting entailment /…
This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.
Browse the complete course catalog or open this lesson on GitHub.