Skip to content

About

Reproducible RAG evaluation pipeline benchmarking FAISS retrieval, cross-encoder reranking, latency, and provenance coverage against an LLM-only baseline.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

RAG + GraphQL Bonus Implementation (Replit-ready scaffold)

This repository is a scaffold for the bonus: a working RAG pipeline with re-ranking, retrieval-quality comparison, and basic latency/accuracy measurements.

It is designed to run on Replit / local machine. The code contains two modes:

  • Provider mode: uses OpenAI for embeddings + LLM (requires OPENAI_API_KEY).
  • Local mode: uses sentence-transformers (for embeddings) and cross-encoder for reranking. Local generation is left as a placeholder (you can plug a local LLM).

What is included

  • rag_demo.py — main script: ingest, index (FAISS), search, rerank, prompt assembly, evaluate (LLM-only vs RAG).
  • vector_store.py — helper: build FAISS index and search.
  • reranker.py — helper: cross-encoder re-ranking wrapper.
  • data/session_doc.txt — placeholder: drop your Session_3 text here (I could not auto-extract DOCX in this scaffold).
  • requirements.txt — suggested packages.
  • run_demo.sh — example run script.

Quickstart (Replit or local)

  1. Create a repl / VM with internet access.
  2. Upload your domain document to data/session_doc.txt (or other txt files in data/).
  3. Option A (OpenAI):
    • Set OPENAI_API_KEY in repl secrets / environment.
    • pip install -r requirements.txt
    • python rag_demo.py --mode openai
  4. Option B (Local embeddings & reranker):
    • pip install -r requirements.txt
    • python rag_demo.py --mode local
    • (This downloads sentence-transformers / cross-encoder models on first run.)

What the demo does

  • Ingests text file(s) and chunks them (200–300 token chunks with overlap).
  • Builds FAISS index from embeddings.
  • Runs sample queries, measuring:
    • LLM-only (if configured) vs RAG answers (assembled prompt + LLM).
    • Retrieval latency, re-rank latency, LLM latency.
    • Simple retrieval quality metrics: provenance coverage (what percent of claimed lines include a substring from retrieved chunks).
  • Outputs a comparison CSV in outputs/.

Notes

  • This scaffold focuses on reproducible evaluation: you can replace placeholder LLM calls with any provider (OpenAI, local Llama, etc.).
  • For production, swap FAISS for Pinecone/Weaviate and Apollo/Hasura for GraphQL layer.

About

Reproducible RAG evaluation pipeline benchmarking FAISS retrieval, cross-encoder reranking, latency, and provenance coverage against an LLM-only baseline.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages