Anchor
Retrieval that says no source instead of guessing.
- TypeScript
- Next.js
- PostgreSQL
- pgvector
- Prisma
The problem
A search always returns its closest match, even when nothing in the data is a good answer, and a model given a weak match will answer with confidence. Most RAG demos improvise when nothing in the index matches, and in real estate an improvised answer is a legal problem.
How it works
Anchor runs a cosine search on pgvector and returns a null answer when the best hit falls under a floor you set per index.
- Listings are stored as vectors in PostgreSQL with pgvector and queried through Prisma.
- The retrieval step, in TypeScript, embeds the query, scores the best match and compares it with the floor. Above it, you get the chunks. Below it, you get
{ answer: null, reason: "no_match" }. - Ingestion upserts on a hash of each chunk's content, so re-running the same documents does not duplicate rows.
- A Next.js and React page lets you type a question and see the answer next to the listing it came from, or see the refusal.
The floor is a config value, not something the model can talk itself out of. The trade-off is that a floor set too high makes Anchor refuse questions it could half answer, and tuning that number is on you.
What it does not do
- One threshold per index. There is no per-query re-ranking or keyword pass.
- The embedding model is fixed per index. Switching models means re-embedding everything.
- The floor cannot tell "no source" apart from "a source exists but embeds poorly".
Links
- Code: github.com/ykstorm/anchor
- Live demo: anchor-iota-ten.vercel.app/playground