すべてのプロダクト
Search
ドキュメントセンター

MaxCompute:AI_SUMMARIZE

最終更新日:May 28, 2026

AI_SUMMARIZE は、MaxCompute の AI 関数で、モデルを呼び出して入力テキストを要約します。

構文

STRING AI_SUMMARIZE(
  STRING <model_name>,
  STRING <version_name>,
  STRING <input>
  [, BIGINT <max_words>]
  [, STRING <model_parameters>]
);

パラメーター

  • model_name:必須。使用するモデルの名前を指定する文字列です。詳細については、「SQL AI 関数」をご参照ください。

  • version_name:必須。使用するモデルバージョンの名前を指定する文字列です。デフォルトバージョンを使用するには、DEFAULT_VERSION を指定します。

  • input:必須。要約対象のテキストを含む文字列です。

  • max_words:任意。生成される要約の最大単語数を指定する整数です。デフォルト値は 50 です。値 0 は単語数制限を無効にしますが、出力の長さはモデルの内部制限と max_tokens パラメーターによって引き続き制約されます。これらの制限を超えた内容は切り捨てられます。

  • model_parameters:任意。モデルパラメーターを JSON 形式で指定する文字列です。max_tokenstemperaturetop_p などを指定できます。例:

    '{"max_tokens": 500, "temperature": 0.6, "top_p": 0.95}'

    • max_tokens:1 回のモデル呼び出しで生成されるトークンの最大数です。MaxCompute パブリックモデルのデフォルト値は 4096 です。

    • temperature:0 ~ 1 の値で、モデルの出力のランダム性を制御します。値が大きいほど、より創造的で多様な出力になり、値が小さいほど、より確定的で保守的な出力になります。

    • top_p:0 ~ 1 の値で、モデルが考慮する候補ラベルの範囲を制限します。値が大きいほど、範囲が広がり多様性が増し、値が小さいほど、範囲が狭まり焦点が絞られた出力になります。

戻り値

入力テキストの要約を含む STRING を返します。戻り値のルールは次のとおりです:

  • 入力が STRING 型でない場合は、エラーを返します。

  • max_wordsNULL の場合は、エラーを返します。

例 1:デフォルトの制限による要約の生成

MaxCompute の qwen3-max 公開モデルを呼び出して、デフォルトの 50 単語の制限でテキスト文字列の要約を生成します。

-- SQL ジョブでモデルコンピューティングサービスを使用します。
SET odps.task.major.version=sql_modelstudio;
SET odps.namespace.schema=true;

SELECT AI_SUMMARIZE(
    bigdata_public_modelset.default.`qwen3-max`,
    DEFAULT_VERSION,
    'MaxCompute (formerly ODPS) is a fast, fully managed, multi-tenant big data processing platform that can handle data from terabytes to petabytes. MaxCompute provides various computing models, including SQL, MapReduce, Graph, and machine learning. It uses a Serverless architecture to elastically scale computing resources based on load, eliminating the need for users to manage infrastructure. The platform is deeply integrated with other Alibaba Cloud services such as DataWorks (for data development), PAI (a machine learning platform), and Quick BI (for data visualization).'
) AS summary;

-- 結果
+---------+
| summary |
+---------+
| MaxCompute is a fast, fully managed, multi-tenant big data platform capable of processing terabytes to petabytes of data. It supports multiple computing models—including SQL, MapReduce, Graph, and machine learning—and uses a serverless architecture for automatic, elastic scaling without infrastructure management. It integrates tightly with Alibaba Cloud services like DataWorks, PAI, and Quick BI. |
+---------+

例 2:指定した制限による要約の生成

MaxCompute の Qwen3-4B-GGUF 公開モデルを呼び出して、複数の記事を 30 単語で要約します。

-- サンプルデータ
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 vast amounts of data to identify patterns that are difficult for humans to detect. However, the rapid adoption of AI also raises concerns about job displacement, data privacy, and algorithm bias. Governments and organizations are actively developing ethical guidelines and regulatory frameworks to ensure the responsible development of AI.'),
    ('Cloud computing has become critical infrastructure for modern enterprises. By migrating to the cloud, businesses can reduce hardware capital expenditures, achieve elastic scaling of resources on demand, and access cutting-edge technologies with low upfront investment. Major cloud service providers like Alibaba Cloud, AWS, and Azure offer a rich portfolio of services spanning computing, storage, databases, and AI. The rise of cloud-native architecture has also driven the widespread adoption of technologies such as microservices, containers, and Serverless.');

-- テーブル内の記事の要約を生成します。
SET odps.sql.ai.treat.as.common.model=true;
SET odps.namespace.schema=true;

SELECT
    AI_SUMMARIZE(
        bigdata_public_modelset.default.`Qwen3-4B-GGUF`,
        DEFAULT_VERSION,
        article,
        30
    ) AS summary,
    article
FROM articles;


-- 結果
+--------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|summary                                                                                           |article                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
+--------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| AI is reshaping the economy, improving efficiency but raising ethical 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 vast amounts of data to identify patterns that are difficult for humans to detect. However, the rapid adoption of AI also raises concerns about job displacement, data privacy, and algorithm bias. Governments and organizations are actively developing ethical guidelines and regulatory frameworks to ensure the responsible development of AI. |
| Cloud computing reduces business costs by providing elastic resources and easy access to advanced technologies. | Cloud computing has become critical infrastructure for modern enterprises. By migrating to the cloud, businesses can reduce hardware capital expenditures, achieve elastic scaling of resources on demand, and access cutting-edge technologies with low upfront investment. Major cloud service providers like Alibaba Cloud, AWS, and Azure offer a rich portfolio of services spanning computing, storage, databases, and AI. The rise of cloud-native architecture has also driven the widespread adoption of technologies such as microservices, containers, and Serverless. |
+--------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+