Inspiration
A 61-year-old man has a dry cough for two months. Everyone has an explanation: a cold, hay fever, dust from the bathroom renovation. The real cause is the blood-pressure pill he started just before the cough. A language model knows this medicine. What goes wrong in practice is three things: doctors and AI stick to the first idea, the key fact is often not written in the record, and an AI answer without reasons is hard to trust.
What it does
flex.exe is a second opinion for a doctor:
- Exact quotes. It cuts the record and the patient's words into small facts. Every fact carries a quote that our code checks word for word.
- Evidence matrix. Facts in rows, possible causes in columns: fits or contradicts.
- First guess, tested. It names the obvious diagnosis explicitly and checks it against every fact.
- One deciding question. It asks the patient the question that best separates the top two causes.
- Live updates. The patient's answer or a doctor's note updates the analysis in seconds; new facts appear on top, changed cells flash, rejected causes are marked.
- Comparison. The same model in one plain request, side by side.
How we built it
FastAPI backend, React + TypeScript frontend with an evidence matrix and a graph view. The model (deepseek-v4.1-flash) runs on the PERUN supercomputer at TU Košice. We do not ask the model one big question: the work is split into five small steps (extract facts, propose hypotheses, evaluate, consistency guards, choose the question). After each step our code checks the result: a quote must exist verbatim, there must be exactly one first guess, the leading cause must not be contradicted by a fact. On a violation the model gets the list of errors and must fix it.
How we tested it
We wrote the benchmark rules before the first run: 13 synthetic cases (5 dev, 4 held-out, 2 blind cases written after the engine was frozen, 2 control cases where the obvious diagnosis is correct), two settings (full record, and first contact with only the patient's words), 3 runs each: 156 runs, 0 failures. A different model plays the patient and judges the answer. The engine was frozen at a git tag before the final run; all raw results are in the repository.
Honest result: on accuracy flex.exe is on the same level as the same model asked directly. The difference is the process: every analysis names and tests the first guess, every fact is a verified quote, and in the control cases flex.exe never dropped a correct obvious diagnosis (12 of 12 runs), while the plain model stopped at a symptom without its cause in one of them.
Challenges we ran into
Making a language model's reasoning checkable, not just plausible. Keeping fact and hypothesis IDs stable while new answers arrive. Measuring honestly: a strong model already knows the medicine, so we had to show where the process adds value without tuning the cases to our results.
Accomplishments that we're proud of
A working prototype where every claim can be traced to the exact words in the record, and a benchmark we can defend: pre-registered rules, blind and control cases, a strict judge we did not relax after seeing the results.
What we learned
Accuracy alone does not separate a good tool from a single prompt. Asking the right question and showing the evidence does.
What's next
Ask about medicines from every prescriber, not only the GP record. Resist false clues in the patient's own words. Re-rank more firmly after a decisive answer. Validate with clinicians on real, anonymised cases.
⚠️ Research prototype on synthetic data. Not medical advice.
Built With
- fastapi
- llm
- pydantic
- python
- react
- react-flow
- tailwindcss
- typescript
- vite
