Skip to content
Adi's Digital Garden

Deep dive · 03

Extracting biomarkers — NER, then RE

Part 2 of the solution. Once a report is confirmed NGS, its text runs through two models: a BERT NER model that finds the biomarkers and the mutations, and a relationship-extraction model that figures out which mutation belongs to which biomarker — the hard part, because OCR scrambles the layout.

The two-model pipeline

NGS report text The OCR'd / parsed text of a confirmed NGS report.
NER model Tags every biomarker and mutation entity, with character spans.
RE model Decides which biomarker–mutation pairs are real relationships.
(biomarker, mutation) Structured records — the genomic profile of the patient.
Finding the entities and linking them are deliberately separate problems — recognition is local, but the correct pairing depends on a layout the text no longer carries.

The NER model — find biomarkers & mutations

BRAFbio result p.V600Emut detected  ·  EGFRbio exon 19 deletionmut  ·  TP53bio no variantmut
biomarker entity mutation entity
A BERT-based token classifier that flags exactly two entity types — biomarker and mutation — each with its start and end position in the text.
Detail — why span-level tagging

The model emits the character span of every entity, not just a label. Those positions are what the next stage reasons over: the relationship model needs to know where each biomarker and mutation sit relative to one another, since proximity is one of the few signals that survives OCR.

Why pairing is the hard part

Different NGS lab tests present results in different layouts. When OCR linearizes the page, a biomarker and its mutation can end up far apart in the text — or in the wrong order — so you can't just pair each entity with its nearest neighbor.

Double-column

Each column holds a biomarker stacked with its own result; the page runs two such columns side by side.

BRAF
V600E
EGFR
exon 19 del

Stacked

Mutation printed directly below the biomarker name.

BRAF
V600E
EGFR
exon 19 del

Split-aligned

Biomarkers left-aligned, results right-aligned across the page.

BRAF······ V600E
EGFR·· exon 19 del

Reading order off the page rarely matches the visual pairing — so associating the right mutation with the right biomarker means a model that has effectively learned all these reporting formats.

The RE model — link mutation to biomarker

After NER — entities + spans
bio › BRAF @ 12–16
bio › EGFR @ 21–25
mut › exon 19 deletion @ 58–73
mut › V600E @ 141–146
— order on the page ≠ correct pairing —
After RE — classified pairs
BRAF → V600E
EGFR → exon 19 deletion
BRAF → exon 19 deletion
EGFR → V600E
The RE model takes candidate biomarker–mutation pairs within a neighborhood and classifies each as a real relationship or not — recovering the pairing the layout encoded but the text lost.
Detail — candidate generation & the learned signal

Rather than assume adjacency, the model enumerates plausible pairs of biomarker and mutation entities within a neighborhood and judges each one. Because it's trained across the different lab-report formats, it learns the spatial and textual cues that distinguish a genuine biomarker–result pair from a coincidental nearby one — which is what makes it robust to double-column, stacked, and split-aligned reports alike.

What comes out

The pipeline turns each NGS report into a clean set of (biomarker, mutation) records — a structured genomic profile per patient. Those records are exactly what feeds the human-in-the-loop validation step next, and ultimately the Genome360 dataset.

← Back to finding the needle Next: Human-in-the-loop →