AI_SUMMARIZE は MaxCompute の AI 関数で、モデルを呼び出して入力テキストの要約を生成します。
構文
STRING AI_SUMMARIZE(
STRING <model_name>,
STRING <version_name>,
STRING <input>
[, BIGINT <max_words>]
[, STRING <model_parameters>]
);パラメーター
model_name: (必須) モデルの名前を指定する STRING です。詳細については、SQL AI 関数 をご参照ください。
version_name: (必須) モデルのバージョンを指定する STRING です。デフォルトバージョンを呼び出すには、
DEFAULT_VERSIONを指定します。input: (必須) 要約するテキストを指定する STRING です。
max_words: (オプション) 整数です。大規模モデルの出力の最大単語数を指定します。デフォルト値は 50 です。このパラメーターを 0 に設定すると制限は適用されませんが、出力はモデル自体と
max_tokensパラメーターによって制約されます。制限を超えた場合、出力は切り捨てられます。model_parameters:任意。STRING。`max_tokens`、`temperature`、`top_p` などのモデルパラメーターを指定します。フォーマットは JSON 文字列です:
'{"max_tokens": 500, "temperature": 0.6, "top_p": 0.95}'。max_tokens:1 回のモデル呼び出しで生成されるトークンの最大数。MaxCompute パブリックモデルの場合、デフォルト値は 4,096 です。
temperature:0 から 1 までの値で、出力のランダム性を制御します。値が高いほど、より創造的で多様な出力になり、値が低いほど、より決定的で保守的な出力になります。
top_p:0 から 1 までの値で、モデルが選択できる候補ラベルの範囲を制限します。値が高いほど範囲が広がり多様性が増し、値が低いほど範囲が狭まり、より焦点の合った結果になります。
戻り値
入力テキストの要約を含む STRING を返します。次の場合はエラーが返されます。
inputが STRING ではない場合。max_wordsが NULL の場合。
例
例 1:デフォルトの単語数制限による要約
qwen3.7-max パブリックモデルを呼び出して、デフォルトの 50 単語の制限でテキスト要約を生成します。
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;
-- 次の結果が返されます。
+------+
| 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. |
+------+例 2:指定した単語数制限による要約
deepseek-v4-pro パブリックモデルを呼び出して、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 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.');
-- テーブル内の記事の要約を一括で生成します。
SET odps.namespace.schema=true;
SELECT
AI_SUMMARIZE(
bigdata_public_modelset.default.`deepseek-v4-pro`,
DEFAULT_VERSION,
article,
30
) AS summary,
article
FROM articles;
-- 次の結果が返されます。
+------------------------------------------------------+--------------------------------------------------------------------+
|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. |
+-------------------------------------------------------+--------------------------------------------------------------------+よくある質問
パブリックモデルに関する一般的な問題のトラブルシューティング
現象: モデルコンピューティングサービスでサポートされているパブリックモデルを呼び出すと、次のエラーが返されます。
FAILED: ODPS-0130071:[1,8] Semantic analysis exception - inference quota status check failed, error message: region cn-shanghai not found in inference quota原因: 中国 (上海) など、プロジェクトが配置されているリージョンでモデルコンピューティングサービスが有効化されていないため、AI 推論リソースを呼び出せません。
解決方法: Alibaba Cloud コンソールにアクセスし、プロジェクトが配置されているリージョンでモデルコンピューティングサービスを有効化してください。詳細な手順については、「MaxCompute モデルコンピューティングサービスの購入と使用」をご参照ください。