AI Engineering1 min read
How I built ExamAI: HyDE, hybrid search and a reranker that saved my GPA
My course notes were too messy for naive vector search. This is the build log of a RAG system that survived garbled PDFs: hypothetical document embeddings, BM25 hybrid search, and a cross-encoder reranker.
The NSK.AI Bootcamp assignment said: build and deploy your own Retrieval-Augmented Generation system. My mind went straight to COS 124, Introduction to Database Systems, whose PDF slides have personally victimized me. Not because the course is hard, but because extracting text from those files produces word salad.
Where naive RAG falls apart
My first version embedded chunks and hoped for the best. It failed exactly where academic documents are weakest: garbled extraction, broken tables, inconsistent formatting. Simple cosine similarity kept returning chunks that shared vocabulary but not meaning.
The three-layer fix
- HyDE: use Groq-hosted Llama3 to generate a hypothetical ideal answer first, then embed that answer instead of the raw question
- Hybrid search: combine dense embeddings with BM25 keyword scoring so exact terms still count
- Cross-encoder reranking: score the top candidates jointly with the query for final ordering
That stack took days of debugging and a lot of “why isn’t this working” moments. It was also the difference between ExamAI being a toy and being something I now genuinely use before exams. The app generates follow-up questions, builds multiple-choice quizzes, and shows the retrieved context behind every answer.
- #RAG
- #LangChain
- #Build log