k@kavya282005ยท 2h
๐ Built a Basic RAG and an Advanced RAG System from Scratch โ Without LangChain
To understand how RAG works internally, I first built a Basic RAG Pipeline:
Basic RAG
PDF โ Extraction โ Chunking โ Embeddings
โ FAISS Search โ Top-K Chunks
โ Prompt โ LLM โ Answer
It works well for simple questions, but struggles with exact keywords, IDs, and complex queries.
So I built an Advanced RAG Pipeline:
Advanced RAG
PDF โ Extraction โ Chunking โ Embeddings
โ Dense + Sparse Index
โ Query Understanding
โ Dense Retrieval + Sparse Retrieval
โ Reciprocal Rank Fusion (RRF)
โ Cross-Encoder Reranking
โ Noise Filtering
โ Context Fusion
โ Prompt โ LLM โ Answer
Key Improvements
โ
Semantic Search (FAISS)
โ
Exact Keyword Search (BM25)
โ
Hybrid Retrieval
โ
Cross-Encoder Reranking
โ
Duplicate Removal
โ
Better Context Selection
โ
Reduced Hallucinations
One of the biggest lessons from this project:
A better RAG system isn't always about using a better LLM. It's often about building a better retrieval pipeline.
Tech Stack: Python โข Streamlit โข FAISS โข Sentence Transformers โข BM25 โข Cross-Encoder Reranker โข Groq
#RAG #GenAI #LLM #AIEngineering #MachineLearning #Python #FAISS #BuildInPublic