AI_SUMMARIZE adalah fungsi bernilai tabel yang memanggil large language model (LLM) untuk menghasilkan ringkasan teks dari string input.
Batasan
-
Memerlukan Ververica Runtime (VVR) 11.4 atau versi yang lebih baru.
-
Throughput dibatasi oleh rate limit platform model yang mendasarinya. Ketika batas tersebut tercapai, pekerjaan Flink mengalami backpressure dan
AI_SUMMARIZEmenjadi bottleneck. Dalam kasus parah, hal ini dapat memicu error timeout dan restart pekerjaan.
Sintaksis
AI_SUMMARIZE(
MODEL => MODEL <model_name>,
INPUT => <input_column>,
MAX_LENGTH => <max_length>
)
Mendukung argumen posisional maupun bernama.
Parameter
| Parameter | Tipe data | Deskripsi |
|---|---|---|
MODEL <model_name> |
MODEL | Nama layanan model yang telah didaftarkan. Model tersebut harus mengembalikan output bertipe VARIANT. Lihat Model Settings untuk mendaftarkan layanan model. |
<input_column> |
STRING | Kolom yang isinya diringkas oleh model. |
<max_length> |
INTEGER | Panjang maksimum output model. Harus berupa nilai konstan. |
Output
| Kolom | Tipe data | Deskripsi |
|---|---|---|
summary |
STRING | Ringkasan yang dihasilkan. |
Contoh
Contoh lengkap dengan data tabel
Contoh berikut membuat model Qwen-Plus, memuat data uji ke dalam tampilan sementara, dan memanggil AI_SUMMARIZE pada kolom tabel menggunakan argumen posisional maupun bernama.
Data uji
| id | description |
|---|---|
| 1 | What is Flink? Apache Flink is an open source distributed stream processing framework for stateful computation over real-time data streams and batch data. In simple terms: Flink is a compute engine for processing real-time data. It handles continuous data streams such as website clicks, Internet of Things sensor data, and stock trades. It provides low latency, high throughput, and exactly-once semantics. It supports both stream processing and batch processing. |
SQL
CREATE TEMPORARY MODEL general_model
INPUT (`input` STRING)
OUTPUT (`content` VARIANT)
WITH (
'provider' = 'openai-compat',
'task' = 'chat/completions',
'model' = 'qwen-plus'
);
CREATE TEMPORARY VIEW infos(id, description)
AS VALUES (1, '
What is Flink?
Apache Flink is an open source distributed stream processing framework for stateful computation over real-time data streams and batch data.
In simple terms:
Flink is a compute engine for processing real-time data.
It handles continuous data streams such as website clicks, Internet of Things sensor data, and stock trades.
It provides low latency, high throughput, and exactly-once semantics.
It supports both stream processing and batch processing.
');
-- Gaya argumen posisional
SELECT id, summary
FROM infos, LATERAL TABLE(
AI_SUMMARIZE(MODEL general_model, description, 10));
-- Gaya argumen bernama
SELECT id, summary
FROM infos, LATERAL TABLE(
AI_SUMMARIZE(
MODEL => MODEL general_model,
INPUT => description,
MAX_LENGTH => 10));
Output
| id | summary |
|---|---|
| 1 | Real-time stream processing engine |