Foundation-model embedding search against a reference atlas — helping pathologists recognize cancer subtypes they may see only once in a career
Cancer classification follows a punishing long-tail distribution: a relatively small number of common subtypes account for the overwhelming majority of cases any individual pathologist encounters, while hundreds of rare and ultra-rare subtypes are each seen only a handful of times — sometimes never — across an entire career. When that rare case arrives, the pathologist has no personal experience bank to draw on, and textbook photographs cannot substitute for having examined confirmed cases directly.
Cancer diagnosis by morphology is fundamentally a pattern-recognition task, and pattern recognition — in humans and in machine learning models alike — depends on prior exposure to enough examples to build a reliable internal representation of what a category looks like across its natural variation. For common subtypes (invasive ductal carcinoma of the breast, conventional clear-cell renal cell carcinoma, typical prostate adenocarcinoma), a practicing pathologist accumulates hundreds to thousands of career exposures, more than sufficient to build robust pattern recognition even for atypical presentations within the subtype.
Rare subtypes invert this entirely. A subspecialist soft-tissue pathologist at a major referral center might see a handful of epithelioid sarcoma cases per year; a general community pathologist may encounter one every few years, if ever. When such a case does arrive, several compounding problems make correct classification disproportionately difficult:
• Morphologic mimicry: many rare subtypes are specifically defined by how closely they mimic more common entities or each other — clear-cell sarcoma can resemble melanoma, epithelioid sarcoma can resemble carcinoma or granulomatous inflammation — precisely the kind of differential that benefits most from having seen multiple confirmed examples side by side • Absent institutional memory: even at large academic centers, any single pathologist's personal case log for an ultra-rare subtype is too small to constitute reliable pattern-recognition training data, regardless of how many years they have practiced • Ancillary test ambiguity: rare subtypes often require specific immunohistochemical panels or molecular confirmation (characteristic translocations, fusion genes) that are only ordered once morphology raises appropriate suspicion — meaning the initial morphologic recognition step is a gating bottleneck for the entire diagnostic workup • Consequence of delay or error: many rare subtypes carry substantially different prognosis and treatment implications than their common mimics, so a missed or delayed rare-subtype diagnosis can materially change clinical management, not merely academic classification
General-purpose AI cancer classifiers trained end-to-end on large labeled datasets face the same long-tail problem as human pathologists: rare subtypes are, by definition, underrepresented in any training set assembled from routine clinical case volume, so a standard supervised classifier trained to output one of N discrete subtype labels will have seen too few examples of the rarest categories to learn a reliable decision boundary for them — often performing far worse on rare classes than its aggregate accuracy metric would suggest.
Reference-atlas similarity search sidesteps this specific failure mode by reformulating the task: rather than asking a classifier to output a single best-guess label from a fixed, imbalanced label set, it asks "which confirmed cases in a curated reference collection does this query most closely resemble morphologically?" This retrieval-based framing has two structural advantages for rare-disease diagnosis:
• New atlas entries require no retraining: adding a newly confirmed rare-subtype case to the reference atlas immediately makes it available as a potential match for future queries, without the cost, delay, or catastrophic-forgetting risk of retraining a supervised classifier • Few-shot robustness: because the underlying embedding model is trained to produce a general-purpose morphological representation (via self-supervised pretraining, not subtype-label prediction), a reference atlas subtype needs only a handful of confirmed exemplar cases — sometimes as few as one — to become a searchable, retrievable category, unlike a supervised classifier which typically needs many examples per class to learn a reliable decision boundary
This is precisely the workflow being simulated here: a pathologist facing an unfamiliar morphology submits the case not to a black-box classifier demanding a single label, but to a similarity search engine that surfaces the most morphologically similar confirmed cases — effectively giving any pathologist, anywhere, access to the pattern-recognition experience of the entire contributing reference collection.
The technical foundation of atlas-based similarity search is a self-supervised foundation model — a large vision encoder pretrained on millions of unlabeled histopathology tiles to produce a dense embedding vector for any input patch or slide, capturing morphological structure without ever having been told what any particular tile "is." This label-free pretraining is precisely what allows the same embedding model to generalize usefully to subtypes it was never explicitly trained to classify.
Pathology foundation models borrow self-supervised learning techniques originally developed for natural images and adapt them to the specific visual statistics of histology:
• Self-distillation approaches (DINO / DINOv2-style): a student network is trained to match the output of a slowly-updated teacher network on different augmented views of the same tile (different crops, color jitter, rotations) — because both views come from the same underlying tissue, the network learns representations that are invariant to superficial variation (staining intensity, orientation, minor cropping) while remaining sensitive to genuine morphological structure • Masked autoencoding (MAE-style): large patches of the input tile are masked out, and the network is trained to reconstruct the missing regions from visible context — forcing the model to learn the statistical regularities of tissue architecture, since accurate reconstruction requires understanding how cellular and glandular patterns typically continue • Multi-institution, multi-scanner pretraining corpora: leading pathology foundation models are deliberately pretrained on tiles sourced from many different hospital systems, scanner vendors, and staining protocols specifically to learn representations robust to the same domain-shift problems that plague narrowly-trained supervised classifiers (see the MIDOG domain generalization challenge discussed in related detection literature)
Because no diagnostic label is used anywhere in this pretraining process, the resulting embedding space organizes tiles by genuine visual and structural similarity rather than by whatever labels happened to be available in a specific training set — which is exactly the property needed for a rare subtype, never specifically labeled during pretraining, to still land in a sensible, retrievable region of the embedding space near its true morphological neighbors.
A whole-slide image must ultimately be represented as a single fixed-length vector (or a small set of vectors) for efficient similarity search, requiring an aggregation step analogous to the multiple-instance-learning pooling used in slide-level classification:
1. Tile embedding: every diagnostically relevant tile in the query slide is passed through the frozen foundation-model encoder, producing one embedding vector per tile 2. Region-of-interest selection: rather than embedding the entire slide (much of which is normal tissue, stroma, or background), the pathologist or an automated tissue/region detector selects the specific area of unusual morphology to be used as the query — concentrating the search on the diagnostically relevant field 3. Aggregation: tile embeddings within the selected region are combined — via mean pooling, attention-weighted pooling, or a dedicated slide-level transformer head — into a single query vector representing that region's overall morphological signature 4. Optional multi-vector representation: some systems retain several representative tile embeddings per case rather than collapsing to one vector, allowing the similarity search to separately match on distinct morphological sub-patterns present in a heterogeneous rare tumor (e.g. both an epithelioid component and a spindle-cell component)
This embedding-extraction step is computationally lightweight relative to full slide classification — because the foundation model is used purely as a frozen feature extractor with no fine-tuning required per query, generating a query embedding for a new rare case typically takes well under a minute on standard inference hardware, making real-time interactive search practical during a live diagnostic session.
With the query slide reduced to a dense embedding vector, the core retrieval operation is a nearest-neighbor search: finding which cases in a reference atlas of thousands of confirmed diagnoses sit closest to the query in embedding space. At atlas scale, this requires purpose-built approximate nearest-neighbor (ANN) algorithms rather than brute-force comparison against every stored case.
Comparing a query embedding against every single case in the reference atlas using exact distance computation scales linearly with atlas size — perfectly tractable for a few thousand cases, but the goal of these systems is to eventually aggregate reference atlases across many contributing institutions, multi-institution consortia, and archived case libraries, potentially reaching hundreds of thousands to millions of confirmed rare-subtype exemplars. At that scale, brute-force search becomes a genuine latency bottleneck for an interactive diagnostic tool where a pathologist expects results in seconds, not minutes.
Approximate nearest-neighbor (ANN) algorithms trade a small, controlled amount of retrieval accuracy for large gains in search speed, using data structures built specifically to avoid exhaustive comparison:
• Hierarchical Navigable Small World graphs (HNSW): builds a multi-layer graph structure over the embedding space where each stored case is a node connected to its approximate neighbors; search proceeds by greedily navigating from a coarse top layer down to fine-grained lower layers, achieving sub-linear query time with very high recall (typically >95% agreement with exact nearest-neighbor results) at the accuracy settings used in clinical retrieval tools • Inverted File with Product Quantization (IVF-PQ): partitions the embedding space into clusters (via k-means), then compresses each stored vector into a compact quantized code; search first identifies the most relevant clusters, then performs fast approximate distance computation within those clusters using the compressed codes — trading some precision for substantially reduced memory footprint at very large atlas scale • ScaNN and related learned-quantization methods: further optimize the compression and search-ordering strategy using techniques tuned specifically to preserve ranking accuracy for the top-k results that matter most, rather than optimizing for overall distance accuracy across all candidates
For the atlas sizes currently deployed in pathology similarity-search tools (typically low thousands to tens of thousands of curated cases), HNSW-based search comfortably returns ranked results in well under a second on standard server hardware — fast enough to be used interactively during a live case review rather than as an offline batch process.
The quality of similarity search results depends entirely on the quality and coverage of the underlying reference atlas — an ANN index over a poorly curated or narrow atlas will confidently return poor matches. Building a clinically useful reference atlas for rare subtypes involves deliberate curation choices distinct from simply aggregating whatever cases happen to be available:
• Confirmed-diagnosis requirement: every atlas entry must carry a gold-standard confirmed diagnosis — typically requiring molecular or cytogenetic confirmation (specific fusion genes, immunohistochemical panels) for subtypes where morphology alone is insufficiently specific, not just an initial pathologist impression • Deliberate rare-subtype oversampling: because the whole point of the atlas is to cover the long tail, curation actively seeks out and prioritizes acquiring confirmed examples of rare and ultra-rare subtypes specifically, rather than passively accumulating whatever case mix reflects routine clinical volume (which would simply reproduce the same common-subtype bias the tool is meant to correct for) • Morphologic diversity within subtype: for each represented subtype, the atlas ideally contains multiple exemplars spanning the known range of morphologic variation (different growth patterns, differentiation grades, staining appearances) rather than a single canonical image — since real query cases will rarely match a single textbook exemplar exactly • Multi-institutional sourcing: atlas cases drawn from multiple contributing institutions and scanners help the retrieval system remain robust to the same staining- and scanner-variation effects that challenge any computational pathology tool, and reduce the risk that retrieval quality is an artifact of a single institution's particular case mix or imaging pipeline • Provenance and consent governance: because atlas entries constitute a shared, cross-institutional diagnostic resource, deployment requires clear data-sharing agreements, de-identification standards, and patient consent frameworks consistent with the sourcing institutions' governance requirements
A similarity-search tool is only as good as its atlas coverage of the specific rare subtype in front of the pathologist — if a subtype has zero or only one confirmed exemplar in the reference collection, the tool can at best return a single weak match rather than a genuinely differential-diagnosis-quality result, which is why atlas curation and multi-institutional contribution pipelines are as central to system quality as the embedding model itself.
Raw similarity search returns a ranked list of embedding-space nearest neighbors; converting that into a clinically usable differential diagnosis requires aggregating per-case similarity scores into subtype-level confidence, surfacing supporting evidence for each candidate, and presenting the result in a format that mirrors how pathologists already structure a differential.
A raw nearest-neighbor list returns individual matched cases, not diagnostic categories — if the top 5 matches happen to include 3 confirmed examples of subtype A and 2 of subtype B, the system must decide how to present this as a structured differential rather than a flat, undifferentiated list:
1. Per-candidate similarity scoring: each returned atlas case carries its own similarity score (typically cosine similarity, rescaled to an intuitive 0–100% range) reflecting how close it sits to the query in embedding space 2. Subtype grouping and aggregation: matched cases are grouped by their confirmed subtype label, and a subtype-level confidence signal is computed — commonly either the maximum similarity among that subtype's matches (favoring subtypes with at least one very close match) or a weighted vote across all matches within a similarity threshold (favoring subtypes with consistent, repeated matches) 3. Evidence-count weighting: a subtype supported by three independent atlas matches, all with high similarity, is presented as stronger evidence than a subtype supported by a single moderate-similarity match — mirroring how a human consultant would weigh "I've seen three cases just like this" more heavily than "this vaguely reminds me of one case" 4. Threshold-based cutoff: candidates below the pathologist-adjustable similarity threshold are excluded from the primary differential, though they typically remain visible in an expanded view — the threshold control lets the reviewer trade off differential breadth (lower threshold, more candidate subtypes shown, useful for genuinely uncertain cases) against differential precision (higher threshold, only very close matches shown, useful when case features are highly distinctive)
The design principle throughout is transparency: rather than collapsing everything into a single opaque "most likely diagnosis" output, the tool is deliberately built to preserve and surface the underlying evidence — which specific atlas cases matched, how closely, and how many — because a differential the pathologist can inspect and interrogate is categorically more useful for a genuinely rare, high-stakes case than a single unexplained top pick.
Interface design for the differential-ranking output directly affects whether the tool genuinely augments pathologist judgment or risks anchoring it inappropriately, echoing similar human-AI interaction concerns documented across explainable-AI pathology tools generally:
• Side-by-side visual comparison: rather than presenting only a subtype name and similarity percentage, effective interfaces show the actual matched atlas thumbnail image next to the query region, letting the pathologist directly visually assess whether the claimed morphological similarity is genuine and clinically convincing — a percentage score alone invites unwarranted trust, while a visible side-by-side comparison invites appropriate scrutiny • Linked case metadata: each matched atlas case is presented with de-identified supporting context — confirming immunohistochemical panel results, molecular findings, original institution and diagnosis date — giving the pathologist the same kind of supporting evidence a human subspecialist consultant would cite when suggesting a rare diagnosis • Explicit uncertainty communication: when the top-ranked similarity score itself is only moderate (common for genuinely ultra-rare or atypical presentations with limited atlas coverage), the interface explicitly flags the result as a lower-confidence differential rather than presenting a forced top-1 answer with false certainty — an important design safeguard against the same automation-bias risk documented in adjacent explainable-AI pathology tools • Multiple morphologic pattern handling: for heterogeneous tumors showing more than one distinct morphologic component, some tools support submitting multiple query regions independently, returning a separate differential for each pattern rather than forcing a single blended result that could obscure a genuine dual-pattern tumor
Given the diagnostic stakes and inherent uncertainty of rare-subtype classification, a similarity-search assistant is deliberately designed as a triage and evidence-gathering tool rather than an autonomous diagnostic authority — high-value or high-uncertainty matches are automatically routed toward confirmatory subspecialist review, molecular testing, or formal consultation rather than being accepted as a standalone diagnosis.
Several converging factors make automatic, assistant-only resolution of rare-subtype cases inappropriate as a matter of both clinical safety and current technical maturity:
• Irreducible retrieval uncertainty: even a high similarity score reflects morphological resemblance in embedding space, not biological ground truth — visually similar tumors can have different confirmed diagnoses, and the assistant has no mechanism to adjudicate this distinction beyond what visual similarity alone can indicate • Requirement for orthogonal confirmation: most rare subtypes with meaningful treatment implications require confirmatory ancillary testing beyond morphology — a specific fusion gene by FISH or RNA sequencing, a defining immunohistochemical marker pattern — that only a pathologist, informed by the assistant's suggested differential, can appropriately order and interpret • Regulatory and liability framing: computational pathology tools of this kind are explicitly positioned and, where applicable, regulatory-cleared as clinical decision support rather than autonomous diagnostic devices — the assistant's output is evidence for a licensed pathologist's judgment, not a standalone report • Rare-disease expertise concentration: true subspecialist expertise for many rare tumor types is concentrated at a small number of reference centers; routing a flagged case to the relevant subspecialist — rather than asking the general pathologist to resolve it entirely with only the atlas tool — connects the case to the deepest available pool of relevant human expertise, which the tool is designed to facilitate access to, not substitute for
The routing decision itself is typically triggered less by the numeric similarity score and more by the atlas match crossing into a designated rare/ultra-rare subtype category — meaning even a highly confident match to a known-rare entity still triggers confirmatory routing, precisely because the clinical stakes of a rare-subtype diagnosis (specific targeted therapy eligibility, distinct prognosis, clinical trial eligibility) generally warrant subspecialist sign-off regardless of how confident the initial computational match appears.
Because the routing step is designed to make the receiving subspecialist's job faster and more focused rather than simply forwarding a raw slide, the assembled consult package typically includes:
1. The original query slide (or the specific flagged region) with the assistant's attention/embedding-derived region-of-interest annotation, directing the subspecialist's eye immediately to the diagnostically relevant morphology rather than requiring a full independent slide review from scratch 2. The full ranked differential with matched atlas exemplars and their similarity scores, giving the subspecialist a starting hypothesis set and the specific comparison cases the assistant considered most relevant 3. Relevant clinical context (patient demographics, anatomic site, prior imaging or biopsy history) pulled from the case record, since rare-subtype likelihood is often materially informed by clinical context beyond morphology alone 4. A suggested confirmatory testing panel, generated from the differential's known defining ancillary markers, letting the subspecialist immediately order the most diagnostically efficient panel rather than working through an elimination sequence from scratch
This structured, pre-triaged consult package is the specific mechanism by which the tool compresses turnaround time (see Stage 6): rather than the referring pathologist needing to first recognize the case as unusual, then search literature or reach out informally to colleagues to identify who might have relevant expertise, then wait for that subspecialist to independently review a raw, unannotated slide from scratch, the assistant compresses the recognition and initial-hypothesis-generation steps into seconds, leaving the subspecialist to focus their limited time on final expert confirmation rather than initial pattern discovery.
The clinical value proposition of atlas-assisted rare-subtype classification is ultimately validated not by embedding-space metrics but by a concrete operational outcome: how much faster does a patient with a rare cancer subtype reach a confirmed diagnosis and, downstream, appropriate treatment — when their case benefits from similarity-search assistance compared to the traditional unassisted pathway of literature search, informal colleague consultation, and serial reference-lab referrals.
Before atlas-assisted similarity search, a pathologist encountering a genuinely unfamiliar morphology typically works through a slower, more serial diagnostic pathway with several identifiable time sinks:
1. Recognition delay: time spent recognizing that a case is unusual enough to warrant escalation beyond routine sign-out — a case that is subtly atypical rather than dramatically unusual can sit unescalated longer than one with obviously bizarre morphology 2. Literature and reference search: manual search of textbooks, journal articles, and online pathology image resources to try to match the observed morphology to a named entity — slow, dependent on the searcher's existing vocabulary of candidate diagnoses to even know what search terms to try 3. Informal colleague consultation: reaching out to colleagues who might have relevant experience, frequently by email or informal image-sharing, with response times dependent on colleague availability and requiring the sender to already have identified who might plausibly have seen a similar case 4. Formal reference-lab referral: for cases that remain unresolved, physical or digital slide referral to a formal reference laboratory or subspecialist consultant, which introduces shipping/transfer time, queue time at the receiving institution, and a full independent review cycle 5. Ancillary test iteration: without a focused differential to guide testing, ancillary immunohistochemistry or molecular panels may be ordered iteratively (test one hypothesis, wait for results, order the next test) rather than as a single efficiently-selected panel — each iteration adding days
Each of these steps individually may only cost a few days, but they compound serially in the traditional workflow, plausibly extending total time to confirmed diagnosis for a genuinely rare subtype into a multi-week timeframe even at well-resourced institutions.
Turnaround-time (TAT) impact is typically measured and reported using a small set of operationally meaningful timestamps across the diagnostic pathway:
• T0 — slide/case availability: when the diagnostic material is ready for review • T1 — escalation/query submission: when the case is recognized as requiring additional workup (assisted pathway: query submitted to the atlas tool; unassisted: informal escalation begins) • T2 — initial differential established: when a candidate diagnosis or differential list first exists (assisted: near-immediate, seconds to minutes after query; unassisted: after literature search and/or informal consultation, commonly days) • T3 — confirmatory testing ordered: when the appropriate ancillary panel is requested, ideally guided by an efficient, focused differential rather than iterative guessing • T4 — confirmed diagnosis: when subspecialist review and ancillary results converge on a final, sign-out-ready diagnosis
Assisted-pathway reductions are concentrated specifically in the T1→T2 interval (recognition and initial-hypothesis-generation time compressed from days to effectively real time) and the T2→T3 interval (a focused, atlas-derived differential enabling single-pass rather than iterative ancillary test selection) — the T3→T4 confirmatory-testing and subspecialist-review interval itself is not fundamentally shortened by the assistant, since genuine biological confirmation still requires real laboratory turnaround and expert judgment time, which the tool deliberately does not attempt to bypass.
Beyond the operational efficiency metric itself, faster time to confirmed rare-subtype diagnosis carries direct downstream clinical significance: many rare subtypes are specifically associated with targeted therapy eligibility (subtype-defining fusion genes increasingly correspond to approved or trial-available targeted agents), clinical trial enrollment windows, and treatment sequencing decisions where earlier confirmed diagnosis directly translates to earlier access to the most appropriate therapy — meaning diagnostic turnaround-time improvement in this setting is not merely an administrative efficiency metric but a proxy for a genuine, patient-relevant clinical outcome.
The primary mechanism by which atlas-assisted similarity search shortens turnaround time is not faster laboratory testing — it is compressing the recognition and initial-hypothesis-generation step, historically the least standardized and most variable part of the rare-subtype diagnostic pathway, from a serial, expertise-dependent search process taking days into a near-instantaneous, systematically thorough embedding-space search taking seconds.
| Product | Indication | Trial Design | Key Result |
|---|---|---|---|
| Recognition of atypical morphology | Pathologist judgment call | Unassisted: experience-dependent; Assisted: same, but low-confidence cases flagged | Earlier, more consistent escalation |
| Initial hypothesis generation | Candidate subtype identification | Unassisted: manual literature/memory search (days); Assisted: embedding search (seconds) | Days-to-seconds compression |
| Confirmatory test selection | IHC / molecular panel ordering | Unassisted: often iterative; Assisted: guided by ranked differential | Single-pass efficient testing |
| Subspecialist engagement | Expert confirmation | Unassisted: informal outreach; Assisted: structured consult routing with pre-annotated package | Faster, better-prepared review |