このトピックでは、大規模言語モデル (LLM) の推論に ML_PREDICT を使用する方法について説明します。
使用制限
Ververica Runtime (VVR) 11.1 以降でのみサポートされています。
ML_PREDICT 文に関連する Flink 演算子のスループットは、Model Studio によるレート制限の対象となります。Model Studio で許可されているトラフィック制限に達すると、Flink ジョブは ML_PREDICT 演算子をボトルネックとしてバックプレッシャーを経験します。深刻な場合、これにより影響を受ける演算子でタイムアウトエラーやジョブの再起動がトリガーされる可能性があります。異なるモデルのレート制限の条件については、「レート制限」をご参照ください。
構文
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 | Good Stuff | I love the part where kids guess voices. It's one of the most romantic narratives I've seen in a movie—gentle and full of warmth. | POSITIVE |
2 | 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, 'Good Stuff', 'I love the part where kids guess voices. It''s one of the most romantic narratives I''ve seen in a movie—gentle and full of warmth.', 'positive'), (2, 'Dumpling Queen', 'Nothing special.', '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 | Good Stuff | POSITIVE | POSITIVE |
2 | Dumpling Queen | NEGATIVE | NEGATIVE |