AI with Lovemesomecoding Tutorials
Build a question-answering assistant over a real corpus, the 989 posts on this site, and measure every step. Chunking, embeddings, pgvector, a golden question set, hybrid search and reranking, grounded answers with citations, neighbouring chunks, answer-quality evals, incremental re-indexing, and an agent that chooses between search and SQL. Everything runs locally except the call to Claude, and every number in the track was measured.
- RAG – An Agent That Chooses Between Search and SQL"What are the latest Spring Boot posts?" is not a question about what a post says. Give Claude a search tool and two SQL tools over the post catalogue, keep citations working through search_result blocks, and test routing with answers computed from the database. The agent passes 15 of 15; plain RAG fails 4 of 6 catalogue questions.
- RAG – Keeping the Index Current Without Rebuilding ItHash each post's article, compare with what was indexed, and touch only new, changed and removed posts, each in one transaction. Adopting an existing index without re-embedding, ETags for downloads, a connection-reuse fix that took a refresh from 31 to 8 seconds, and an integration test proven to catch the bug it guards.
- RAG – Evaluating Answers: Groundedness and CorrectnessSplit every answer into claims and check each against the passages the model was given; check every answer against key points drafted from the full posts. Structured outputs for the judges, what the numbers say about three prompt setups, and the content contradiction on this site the eval surfaced.
- RAG – Contextual Retrieval, Measured and Not AdoptedClaude Haiku writes a sentence situating each of 11,701 chunks in its post, for $2 with prompt caching. On this site it did not help: same hit@5, slightly worse at rank one. Why a well-known technique can be a no-op, the fairness checks behind that verdict, and the rate limit and silent pipeline failure we hit running it.
- RAG – Search Small, Answer Big: Neighbouring ChunksSearch on small chunks, but give the model the chunks around each hit. One neighbour on each side takes full answers from 18 to 24 of 33 with no new padding, for about 1.8 times the input tokens. Two neighbours add little more. How to merge windows, and the ordering assumption it depends on.
- RAG – Grounded Answers, Citations and Saying "Not Covered"A prompt with explicit rules for full, partial and missing coverage, and the Claude API's citations feature returning the exact source span behind each statement. Measured on 40 questions: padded refusals go from 3 to 0, and the new partial answers turn out to be honest reports of a retrieval gap.
- RAG – Hybrid Search, Reranking and Pooled JudgingKeyword search in Postgres (and the missing IDF that made it score 3%), reciprocal rank fusion, a local cross-encoder reranker and a per-post cap, each measured. Why the reranker first looked worse than it was, how pooled judging fixed the golden set, and the result: the simplest setup with the better embedding model wins.
- RAG – Measuring Retrieval with a Golden Question SetStop eyeballing results. Write questions with known answers, score hit@1, hit@5 and MRR, and compare. Hand-written versus Claude-generated questions (generated ones flatter search by 14 points), the five labelling mistakes found by reading misses, and why no similarity threshold can tell an answerable question from an off-topic one.
- RAG – Storing Embeddings in Postgres with pgvectorMove the vectors from a NumPy file into Postgres: the table, the HNSW index, the cosine-distance query, and what a bigger embedding model costs. Plus two bugs worth learning from: a NUL byte Postgres refuses to store, and a psycopg transaction that silently turned the index off and made a benchmark compare exact search with itself.
- RAG – Chunking by Structure, Not by Character CountSplit at headings, keep code blocks whole and exact, drop the Copy buttons, put the post title and section in every chunk, skip stub posts, and respect the embedding model's 512-token limit. Same model, same search, same prompt as the naive version: the Python decorators post goes from third to first.
- RAG – A Naive Pipeline in 100 LinesThe simplest RAG that works: flatten HTML to text, cut it into 1,000-character pieces, embed them locally with bge-small, find the closest five with NumPy and ask Claude to answer from them with citations. It answers most questions, and its failures (a TypeScript post winning a Python question, mangled code) set the agenda for the rest of the track.
- RAG – Project Setup and Getting the DataThe project skeleton, Postgres with pgvector in Docker, and an export script that downloads every post from the public site as JSON. Why we keep HTML instead of plain text, the 18 stub posts we found, and two problems worth knowing about before you start: macOS Python without root certificates, and a port that is already taken.
- RAG – What It Is, When You Need It, and What We Will BuildRetrieval-augmented generation in one picture: find the relevant text, hand it to the model, make the model answer from it. When it beats long context or plain search and when it doesn't, what we will build in this track (a cited Q&A assistant over the 989 posts on this site), the local stack, and the rule the whole track follows: measure every change.