Live data from Hacker News

Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

playground.shaped.ai

1–10 of 24 posts

Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

#1
Hi HN,

I’m Tullie, founder of Shaped. Previously, I was a researcher at Meta AI, worked on ranking for Instagram Reels, and was a contributor to PyTorch Lightning.

We built ShapedQL because we noticed that while retrieval (finding 1,000 items) has been commoditized by vector DBs, ranking (finding the best 10 items) is still an infrastructure problem.

To build a decent for you feed or a RAG system with long-term memory, you usually have to put together a vector DB (Pinecone/Milvus), a feature store (Redis), an inference service, and thousands of lines of Python to handle business logic and reranking.

We built an engine that consolidates this into a single SQL dialect. It compiles declarative queries into high-performance, multi-stage ranking pipelines.

HOW IT WORKS:

Instead of just SELECT , ShapedQL operates in four stages native to recommendation systems:

RETRIEVE: Fetch candidates via Hybrid Search (Keywords + Vectors) or Collaborative Filtering. FILTER: Apply hard constraints (e.g., "inventory > 0"). SCORE: Rank results using real-time models (e.g., p(click) or p(relevance)). REORDER: Apply diversity logic so your Agent/User doesn’t see 10 nearly identical results.

THE SYNTAX: Here is what a RAG query looks like. This replaces about 500 lines of standard Python/LangChain code:

SELECT item_id, description, price

FROM

  -- Retrieval: Hybrid search across multiple indexes

  search_flights("$param.user_prompt", "$param.context"),

  search_hotels("$param.user_prompt", "$param.context")
WHERE

  -- Filtering: Hard business constraints

  price 
ORDER BY

  -- Scoring: Real-time reranking (Personalization + Relevance)

  0.5 * preference_score(user, item) +

  0.3 * relevance_score(item, "$param.user_prompt")
LIMIT 20

If you don’t like SQL, you can also use our Python and Typescript SDKs. I’d love to know what you think of the syntax and the abstraction layer!

Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG
playground.shaped.ai

Re: Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

#2
RE: syntax For casual use, I kinda always liked the whole MATCH/AGAINST syntax for old school Innodb, though obviously things have changed a lot since those days. But it felt less like calling embedded functions and more like extending SQL’s grammar.

Regarding the rest, it seems like a reasonable approach at first tinker.

Re: Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

#5
If I upload my own data, who exactly is it shared with? I can't find a list of subprocessors and this line in the privacy policy is alarming:

> We’ll whenever feasible ask for your consent before using your Personal information for a purpose that isn’t covered in this Privacy Policy.

Re: Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

#6
this is cool, but:

> This replaces about 500 lines of standard Python

isn't really a selling point when an LLM can do it in a few seconds. I think you'd be better off pitching simpler infra and better performance (if that's true).

i.e. why should I use this instead of turbopuffer? The answer of "write a little less code" is not compelling.

Re: Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

#7
post #3

Neat examples, and I agree that extending SQL like this has real potential. Another project along very similar lines is https://github.com/ryrobes/larsql

Fairly easy to extend SQLite, Postgres and MariaDB/MySQL!

Curious what relational database do you @refset use? Is the code open source? Is the engine from scratch? What general dialect does it support?

Cheers!

Re: Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

#9
post #3

Neat examples, and I agree that extending SQL like this has real potential. Another project along very similar lines is https://github.com/ryrobes/larsql

Fairly easy to extend SQLite, Postgres and MariaDB/MySQL! Curious what relational database do you @refset use? Is the code open source? Is the engine from scratch? What general dialect does it support? Cheers!

I work on https://github.com/xtdb/xtdb which is broadly Postgres-compatible with a few key SQL extensions (SQL:2011 bitemporal tables + immutability, first-class nested data, pipeline syntax, etc). Built on Arrow and the JVM but is otherwise mostly from scratch.

XTDB is perhaps not directly relevant to the topic at hand, but I am a firm believer that ML workflows can benefit from robust temporal modelling.

Re: Show HN: ShapedQL – A SQL engine for multi-stage ranking and RAG

#10
>> Apply diversity logic so your Agent/User doesn’t see 10 nearly identical results

On Instagram this is a good thing, but here the example is hotel and flight search, where a more deterministic result is preferable.

In the retrieve → filter stage, using predicate pushdown may be more performant: first filter using hard constraints, then apply hybrid search ?

Post reply on HN