全部产品
Search
文档中心

Realtime Compute for Apache Flink:AI_CLASSIFY

更新时间:Dec 04, 2025

Topik ini menjelaskan cara menggunakan fungsi AI_CLASSIFY untuk mengklasifikasikan teks dengan model AI besar.

Batasan

  • Fungsi ini hanya mendukung Ververica Runtime (VVR) 11.4 dan versi yang lebih baru.

  • Throughput operator Flink yang menggunakan pernyataan AI_CLASSIFY dibatasi oleh pembatasan kecepatan trafik di Alibaba Cloud Model Studio. Jika trafik melebihi batas platform, pekerjaan Flink mengalami tekanan balik (backpressure), sehingga operator tersebut menjadi bottleneck. Pembatasan kecepatan trafik yang parah dapat menyebabkan error timeout dan restart pekerjaan.

Sintaksis

AI_CLASSIFY(
  MODEL => MODEL <MODEL NAME>, 
  INPUT => <INPUT COLUMN NAME>,
  LABELS => <LABELS>
)

Parameter input

Parameter

Tipe data

Deskripsi

MODEL <MODEL NAME>

MODEL

Nama layanan model yang telah didaftarkan. Untuk informasi selengkapnya tentang pendaftaran layanan model, lihat Pengaturan model.

Catatan: Tipe output model ini harus berupa VARIANT.

<INPUT COLUMN NAME>

STRING

Data yang akan diklasifikasikan oleh model.

<LABELS>

ARRAY<STRING>

Kategori klasifikasi yang diharapkan.

Catatan: Parameter input ini harus berupa konstanta.

Keluaran

Parameter

Tipe data

Deskripsi

category

STRING

Kategori yang ditentukan oleh model.

confidence

DOUBLE

Tingkat kepercayaan yang dihasilkan oleh model.

Contoh

Data contoh

id

movie_name

comment

actual_label

1

Good Stuff

I love the part where the kids guess the sounds. It is one of the most romantic narratives in the movies I have seen. Very gentle and full of love.

POSITIVE

2

Dumpling Queen

Unremarkable.

NEGATIVE

Pernyataan contoh

Pernyataan SQL contoh berikut membuat model Qwen-Plus dan menggunakan fungsi AI_CLASSIFY untuk mengklasifikasikan kategori produk.

CREATE TEMPORARY MODEL general_model
INPUT (`input` STRING)
OUTPUT (`content` VARIANT)
WITH (
    'provider' = 'openai-compat',
    'endpoint'='<YOUR ENDPOINT>',
    'apiKey' = '<YOUR KEY>',
    'model' = 'qwen-plus'
);

CREATE TEMPORARY VIEW products(id, content)
AS VALUES (1,  '[Li-Ning Official Flagship Store] Way of Wade 10 Men''s Basketball Shoes, Performance Shoes, Shock Absorption and Rebound, Cloud V Technology, Black/Red Colorway'), (2, 'Apple iPhone 15 Pro Max 256GB Deep Space Black 5G Phone A17 Pro Chip Titanium Frame Official Genuine China Version');

-- Gunakan argumen posisional untuk memanggil AI_CLASSIFY
SELECT id, category, confidence FROM products, 
LATERAL TABLE(
  AI_CLASSIFY(
    MODEL general_model, content, ARRAY['Digital Product', 'Clothing Shoes Accessories']));

-- Gunakan argumen bernama untuk memanggil AI_CLASSIFY
SELECT id, category, confidence FROM products, 
LATERAL TABLE(
  AI_CLASSIFY(
    MODEL => MODEL general_model, 
    INPUT => content, 
    LABELS => ARRAY['Digital Product', 'Clothing Shoes Accessories']));    

Output

id

category

confidence

1

Clothing Shoes Accessories

0.95

2

Digital Product

0.99