PHIRE
A health assistant that runs on your own machine and traces every claim it makes to the record behind it.
The question
Can a local health assistant show where each part of its answer came from, instead of asking you to trust a confident-sounding paragraph?
PHIRE keeps your lab history and the language model on your own machine. It splits every answer into small claims and checks each one against your records and a public medical reference set before showing it.
Why it exists
Health answers depend on your own lab history, and PHIRE keeps both the records and the model on your machine, with no cloud APIs and no external model calls. When the evidence is thin, it says it cannot answer.
How it works
How a document gets in
- 1
Document
A lab report or health record, as a PDF or a scan.
- 2
Reader
A vision model reads the pages in one pass.
- GPU machine
- A 9.7B model, quantised to 4 bits.
- No GPU
- An Ollama vision model.
- 3
Checks
The extracted fields are validated. If no date can be found, the app asks you for one.
- 4
Storage
The same document is kept three ways.
- Neo4j
- Readings, medications and conditions, as a timeline graph.
- Chroma
- Sentences written from those readings, indexed for search.
- PostgreSQL
- The upload and its saved extraction.
How a question gets answered
- 1
Question
For example: What was my most recent LDL level?
- 2
Evidence
Two sources are read together.
- Health graph
- Links the question to metrics, medications and conditions in your records.
- Passage search
- Keyword and semantic matching, fused and then reranked.
- 3
Draft
The local model (medgemma:4b, served through Ollama) drafts an answer from that evidence.
- 4
Claims
The draft is split into atomic claims, each one a single checkable statement.
- 5
Verification
An entailment model scores each claim against what it should rest on.
- Evidence
- The reranked passages.
- Your records
- Current values and precomputed trend changes.
- 6
Confidence
Each claim gets a score from how strongly the evidence entails it, how highly that evidence ranked and how authoritative the source is.
- 7
Answer
Only claims that are supported or derived and clear the threshold make it into the answer, each with its sources. If none do, PHIRE says it cannot answer.
Decisions
The network boundary is enforced in code
Every connection to the local model server or the graph database is checked, and anything that does not resolve to the same machine raises an error. An earlier check only tested that the address started with “localhost”, which a hostname like localhost.attacker.example passes. Code review caught it, and the check now parses the real hostname. The only outbound calls fetch public reference material (PubMed, MedlinePlus, USDA) and never carry patient data.
Claims, not paragraphs, are what get verified
A draft answer is broken into atomic claims. An entailment model scores each against the retrieved evidence and the person’s own records, and only claims that pass are shown, each with every source it rests on. When confidence is low, PHIRE declines to answer.
Three kinds of retrieval
BM25 catches exact terms and lab values, and semantic search catches paraphrases. Both are fused, then reranked with authority and recency. The third is a graph of the person’s own records: it links a question to metrics, medications and conditions, follows one hop (a statin to the lipid panel), and returns the full history, the overall change and any records that disagree.
Two document readers behind one interface
On a GPU machine a 9.7B vision model reads the document in one pass, quantised to 4 bits to fit in about 6.5 GB. On a laptop without a GPU an Ollama vision model does it. Both feed the same validation and storage.
A missing date is a question, not a default
If a document has no date, the app asks for one instead of assuming today. The extraction is saved, so facts are rebuilt at the date you give without reading the document again.
Evidence
- Tested312passing tests in the ML package
The ML package has 312 passing tests, with 7 live or GPU-bound ones deselected. The graph tests need a running Neo4j.
- Measured96.9%entailment accuracy, BART-large-MNLI
Six entailment models were compared on 129 labeled claim and evidence pairs across 43 clinical topics. The general-purpose BART-large-MNLI scored 96.9% accuracy, ahead of the best medical model, BioLinkBERT-MedNLI, at 93.0%.
- Measured0.92recall at 10, MedCPT
Seven embedding models were compared on 215 passages and 129 queries. MedCPT led on recall at 5 and at 10, with 0.77 and 0.92. An earlier round of only 12 queries had favoured a general-purpose model, so the default was switched once the larger round disagreed.
CaveatBoth test sets are synthetic and were written by the person building the system. The figures show which model fit best, not how PHIRE performs on real records.
- Tested
Run end to end against real models, on a GPU machine and in a CPU-only container, not only against mocks.
- Tested
A live check found that a true claim about salmon scored only 0.30 entailment against terse nutrition-table text, because the benchmark had used only prose. The reference data is now written out as sentences at ingestion.
- Measured
Batching claim verification in half precision on a GPU gave identical accuracy on the same 129 pairs.
Trade-offs and limits
- The GPU variant needs an NVIDIA GPU with 8 GB of VRAM and about 20 GB of disk, of which the document reader alone is 18 GB. The reader and the chat model share that GPU by swapping in and out. The CPU variant needs about 10 GB of disk, recommends 16 GB of RAM, and is slower.
- Medication-to-metric links come from a curated table, so they cover only the relationships written into it.
- Graph facts and guideline passages are combined in the prompt, not followed as one path.
- PHIRE is for wellness and decision support. It is not a medical device and not for diagnosis or treatment decisions.
Not built yet
- Fitness and nutrition recommendation models
- Wearable integration
- Doctor-preparation summaries
- FHIR output
- Storing claim-to-evidence links in the graph
Built with
Languages
- Python3.12
Frameworks and libraries
- Next.js16
- React19
- FastAPI
Data and storage
- Chroma
- Neo4j
- PostgreSQL
AI and models
- Ollama
Infrastructure and services
- Docker