liveBook · Manning

Disambiguation

As explained in Knowledge Graphs and LLMs in Action

Named entity disambiguation is the technique of determining which real-world entity a mention in text refers to and linking it to the correct knowledge-base entity.

Named entity disambiguation (NED) determines which real-world entity a mention denotes by using its context and linking it to a reference knowledge base. It resolves distinctions that named entity recognition alone leaves ambiguous, such as Zika virus, Zika virus infection, and congenital Zika syndrome. section 7.1 section 7.2

A knowledge-base NED pipeline usually proceeds through three phases:

  • Candidate selection finds possible entities for each recognized mention against a knowledge base. section 7.2
  • Candidate ranking scores candidates using surrounding contextual words and selects the highest-scoring target. section 7.2
  • Ontology integration combines terminology, classifications, coding standards, and relationships from domain ontologies into a knowledge graph. section 7.2 section 7.8

Disambiguating Zika mentions

In a report about Belize, scispaCy ranks “Zika virus” as UMLS C0318793, “congenital Zika syndrome” as C4546023, and “Zika virus infection” as C0276289. The distinct links preserve medically important differences between related mentions. section 7.1 section 7.2

The linked entities become entry points for retrieving ontology relationships and supporting conceptual search, structured knowledge-based search, interpretability, discovery, and knowledge discovery. Production representations can retain both the original EntityMention and the disambiguated MedicalEntity, preserving mention positions, aliases, and source-page links. section 7.6.3 section 7.7

Traditional systems such as scispaCy depend on domain vocabularies, struggle to extend or update their reference knowledge, and do not use ontology paths during disambiguation. An alternative combines a general-purpose LLM with a domain ontology: full-text search selects candidates, then shortest paths, path-to-text translation, and textual-path summarization provide relational context for final selection. section 8.1 section 8.4

Figure 7.2 Architecture of the NED system, including the three main phases: candidate selection, candidate ranking, and ontology integration
figure

Use the architecture to trace candidate selection, candidate ranking, and ontology integration as one NED workflow. section 7.2

Listing 7.1 Selecting and ranking candidates with the scispaCy model
import spacy
from scispacy.linking import EntityLinker

nlp = spacy.load("en_core_sci_md")
nlp.add_pipe("scispacy_linker",
             config={"resolve_abbreviations": True, "linker_name": "umls"})

linker = nlp.get_pipe("scispacy_linker")
linker_dict = linker.kb.cui_to_entity

doc = nlp("""In the week of 13 April, Belize reported for the first time 
mosquito-borne Zika virus transmission. Update on the observed increase 
of congenital Zika syndrome and other neurological complications 
Microcephaly and other fetal malformations potentially associated with 
Zika virus infection.""")
for ent in doc.ents:
  if "Zika" in ent.text:
    print("Recognized entity:", ent.text, ent.start_char, ent.end_char)
  print("Ranked target candidates:")
  for kb_ent in ent._.kb_ents:
    print('-', linker_dict[kb_ent[0]][0], linker_dict[kb_ent[0]][1])

Use the scispaCy listing to implement UMLS candidate retrieval and ranked linking in Python. section 7.2

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains candidate selection, ranking, ontology integration, ingestion, and LLM path-based disambiguation, while noting traditional-system limitations.
Examples
Uses Zika mentions, UMLS identifiers, scispaCy rankings, SNOMED relationships, Python ingestion, and Neo4j knowledge-graph construction.
What you can do after
Build it with scispaCy and UMLS, ingest linked entities into Neo4j, or operate an ontology-guided LLM pipeline for complex biomedical text.
How it connects
Connects named entity recognition, knowledge bases, ontology integration, knowledge graphs, full-text search, large language models, and shortest-path detection.

Also explained in

Compare how 3 books explain disambiguation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.