# Filter vector search results before they reach the model

> Source: <https://dev.to/conorbronsdon/filter-vector-search-results-before-they-reach-the-model-p2e>
> Published: 2026-11-27 20:32:08+00:00

**Recommendation:** Over-fetch vector candidates, then reject those failing metadata and relationship constraints (tenant, product, jurisdiction, policy version) before ranking and passing a small tool set to the model.
More in the playbook "Retrieval and RAG": <https://wpnews.pro/playbooks/rag-retrieval>

Vector search returns what looks similar, which isn't always what fits the question. Treat retrieval as a pipeline instead: similarity search proposes candidates, metadata and relationships reject what doesn't fit, and the model gets a small tool set chosen for the use case. [Sudhir Hasbe](https://chainofthought.show/guests/sudhir-hasbe/) says customers who start with pure vector RAG see accuracy around 60% to 65%, and that adding metadata, relationships and specific tools can get them above 95% over time.

Sudhir Hasbe is President and Chief Product Officer at Neo4j. In an April 2026 episode he argued that many enterprise hallucinations trace back to how data is organized and exposed.

Because embeddings measure closeness, not your business's definition of a match. Hasbe's go-to example came from Spotify's CTO on another podcast: a pop listener could get a country song next because the vectors sat close together. Spotify fixed it with song metadata that kept recommendations inside the listener's genre:

they were able to use this metadata behind it to say, no, no, no. When the user is listening to this, now you use this additional metadata as a context to go ahead and restrict what the answers look like within that domain.

*Sudhir Hasbe, President and Chief Product Officer at Neo4j, on [Chain of Thought ep 55](https://chainofthought.show/podcast/55-hallucinations-are-a-data-architecture-problem-sudhir-hasbe-neo4j/)*

Document RAG hits the same wall. Chunk-and-embed works for simple collections, but once questions span product lines, regions or time periods, several plausible chunks compete. GraphRAG, as Hasbe uses the term, adds a filtering layer built from metadata and relationships on top of vector search. He said there is research in that range, and that some Neo4j customers using this approach are well above 90% accurate.

The design question is what must stay true for an answer to count as correct (tenant, product, jurisdiction, policy version) and which of those predicates you enforce before the model sees text.

*A minimal sketch to adapt. `vector_search`, `metadata_matches` and the `graph` object are hypothetical.*

``` php
def retrieve_for_question(question: str, filters: dict, graph) -> list[str]:
    candidates = vector_search(question, top_k=50)
    candidates = [c for c in candidates if metadata_matches(c, filters)]
    candidates = [
        c for c in candidates
        if graph.satisfies_constraints(c.entity_id, filters["relations"])
    ]
    return rank_by_graph_proximity(candidates, graph, limit=8)
```

Hasbe sorts the data an enterprise agent needs into overlapping asset types: systems of record for present state, analytical stores for history, agent memory for workflow state, context that explains decisions made outside formal schemas, and reference or semantic mapping so ambiguous terms resolve correctly. At EA Sports, "FIFA" could mean this year's game or last year's. The data can stay in separate systems if a shared layer tells the agent where to read and what each field means.

He sees three deployment patterns: a semantic map only (data stays in source systems), semantic map plus consolidated domain slices (for example customer data split across many apps), and full knowledge consolidation into one graph, which he said Klarna did for its internal employee chat.

The approved discount lives in the CRM as the decision. The negotiation that justified an exception often lives in email and Slack between the rep, the customer, and management. Future agents that price deals need that "why," not only the final number.

Hasbe calls this a context graph. It records the decision and the interactions that justified it so later automation can ask why a customer received an above-normal discount. He treats the context graph as one part of a broader agent memory, which spans individual memory (what one agent has done) and organizational memory shared across agents dealing with the same customer.

Now the system of record is going to store the decision, which is like, okay, the discount approved was this, and this is what it is. But all the context graph talks about, this context graph is the decision that was made, which should be recorded, but also the context of the decision, which is not in the systems anymore, which will be important for future decision making for autonomous agents.

A practical version I'd add: when a human or agent sets a field in a system of record, attach or link a structured summary of the thread that authorized it, with retention and access controls aligned to the source channels.

Because the model has more wrong options. Hasbe said customers keep reporting the same pattern: a small tool set works well, and results get worse as they attach more tools, up to hundreds, to one reasoning engine. Architects at multiple companies (he mentions someone who moved from Intuit to Salesforce) converged on scoping tools to the use case. Fraud review and marketing outreach may both need a similarly named get-customer tool with different fields and side effects; dumping every API into one menu increases wrong picks and token cost from irrelevant context.

He suggests a knowledge graph as one way to map an intent to a short list: for fraud, the 10 or 15 most relevant tools. Uber, a Neo4j customer, described at one of Neo4j's customer summits using its knowledge graph as a business validation layer, because Uber Eats works across many jurisdictions with different payment and minimum-wage rules. The principle is the same in both cases: limit what the model can invoke to what the scenario allows.

*A minimal sketch to adapt, not a drop-in library.*

```
TOOL_REGISTRY = {
    "fraud_review": ["get_account_graph", "list_recent_tx", "flag_case"],
    "sales_pricing": ["get_crm_quote", "get_discount_context", "submit_approval"],
}

def tools_for_intent(intent: str) -> list[str]:
    return TOOL_REGISTRY.get(intent, [])
```

**Is this a prompt problem or a data problem?**

Hasbe treats the model as one component of the system and puts the work on data architecture: how siloed enterprise data is represented and exposed so models can reason over it.

**What accuracy should I expect from vector-only RAG?**

Hasbe put pure vector RAG deployments at around 60% to 65%. With metadata, relationships and use-case-specific tools, he said teams can get above 95% over time.

**Do I have to move all data into one graph?**

No. He outlines semantic-map-only patterns where agents read source systems after consulting a map, plus hybrid consolidation when a single customer view requires joining fragments.

The full conversation, with the transcript, is on [Chain of Thought](https://chainofthought.show/podcast/55-hallucinations-are-a-data-architecture-problem-sudhir-hasbe-neo4j/).

[Subscribe to the Chain of Thought newsletter](https://newsletter.chainofthought.show/subscribe?utm_source=devto&utm_medium=referral&utm_campaign=newsletter) for new episodes and write-ups like this one.

*Drafted with AI assistance from the episode transcripts.*
