Zero Labs
Industry News / AI

The Fact Your Extractor Never Mentioned

Source · Towards AI By Massimiliano Geraci

From the publisher’s feed, collected in the ZeroLabs newsroom.

In a regulated domain, the dangerous answer isn’t the wrong one. It’s the true one your source never said.A source can be entirely correct and still dangerously incomplete.Picture an extraction system that does everything you asked of it. You feed it a clinical summary — “metformin, first-line for type 2 diabetes” — and it returns clean, typed, well-formed facts. Every one of them is correct. The system is also, in the way that matters most, unsafe.Metformin is contraindicated in severe renal impairment, and the summary never said so. The extractor didn’t get a fact wrong; it stayed faithful to a document that was itself incomplete. In a SaaS catalog, that omission is a blank field. In pharma, it is the distance between a useful answer and a harmful one.This is the failure almost no “LLM-plus-knowledge-graph” demo accounts for, because almost all of them are built to measure agreement: does the extracted fact match the text? The more useful question — and in a regulated domain, the more dangerous one to ignore — runs the other way. What does the source fail to say that the world already knows to be true?That question only has an answer if something other than the language model holds the ground truth.So the premise underneath everything that follows is deliberately narrow: the model proposes, an authority disposes. A language model is an excellent candidate generator. It reads messy prose and suggests typed entities and relations faster, and far more flexibly, than any rule set. It is a poor system of record. The moment you let it decide what is true — what a drug is, what it interacts with, what it must never be combined with — you have traded a checkable claim for a fluent assertion. In a regulated domain, fluent assertions are precisely the thing you cannot ship.What follows is a working pipeline built on that premise: an open-source semantic library, public biomedical corpora, and public authorities such as RxNorm and openFDA — wired so the language model never gets the last word, and so the system notices not only when a document is wrong, but when it is silent.What this is — and what it isn’tThis is a lab build, not a product. There is no client behind it and no private data inside it.The semantic layer is Semantica, an open-source library by Mohd Kaif. The corpora are public biomedical documents. The authorities are public services: RxNorm, openFDA, ChEMBL, and ChEBI. Nothing here was trained on proprietary records, and nothing here claims regulatory clearance.The reason to say so plainly is that the claim is architectural, not commercial. A knowledge graph does not make a system honest. It makes a system inspectable, which is a different and lesser virtue. If you fill a graph with whatever a language model asserted and then read those assertions back as ground truth, you have not removed the hallucination — you have given it a schema. Inspectability only ever asks whether the graph agrees with its sources; it cannot ask whether those sources are safe against what the world already knows. Agreement is local to a document. Safety is relative to the world. The build exists to draw that line precisely: where the model’s authority ends and an external authority’s begins.The pipeline at a glanceThe pipeline runs in ten phases: ingest, parse, chunk, extract, enrich, validate, ontology, KG, persist, truth-align.The ten phases. The model proposes at extraction; nothing downstream of it lets the model adjudicate a fact.Most of these are unremarkable, and that is intended. Ingestion records documents with their provenance. Parsing normalizes them to text. Chunking cuts that text into evidence units that keep a document ID, character offsets, and a quotable span. Extraction proposes entities and relations. Enrichment attaches external identifiers. Validation removes duplicates and flags conflicts. Ontology generation lifts the observed shape into a formal vocabulary. The KG phase assembles the payload, persistence stores it, and truth-alignment compares what was extracted against what the authority-backed graph already holds.The diagram’s real content is not the count of boxes. It is the order. The model does its work early — at extraction — and is never again allowed to decide what is true. A later phase may still call a language model (ontology generation, for instance, can use one to draft vocabulary), but nothing downstream of extraction lets the model adjudicate a fact. Everything after it is code checking the model’s proposals against something the model does not control.Where the model acts, and where it can’tThe model earns its place in exactly one situation: when the input is prose and the output needs structure.Given a label excerpt or a study abstract, it reads “metformin,” guesses Drug, reads “type 2 diabetes,” guesses Disease, and proposes that the link between them is Drug_indicatedFor. No rule set does this as fluently across messy text. That is genuine work — but it is candidate generation, not adjudication.The first thing that disciplines the candidate is the extraction contract. A relation in this system is not a string the model happened to produce. It is a typed predicate with a domain, a range, and an evidence requirement.entities: Drug: { examples: [metformin, aspirin, pembrolizumab] } Disease: { examples: [type 2 diabetes, melanoma] } AdverseEvent: { examples: [nausea, neutropenia] } relations: Drug_indicatedFor: { domain: Drug, range: [Disease, Indication] } Drug_contraindicatedFor: { domain: Drug, range: [Disease, Indication] } Drug_interactsWith: { domain: Drug, range: Drug } evidence: required: [source_doc_id, chunk_id, sentence, char_start, char_end]The contract is not cosmetic typing. It converts every proposed fact into a set of checkable questions. When the model offers Drug_contraindicatedFor(metformin, renal impairment), the pipeline can ask whether the subject is really grounded as a drug, whether the object is a permitted clinical target for that predicate, whether the cited span actually supports the claim, and — later — whether an outside authority agrees. The build’s pharma contract defines seventeen entity types and twenty-two predicates, each with an explicit domain and range. The model proposes; the contract narrows; the authorities decide.Grounding: identity is not the model’s to assignDrug identity is the first place the pipeline refuses to trust fluent text.A model will happily treat “metformin,” “metformin HCl,” and a branded combination product as roughly the same thing, or roughly different things, depending on the sentence. That decision should not be made by whatever read the page. It belongs to a terminology authority.So RxNorm — the National Library of Medicine’s normalized naming system for clinical drugs, exposed through the RxNav APIs — grounds identity first. Instead of carrying a loose surface string, the entity carries a concept and an RxCUI.drug = rxnorm.normalize_drug_name("metformin") entity["canonical_name"] = drug.name entity["identifiers"]["rxcui"] = drug.rxcui # e.g. "6809" entity["identifiers"]["source"] = "RxNorm"Other authorities ground other facts. openFDA exposes structured product labeling — indications, contraindications, warnings, adverse reactions, interactions. ChEMBL links molecules to targets and mechanisms. ChEBI supplies chemical classification. No single service is treated as omniscient; the point is that every identity and every safety-sensitive relation has a traceable path back to a source that is not the language model.The dual-layer cache behind these calls looks like an optimization, but it is closer to craft. Public APIs rate-limit, lag, and occasionally fail, and a pipeline that re-asks RxNorm for the same drug on every run is both slow and a bad citizen on a shared endpoint. So lookups land in memory for the current run and in a file cache, with bounded expiry, across runs. The first run pays the network; later runs read identity from disk. The quieter benefit is consistency: two reviewers who open the same drug a week apart see the same grounded answer and the same evidence trail, not two independent guesses.The hero: four-class truth alignment, and why omission winsAlmost every “LLM-plus-graph” demo measures one thing — agreement. Did the extracted fact match the text? That check is necessary and entirely insufficient, because it only ever runs in one direction.Truth alignment produces three candidate-level outcomes — does the extracted fact match the graph, contradict it, or add to it — then performs a reverse-direction omission scan. That is four report classes in total, and the fourth is the one the others never look for.Three classes run document → graph. OMISSION runs graph → document — the one direction agreement checks never take.def classify(candidate, graph): if graph.has_exact_fact(candidate): return "ALIGNED" if graph.has_subject_predicate(candidate.subject, candidate.predicate): return "CONTRADICTION" # same subject+predicate, different object return "NEW_INFORMATION" WATCHED = {"Drug_interactsWith", "Drug_contraindicatedFor", "Drug_hasAdverseEvent", "Drug_indicatedFor"} def omissions(mentioned, graph, document): return [f for f in graph.facts_about(mentioned, predicates=WATCHED) if not document.supports(f)] # the source stayed silentThat last class — OMISSION — is the whole argument.Return to the document from the opening. It says metformin is first-line for type 2 diabetes. Extraction returns a clean, correct fact:(metformin, Drug_indicatedFor, type_2_diabetes)The fact aligns. It is true and it is useful. It is also dangerously partial. The graph, grounded in FDA labeling, knows that metformin is contraindicated in severe renal impairment — an eGFR below 30 mL/min/1.73 m², because the drug is renally cleared and accumulation raises the risk of lactic acidosis. The document never mentioned it. The extractor made no error; it mirrored an incomplete page faithfully.An honest report therefore cannot stop at “extracted fact correct.” It has to say:{ "classification": "OMISSION", "subject": "metformin", "predicate": "Drug_contraindicatedFor", "object": "severe_renal_impairment", "action": "FLAG_FOR_REVIEW", "reason": "Mentioned drug has a watched safety fact this source never states." }This is the one analytical move the specifications do not hand you. Agreement is source-local. Safety is world-relative. An agreement-only system grades the extractor against the document and calls a faithful mirror of an incomplete page a success; an omission-aware system grades the document against the authorities and treats that same page as a liability with named gaps. The difference is not a threshold to tune — it is which way the question faces. And omission is scoped on purpose. It watches a small set of safety predicates, because the cost of silence is not uniform. A missing marketing claim is noise. A missing contraindication is the failure the opening described.The honest part: building on a pre-1.0 libraryThere is a second reason this stays a lab build. The library is young — Semantica’s public package is still on its 0.x line — and pretending a pre-1.0 API is stable is how a pipeline breaks quietly in production. The response is not to avoid the library. It is to contain it.Every Semantica call sits behind a compatibility layer that detects features at runtime, tries documented import paths before fallbacks, and coerces returned objects into plain mappings before any later phase depends on their shape.def to_mapping(value): if isinstance(value, dict): return value if hasattr(value, "model_dump"): return value.model_dump() if hasattr(value, "__dict__"): return dict(value.__dict__) return {"value": value} extract = getattr(extractor, "extract_triplets", None) or extractor.extract triplets = [to_mapping(t) for t in extract(text)]None of this is impressive code. It is the unglamorous seam between a demo and something you can keep running while the dependency matures. The same restraint governs persistence and validation: prefer stable primitives, detect what the environment actually offers, and record it in the run manifest. If a deduplication or conflict module is missing in a given install, the report should say the check did not run — not imply, by silence, that it passed.Governance: the reviewer gets an artifact, not a vibeHuman-in-the-loop is too often a euphemism for parking a person at the end of an automation that already failed. That is not the role here.The reviewer’s input is the truth-alignment report, and it is a real artifact. It lists aligned facts, contradictions, new information, and omissions, and for each it carries the source document ID, the chunk ID, the evidence span, the external identifiers, the authority lookups, and a proposed action. A contradiction shows the extracted value beside the graph value. New information says whether the fact is merely absent or genuinely novel. An omission explains why the system expected the source to mention a watched safety fact and what authority backs that expectation.This is also where consistency comes from, and it is worth being exact about the mechanism, because it is not a smarter model. It is cached, expert-validated answers, stable identifiers, and repeatable alignment logic. Once an SME approves a grounded answer for a recurring question, the system reuses that reviewed answer, its evidence, and its graph path the next time a semantically equivalent query arrives. The model may format the response; it does not get to reopen settled truth unless the underlying authority data has changed. Consistency is an engineering property of the cache and the contract, not a personality trait of the generator.What generalizedThe same architecture carried into an automotive vertical with almost no structural change. The pharma contract was swapped for an automotive one; RxNorm and label authorities gave way to NHTSA vPIC for VIN decoding and EEA emissions data for type approval; drug identity became vehicle identity; contraindication omissions became fitment, safety, or emissions omissions. The ten phases did not move. What changed was configuration — the contract, the identifiers, the authorities. The architecture is reusable; the domain is config.CloseThe spine is one sentence: a generated assertion is not a grounded measurement.A language model can read faster than any rule set and propose structure from text too irregular to parse by hand. That is worth a great deal. But in a regulated domain it cannot be the thing that decides what is true, what is safe, or what was quietly omitted. The useful architecture is therefore not “LLM plus knowledge graph.” It is a staged pipeline in which the model proposes, the contract constrains, public authorities ground, validation checks, the graph persists, and truth-alignment asks the question extraction skips: what did the source fail to say?That question is the contribution of this build. The semantic layer is Semantica, and credit for it belongs to Mohd Kaif, who released the library that made this practical to test. The remaining discipline is in the pipeline around it. A graph is not trustworthy because it is a graph. It earns trust only when something outside the model is allowed to say no.Tools and data referenced• Semantica (open-source semantic layer, MIT, by Mohd Kaif / Hawksight AI) — repo: https://github.com/Hawksight-AI/semantica · package: https://pypi.org/project/semantica/• RxNorm (NLM clinical-drug terminology) — https://www.nlm.nih.gov/research/umls/rxnorm/index.html · RxNav APIs — https://rxnav.nlm.nih.gov/• openFDA (FDA drug labels) — https://open.fda.gov/ · drug-label endpoint — https://open.fda.gov/apis/drug/label/• ChEMBL (bioactivity, targets, mechanisms) — https://www.ebi.ac.uk/chembl/• ChEBI (chemical ontology / classification) — https://www.ebi.ac.uk/chebi/• NHTSA vPIC (VIN decoding) — https://vpic.nhtsa.dot.gov/api/• EEA CO2 cars (EU type-approval emissions) — https://co2cars.apps.eea.europa.eu/The Fact Your Extractor Never Mentioned was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.