WhoBuilt

Building efficient hybrid context query for LLM grounding

Feb 5, 2025· 12 min· 300 views·Watch on YouTube

Speaker

Simrat Hanspal, technical evangelist at Hasura, explains how to build hybrid queries for grounded product search using Hasura.

Why product search needs context

Hanspal contrasts keyword search with natural language search, which can capture descriptive intent as well as structured filters. He explains that retrieval-augmented generation supplies relevant context to language models, helping them answer questions about data they did not encounter during training.

Building a unified retrieval pipeline

The product search example combines semantic search over product descriptions with structured filters such as price and category. Hanspal describes using Hasura to expose multiple data sources through one GraphQL API, and a Streamlit app that turns user input into GraphQL queries. Event triggers automatically send newly inserted product records to the vector database.

Trying semantic, structured, and hybrid queries

The demo searches for essential oils for relaxation, filters products priced below $500, and combines a search for essential oil diffusers with a $500 to $1,000 price range. The app identifies the descriptive search text and structured price condition, then returns matching products.

Restricting what generated queries can do

A maliciously phrased request generates and executes an insert mutation, adding a product to the database. Hanspal then creates a role with select access only and reruns a similar request. The insert mutation is still generated, but the database rejects it because the role lacks insert permission.

Takeaways

  • Pair semantic similarity with structured filters when a search query includes both descriptive intent and constraints such as price.
  • A unified API can let an application query relational and vector data through one interface.
  • Use event triggers to keep product vectors updated when source records are inserted.
  • Treat generated queries as untrusted: enforce database permissions so a search role cannot insert or modify records.

Mentioned in this talk

Search inside this talk

What was claimed 3

  • works at
    AI Engineer; leads AI product strategy
    “technical evangelist at Hasura”
    YouTube
    Unverified2 sources· Talk, Web· archived
  • feature
    Hasura: Provides unified, dynamic, secure GraphQL data APIs over multiple data sources
    “a unified, dynamic, secure data API”
    YouTube
    Unverified1 source· Talk
  • feature
    Hasura: Supports permissions that can restrict a role to select queries and reject insert mutations
    “a role that does not have permission for insert queries”
    YouTube
    Unverified1 source· Talk

Related talks