Route a Clinical Note
A free-text medical note comes in. This model reads it and does three things a clinical-NLP pipeline actually has to do: routes it to the right specialty, extracts the clinical entities (with negation, so denies chest pain is not the same as chest pain), and answers questions grounded in the text. Trained on the public MTSamples transcriptions and running entirely in your browser. No server, and the note never leaves this page.
triagnosis.json. Run triagnosis/train.py to generate it.
Watch it route
The real model, read word by word. Each word casts a weighted vote, the running odds shift with every one, and softmax settles the call. This case looks pulmonary at first (a chronic cough, a lung mass), so Cardiovascular leads, until the biopsy and oncology terms flip it to Hematology-Oncology. A logistic-regression scorecard is a one-layer network, so this is not a metaphor, it is literally the model.
How good is the routing?
Held-out 25% test set. The model is deliberately linear and inspectable, and its mistakes are clinically sensible.
How it works
- Scope. MTSamples has 40 buckets, but many are document types (Discharge Summary, Progress Notes) or catch-alls (Surgery, General Medicine), not routable specialties. Keeping genuine specialties with at least 80 notes leaves 12 classes.
- Route. TF-IDF over the note, trimmed to the 1,200 most discriminative terms by chi-squared, then multinomial logistic regression. Small enough to ship the whole model to the browser, which reproduces the training math exactly.
- Extract. A gazetteer tagger for problems, medications, tests, and anatomy, with NegEx-style negation so asserted and denied findings are told apart. Everything it highlights is traceable to a term and a rule.
- Ground. Each sentence is vectorized in the same TF-IDF space; a question is matched by cosine similarity, boosted when a sentence carries the entity type the question is about. This is the retrieval half of a RAG system, done client-side.
- Generate (production). In production the retrieved passages become the context for an LLM. That prompt is the one honest server-side step, and it looks like this:
You are a clinical assistant. Answer the question using ONLY the
passages below. If the answer is not in them, say you do not know.
Do not infer beyond the text.
Question: {question}
Passages:
{top_retrieved_sentences}
Answer (cite the passage number): MTSamples is public-domain, de-identified sample documentation. This is a demonstration of clinical-NLP technique, not a medical device.