Zero-Result Recovery in Agentic Search: Progressive Filter Relaxation
Handle zero results in agentic RAG search by relaxing hard payload filters progressively, then falling back to a broad semantic query.
Lessons from building real AI systems — the thinking behind the work, not step-by-step tutorials.
Browse by topic →Handle zero results in agentic RAG search by relaxing hard payload filters progressively, then falling back to a broad semantic query.
Tables break RAG because flattening them destroys row/column relationships; keep them as HTML and attach headers to every row to fix it.
When RAG breaks, the model usually isn't the problem — retrieval is, about 73% of the time. Here's the real failure map and what to fix first.
Qdrant applies payload filters during HNSW graph traversal, not after — so filtered queries stay fast and always return a full top-k.
Frameworks are great for a demo. In production, the abstraction you can't see into costs more than it saves.
Vector search misses exact terms like SKUs and error codes because embeddings blur rare tokens; a sparse channel restores exact-match signal.
RAG became the default reflex for every LLM problem. Often it's the wrong tool. A straight decision framework for RAG vs fine-tuning vs just prompting.
Stream LLM tokens in FastAPI with SSE the moment they arrive, kill buffering layers, and cancel on disconnect so you stop paying for unseen tokens.
Yes — a quantized 3-8B judge running on MLX on Apple Silicon handles objective eval batches at effectively zero marginal cost.
Run semantic search fully on-device on iOS: convert EmbeddingGemma to Core ML, store vectors with SimilaritySearchKit, quantize to fit memory.
Use per-recognition OCR confidence as a metadata gate: drop, re-OCR, or flag low-confidence spans before they pollute your RAG index.
If you log one thing in your RAG pipeline, log the final assembled prompt. It's the fastest path from 'bad answer' to root cause.
Running an LLM locally removes network egress, but telemetry, model downloads, and RAG indexes still leak — here's what to check.
Make a RAG ingestion pipeline idempotent by keying every stage on a SHA-256 content hash, isolating failures in DLQs, and reprocessing deterministically.
Add sparse/keyword search to dense embeddings only when your eval shows lexical misses on IDs, rare terms, acronyms, code, or names.
A step-by-step debug order for bad RAG answers — start with the assembled prompt, not the model. Most bugs are retrieval, not generation.
Moving a production cloud RAG pipeline on-device: the shape transfers, but index scale, embedder size, and re-ranking budgets do not.
How to build a production agentic search system on Qdrant: single-shot vector+filter tool calls, Postgres hydration, and progressive relaxation.
On macOS, Apple Vision beats Tesseract for RAG ingestion — faster, more accurate on real scans, free, offline. Tesseract wins on Linux CI.
Score retrieval and generation separately: the pair of metrics localizes whether a bad RAG answer is a retriever or an LLM problem.
CRAG fixes retrieval quality before generation; Self-RAG uses fine-tuned reflection tokens to critique its own output. Here's when to use each.
Structured Outputs with grammar-constrained decoding is the most reliable way to get valid JSON from an LLM. Here's how the three mechanisms compare.
Reference-based evals compare output to a known correct answer; reference-free evals score intrinsic properties like grounding without ground truth.
Version prompts in Git for small eng teams, move to a prompt tool when non-engineers contribute, and gate every change on an eval suite.
Prompt caching reuses precomputed KV state for identical prompt prefixes, cutting cost up to 90% and latency up to 85% with no quality change.
The stages every production RAG system needs — indexing, query-time retrieval, and always-on evaluation — and how to order them.
Use the OpenAI Batch API for non-real-time bulk jobs to get 50% cheaper tokens with a 24h SLA and a separate rate-limit pool.
Attach structural, content, and contextual metadata to chunks, then use it for filtered multi-axis retrieval to sharpen RAG accuracy.
Matryoshka Representation Learning packs meaning into early dimensions so you can truncate one embedding to many sizes for fast, cheap retrieval.
Build a production LLM fallback strategy: a cost-ordered chain of models with health checks, backoff, and cross-provider routing.
Use VLM parsing for scanned, complex, or merged-cell PDFs; use layout parsers for clean digital docs to save cost and latency.
Why you can't average keyword and vector scores — and how Reciprocal Rank Fusion combines them for an 8–15% accuracy gain.
Most RAG hallucinations are retrieval bugs in disguise. A concrete checklist to cut them — grounding, retrieval quality, and faithfulness checks.
Pick an embedding model and dimension by trading MTEB quality against RAM, latency, and re-embedding cost — with a decision tree.
Start at 512 tokens with light overlap, then tune by query type. A practical, benchmark-backed guide to chunk size for retrieval.
On normalized embeddings all three metrics rank identically, so pick dot product for speed; magnitude only matters with unnormalized vectors.
Corrective RAG inserts a retrieval evaluator between vector search and the LLM that scores documents and routes to proceed, filter, or re-retrieve.
MLX runs on-device LLMs on the GPU for throughput; Core ML can place them on the ANE to keep the GPU free — here's how to choose.
Strip repeating headers/footers, de-hyphenate line breaks, and normalize unicode before chunking so RAG embeddings stay clean.
Use structure-defined chunks first; when you must set a size, 256-512 tokens with 10-20% overlap is a sane default, then tune.
Mine failing production traces, store input plus retrieved chunks plus expected behavior, and version 50-100 focused cases in-repo.
BM25 is lexical, SPLADE learns term expansion, and Qdrant's BM42/miniCOIL add neural weights to the BM25 formula—compared for hybrid RAG.
The common chunking approaches for retrieval, when each one helps, and the tradeoffs — a quick reference you can come back to.