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

Realtime Compute for Apache Flink:ML_PREDICT

最終更新日:Dec 04, 2025

このトピックでは、`ML_PREDICT` 関数を使用して大規模 AI モデルで推論を実行する方法について説明します。

制限事項

  • Ververica Runtime (VVR) 11.1 以降のみがサポートされています。

  • `ML_PREDICT` オペレーターのスループットは、Alibaba Cloud Model Studio のレート制限を受けます。トラフィックがモデルのレート制限に達すると、Flink ジョブでバックプレッシャーが発生し、`ML_PREDICT` オペレーターがボトルネックになります。レート制限が深刻な場合、オペレーターのタイムアウトやジョブの再起動がトリガーされる可能性があります。各モデルのレート制限の条件に関する詳細については、Model Studio ドキュメントのレート制限をご参照ください。

構文

ML_PREDICT(TABLE <TABLE NAME>, MODEL <MODEL NAME>, DESCRIPTOR(<INPUT COLUMN NAMES>))

入力パラメーター

パラメーター

データ型

説明

TABLE <TABLE NAME>

TABLE

モデル推論の入力データストリームです。物理テーブル名またはビュー名を指定できます。

MODEL <MODEL NAME>

MODEL

登録済みのモデルサービスの名前です。モデルサービスの登録方法に関する詳細については、「モデル設定」をご参照ください。

DESCRIPTOR(<INPUT COLUMN NAMES>)

-

モデル推論に使用する 入力データ の列。

テストデータ

id

movie_name

user_comment

actual_label

1

Quality item

My favourite part was when the kid guessed the sounds. It was romantic, heartwarming, and loving.

POSITIVE

2

The Dumpling Queen

Nothing special.

NEGATIVE

テストステートメント

次の SQL の例では、Qwen-Turbo モデルを作成し、`ML_PREDICT` 関数を使用して映画レビューの感情分類を実行します。

CREATE TEMPORARY MODEL ai_analyze_sentiment
INPUT (`input` STRING)
OUTPUT (`content` STRING)
WITH (
    'provider'='bailian',
    'endpoint'='<YOUR ENDPOINT>',
    'apiKey' = '<YOUR KEY>',
    'model'='qwen-turbo',
    'systemPrompt' = 'Classify the text below into one of the following labels: [positive, negative, neutral, mixed]. Output only the label.'
);


CREATE TEMPORARY VIEW movie_comment(id, movie_name,  user_comment, actual_label)
AS VALUES (1, 'The Good Stuff', 'I love the part where the child guesses the voice. It is one of the most romantic narratives in any movie I have seen. Very gentle and full of love.', 'positive'), (2, 'Dumpling Queen', 'Unremarkable', 'negative');


SELECT id, movie_name, content as predict_label, actual_label 
FROM ML_PREDICT(TABLE movie_comment, MODEL ai_analyze_sentiment, DESCRIPTOR(user_comment));

出力結果

predict_label 列の予測結果は、actual_label 列の実際の結果と一致します。

id

movie_name

predict_label

actual_label

1

Benefits

POSITIVE

POSITIVE

2

The Dumpling Queen

NEGATIVE

NEGATIVE