liveBook · Manning

Candidate ranking

As explained in Knowledge Graphs and LLMs in Action

Candidate ranking is the phase of entity disambiguation that scores and orders possible reference entities using contextual and other evidence.

Candidate ranking scores and orders possible reference entities after named entity recognition and candidate selection. Contextual words surrounding a mention determine the scores; the highest-scoring candidate becomes the linked target. section 7.2

A typical knowledge-base entity-disambiguation pipeline is:

  • Recognize named entity mentions. section 7.2
  • Select possible candidates from a structured knowledge base. section 7.2
  • Rank candidates using contextual information and use the highest score for linking. section 7.2
  • Integrate linked entities with domain ontologies into a unified knowledge graph. section 7.2

Zika disambiguation

For “Zika virus,” scispaCy ranks Zika Virus (C0318793) first, while “Zika virus infection” ranks Zika Virus Infection (C0276289) first. The same surface term can therefore resolve to different UMLS entities by context.

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])

A scispaCy implementation loads an NLP model, configures UMLS linking, processes biomedical text, and prints ranked candidates. section 7.2

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Defines contextual scoring and demonstrates ranked outputs, but does not detail the scoring algorithm’s internals.
Examples
Uses biomedical Zika mentions, ranked UMLS identifiers, scispaCy code, and an annotated linked-text workflow.
What it assumes
Assumes recognized mentions and an existing structured knowledge base, while explaining the unresolved ambiguity left by NER.
What you can do after
Apply it via scispaCy to inspect ranked candidates and link recognized biomedical mentions to UMLS entities.
How it connects
Connects named entity recognition, candidate selection, knowledge bases, ontology integration, UMLS, and knowledge graphs.

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.