AI_SUMMARIZE is an AI function in MaxCompute that calls a model to generate a summary of input text.
Syntax
STRING AI_SUMMARIZE(
STRING <model_name>,
STRING <version_name>,
STRING <input>
[, BIGINT <max_words>]
[, STRING <model_parameters>]
);Parameters
model_name: Required. A STRING that specifies the name of the model. For more information, see SQL AI function.
version_name: Required. A STRING that specifies the version of the model. To call the default version, you can specify
DEFAULT_VERSION.input: Required. A STRING that specifies the text to summarize.
max_words: Optional. An integer. Specifies the maximum number of words that the large model can output. The default value is 50. If this parameter is set to 0, no limit is imposed, but the output is still constrained by the model itself and the
max_tokensparameter. If the limit is exceeded, the output is truncated.model_parameters: Optional. STRING. Specifies model parameters such as
max_tokens,temperature, andtop_p. The format is a JSON string:'{"max_tokens": 500, "temperature": 0.6, "top_p": 0.95}'.max_tokens: The maximum number of tokens to generate in a single model call. For MaxCompute public models, the default value is 4,096.
temperature: A value between 0 and 1 that controls the randomness of the output. A higher value results in more creative and diverse output, while a lower value produces more deterministic and conservative output.
top_p: A value between 0 and 1 that limits the range of candidate labels the model can choose from. A higher value allows for a broader range and more diversity, while a lower value narrows the range and produces more focused results.
Return value
Returns a STRING containing the summary of the input text. An error is returned if:
inputis not a STRING.max_wordsis NULL.
Examples
Example 1: Default word limit summary
Call the qwen3.7-max public model to generate a text summary with the default 50-word limit.
SET odps.namespace.schema=true;
SELECT AI_SUMMARIZE(
bigdata_public_modelset.default.`qwen3.7-max`,
default_version,
'MaxCompute provides the SQL AI function, which supports AI inference by calling built-in large language models, user-imported models, or remote PAI-EAS models through SQL.') AS info;
-- The following result is returned:
+------+
| info |
+------+
| MaxCompute provides the SQL AI function, supporting inference by calling built-in large language models, user-imported models, or remote PAI-EAS models via SQL. |
+------+Example 2: Specified word limit summary
Call the deepseek-v4-pro public model to batch-generate summaries for multiple articles with a 30-word limit.
-- Sample data
CREATE TABLE articles (
article STRING
);
INSERT INTO articles VALUES
('Artificial intelligence is reshaping the global economy. Industries from healthcare to finance are adopting AI solutions to automate processes, reduce costs, and improve decision-making. Machine learning models can analyze massive datasets to identify patterns that are difficult for humans to detect. However, the rapid adoption of AI has also raised concerns about job displacement, data privacy, and algorithmic bias. Governments and organizations are actively developing ethical guidelines and regulatory frameworks to ensure the healthy development of AI.'),
('Cloud computing has become a key infrastructure for modern businesses. Through cloud migration, companies can reduce capital expenditure on hardware, achieve elastic scaling of resources on demand, and use cutting-edge technologies with low upfront investment. Major cloud service providers like Alibaba Cloud, AWS, and Azure offer a rich set of services covering computing, storage, databases, and AI capabilities. The rise of cloud-native architecture has also driven the widespread adoption of technologies such as microservices, containers, and Serverless.');
-- Generate summaries for the articles in the table in a batch
SET odps.namespace.schema=true;
SELECT
AI_SUMMARIZE(
bigdata_public_modelset.default.`deepseek-v4-pro`,
DEFAULT_VERSION,
article,
30
) AS summary,
article
FROM articles;
-- The following result is returned:
+------------------------------------------------------+--------------------------------------------------------------------+
|summary |article |
+------------------------------------------------------+--------------------------------------------------------------------+
| AI is driving automation and data analysis across industries but also raises ethical and regulatory concerns. |Artificial intelligence is reshaping the global economy. Industries from healthcare to finance are adopting AI solutions to automate processes, reduce costs, and improve decision-making. Machine learning models can analyze massive datasets to identify patterns that are difficult for humans to detect. However, the rapid adoption of AI has also raised concerns about job displacement, data privacy, and algorithmic bias. Governments and organizations are actively developing ethical guidelines and regulatory frameworks to ensure the healthy development of AI. |
| Cloud computing reduces business costs and provides easy access to elastic resources and cutting-edge technologies. |Cloud computing has become a key infrastructure for modern businesses. Through cloud migration, companies can reduce capital expenditure on hardware, achieve elastic scaling of resources on demand, and use cutting-edge technologies with low upfront investment. Major cloud service providers like Alibaba Cloud, AWS, and Azure offer a rich set of services covering computing, storage, databases, and AI capabilities. The rise of cloud-native architecture has also driven the widespread adoption of technologies such as microservices, containers, and Serverless. |
+-------------------------------------------------------+--------------------------------------------------------------------+FAQ
Troubleshoot common issues with public models
Symptom: Calling a public model supported by the model computing service returns the following error:
FAILED: ODPS-0130071:[1,8] Semantic analysis exception - inference quota status check failed, error message: region cn-shanghai not found in inference quotaCause: The model computing service is not active in your project's region, such as China (Shanghai), which prevents calls to AI inference resources.
Solution: Go to the Alibaba Cloud console and activate the model computing service for your project's region. For detailed instructions, see Purchase and use the MaxCompute model computing service.