← Back to Projects

Raphael AI

TypeRAG Chat App
StackNext.js
Raphael AI

Overview

Raphael AI is a production-grade, multi-tenant AI document research platform designed to solve the hallucination and traceability problems in enterprise LLM workflows. Powered by a Hybrid Retrieval-Augmented Generation (RAG) architecture, the platform allows users to chat with large PDF documents while enforcing strict factual grounding. Unlike standard AI wrappers, Raphael AI ensures that every claim generated by the LLM is backed by an exact, verifiable page-level citation, making it a reliable tool for deep document analysis and research.

Key Features

  • ✦Hybrid Retrieval System (RRF): Combines dense semantic search (pgvector HNSW cosine distance) for contextual understanding with sparse keyword search (PostgreSQL full-text search) for exact terminology using Reciprocal Rank Fusion.
  • ✦Zero-Hallucination Guardrails: Implements a strict confidence gate. If retrieved context is insufficient, the system actively refuses to answer rather than fabricating facts.
  • ✦Verifiable Page-Level Citations: Every generated response is pinned to exact page boundaries with interactive citation chips.
  • ✦Resilient Multi-LLM Routing: Features a dynamic cascading fallback engine (Groq ➔ Gemini ➔ OpenRouter) with zero downtime to the user.
  • ✦Contextual Query Rewriting: Automatically intercepts ambiguous follow-up questions and rewrites them into standalone search queries using conversation history.
  • ✦Automated Evaluation Harness: Built-in benchmarking suite to programmatically measure Retrieval Hit Rate, Citation Accuracy, and End-to-End Latency.

Technologies Used

Next.js 16SupabasepgvectorGeminiGroqTailwind CSS

Project Links

Challenges & Solutions

Overcoming the Limitations of Pure Semantic Search

Standard vector search is great for semantic meaning but fails terribly at finding exact acronyms, specific dates, or part numbers within dense documents.

Hybrid Search via RRF

Developed a dual-pipeline Hybrid Search combining pgvector embeddings with PostgreSQL's native ts_rank full-text search. Merged results using Reciprocal Rank Fusion (RRF) to guarantee accurate retrieval of both context and terminology.

Preventing LLM Hallucinations in High-Stakes Q&A

Large Language Models naturally want to guess answers when context is sparse, breaking trust.

Grounded Refusal & Confidence Gate

Designed a strict grounding prompt architecture paired with a confidence gate that strictly forces the LLM to output a grounded refusal when data is absent.

Maintaining High Availability Amidst LLM API Instability

Relying on a single provider caused sporadic timeouts and rate-limit errors during high usage.

Dynamic Multi-LLM Cascading Router

Built a router that automatically catches errors and routes the prompt to secondary models (Gemini, then OpenRouter) seamlessly in the background while maintaining the SSE stream.

Handling Ambiguous Follow-Up Questions

Users ask pronoun-heavy questions like "Why did that happen?", which yield useless results in a vector database.

LLM-Powered Query Rewriter

Implemented a module that intercepts follow-up questions, analyzes the chat history, and reformulates the prompt into a context-rich, standalone query before executing the vector search.