Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High-Performance Vector Database & Local RAG Engine

Author: Shubham Rajpurohit

Overview

A custom, low-latency vector database engineered entirely from scratch in C++. This project bypasses standard Python wrappers (such as LangChain or ChromaDB) to implement foundational spatial indexing algorithms at the systems level. It includes a fully integrated Retrieval-Augmented Generation (RAG) pipeline powered by local LLMs via Ollama, demonstrating a complete end-to-end AI backend architecture.


Core Architecture

Hierarchical Navigable Small World (HNSW)

Implemented a multi-layer graph index for approximate nearest-neighbor search, achieving O(log N) retrieval complexity for high-dimensional semantic embeddings.

Algorithmic Benchmarking

Built-in side-by-side performance comparisons between:

  • HNSW
  • KD-Tree (axis-aligned space partitioning)
  • Exact Brute Force Search

to evaluate retrieval speed and accuracy.

Local AI Integration

Seamless HTTP integration with local Ollama instances.

  • Embedding Model: nomic-embed-text (768-dimensional embeddings)
  • Language Model: llama3.2

The system generates document embeddings, performs semantic retrieval, and produces context-aware responses using a fully local RAG pipeline.

RESTful API & Visualization

A lightweight C++ backend serves a responsive web interface with real-time PCA dimensionality reduction for visualizing vector clusters.


Tech Stack

Category Technologies
Backend C++17, Winsock2
AI / ML Ollama, Llama 3.2, Nomic Embeddings
Frontend HTML5, CSS3, Vanilla JavaScript
Visualization PCA (Principal Component Analysis)

Quick Start

Prerequisites

  • MSYS2 (GCC Compiler)
  • Ollama

Install Required Models

ollama pull nomic-embed-text
ollama pull llama3.2

Compile

g++ -std=c++17 -O2 main.cpp -o db -lws2_32

Run

./db

Then open your browser and visit:

http://localhost:8080

About

Custom C++ vector database implementing HNSW and KD-Tree algorithms, fully integrated with a local LLM RAG backend.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages