Skip to content
All projects
CompletedAI/ML2026

RAG Retrieval System

Find the passages that answer a question, by meaning, not keywords.

Source Try the live demo
  • Python
  • SentenceTransformers
  • NumPy

Live demo

The search bar on my homepage is this pipeline: same model, chunk → embed → cosine → top-k, running in your browser.

Built

  1. Overlapping chunks of the source text
  2. 384-d embeddings with all-MiniLM-L6-v2
  3. Cosine-similarity ranking → top-k passages

Architecture

  1. 1 · Chunk
    overlapping windows
  2. 2 · Embed
    all-MiniLM-L6-v2 · 384-d
  3. 3 · Score
    cosine similarity
  4. 4 · Retrieve
    top-k passages
Retrieval pipeline

Real output

From my Python version: 61 chunks · all-MiniLM-L6-v2

“What is this document about?”
  1. 0.224chunk 35…for natural language processing, showcasing an elegant convergence of ideas across…
  2. 0.195chunk 57…content from minimal inputs like single images or text prompts. This fusion leverages the…
  3. 0.185chunk 32…allowing it to overcome the spectral bias of standard MLPs that favor low-frequency…
“How does NeRF represent a 3D scene?”
  1. 0.690chunk 10…core innovations in NeRF is the use of volumetric rendering, where a ray is cast from the…
  2. 0.670chunk 37…has been the adaptation of NeRF-like models for dynamic scenes, where the geometry and…
  3. 0.640chunk 2…novel views of complex 3D scenes. Unlike traditional graphics pipelines that rely on…

Insight

With normalized embeddings, cosine similarity is a dot product. Retrieval is linear algebra.

Challenge

ProblemBig chunks match vaguely; small chunks lose context.

FixTuned chunk size and overlap to balance the two.

Code

pythonFrom the project repo
size = 100overlap = 40​cs = [content[0:size]]for i in range(size, len(content), size - overlap):    start = i - overlap    end = i + size - overlap    cs.append(content[start:end])​model = SentenceTransformer("all-MiniLM-L6-v2")chunk_emb = [model.encode(chunk) for chunk in cs]
Chunking and embedding from main.py in the prototype (repository not yet public).

Status

Done

  • Chunking with overlap
  • 384-d embeddings (all-MiniLM-L6-v2)
  • Cosine similarity → top-k
  • Live demo: this site's search bar

Next

  • LLM answers grounded in the retrieved passages
  • Evaluation: Recall@k, MRR
  • Sentence-aware chunking
↑↓ navigate↵ selectesc close