HLAB field notes

RAG

Stories and analysis filed under RAG.

07 stories
Terminal screenshot of the Claude RAG CLI answering a question and citing local source files

Test model output with deterministic rules

Add deterministic rule checks to a prompt-evaluation workflow, then measure exactly where simple substring rules produce false positives and false negatives.

Terminal screenshot of the Claude RAG CLI answering a question and citing local source files

Benchmark retrieval quality

Turn six labeled retrieval questions into a repeatable BM25 quality report using Hit@k, Recall@k, and mean reciprocal rank, then use the report to find what lexical retrieval misses.

Terminal screenshot of the Claude RAG CLI answering a question and citing local source files

Merge rankings with Reciprocal Rank Fusion

Combine BM25 and vector rankings with Reciprocal Rank Fusion, promoting chunks found by multiple retrievers without ever comparing their incompatible raw scores.

Terminal screenshot of the Claude RAG CLI answering a question and citing local source files

Build and search a vector index

Build a small exact vector index that stores L2-normalized vectors, ranks results by cosine similarity, and rejects vectors from an incompatible model or dimension.

Terminal screenshot of the Claude RAG CLI answering a question and citing local source files

Implement Okapi BM25 from scratch

Build the keyword-ranking function behind a local retrieval pipeline: preserve identifiers, calculate Okapi BM25 scores, and return deterministic ranked results without a search library.

Terminal screenshot of the Claude RAG CLI answering a question and citing local source files

Chunk Python and Markdown for retrieval

Build the ingestion pipeline that splits Python and Markdown files into stable, citable chunks, the foundation every retrieval guide in this series searches.