Lexical Substitution — Context-Sensitive Word Replacement

Machine Learning
Introduced by
McCarthy & Navigli (SemEval shared task, 2007/2009)
Year
2007
Type
NLP lexical-level text transformation

What does it do?

Lexical substitution is a natural-language-processing task — formalised by McCarthy and Navigli through the SemEval shared task series starting in 2007 — that replaces a target word in a sentence with a semantically equivalent alternative that preserves the meaning of the surrounding context.

It draws on synonym resources such as WordNet or on distributional word embeddings and masked language models to generate and rank candidate replacements, and is used for text robustness testing, style adaptation, and training-data augmentation.

The intuition behind the method

Imagine reading a sentence and wanting to swap one word for a synonym — but only a synonym that still makes sense in that exact sentence. 'The bank was steep' and 'The bank was solvent' need completely different substitutes for 'bank' because the context is different. Lexical substitution captures this: it does not look up a word in isolation but reads the surrounding words to choose the replacement that fits. WordNet-based methods draw on curated synonym lists filtered by the word's sense in context; embedding-based methods find words that appear in similar contexts; and BERT-style fill-mask models predict the most likely word given all surrounding tokens.

History

The task was formalised by McCarthy and Navigli through the SemEval shared task series. The originator is recorded as their work from 2007 and 2009, and the 2009 reference is their paper in Language Resources and Evaluation. WordNet-based systems select candidates from synonym sets, while later systems use distributional embeddings and masked language models such as BERT as candidate generators.

When to use it

Choose lexical substitution when you have a text corpus in a language for which at least one candidate source is available: a WordNet-style synonym inventory, distributional word embeddings, or a masked language model. It suits generating paraphrased variants for data augmentation, adapting the vocabulary of a document to a register, and checking whether a downstream NLP model is sensitive to surface wording. Do not use it when no candidate source exists for the language or domain, because the candidates can be no better than the resource that produces them. It is also a poor fit when the question concerns meaning across whole passages or fixed multi-word expressions, since the method replaces one target word at a time. The method alters text rather than estimating quantities from data, so distributional assumptions about numeric measurements do not apply, but substitutions should still be checked for fluency and meaning before use.

Limitations and considerations

  • Candidate quality depends directly on the synonym resource or language model: sparse WordNet coverage of a specialised domain leaves few usable substitutes.
  • Errors in word-sense disambiguation upstream carry into candidate generation, so the substitutes may fit a different sense of the target word than the one intended.
  • The context the ranking sees is bounded by the model's window, so constraints that span paragraphs, such as narrative consistency, are not captured.
  • Multi-word expressions and idioms are not handled as units; replacing one word inside a fixed phrase usually breaks the expression.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Only the target position changes, so the rest of the sentence is left exactly as written; the scope of each edit is easy to inspect.
  • Works with several candidate sources (WordNet-style synonym inventories, word embeddings, or BERT-style fill-mask predictions), so the backend can match the resources available for a given language.
  • Can generate many varied paraphrases of a sentence cheaply, which is the main practical reason it is used for training-data augmentation.

Applications

  • Data augmentation for text classification and natural language understanding models, generating surface-varied training examples.
  • Style adaptation, replacing domain-specific or register-specific vocabulary for a target audience without rewriting full sentences.
  • Robustness testing of NLP pipelines, checking whether downstream outputs remain consistent when surface wording changes.
  • Writing assistance, suggesting alternative words for a chosen term in its sentence context.

How it works

How it works

1

The raw text is split into tokens (words, punctuation). The target word or words to be substituted are marked by their position in the token sequence. This step only marks the substitution sites and assigns no sense. It standardises the input so that later stages operate on clearly delimited units.

2

Each marked target word is disambiguated: the word sense it carries in its particular context is determined. This is the word-sense disambiguation step that steers candidate generation toward the right part of the lexicon. Without it, a polysemous word like 'bank' or 'light' would attract irrelevant synonyms.

3

A set of candidate replacement words is assembled for the target word in its resolved sense. WordNet-based approaches draw synonyms directly from the synset of the target sense; embedding-based approaches retrieve nearest neighbours in a distributional vector space; and masked language models (BERT fill-mask) predict the top-k tokens that complete the sentence with the target word masked out.

4

The candidate pool is ranked by contextual fit. Ranking signals include cosine similarity of contextual embeddings, language-model probability scores, or a combination of lexical-resource constraints and neural scores. How these signals are weighted or combined depends on the backend in use. Candidates that change the meaning or break grammatical agreement are penalised or filtered.

5

The highest-ranked candidate is inserted in place of the original target word, producing the output sentence. Optionally, the top-n candidates are returned so downstream tasks can sample diverse paraphrases for data augmentation.

Common pitfalls

  • Skipping word-sense disambiguation and drawing candidates from all senses of a polysemous word yields contextually wrong substitutes, for example replacing 'bank' with a financial term in a river sentence.
  • A language model or embedding trained on a different domain or language ranks domain-specific terms poorly; confirm that the resource language and domain match the corpus.
  • Substituting many words in one sentence compounds errors, and the resulting text may degrade downstream model performance rather than improve it.
  • Reporting only the substitution rate says nothing about output quality; include a fluency check, either automatic or on a sample read by a person.

Frequently asked questions

What is the difference between lexical substitution and simple synonym replacement?

Simple synonym replacement looks up a word in a thesaurus and picks any entry, ignoring context. Lexical substitution first disambiguates the word sense in the specific sentence and then ranks candidates by how well they fit that context, so the output is coherent in context, not just lexically related.

Do I need BERT to run lexical substitution?

No. BERT fill-mask is one backend; WordNet synsets are another. If you have a WordNet for your language, a WordNet-based pipeline works without any neural model. BERT-based pipelines depend on a pretrained masked language model that covers your language, so check that one exists before choosing that backend.

Can lexical substitution be applied to languages other than English?

Yes, provided a synonym resource (a WordNet variant, multilingual embeddings, or a multilingual masked language model) covers the target language. Applying an English-trained model or the English WordNet to another language is unlikely to yield usable substitutes.

How do I evaluate the quality of substitutions?

McCarthy and Navigli (2009) compare system-ranked candidates against human-annotated substitutes; consult that paper for its scoring details before reporting results against it. For applied use, a practical protocol does not depend on a shared benchmark: draw a sample of substituted sentences, have a reader judge for each whether the substitute keeps the original meaning and reads fluently, and report the share accepted. For data augmentation, also compare the downstream model's results on the original and substituted training text.

Related methods

Sources

  1. McCarthy, D. & Navigli, R. (2009). The English Lexical Substitution Task. Language Resources and Evaluation, 43(2), 139-159.

    Open publication reference
  2. Zhou, W. et al. (2019). BERT for Context-Aware Lexical Substitution. Proceedings of the AAAI Conference on Artificial Intelligence, 33, 7557-7564.

    Open publication reference