In clinical entity linking, candidate generation is the critical first-pass filter that reduces the search space from millions of potential concepts to a manageable shortlist—typically 5 to 50 candidates. This stage prioritizes recall over precision, ensuring the correct concept is almost certainly within the retrieved set. Common techniques include BM25 lexical retrieval against entity descriptions, dense passage retrieval using bi-encoder architectures like SapBERT, and dictionary-based lexical variant generation that programmatically expands acronyms and morphological variations to match against the UMLS Metathesaurus.
Glossary
Candidate Generation

What is Candidate Generation?
Candidate generation is the initial, high-recall retrieval stage in an entity linking pipeline that uses fast, approximate methods to fetch a small set of plausible knowledge base entries for a given text mention.
The efficiency of candidate generation directly determines the latency profile of the entire linking system. By leveraging approximate nearest neighbor (ANN) search over pre-computed dense vector indices, modern systems can retrieve candidates in sub-millisecond timeframes. Constraints like semantic type filtering—restricting matches to specific UMLS Semantic Types such as 'Clinical Drug' or 'Disease or Syndrome'—further prune irrelevant candidates before the computationally expensive candidate ranking stage applies a cross-encoder reranker for final disambiguation.
Key Characteristics of Candidate Generation
Candidate generation is the high-recall, low-latency first stage of entity linking that rapidly narrows a knowledge base of millions of concepts down to a manageable shortlist of plausible matches for a given text mention.
High Recall Over Precision
The primary objective is to ensure the true entity is present in the candidate set, even at the cost of including false positives. A recall of >95% is typically targeted. The downstream candidate ranking stage handles precision.
- Trades specificity for comprehensiveness
- Often uses approximate methods to avoid missing rare concepts
- Failure here is catastrophic; a missed entity cannot be recovered later
Sub-Linear Retrieval Speed
Candidate generation must execute in milliseconds against knowledge bases containing millions of entities. This is achieved through indexing structures that avoid exhaustive comparison.
- Inverted indices for lexical matching
- Approximate Nearest Neighbor (ANN) graphs for dense vector search
- Pre-computed alias tables mapping surface forms directly to concept IDs
Lexical-Dense Hybrid Retrieval
Modern pipelines combine BM25 sparse retrieval with dense bi-encoder similarity to capture both exact terminology and semantic meaning.
- Lexical: Matches 'myocardial infarction' to entries containing that exact phrase
- Dense: Matches 'heart attack' to 'myocardial infarction' via embedding proximity
- Hybrid scoring merges results from both pathways for robust coverage
Alias and Synonym Expansion
Knowledge bases are pre-processed to generate extensive surface form dictionaries that map common clinical shorthand and variants to canonical IDs.
- 'HTN' → Hypertension
- 'MI' → Myocardial Infarction
- Abbreviation expansion and lexical variant generation are critical pre-retrieval steps
- Reduces reliance on computationally expensive semantic matching at query time
Semantic Type Filtering
A hard constraint applied during retrieval to restrict candidates to a specific UMLS Semantic Type. If a mention is identified as a medication, only entities typed as 'Pharmacologic Substance' or 'Clinical Drug' are considered.
- Dramatically reduces the candidate pool size
- Prevents cross-domain false positives (e.g., linking a drug name to a disease concept)
- Requires accurate upstream mention type classification
NIL Prediction Awareness
The retrieval stage must be designed to facilitate NIL prediction—identifying when a mention has no valid target in the knowledge base. This is often handled by setting a minimum similarity threshold.
- If no candidate exceeds the threshold, the mention is flagged as unlinkable
- Prevents forced grounding of novel or misspelled terms
- Critical for maintaining clinical data integrity in production systems
Frequently Asked Questions
Clear, technical answers to the most common questions about the initial retrieval stage in clinical entity linking pipelines.
Candidate Generation is the initial, high-recall retrieval stage in an entity linking pipeline that uses fast, approximate methods to fetch a small set of plausible knowledge base entries for a given text mention. Its primary goal is to reduce the search space from millions of potential concepts to a manageable shortlist—typically 5 to 100 candidates—that a more computationally expensive Candidate Ranking model can then score precisely. This stage prioritizes recall over precision; it is acceptable to retrieve some incorrect candidates as long as the correct entity is almost always present in the candidate set. Common techniques include BM25 lexical retrieval, Approximate Nearest Neighbor (ANN) search over dense embeddings, and dictionary-based Lexical Variant Generation using pre-built alias tables from the UMLS Metathesaurus.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Explore the core components that interact with candidate generation to form a complete clinical entity linking system.
Candidate Ranking
The final stage of entity linking where a more computationally intensive model scores and orders the generated candidates to select the single best match. Unlike candidate generation's focus on high recall with fast, approximate methods, ranking applies cross-encoders or deep transformer models to jointly encode the mention and each candidate, producing a high-fidelity relevance score. This stage handles the nuanced disambiguation that coarse retrieval cannot resolve.
Bi-Encoder Architecture
A dual-tower neural network that independently encodes a text mention and a knowledge base entity into dense vectors for efficient, scalable semantic similarity search. This architecture is the backbone of modern candidate generation:
- Mention Encoder: Processes clinical text spans into fixed-length embeddings
- Entity Encoder: Encodes canonical knowledge base entries offline
- Similarity: Computed via dot product or cosine distance between the two vectors
- Indexing: Entity embeddings are pre-computed and stored in a vector index for sub-linear retrieval
BM25 Retrieval
A robust, bag-of-words-based ranking function used as a strong lexical baseline for generating candidate entities. BM25 excels at exact and near-exact string matching, making it highly effective for clinical terms with standardized nomenclature. It serves as a complementary signal to dense retrieval:
- Term Frequency: Rewards repeated term overlap between mention and entity description
- Inverse Document Frequency: Down-weights common tokens like 'syndrome' or 'acute'
- Document Length Normalization: Prevents bias toward longer entity descriptions
Approximate Nearest Neighbor Search
An indexing algorithm that trades a small amount of accuracy for a massive gain in speed when searching for the closest dense vectors in a high-dimensional entity embedding space. ANN is essential for scaling candidate generation to large ontologies like UMLS, which contains millions of concepts. Common implementations include FAISS (Facebook AI Similarity Search) and ScaNN (Scalable Nearest Neighbors), which use techniques like product quantization and hierarchical clustering to achieve sub-millisecond retrieval.
Semantic Type Filtering
A constraint applied during candidate retrieval that restricts potential matches to entities belonging to a specific UMLS Semantic Type. For example, if a mention is known to be a medication, candidates are filtered to only 'Pharmacologic Substance' or 'Clinical Drug' types. This dramatically reduces the candidate pool and prevents cross-domain false positives:
- Type Detection: Often performed by a preceding NER model
- Filtering Granularity: Can use broad categories (Disorders, Chemicals & Drugs) or fine-grained types
- Fallback: If no candidates match the type constraint, the filter is relaxed to ensure recall
Contrastive Learning
A self-supervised training paradigm that learns representations by pulling positive mention-entity pairs together and pushing negative pairs apart in vector space. This is the dominant training strategy for the dense retrievers used in candidate generation:
- Positive Pairs: A clinical mention and its correct UMLS concept
- Negative Pairs: The same mention paired with randomly sampled or hard-mined incorrect entities
- Loss Function: Typically InfoNCE or triplet loss, optimizing for a representation space where relevant entities are nearest neighbors
- Hard Negative Mining: Selects highly confusable but incorrect candidates to sharpen the embedding space

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us