PATTERN Cited by 1 source
Analytical intent retrieval¶
Analytical intent retrieval is the query-time half of Pinterest's Text-to-SQL stack: at request time, the user's natural-language question is embedded into the same unified context-intent embedding space as past-query descriptions, and the top-k semantically similar past queries are returned as validated building blocks for SQL generation.
(Source: sources/2026-03-06-pinterest-unified-context-intent-embeddings-for-scalable-text-to-sql.)
The pattern¶
user question (natural language)
│
▼
[ embedding model ] ── same model used for past-query descriptions
│
▼
[ vector search over intent index ]
│
▼
[ top-k past queries, with their ]
[ validated join keys + filters ]
[ + aggregation patterns ]
│
▼
[ governance-aware re-rank ] ── fuse with tier / freshness / ownership
│
▼
ranked candidates for SQL generation
What makes it robust to vocabulary mismatch¶
Retrieval works at the level of business questions, not tables/columns. Pinterest's example:
- User asks: "What's the engagement rate for organic Pins by country?"
- Matches a historical query originally described as "non-promoted pin interaction rates by country" — even though the tables, column names, and keyword phrasing all differ. The match happens because both describe the same analytical question, and the embedding space captures semantic similarity between them.
This is the question-to-question bridge in action.
What the retrieved candidates contribute¶
Each retrieved past query carries:
- Summary + analytical questions — confirmation of semantic match.
- Detailed breakdown — transformation logic the LLM can reuse.
- Extracted structural patterns — join keys, filter conventions, aggregation logic from parsed SQL.
- Statistical signals — success rate, usage recency, author expertise — for ranking fusion.
Relationship to retrieve-then-rank¶
Analytical intent retrieval is the retrieval half of a retrieve- then-rank LLM cascade (patterns/retrieve-then-rank-llm). The ranker is governance-aware: patterns/governance-tier-ranking-fusion. The final consumer is the Analytics Agent's SQL-generation step, which uses the top-ranked candidates as validated building blocks.
Seen in¶
- sources/2026-03-06-pinterest-unified-context-intent-embeddings-for-scalable-text-to-sql — canonical wiki instance.
Related¶
- patterns/sql-to-intent-encoding-pipeline — the build side.
- patterns/governance-tier-ranking-fusion — the re-rank step.
- concepts/unified-context-intent-embedding
- systems/pinterest-analytics-agent