llm
π 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
RAG
For a while now, I've been experimenting with Retrieval-Augmented Generation (RAG), exploring how to make LLMs answer questions using information retrieved from actual documents. Today's experiment with Raggy took me through another complete RAG pipeline. Document ingestion: Processed a research paper in PDF format. Text chunking: Split the document into 82 chunks. Vector embeddings: Used nomic-embed-text to convert text into 768-dimensional vector representations. Semantic search: Retrieved the top 5 chunks based on similarity to the user's query. LLM inference: Used a locally running qwen3:4b model to generate an answer from the retrieved context. Retrieval tracing: Inspected chunk rankings, similarity scores, source pages, token usage, and execution timings. Then I asked: βWhat was the IoT adoption rate across the companies?β Raggy returned 74.4%, grounded in the retrieved document context. But here's where it gets interesting. The trace exposed duplicate chunks in the retrieval results. The generation stage also took significantly longer than embedding and retrieval in this run. These are exactly the kinds of details I want to investigate. Because building RAG isn't simply about connecting a vector database to an LLM. It's about understanding document parsing, chunking strategies, embedding models, vector similarity, top-k retrieval, context construction, grounding, and inference latency. A system can return the right answer and still have room for improvement. My next focus is making retrieval more reliable, reducing redundant context, and improving response time without sacrificing answer quality. Still experimenting. Still debugging. Still learning by building. The goal isn't just to make AI work. It's to understand the engineering behind making it work well. RAG AIEngineering LLM Python MachineLearning softwareengineering