用于可扩展 Text-to-SQL 的统一上下文-意图嵌入

[

[

](https://medium.com/@Pinterest_Engineering?source=post_page---byline--793635e60aac---------------------------------------)

](https://medium.com/@Pinterest_Engineering?source=post_page---byline--793635e60aac---------------------------------------)

Your Analysts Already Wrote the Perfect Prompt

你的分析师已经编写了完美的提示

Authors: Keqiang Li, Bin Yang

作者:Keqiang Li, Bin Yang

In our previous blog post, we shared how Pinterest built Text-to-SQL with RAG-based table selection (Retrieval-Augmented Generation). That system introduced schema-grounded SQL generation and retrieval-augmented table selection. These were important first steps, but not enough for reliable analytics at Pinterest scale.

在我们之前的博客文章中,我们分享了Pinterest如何使用RAG-based table selection(Retrieval-Augmented Generation)构建Text-to-SQL。该系统引入了schema-grounded SQL generation和retrieval-augmented table selection。这些是重要的第一步,但不足以支持Pinterest规模的可靠分析。

The challenge was fundamental: with over 100,000 analytical tables and 2,500+ analytical users across dozens of domains, simple keyword matching and table summaries were not enough. When an analyst asks “What’s the engagement rate for organic content by country?”, they need more than a list of tables with similar names. They need the system to understand analytical intent, the business question behind the query, and surface patterns that have actually worked for similar analyses.

挑战是根本性的:拥有超过 100,000 个分析表格和跨越数十个领域的 2,500+ 分析用户,简单的关键词匹配和表格摘要是不够的。当分析师询问“organic content 按国家划分的参与率是多少?”时,他们需要的不仅仅是具有相似名称的表格列表。他们需要系统理解analytical intent,即查询背后的业务问题,并呈现实际对类似分析有效的模式。

This article describes how we evolved from basic Text-to-SQL to a production Analytics Agent that helps analysts discover tables, find reusable queries, and generate validated SQL from natural language. Now the most widely adopted agent at Pinterest, it was built on two key engineering choices:

这篇文章描述了我们如何从基本的 Text-to-SQL 演进到一个生产环境的 Analytics Agent,该代理帮助分析师发现表、找到可重用查询,并从自然语言生成验证过的 SQL。现在它是 Pinterest 最广泛采用的代理,它基于两个关键的工程选择构建:

  1. Unified context-intent embeddings — We transform historical ...
开通本站会员,查看完整译文。

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.0. UTC+08:00, 2026-03-24 00:40
浙ICP备14020137号-1 $Map of visitor$