基于智能体的商业智能
能基于你的数据仓库,把业务问题转化为可信洞察的智能体:分层上下文、语义层中受治理的指标、有防护的 SQL、无法作答时会明确说明的回答、智能体无法用言辞绕过的访问规则,以及基于你自己的标准问题集的评估,通过 MCP 提供服务,全部构建在 DuckDB、sqlglot 和 MetricFlow 之上。
适合谁 本书写给会写 SQL、熟悉自家数据仓库、并受托让人们向数据提问的分析工程师、BI 开发人员和数据科学家,借助能给出正确数字的助手。
在 Kindle 或任意电子阅读器上阅读
EPUB 格式也适用于 Apple Books、Kobo 及大多数电子阅读器。
发送到 Kindle
将本版次的 EPUB 发送至 简体中文.
-
批准我们的地址
亚马逊仅向您已批准的地址所发送的内容投递至 Kindle,且每项邮件服务须单独批准。请将我们的地址添加到您的已批准个人文档电子邮件列表中。
books@rollingedition.com打开亚马逊的个人文档设置. 在亚马逊上,该选项位于“管理您的内容和设备”、“偏好设置”、“个人文档设置”下。
已发送。几分钟后将出现在您的 Kindle 书库中。
如果未能送达,几乎总是第 1 步的批准设置有问题:请检查 books@rollingedition.com 是否已列入您的已批准个人文档电子邮件列表。
您已保存图书的每个新版次也将发送到您的 Kindle。
这不是 Kindle 地址。地址应以 @kindle.com 结尾,可在亚马逊的“个人文档设置”中找到。
你今天已发送{count}本图书,这是单个账户一天可发送的最大数量。请明天再试。
今日可发送的书籍已达上限。请明天再试。
图书未能发送,请几分钟后重试。
本版次体积过大,无法通过电子邮件发送。
发送到 Kindle 功能随 Labs 提供。
这不是 Kindle 地址。地址应以 @kindle.com 结尾,可在亚马逊的“个人文档设置”中找到。
图书未能发送,请几分钟后重试。
或者下载 EPUB 文件,并将其拖放到亚马逊的“发送至 Kindle”页面。
Kindle is a trademark of Amazon.com, Inc.
目录
11章,阅读约需 15小时 47分钟,包含 78个示例。
-
1端到端的数据智能体
读完本章,你将能够构建商店的数据仓库,让一个已录制的模型为某个业务问题编写 SQL,运行该 SQL 并发现它返回的错误数字,用一个已定义的指标回答同一个问题,并在五个黄金问题上为两种做法打分。
-
2Where raw text-to-SQL gets the number wrong
By the end of this chapter, you can name the five ways schema-only text-to-SQL returns a plausible wrong number on a real warehouse, show each one on the shop's warehouse, count them across a set of golden questions, and tell which a better prompt can fix and which need definitions the schema doesn't hold.
-
3从你自己的工作中构建黄金问题
读完本章,你将能够根据企业中人们提出的问题编写黄金问题,并为每个问题配上黄金 SQL、提问的角色以及所需的答案类型。
-
4Give the agent layered context
By the end of this chapter, you can give a model that writes SQL more than the schema, in layers: notes on columns whose names mislead, a glossary of the shop's business terms, and verified queries retrieved for each question.
-
5Define metrics once in a semantic layer
By the end of this chapter, you can write the shop's semantic models and metrics in MetricFlow's YAML spec, compile a metric request to SQL with the book's own compiler, show that its entity joins can't fan out, group by the fiscal calendar, and confirm that MetricFlow compiles the same definitions to the same results.
-
6优先将问题路由到受治理的指标
读完本章,你可以把语义层的指标而不是数据仓库的表作为工具交给智能体,让它返回结构化的指标请求,并在任何查询运行之前先对该请求进行校验;当一个问题可能对应多个指标时,让它向提问者反问;并在黄金问题上衡量这些改变带来的效果。
-
7Let the agent write SQL inside guards
By the end of this chapter, you can handle the questions no metric covers by letting the agent write SQL that runs read-only on a database holding only the rows and columns its role may read, and that is parsed, checked against an allowlist of tables, bounded in rows, size, cost and time, repaired once from an error, and transpiled to your warehouse's dialect.
-
8在无法回答时明确说明
读完本章,你可以把拒答变成一种正式的回答:区分仓库无法回答的问题和能够回答的问题;以已知类别的理由拒答;检查所问时间段的数据是否已经到达;展示每个回答背后的数据来源;并用精确率和召回率衡量拒答,使智能体既不乱猜,也不过于频繁地拒绝。
-
9让智能体只在许可范围内查看数据
读完本章,你将能够在智能体之下、在各角色自己的数据库中,强制执行每个角色的行过滤、列掩码和最小分组规模,并以语义层中的改写作为一道防线,以守卫作为纵深防御,使任何提示词都无法扩大访问范围。
-
10评判回答并发现回归
学完本章,你将能够:同时用多项指标为智能体的一次运行打分;只在结果无法直接比较时才使用模型作为评判者;对照任何人都能重新计算的参考标注来校准这个评判者;看出分数在两次运行之间的波动幅度;并在 CI 中基于已记录的运行,对提示词、上下文或指标的变更设置门禁。
-
11Serve the semantic layer over MCP
By the end of this chapter, you can serve the shop's governed metrics as MCP tools that answer for the role the server was built for, return each answer with its provenance as structured data, test the server in memory, and run the book's agent through it as a host.