Elide splits redaction into two calls. The first finds what is sensitive and returns a report; the second applies that report to the file. This post is about the first half: how the findings of several recognizers become one set of entities, and how a person checks that set before anything is destroyed. Part 2 covers what happens to the file after.
If you have not met Elide yet, Introducing Elide is the shorter tour.
One recognizer is never enough
Each kind of recognizer is good at something the others are bad at.
Patterns with validators are precise on identifiers with a known shape. A card number has to pass Luhn, an IBAN its check digits. They run in microseconds and find nothing they were not told to look for.
Named-entity models find names, organizations and addresses, which have no fixed shape. They are noisy near class boundaries and degrade quietly when the text drifts away from what they were trained on.
Language models catch what neither of the others can: a codename that only matters inside one company, “my condition” in a medical note. They are the slowest, the most expensive and, in the words of the detection design notes, the least calibrated.
None of them subsumes the others, so Elide runs all three and decides later. The rest of this post is that decision.
A running example
Take one line from a clinic’s intake form:
Patient Jordan Lee, SSN: 214-55-0193, seen at Harbor Clinic, 1200 Harbor
Road, Springfield, IL 62704.
With patterns, a NER model and an LLM registered, the candidate set might look like this. The pattern scores come from Elide’s shipped rules; the model scores are illustrative.
The SSN pattern matches 214-55-0193. The US postal code pattern matches
62704 at 0.2. The NER model reports Jordan Lee as a person at 0.7 and the
whole street address as an address at 0.8. The LLM also reports Jordan Lee as
a person, at 0.6.
That is already every kind of disagreement. The same name was found twice. The postal code sits inside the address. And the numbers sit on different scales: a 0.7 from a NER model and a 0.6 from a language model measure different things.
Confidence moves before anything is compared
The first adjustment happens inside the pattern recognizer. A rule can declare context keywords, and a keyword found within five words either side of a match lifts its score.
Elide’s shipped SSN rule shows why this matters. A formatted match like
214-55-0193 scores 0.5. The rule’s keywords include “ssn” and “social
security”, matched whole-word and case-insensitively, and the default lift is
0.35, so the same digits after SSN: are a 0.85. The nine digits run together,
214550193, score only 0.05, because on its own a nine-digit number is more
likely an order number than an identity. That is below the default threshold
of 0.35, so a bare run is dropped, unless a keyword lifts it to 0.4 and over
the line. The keyword is what tells a social security number from a parcel
number. A rule can set its own lift, and can also be lifted by an anchor: a
nearby match of another label, such as a currency beside an amount.
The postal code gets no lift. None of its keywords (“zip”, “postal”, “address”, “mailing” and a few more) appear near it, so it stays at 0.2. Each lift is recorded on the entity’s audit trail with the keyword that fired. Model-based recognizers weigh context themselves and skip this pass.
Calibrate
Calibration belongs to a recognizer, so it is attached to one.
Calibrated wraps a recognizer with a Calibration: a multiplier
for every label it reports and, where a model runs hot or cold on some labels,
one per label. Each finding is scaled as the recognizer reports it, and the
result is clamped to [0, 1]. Because the wrapper is itself a recognizer, it
goes anywhere the one it wraps does, and RecognizerExt makes it a method:
llm.calibrated(calibration). Multipliers are checked when they are made, so
building a calibration cannot fail.
This is how you say that a language model’s 0.6 should count for less than a NER model’s 0.6, or that a regex returning 1.0 for everything should be brought down before it is compared with a model. Two NER models get two calibrations, since each is wrapped on its own. It is a plain linear rescale, and it only helps if you have measured your recognizers on your own data. The multiplier and the new score both go on the trail.
Fuse what agrees
FuseLayer clusters findings that share a label and overlap, and fuses each
cluster into one entity over the union of their spans. How the fused score is
computed is a choice between two shipped scorings.
FuseLayer::max() keeps the highest score, and is the default. The NER model’s
0.7 and the LLM’s 0.6 on Jordan Lee fuse into one person at 0.7. Agreement
never lowers the score, and nothing is assumed about how the two recognizers
relate.
FuseLayer::noisy_or() treats each finding as an independent witness and
combines them as 1 − (1 − a)(1 − b):
1 − (1 − 0.7)(1 − 0.6) = 1 − 0.3 × 0.4 = 0.88
Three agreeing witnesses at 0.6 reach 1 − 0.4³ = 0.936. Agreement raises
confidence, which is the point, and is also the risk: noisy-OR is sound only
when the witnesses really are independent. Two regexes for the same format are
not, and fusing them with noisy-OR inflates the score. That is why it is not
the default. Either way, the fused entity keeps every member’s trail, joined by
one fusion event that names the scoring and the pooled score.
Reconcile what conflicts
ReconcileLayer handles overlaps between different labels. The default,
ReconcileLayer::structural(), reads how the two spans relate and
treats only some overlaps as a fight.
Nested. One span lies strictly inside the other. A postal code inside an address is
a real hierarchy, so both are kept, unless the inner one is weaker than its
container by at least 0.25. Here 62704 at 0.2 sits inside an address at 0.8,
and 0.2 + 0.25 ≤ 0.8, so the postal code is dropped as a subsumed sub-match
and recorded on the address’s trail.
Touching. The spans cross with an intersection-over-union below 0.5. These are two distinct findings that happen to share some characters, and both are kept.
Coincident. The spans are the same, or cross with an intersection-over-union of 0.5 or more: two recognizers claiming substantially the same text under different labels. Say a person over characters 0 to 12 at 0.9 and an organization over 2 to 14 at 0.7. They share 10 of 14 characters, an IoU of about 0.71. This is a true conflict, and so, most plainly, is a person and an organization over exactly the same characters.
By default a conflict is resolved: the tiebreaker keeps the higher-confidence
finding, drops the other, and records the loser’s label and score on the
winner. That is clean output, and it is a machine guessing at a question of
meaning. With Structural::default().reviewing(), the layer declines to guess.
Both findings survive, each flagged as contested against the other, for a
person to settle during review.
Threshold, and why the order matters
ThresholdLayer drops whatever is below a confidence cutoff. Its default,
ConfidenceThreshold::BASELINE, is 0.35, the same as Presidio’s default
acceptance level. The full pipeline, with the language model’s scores
discounted, noisy-OR, and contested conflicts left for review, is:
use elide::prelude::*;
use elide::recognition::decorator::RecognizerExt;
use elide::recognition::decorator::calibrated::{Calibration, Multiplier};
const LLM: Multiplier = Multiplier::new(0.8).unwrap();
let analyzer = Analyzer::<Text>::new()
.with_recognizer(patterns)
.with_recognizer(ner)
.with_recognizer(llm.calibrated(Calibration::scale(LLM)))
.with_layer(FuseLayer::noisy_or())
.with_layer(ReconcileLayer::new(Structural::default().reviewing()))
.with_layer(ThresholdLayer::default());
Layers run in the order they are added, and none are implicit. Calibration happens earlier: every later step compares scores, and the comparison only means something once the scales agree, so scores are scaled as each recognizer reports them, before the first layer runs. There is no order to get wrong.
Fusion goes before reconciliation because it changes who wins. Suppose an
organization claim at 0.8 crossed Jordan Lee. Reconciled one by one, each
person finding loses to it: 0.7 and 0.6 are both below 0.8. Fused first with
noisy-OR, the person is a single 0.88 and keeps the span.
The threshold goes last because evidence accumulates. Two witnesses at 0.3 are
each below 0.35, and a threshold run first would drop both. Fused, they are
1 − 0.7 × 0.7 = 0.51 and pass.
For the intake line, leaving the language model uncalibrated, what comes out is an SSN at 0.85, one person at 0.88 and an address at 0.8. The postal code is gone, and its claim is recorded on the address.
Detection ends in a report
That set goes back to the caller first. The orchestrator’s analyze
returns it as a Report: every entity, keyed by the part of the document it
sits in, with its full trail and no live document state. anonymize_with
applies a report later. Between the two calls the report is just data, which
is what makes it reviewable.
The address is a good reason to review. It belongs to the clinic, and it is printed on every form the clinic sends. A reviewer keeps it:
use elide::entity::audit::Attribution;
let analyzed = orchestrator.analyze(&mut document).await?;
let mut report = analyzed.report;
report
.part_mut::<Text>(&document.id())?
.by("reviewer-7")
.because(Attribution::freeform("public clinic address"))
.suppress(address_id);
Through part_mut a reviewer can also include something detection missed,
relabel an entity, or move its span. None of these rewrite detection’s output
in place. Each is recorded on the entity’s trail as a manual event naming the
intent, the location, who made it, and why. Without by, the source is
"manual", so an unattributed edit is still visibly a human one.
Suppressed entities stay
A suppressed entity stays in the report. Whether it is suppressed is read from its trail; there is no separate flag that could drift out of sync with it. The address’s trail now reads:
model 0.80 ner, address, at 61..100
conflict 0.80 won over a postal code at 0.20
manual 0.80 reviewer-7, suppress, "public clinic address"
This answers the question an auditor asks second: “what did you find and choose to leave?” A system that drops rejected findings cannot answer it.
Reviewers often want to clear a whole area at once, such as a letterhead.
suppress_within takes a region and suppresses every entity it contains,
returning which ones. The word that matters is “contains”: a finding that
starts inside the letterhead and runs past its edge is left alone and still
redacted. A region that spared anything it touched would leak the half that
sits outside it.
Review takes time
Review is rarely immediate, so a Report serializes, trails included, and
Report::deserializer() reads one back days later in another process. Every
trail is verified as it loads, so a report with an event edited on the way is
refused. That proves each trail is consistent with itself, which is less than
proving the report is the one you saved: a trail cut back to an earlier event,
or rewritten with its hashes recomputed, still loads. Record report.digest()
somewhere the report’s carrier cannot write, after analysis and again after a
trusted review, and compare it before applying; part 2
covers what it catches. A part of a modality the reader does not know is an
error too, because its entities may carry a reviewer’s edits.
Analysis also returns its artifacts: the OCR layouts and transcripts it
produced. Keep them beside the report and pass them to re_analyze to detect
again, under a new scope or with another recognizer, without running OCR or
speech-to-text a second time.
What this does not promise
The pipeline is deterministic: the same inputs give the same set. That makes it predictable, and says nothing about whether the set is right. Reconciliation cannot find what no recognizer reported, and a fused score is only as meaningful as the scores that went into it. The weakest of those are a language model’s: Elide uses the confidence the model reports, and 0.5 when it reports none, and a model’s confidence in its own output may carry little information. Calibrating it, or keeping it out of noisy-OR, is a decision to make on measured data.
Elide is also a library. It records a reviewer’s decisions; the review queue, the interface, and who may approve what belong to the application around it.
Part 2 picks up the reviewed report: what each entity becomes, what else leaves the file with it, and how the record proves the plan a reviewer saw is the plan that ran. The source is at nvisycom/elide.
