Healthcare Retrieval Augmented Generation Algorithm
AI Research Intern · Basys.ai · Cambridge, MA

RAGAlgorithmforPriorAuthorization

Proprietary LLM Infrastructure · Vector Patient-Policy Matching · 35% Hallucination Reduction

Year2025
CompanyBasys.ai
LocationCambridge, MA
RoleAI Research Intern
Impact35% Hallucination Reduction

Basys.ai is a Cambridge-based healthcare AI company building proprietary LLM infrastructure for prior authorization automation — recognized by CMS as a national finalist, cited in Gartner's 2025 Hype Cycle, featured in Harvard Business Review, and backed by MIT, Eli Lilly, and Mayo Clinic. Unlike companies deploying general-purpose models, Basys.ai was building their own LLM tailored specifically to the clinical and administrative logic of prior authorization: a model that needed to understand payer policy language, interpret patient-specific clinical data, and produce recommendations accurate enough to operate in a regulated healthcare environment. My role as an AI research intern was to build the retrieval and grounding infrastructure that made that proprietary model reliable.

The core technical objective was to make the model's decision-making faster, more accurate, and verifiably grounded. The fundamental problem with any LLM operating on healthcare data is that it can generate plausible-sounding recommendations based on statistical patterns — which in prior authorization means recommending approvals or denials that aren't actually supported by the patient's real clinical profile or the payer's real policy criteria. The RAG pipeline I built addressed this by vectorizing both sides of the decision: real patient profiles — EHR data, diagnosis codes, medications, lab values, clinical notes — were embedded into vector space and semantically compared against embedded payer policy requirements. The retrieval step surfaced the most relevant policy sections for each specific case before any generation occurred, ensuring the model was reasoning from the right evidence, not hallucinating from memory.

I designed and implemented the full pipeline independently: ingesting and chunking payer policy documents with context preservation, generating embeddings using HuggingFace models, building the semantic retrieval layer that matched patient-specific vectors against policy vectors, encoding criteria as JSON rule logic for deterministic comparison, and constructing the grounded context window the proprietary LLM used to synthesize its recommendation. The system produced traceable approve, deny, or escalate outputs tied to specific retrieved policy clauses. It was demonstrated live to Eli Lilly — one of Basys.ai's enterprise backers — and reduced hallucinations by approximately 35%, directly improving the reliability and speed of the model's prior authorization decisions.

The Problem

01

Building a Proprietary Clinical LLM

Basys.ai wasn't deploying a general-purpose model. They were building their own LLM trained specifically on prior authorization workflows — payer policy language, clinical criteria, utilization management logic. For that model to be deployable in a real healthcare environment, it needed a retrieval and grounding layer that connected its outputs to real, case-specific evidence rather than statistical patterns from training data.

02

The Patient-Policy Gap

Every prior authorization decision requires matching a specific patient's clinical profile against a specific payer's approval criteria. A model without retrieval infrastructure treats this as a generative problem — it produces a recommendation based on what it has seen before. With retrieval, the model reasons from the actual patient data and the actual policy in real time. That difference is the gap between a demo and a clinical tool.

03

Speed, Reliability, and Traceability

Three requirements defined the pipeline: the decision had to be faster than manual review, accurate enough to trust without constant human verification, and traceable to a specific policy clause a reviewer could audit. None of those requirements could be met by prompting a model alone. All three required an infrastructure layer — retrieval, rule encoding, and grounding — built around the model rather than inside it.

Pipeline Architecture

Patient profiles and payer policies are independently vectorized, semantically compared, and the most relevant matches are retrieved — then structured through JSON rule logic before the proprietary LLM synthesizes a grounded prior authorization recommendation.

Prior authorization requestReal patient profile · treatment · diagnosisPayer policy documentsPDF · guidelines · clinical criteriaVectorize & indexHuggingFace embeddings · vector DBSemantic retrievalPatient vector → policy matchPatient profileEHR · codes · meds · lab valuesJSON rule engineStructured criteria · deterministic policy matchBasys.ai proprietary LLMGrounded synthesis · prior auth–specificApproveAll criteria metDenyCriteria unmetEscalateNeeds human review

Click any node to jump to the technical breakdown · Teal = policy retrieval path · Purple = patient profile · Amber = rule engine · Blue = Basys.ai proprietary LLM

Technical Breakdown

How the retrieval and grounding infrastructure was built to make Basys.ai's proprietary prior authorization LLM faster, more accurate, and less prone to hallucination.

01

Policy Document Ingestion & Vectorization

Payer policy documents — PDFs, clinical guidelines, utilization management criteria — were the first half of the retrieval equation. These documents had to be ingested, cleaned, and chunked in a way that preserved the logical structure of each approval requirement, since a single condition often depends on surrounding definitions, exceptions, and nested criteria. The chunked policy text was then embedded using HuggingFace models into a vector space, creating a searchable index of policy requirements that could be semantically compared against incoming patient data. This was the foundational layer: the quality of every downstream decision depended on how well the policy embedding captured the meaning of each clinical criterion.

02

Patient Profile Vectorization & Semantic Matching

Real patient profiles — EHR records, diagnosis codes, medications, lab values, clinical notes — were embedded into the same vector space as the policy documents. This is the core mechanism of the RAG pipeline: by representing both sides of the prior authorization decision as vectors in a shared embedding space, the system could perform semantic similarity search to find which policy sections were most relevant to a specific patient's case. A patient with a specific diagnosis and medication history would retrieve the policy sections governing exactly those conditions — not generic policy text, and not text the model was guessing at from training data. The retrieval step ensured the model was reasoning from the right evidence before it generated a single token.

03

JSON-Based Policy Rule Engine

Retrieved policy sections were accurate but still natural language — interpretable by humans, but inconsistently structured for machine comparison. The JSON rule encoding layer translated those retrieved sections into structured decision logic: explicit, machine-comparable conditions representing required diagnosis codes, prior medication history, lab thresholds, age range, documentation requirements, contraindications, and exception pathways. This gave the pipeline deterministic coverage of criteria that didn't require LLM inference — the model only needed to synthesize the parts of the decision that required genuine reasoning, not the parts that could be evaluated by direct comparison. This reduction of model dependency for deterministic conditions was central to Basys.ai's technical approach.

04

Hallucination Reduction & Grounding Mechanisms

Without grounding, the proprietary LLM would produce recommendations based on statistical patterns from training — which in a clinical context means recommendations that can't be verified, audited, or trusted. Grounding constrained the model's generation to the specific retrieved policy sections and structured rule outputs for each case, not its parametric memory of similar cases. Improvements across chunking granularity, embedding model selection, retrieval ranking strategy, context window construction, and JSON rule enforcement collectively produced approximately a 35% reduction in hallucinations — making the model's prior authorization decisions reliable enough to operate in a regulated environment and auditable by a nurse reviewer or payer administrator.

05

Proprietary LLM Synthesis & Enterprise Demonstration

The Basys.ai proprietary LLM was purpose-built for prior authorization — trained on clinical and administrative language specific to utilization management, payer policy interpretation, and healthcare decision-making. The RAG pipeline's job was to make that model's generation trustworthy by construction: every recommendation was synthesized from a context window containing the retrieved policy sections most semantically relevant to the patient's case, the structured JSON rule outputs for deterministic criteria, and the patient-specific clinical data. The model identified which criteria were satisfied, which were unmet, which required additional documentation, and what policy evidence supported each conclusion. The completed pipeline was demonstrated live to Eli Lilly — one of Basys.ai's enterprise backers — as a working system for pharmaceutical prior authorization. Basys.ai has since gone on to be named a CMS national finalist for fraud and waste reduction, recognized in Gartner's 2025 Hype Cycle for AI-driven prior authorization, and featured in Harvard Business Review — the infrastructure-level work I contributed to was part of building what became an enterprise-grade clinical AI platform.

Results

35%

Hallucination reduction

4x

Faster to decision

3

Traceable output states

Approve · Deny · Escalate

The pipeline didn't make the proprietary LLM smarter — it made the model's reasoning trustworthy by design. By ensuring every recommendation was grounded in the specific patient data and the specific policy evidence relevant to that case, the system produced outputs a clinical reviewer could verify, an auditor could trace, and a regulator could examine. That traceability is what separates a functional AI tool from one that can actually be deployed in healthcare.

Stack

PythonLangChainLlamaIndexHuggingFaceFastAPIVector DatabasesSemantic EmbeddingsSemantic SearchRAG ArchitectureJSON Rule LogicPrompt EngineeringNLPProprietary LLM OptimizationPandasNumPySQLGit / GitHubLinux

My Documents

Presentations from Basys.ai including the RAG pipeline demonstration, the Eli Lilly enterprise demo, and the full ML module architecture overview.