An end-to-end retrieval-augmented generation engine engineered to ingest complex technical research papers, index dense embeddings with pgvector, and generate cited answers with verifiable page provenance.
Standard LLM question-answering pipelines suffer from two critical failures: hallucination and opaque citations. In technical, academic, or legal domains, an answer without an exact source page is unusable.
RAGBase solves this by enforcing page-preserving chunk boundaries. Rather than blindly slicing raw text by character counts, chunk headers retain explicit metadata (document ID, page number, bounding paragraph), ensuring every returned answer directly links to its origin text.
Uploaded PDFs are parsed in-memory. Text extraction respects natural layout flow and page boundaries, generating bounded overlapping chunks with persistent provenance metadata.
Pre-trained all-MiniLM-L6-v2 models transform chunked passages into 384-dimensional dense vector embeddings, optimized for high throughput on CPU and memory-constrained hosts.
Vectors are indexed in PostgreSQL using pgvector with IVFFlat clustering. Hybrid retrieval combines dense cosine similarity with relational full-text search via Reciprocal Rank Fusion (RRF).
Top-k retrieved chunks populate a structured context envelope sent to high-throughput Groq LLM inference endpoints. The model is constrained to generate answers strictly derived from citations.
The original implementation was deployed on an AWS EC2 t2.small instance (2 GB RAM) with Amazon RDS PostgreSQL. Operating within strict memory boundaries required configuring 4 GB of swap space, container memory limits in Docker Compose, and batching vector ingestion to prevent OOM termination.
The current production pipeline runs on Railway, packaging FastAPI backend services, a Streamlit evaluation interface, and persistent PostgreSQL vector storage with continuous integration via GitHub Actions.