kevin@portfolio:~$ cat projects/hybrid-rag.md
# AI Engineering · RAG
Hybrid RAG Knowledge Assistant
An internal assistant that answers questions from company documents with hybrid retrieval, reranking and a local language model.
Numbers
Problem
Staff at PT PAL Indonesia needed a faster way to find answers inside long internal PDF documents. Answers had to cite their sources and run on local models.
How it works
Uploaded PDFs are extracted, including tables, split into chunks that follow the document structure and indexed twice, once as embeddings and once as keywords. At query time both indexes return candidates, which are merged with Reciprocal Rank Fusion and reranked by a cross-encoder. The top chunks go to a local language model with the question, and the answer comes back with its source documents.
Evaluated with RAGAS (LLM-as-a-judge).
› hover or tap a node for a one-line explanation
- PDF upload An admin uploads a document in the dashboard.
- Extraction Text and tables are pulled from the PDF.
- Chunking The split depends on document type. Regulations are cut by chapter and article, other structured files by section and the rest where topic similarity drops. Pieces over 4000 characters are cut again into 2000 characters with 200 overlap.
- Embedding index Chunks are embedded with an Indonesian e5 model into a vector store.
- Keyword index The same chunks are tokenized for BM25.
- User question A question arrives from the chat interface.
- Rank fusion Top 10 vector and top 10 BM25 candidates are merged with RRF.
- Reranking A cross-encoder reranker keeps the top 5 chunks.
- Generation A local language model writes the answer from the chunks.
- Answer with sources The reply lists the source documents.
Key decisions
- 01
Hybrid retrieval, vector plus BM25. Semantic and exact keyword search miss different things, so the two are fused.
- 02
A reranking step after fusion to raise the relevance of the final chunks.
- 03
A small local model, SeaLLMs-v3 1.5B, tuned for Bahasa Indonesia.
- 04
Table cleanup before generation, so rows from PDF tables do not confuse the model.
- 05
The reranker runs on CPU, so the GPU memory stays free for the language model.
Results
- 86.67% Context Recall and 78.89% Context Precision.
- Evaluated with RAGAS (LLM-as-a-judge).
- The evaluation set has 15 questions.