Retrieval is the part of the stack that either makes an AI agent feel omniscient — or catches it in its first hallucination. Here's how we designed ours.
Why pgvector won for us
We run Postgres for every other durable thing. Adding a separate vector store would have meant a second source of truth on top of the product catalog. pgvector + HNSW indexing solved the latency and recall tradeoff inside the same database.
The four-tier ranking
- Tier 1 — cosine top-20 against a 1536-dim embedding.
- Tier 2 — structural filters: stock, price band, category, store-of-origin.
- Tier 3 — merchant rules: blocks, guardrails, boosts, semantic pins.
- Tier 4 — variant-aware rerank by the current shopper context.