HLAB field notes

Python

Stories and analysis filed under Python.

26 stories
Terminal screenshot showing datagen generating a synthetic ERP and CRM dataset, followed by reconcile reporting a match rate by entity type

Score match quality and load results into Postgres

Use eval/score.py to compute precision, recall, and F1 for a reconciliation run against the ground_truth.json answer key, then optionally load the same run into a Postgres target schema.

Terminal screenshot showing datagen generating a synthetic ERP and CRM dataset, followed by reconcile reporting a match rate by entity type

Generate a synthetic ERP and CRM dataset

Use the datagen CLI to produce a reproducible, deliberately messy ERP and CRM export pair, complete with a ground-truth answer key, the foundation every reconciliation lesson in this series runs against.

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.