GUÍA de IA en idiomas

Inferencia y vinculación del lenguaje natural

Natural language inference (NLI), also called recognizing textual entailment, is the task of deciding whether one sentence, the premise, makes another, the hypothesis, true (entailment), false (contradiction) or neither (neutral).

Escuche esta guíaNarrado por IA · ~7 min

En esta pagina8 minutos de lectura
  1. Descripción general
  2. Conclusiones clave
  3. Buceo profundo
  4. Check a summary sentence against its source with NLI
  5. Implementación en el mundo real
  6. El futuro de la inferencia y vinculación del lenguaje natural
  7. Poniéndolo en práctica
  8. Fuentes y lecturas adicionales
  9. Sigue explorando
  10. Preguntas frecuentes

Descripción general

It matters because it is a standard test of language understanding and a working tool for zero-shot classification and for checking whether generated text is supported by its source.

Conclusiones clave

  1. Natural language inference labels a premise and hypothesis pair as entailment, contradiction or neutral, based on what a reasonable reader would infer.
  2. SNLI (2015) has 570,000 labeled pairs and MultiNLI (2017) has 433,000 pairs drawn from ten genres of English.
  3. A classifier that sees only the hypothesis gets about 67% of SNLI right, showing that crowd-written data contains exploitable artifacts.
  4. Any trained NLI model can act as a zero-shot classifier by turning each candidate label into a hypothesis and scoring entailment.
  5. NLI-based checkers flag unsupported summary sentences, and SummaC reached 74.4% balanced accuracy by aggregating sentence-level scores across a document.

Buceo profundo

Natural language inference asks a question people answer constantly without noticing: if this sentence is true, what follows? A system receives two pieces of text. The premise is taken as true, for example "A man is playing a guitar on stage." The hypothesis is a claim to evaluate, such as "A man is performing music." The system outputs one of three labels. Entailment means a typical reader would conclude the hypothesis is true given the premise. Contradiction means the hypothesis must be false, as with "The man is asleep in bed." Neutral means the premise does not settle it, as with "The man is a famous musician." The judgment is about what a reasonable person would infer, not strict formal logic.

Modern NLI systems are text classifiers built on pretrained Transformer language models. The premise and hypothesis are joined into one input with a separator token between them, so every word of the hypothesis can attend to every word of the premise. A small classification layer on top of the model's output produces three scores, which a softmax function turns into probabilities for entailment, neutral and contradiction. The model is fine-tuned, meaning further trained, on hundreds of thousands of labeled pairs until its predictions match the human labels.

The task is older than neural networks. Early Recognizing Textual Entailment (RTE) challenges used small test sets, which limited learning-based approaches. That changed in August 2015, when Samuel Bowman and colleagues released the Stanford Natural Language Inference corpus (SNLI) with 570,000 human-labeled sentence pairs, about two orders of magnitude larger than earlier resources of its kind. SNLI premises are image captions, and crowd workers wrote a hypothesis for each label. In 2017 Adina Williams, Nikita Nangia and Bowman released MultiNLI with 433,000 examples from ten genres of written and spoken English, published at NAACL 2018. MultiNLI became a standard training set for general-purpose NLI models.

High scores soon turned out to hide shortcuts. In 2018 Suchin Gururangan and colleagues showed that a classifier that never sees the premise, only the hypothesis, labels about 67% of SNLI and 53% of MultiNLI correctly, against a chance rate of about 33%. Crowd workers left annotation artifacts: negation words, for example, correlate strongly with contradiction. In 2019 Tom McCoy, Ellie Pavlick and Tal Linzen built HANS, a test set where three tempting heuristics fail: assuming entailment when the hypothesis reuses the premise's words, when it is a contiguous piece of the premise, or when it is a complete subtree of the premise's parse. Models trained on MultiNLI, including BERT, did very poorly on it. Adversarial NLI (ANLI), released by Yixin Nie and colleagues in 2019, answered by having people write examples specifically to fool strong models in a human-and-model-in-the-loop process, producing a harder test set.

NLI is now used more as a tool than a leaderboard. Wenpeng Yin, Jamaal Hay and Dan Roth showed in 2019 that a trained NLI model can act as a zero-shot classifier: treat the text as the premise, write each candidate label as a hypothesis, and pick the label with the highest entailment score. The bart-large-mnli model on Hugging Face packages exactly this method. A second use is checking generated text. A summary sentence that is entailed by the source is supported; one that is contradicted or neutral may be a hallucination, meaning a statement the source does not back.

Compared with alternatives, NLI-based checks are cheap and transparent. A fine-tuned NLI model is far smaller than a chatbot-scale language model, runs quickly on modest hardware and returns probabilities that can be thresholded and audited. Question-answering-based metrics, which generate questions from a summary and check whether the source answers them the same way, are slower but catch different errors; the TRUE study found the two families complementary. Asking a large language model to judge consistency is flexible but costlier, and its verdicts can vary with the prompt.

The limitations are real. NLI datasets are built at sentence level, while documents spread facts across many sentences; Laban and colleagues identified this granularity mismatch as the reason early NLI-based summary checkers performed poorly, and their SummaC method, which aggregates sentence-pair scores, reached 74.4% balanced accuracy on its six-dataset benchmark. Labels also depend on background assumptions about what a reasonable reader infers, so annotators sometimes disagree. Shortcut learning can reappear in any new domain, and a model trained on captions and fiction may misjudge legal or medical text. A neutral label means only that the premise does not settle the claim; it does not mean the claim is false.

In practice, building with NLI requires a pretrained model already fine-tuned on MultiNLI or a combination of SNLI, MultiNLI and ANLI, which are freely available, plus a validation set from the target domain to set decision thresholds. Fine-tuning a new model takes a single modern GPU and the public datasets. The main ongoing cost is evaluation: checking examples where the model's labels and human judgment differ, and watching for the overlap and negation shortcuts the research literature has documented.

04Ejemplo resuelto

Check a summary sentence against its source with NLI

  1. Load a public NLI model fine-tuned on MultiNLI, such as facebook/bart-large-mnli, with the Hugging Face Transformers library.

  2. Take a source sentence as the premise: "The library will close at 6 p.m. on Friday for staff training."

  3. Score three hypotheses: "The library closes early on Friday.", "The library is open late on Friday." and "The training is mandatory for all staff."

  4. Read the three probabilities for each pair and record the highest label.

  5. Expect entailment for the first, contradiction for the second and neutral for the third, since the premise does not say whether training is mandatory.

  6. Repeat with the premise reworded to share few words with the first hypothesis to see whether the model relies on word overlap.

lo que muestra

A small table of labels and probabilities showing which claims the source supports, contradicts or leaves open. Check it by labeling the same pairs yourself; disagreements, especially on the reworded premise, show where the model may be using shortcuts rather than meaning.

Implementación en el mundo real

The facebook/bart-large-mnli model on Hugging Face classifies text into labels it was never trained on by turning each label into a hypothesis such as "This example is travel." and scoring entailment.

SummaC, published in 2021, splits a document and its summary into sentences and runs NLI on every pair to flag summaries that state things the source does not support.

The 2022 TRUE study found that large-scale NLI models performed strongly at judging factual consistency across 11 manually annotated datasets drawn from diverse generation tasks.

Researchers use the HANS test set to check whether a model trained on MultiNLI really reasons or just assumes that high word overlap means entailment.

Benchmarks such as SNLI, MultiNLI and Adversarial NLI are used to compare language models, since each item has a clear three-way label that makes scoring simple.

El futuro de la inferencia y vinculación del lenguaje natural

NLI research since 2019 has shifted from beating benchmarks toward measuring robustness and supporting other tasks. Adversarial collection, as in ANLI, showed that test sets written to fool current models stay hard longer than static ones. In evaluation, NLI models remain a common, inexpensive way to score factual consistency, and the 2022 TRUE study recommended NLI-based and question-answering-based metrics as starting points while noting that they catch different errors. Open problems include document-level inference, where the evidence for a claim is spread across many sentences; graded or disputed labels, where reasonable annotators disagree; and domain shift into specialized fields such as law or medicine, where training data is scarce. Large language models can perform NLI when prompted, which raises a practical question that research has not settled: when a small fine-tuned NLI classifier is preferable for its speed, cost and calibrated probabilities, and when a general model's broader knowledge justifies its cost. For hallucination detection, the consistent finding is that NLI provides useful evidence for human review rather than a final verdict on truth.

Poniéndolo en práctica

Por qué es importante

  • Velocidad y escala. Los flujos de trabajo lingüísticos pueden avanzar más rápido sin sacrificar la coherencia.
  • Acceso y alcance. Amplía el acceso a través de idiomas y estilos de comunicación.
  • Decisiones más claras. Los equipos pueden dedicar más tiempo a juzgar mientras la automatización se encarga de la repetición.

cuidado con

  • Los hechos alucinados pueden aparecer silenciosamente en informes, flujos de apoyo o resultados de investigaciones.
  • La sensibilidad rápida puede crear resultados inconsistentes en solicitudes similares.
  • Los datos de texto confidenciales pueden quedar expuestos si los controles de acceso son débiles.

Próximos pasos

  1. Defina el formato de salida, el tono y los estándares de calidad antes del lanzamiento.
  2. Respuestas terrestres con fuentes confiables siempre que la precisión sea importante.
  3. Mantenga un punto de control de revisión humana para los resultados de alto riesgo.
  4. Realice un seguimiento de los patrones de error y vuelva a capacitar las indicaciones o los flujos de trabajo con regularidad.

Fuentes y lecturas adicionales

  1. arXiv (EMNLP 2015)A large annotated corpus for learning natural language inference
  2. arXiv (NAACL 2018)A Broad-Coverage Challenge Corpus for Sentence Understanding through Inference
  3. arXiv (NAACL 2018)Annotation Artifacts in Natural Language Inference Data
  4. arXiv (ACL 2019)Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural Language Inference
  5. arXiv (ACL 2020)Adversarial NLI: A New Benchmark for Natural Language Understanding
  6. arXiv (EMNLP 2019)Benchmarking Zero-shot Text Classification: Datasets, Evaluation and Entailment Approach
  7. arXiv (TACL)SummaC: Re-Visiting NLI-based Models for Inconsistency Detection in Summarization
  8. arXiv (NAACL 2022)TRUE: Re-evaluating Factual Consistency Evaluation

Sigue explorando

Boletín gratuito

Recibe el resumen diario de IA

Tres noticias verificadas sobre IA cada mañana de lunes a viernes, explicadas con claridad. Gratis para siempre y sin anuncios.

Un correo cada día laborable. Date de baja con un clic. Nunca vendemos ni compartimos tu dirección.

Ponte a prueba

Take the Natural Language Inference and Entailment quiz

Corrección inmediata en cada respuesta y un certificado para compartir, con un ID verificable, cuando apruebas un curso.

Empezar el cuestionario

Apoya la educación gratuita sobre IA. AI Understanding es una organización sin fines de lucro 501(c)(3): sin anuncios ni muros de pago, nunca. Hacer una donación

Preguntas frecuentes

¿Qué es la inferencia y vinculación del lenguaje natural?

Natural language inference (NLI), also called recognizing textual entailment, is the task of deciding whether one sentence, the premise, makes another, the hypothesis, true (entailment), false (contradiction) or neither (neutral). It matters because it is a standard test of language understanding and a working tool for zero-shot classification and for checking whether generated text is supported by its source.

¿Cuáles son las tres etiquetas estándar en la inferencia del lenguaje natural?

NLI clasifica un par premisa-hipótesis como vinculación, contradicción o neutral.

En NLI, ¿qué significa "vinculación"?

La vinculación significa que la premisa garantiza la verdad de la hipótesis.

Dada la premisa "Un hombre toca la guitarra en el escenario", ¿qué hipótesis es una contradicción?

Si un hombre toca la guitarra en el escenario, el escenario no puede estar vacío, por lo que esa hipótesis contradice la premisa.

What is an annotation artifact in an NLI dataset?

NLI datasets can contain patterns such as certain words being associated with a label, allowing shortcut prediction that may fail out of domain.

¿Qué conjuntos de datos se utilizan ampliamente para entrenar y evaluar NLI?

SNLI y MultiNLI son grandes corpus etiquetados por humanos creados específicamente para la inferencia del lenguaje natural.