The problem
Support chatbots fail in one of two ways. They either know nothing about the product they’re bolted onto, or they invent answers that sound right. Both cost more trust than they save time.
The bar I set: a visitor should be able to check the answer. If the widget can’t point at the paragraph it came from, it shouldn’t say it.
And one for me: a model I can’t measure is a demo, not a product. So retrieval has a fixed benchmark, and any change to chunking, embeddings or ranking gets scored against it.
How it works
Ingest
Pages are crawled and chunked at 400 words with a 50-word overlap, so a chunk still makes sense read on its own. Each is embedded with gemini-embedding-001 at 768 dimensions and stored in Postgres with pgvector, next to the data it came from.
Rewrite the follow-up
“And on mobile?” means nothing to a search. A follow-up is rewritten into a question that stands on its own first, with a 4-second budget. If that fails, the raw message goes through: a worse search beats no answer.
Search by meaning
pgvector over the workspace’s own chunks, 20 candidates. Hits too far from the question are dropped and the closest 5 go on. When a question has an exact token in it, such as an endpoint, a file name or an error code, a literal search for it fills any of those 5 places the embeddings left empty.
Answer from those chunks
Gemini 3.5 Flash-Lite, on minimal thinking, answers from those chunks alone and cites them. If they don’t cover the question, it says so instead of improvising.
Hand off
When a question needs a person, such as billing, a refund or a bug, the model flags it, the team gets an email or a Slack message, and the conversation moves to a shared inbox. A visitor can also just ask: “Talk to a human” is one of the widget’s default quick replies.
Embed anywhere
A single script tag mounts the widget in an isolated root. No build step and no framework requirement on the customer’s site.
The benchmark
The app’s own crawl, chunking, embeddings and search, run against a public help centre. 45 questions are written the way customers type them, not the way the docs title things; 17 more hinge on an exact token, like an endpoint or a file name. Each one has exactly one right page.
- 100%62 of 62 found in the top 5
- 94%58 of 62 ranked first
- 0.97Mean reciprocal rank
One dot a question: 58 ranked the right page first, 4 put it in the top 5, 0 missed.
Dots are sorted by outcome, not by question. Pick “Hybrid, as first shipped” to see what it missed.
Miss 1 of 5
“i want a weekly summary of my traffic in my inbox”
- wanted
- /docs/email-reports
- got
- Slack reports and traffic-spike alerts
The first version was hybrid: embeddings and a keyword search, merged by rank. On the first 45 questions it found 41. Then I ran each half on its own, with the same embeddings. Embeddings alone beat the hybrid search I shipped, and every question it missed, they ranked first or second.
That wasn’t yet a fair fight. None of those 45 questions had an exact token in it, the case the keyword half is there for, so I wrote 17 that do before changing anything. Embeddings won those too: 17 of 17 in the top 5, against hybrid’s 16. So now the embeddings rank, and the literal search only speaks when they come back short. On these 62 it never had to, which is why the live row and “Embeddings alone” match.
What it used to miss
The first version missed 5 of the 62. These are the four from the first 45, as it returned them; the fifth was one of the 17 exact-token questions, and its text wasn’t recorded. In all four, the right topic came back, just the wrong page of it.
“i want a weekly summary of my traffic in my inbox”
- wanted
- /docs/email-reports
- got
- Slack reports and traffic-spike alerts
“track how much money each campaign brings in from purchases”
- wanted
- /docs/ecommerce-revenue-tracking
- got
- The Shopify and goals pages
“is there a wordpress plugin that proxies the analytics requests”
- wanted
- /docs/proxy/guides/wordpress
- got
- The general WordPress page
“attach the logged in user’s plan type to every pageview”
- wanted
- /docs/custom-props/for-pageviews
- got
- The custom properties introduction
My first guess was chunking: a 400-word chunk cut from the middle of a page doesn’t say which page it came from. The numbers said otherwise. The culprit was rank fusion, which rewards a chunk both searches return, and a keyword search for “weekly”, “summary”, “traffic” and “inbox” returns plenty of pages that aren’t about email reports. The search that ships now finds all four, three of them ranked first.
Trade-offs
Exact vector search over an HNSW index
Every workspace shares one table. An approximate index filters by workspace after the scan, so a small workspace could come back with nothing. An exact scan of only its own chunks can’t.
Embeddings first, exact tokens as a fallback over the hybrid I first shipped
The hybrid I first shipped, embeddings and keywords fused by rank, promised the best of both and measured worse than the search that ships now: 5 fewer top-5 hits and 9 fewer first places on 62 questions. Fusing a literal search by rank instead still cost first places, because “SSO” is on many pages. As a fallback it can’t push a right answer down.
A loose relevance cutoff over always sending the top 5
Vector hits past a cosine distance of 0.55 are dropped. That only removes what has nothing to do with the question, so with nothing relevant left, the model says it doesn’t know instead of improvising from noise.
Gemini 3.5 Flash-Lite over Gemini 3.8 Flash
In testing it answered from the sources and flagged handoffs and unknowns correctly. 3.8 Flash cost 2.5× as much for no gain, and once stalled for 228 seconds.
When it shouldn’t answer
The model ends a reply with a hidden marker when it shouldn’t be the one answering: one for a human (billing, refunds, bugs), one for “not in the docs”. The customer never sees one. The stream holds back a trailing “<<” until it either completes a marker or can’t, so a marker never gets split across two chunks and flashed on screen.
Every question the AI couldn’t handle lands in one Unanswered list, from three places: a handoff, a no-answer or a thumbs-down on a reply. Near-duplicates are grouped, so “how do I cancel” and “how can I cancel my plan” are one row.
When a teammate replies in the inbox, a stronger model turns that reply into a reusable answer, and skips replies that only fix one customer’s account. One click approves it, indexes it and closes the whole group, and the answer is in the docs for the next customer who asks.
What I would change next
Score the questions with no right page. Every benchmark question has one. Customers also ask what the docs don’t cover, where the right answer is a handoff, and that path has no number yet.
It also needs questions I didn’t tune on. I wrote all 62 and chose the search that ships on those same 62, so a held-out set, ideally on a second corpus, is what would show the 94% holds.
Then chunking, which works for docs and badly for changelogs, and speed: most of the wait today is the model, not the search.
Next case study
Bunny’s Cafe
Pitched & built solo · live
The cafe behind my college was jammed every lunch break. I pitched the owner, then built ordering, payments and a live kitchen feed solo.
21 daysFirst commit to live domain

