← Back to All Projects

VectorVault RAG: Semantic Knowledge & Search Engine

A grounded RAG system built with a custom NumPy cosine similarity vector store, gemini-embedding-2 vectors, and source-cited synthesis via Gemini 2.5 Flash.

What I Built

VectorVault RAG is a semantic document search and Q&A engine built using Python 3.12, NumPy, the Google GenAI SDK (gemini-embedding-2 & gemini-2.5-flash), and Streamlit. It breaks unstructured text/markdown documents into overlapping text chunks, generates 3,072-dimensional dense embeddings, stores them in an in-memory NumPy matrix, and uses cosine similarity math to retrieve relevant context for grounded LLM answer synthesis.

Problem

Standard keyword searches (BM25 or text matching) fail when users query knowledge bases using different phrasing than the exact text. Additionally, off-the-shelf LLMs frequently hallucinate facts when asked questions outside their training data or when handling private enterprise documentation.

Solution

VectorVault RAG resolves this by decoupling knowledge storage from model weights. It converts user queries into dense vector embeddings and uses high-dimensional vector space math (cosine similarity) to identify semantically related document chunks. These top-$k$ retrieved chunks are passed into gemini-2.5-flash with strict grounding system instructions, forcing the model to cite its sources ([Source: filename]) and prevent hallucinations.

Design Decisions

Tradeoffs

Challenges

During integration of the google-genai SDK, legacy embedding model aliases (text-embedding-004) triggered 404 NOT_FOUND errors on the standard endpoint. Migrating the embedding generator to gemini-embedding-2 resolved the endpoint mapping and yielded high-density 3,072-dimensional vector representations.

What I’d Improve

Demo

Live Demo on Streamlit Cloud

Source Code

GitHub Repository