HybridFlow @sushrutalgs.ai

See the full portfolio →

Built with

  • Python
  • FastAPI
  • Qdrant
  • Neo4j
  • Docker
  • Cloudflare

Links

  • live product↗
  • Request repo access→

Source is private; sushrutalgs.ai is a live product. Happy to walk through the code or grant read access on request.

A search-and-answer backend that lets clinicians and medical students ask questions of major surgical textbooks and get cited, structured answers back, combining semantic vector search, a knowledge graph of how the books are organized, and a streaming service that uses Claude to plan and write each one.

The problem

sushrutalgs.ai answers surgical exam questions with citations that trace back to a specific place in a specific textbook, so retrieval has to return more than a plausible paragraph. Three full surgical textbooks are structured documents: the same sentence carries a different meaning under operative technique than under complications, and the answer to a real clinical question is usually spread across a chapter rather than sitting in one chunk. Ordinary chunk-and-embed search finds text that reads correctly but hands it back stripped of where it came from, which is the part a clinician needs in order to check it. HybridFlow exists to keep the structure of the book attached to whatever retrieval returns.

Why one index is not enough

Vector search can find the right paragraph from a question phrased in a clinician's words, but it cannot say which chapter that paragraph belongs to or which cross-reference qualifies it. A graph of the book's hierarchy knows all of that and cannot be searched by meaning, so on its own it never finds the entry point. The naive fix, querying both and concatenating, produces two rankings on no shared scale and leaves the writing model to reconcile them, while every extra passage it drags in widens the context. That is the condition under which the answer stays fluent and starts attributing a figure to the wrong chapter, which is the one failure a cited product cannot absorb.

The design

  • Vector first, graph second. Semantic search over 53K 768-dim BioLORD vectors finds the entry points, then each hit is expanded through a 73K-node, four-level Neo4j graph to pick up its chapter, its siblings and its cross-references. One ranking decides relevance and structure is attached afterwards, rather than two incomparable scores being merged.
  • A cheap model narrows before an expensive one writes. Claude Haiku validates the question, selects the chapters worth reading and scores the figures and tables; Sonnet only ever sees the shortlist. The rejected alternative was a single large Sonnet call over everything retrieved: fewer moving parts, but it pays full price for a wide context on every query and gives the writing model no reason to prefer one retrieved passage over another.
  • One query, three stores, one loader. Qdrant, Neo4j and a SQLite metadata store covering 220 chapters are read together per query and written together on ingest, with content-hash change detection so a re-run of the Samhita export only touches what changed. The cost is that a partial write becomes a real failure mode, so ingestion is transactional across all three instead of three independent upserts.
System architecture. Tap to enlarge.

What it cost

Splitting the pipeline into a planning call and a writing call adds a round trip to every query, and prompt caching is what makes that affordable: the planning prompt hits cache about 80 percent of the time, holding an answered query near five to six cents. The other standing cost is verification. Answers run against an eight-gate regression suite covering classification, citation integrity, hallucination density, format and fallbacks, because a system that cites its sources is only worth the extra machinery if the citations are checked automatically rather than by reading.

Where it stands

It runs live behind sushrutalgs.ai, reached through a Cloudflare Worker gateway with two-factor service auth. Under load it sustained 30 concurrent queries with zero errors at about 14.7 times the throughput of a sequential baseline, and it passes the answer-quality suite 20 of 20. Measured on its own, vector retrieval scores success@5 of 0.90 and MRR 0.79 against a frozen gold set, at a p50 search latency around 178 ms. The honest reading of that 0.90 is that roughly one question in ten does not have its best passage in the top five, and the chapter-selection pass and graph expansion are what keep those cases turning into thin answers rather than confident wrong ones.

In numbers

15
agentic tools exposed
53K
vectors, 768-dim
73K
graph nodes, 4-level
3
stores, one query

success@5 of 0.90 means one question in ten still needs the graph expansion to save it, and that is the actual argument for a hybrid design over a single vector index: the failures it catches are the ones a cited product cannot afford to have answered confidently and wrong.