REGULATED RAG · KNOWLEDGE GRAPH · COMPLIANCE · LoRA

The parts of RAG that are hard.

Most RAG demos stop at "embed a PDF, ask a question." Real deployments in regulated industries (pharma, finance, healthcare) need the hard part: traceability, compliance guardrails that cut false positives, model/prompt versioning, a knowledge graph for exact relationships, and an observability layer a compliance officer can audit. InsightRAG implements all of that end-to-end, on a fictional knowledge base — no sensitive data.

4/4 compliance
CI-gated compliance eval · 5/5 offline unit tests
hybrid GraphRAG
vector + graph expansion + rerank for exact relationships
LoRA 24 GB GPU
domain adapter trained bf16, rank 16, on the GPU
traced everything
p50/p95 latency, tokens, prompt version per request
Request path

Two endpoints, and the one that earns its keep.

Dense retrieval alone can dilute an exact relation — which molecule reverses which drug — across chunks that all look relevant. The graph endpoint links the entities named in the question, pulls their 1-hop neighbourhood as typed facts, and only then retrieves. Pick a path and watch it run.

question k = 4 link entities substring · len ≥ 4 graph facts 1-hop · typed triples vector search Qdrant · hcp_kb · 768d rerank +0.15 if product doc context facts + passages local LLM Ollama · Modelfile trace JSONL → p50 / p95
THE TEMPTING FIX

"Just retrieve more chunks."

Widening k gets you more text that resembles the question, not the one relation that answers it. Vestrila is reversed by veligumab is a fact, not a paragraph — it survives as a triple and dissolves as prose. The graph is not there to find text; it is there to carry the relations that text loses.

WHAT IT COSTS

Entity linking is a substring match.

Linking is name.lower() in question.lower(), gated at 4+ characters. Ask a question that names no entity and the graph lane contributes - (none matched): you paid for the hop and got dense retrieval anyway — the third scenario above. It is deliberate for a corpus this size, and it is the first thing that would need replacing at a larger one.

What's inside

Everything a regulated AI product needs.

CapabilityImplementation
RAGchunking → local embeddings (nomic-embed) → Qdrant → grounded synthesis
Knowledge graphtyped graph (products, classes, indications, reversal agents) + hybrid GraphRAG (vector + graph expansion + rerank)
Compliance promptingversioned system prompts: on-label only, fair balance, scoped off-label refusal
Observabilityper-request trace store · p50/p95 latency · tokens · error rate · CI-gated compliance eval · dashboard
Fine-tuningcustom domain LoRA adapter trained on a single 24 GB GPU (bf16, rank 16)
MLOpsversioned FastAPI endpoints (model+prompt version per response) · offline tests · GitHub Actions CI
The behavior that matters

A scoped refusal, not a full block.

OFF-LABEL

"Can I use Pulmyra for asthma?"

A compliant answer is a scoped refusal + on-label facts, not a flat refusal — it cuts false positives, exactly as the domain requires. That case is the whole point of the project.

FAIR BALANCE

Efficacy always paired with safety

"Orvenda MoA + key risks" → efficacy always comes paired with safety. And when asked a price that isn't in the sources: "not covered in my sources" — no hallucination.

Design principles

Local-first, frontier on-demand.

1

Local-first, frontier on-demand

Resolve locally when local capability clears the task's threshold; escalate on evidence of insufficiency, not by reflex.

CORE
2

Backend-agnostic

The same call path points to local Ollama or a frontier endpoint via env var.

3

Everything traced

Latency, tokens, retrieval hits and prompt version logged per request; schema exportable to Langfuse/Phoenix.