适用于: Databricks SQL
Databricks Runtime
ai_summarize()
函数允许调用最先进的生成式 AI 模型,使用 SQL 生成给定文本的摘要。 此函数使用由 Databricks 基础模型 API 提供的聊天模型服务端点。
要求
重要
目前可能使用的基础模型根据 Apache 2.0 许可证及版权 © Apache Software Foundation,或根据 LLAMA 3.3 社区许可证 及版权 © Meta Platforms, Inc. 获得许可。保留所有权利。 客户需负责确保遵守适用的模型许可条款。
Databricks 建议查看这些许可证,以确保遵守任何适用的条款。 如果模型在未来根据 Databricks 的内部基准表现更好,Databricks 可能会更改模型(以及本页中提供的适用许可证列表)。
- 此函数仅适用于使用基础模型 API 的 AI 函数支持的区域中的工作区。
- 此函数在 Azure Databricks SQL Classic 上不可用。
- 查看 Databricks SQL 定价页。
- 批处理推理工作负荷需要 Databricks Runtime 15.4 ML LTS 来提高性能。
语法
ai_summarize(content[, max_words])
争论
-
content
:一个STRING
表达式,即要汇总的文本。 -
max_words
:一个可选的非负整数数值表达式,表示返回的摘要文本中的最大努力目标单词数。 默认值为 50。 如果设置为 0,则没有字数限制。
返回
一个 STRING
。
如果 content
为 NULL
,则结果为 NULL
。
示例
> SELECT ai_summarize(
'Apache Spark is a unified analytics engine for large-scale data processing. ' ||
'It provides high-level APIs in Java, Scala, Python and R, and an optimized ' ||
'engine that supports general execution graphs. It also supports a rich set ' ||
'of higher-level tools including Spark SQL for SQL and structured data ' ||
'processing, pandas API on Spark for pandas workloads, MLlib for machine ' ||
'learning, GraphX for graph processing, and Structured Streaming for incremental ' ||
'computation and stream processing.',
20
);
"Apache Spark is a unified, multi-language analytics engine for large-scale data processing
with additional tools for SQL, machine learning, graph processing, and stream computing."