All Products
Search
Document Center

Realtime Compute for Apache Flink:Anotasi teks cerdas berbasis AI dengan YAML CDC

Last Updated:Aug 15, 2026

Topik ini menjelaskan cara menggunakan pekerjaan YAML Flink CDC bersama Fungsi AI untuk melakukan anotasi teks cerdas secara real-time selama ingesti data ke dalam data lake.

Arsitektur solusi

Perusahaan menghasilkan volume besar data teks tidak terstruktur setiap hari, seperti tiket layanan pelanggan, ulasan pengguna, dan catatan keluhan. Pendekatan tradisional mengandalkan anotasi manual atau pemrosesan batch offline T+1, yang mahal, lambat, dan tidak konsisten.

Dengan memanggil Fungsi AI di modul Transform pekerjaan YAML CDC, data dianotasi secara real-time saat mengalir dari Kafka ke data lake Paimon, mencapai anotasi streaming dalam waktu kurang dari satu detik.

Solusi ini mencakup skenario-skenario khas berikut:

  • Anotasi risiko keluhan pelanggan: Menggunakan AI_COMPLETE untuk menilai tingkat keparahan keluhan, mendeteksi niat eksposur, dan melakukan anotasi risiko multidimensi pada tiket layanan pelanggan.

  • Anotasi klasifikasi konten: Menggunakan AI_CLASSIFY untuk secara otomatis mengklasifikasikan ulasan atau umpan balik pengguna ke dalam kategori yang telah ditentukan.

  • Penyembunyian informasi sensitif: Menggunakan AI_MASK untuk mengidentifikasi dan menyembunyikan informasi identitas pribadi (PII) dalam data sebelum masuk ke data lake.

Prasyarat

  • Realtime Compute for Apache Flink telah diaktifkan dan ruang kerja telah dibuat. Untuk informasi selengkapnya, lihat Aktifkan Realtime Compute for Apache Flink.

  • Flink AI Service (model bawaan) telah diaktifkan.

  • Hanya mesin Realtime Compute versi VVR 11.9 (termasuk edisi pratinjau) dan yang lebih baru yang didukung.

  • Instans Kafka telah dibuat, dan topik berisi data teks untuk anotasi telah disiapkan.

Batasan

  • Fungsi AI hanya dapat digunakan dalam ekspresi projection modul Transform pada pekerjaan YAML CDC.

  • Throughput Fungsi AI tunduk pada pembatasan laju Alibaba Cloud Model Studio. Saat batas laju tercapai, pekerjaan Flink mungkin mengalami tekanan balik atau restart akibat timeout. Untuk informasi selengkapnya, lihat Rate limiting.

Model bawaan Model Studio berikut didukung pada versi saat ini:

Model

Deskripsi

qwen3.6-flash

Generasi teks umum, direkomendasikan untuk skenario anotasi

qwen3.6-plus

Kemampuan penalaran lebih kuat

qwen3.5-flash

Generasi teks umum

qwen3.5-plus

Kemampuan penalaran lebih kuat

text-embedding-v4

Vektorisasi teks

Referensi Fungsi AI

Modul Transform YAML CDC mendukung Fungsi AI berikut.

Fungsi

Tanda tangan

Bidang hasil

Deskripsi

AI_COMPLETE

AI_COMPLETE('modelName', input, systemPrompt)

result

Generasi teks umum

AI_CLASSIFY

AI_CLASSIFY('modelName', input, labels)

category, confidence

Klasifikasi teks

AI_TRANSLATE

AI_TRANSLATE('modelName', input, sourceLang, targetLang)

translated_text, detected_language

Terjemahan teks

AI_SUMMARIZE

AI_SUMMARIZE('modelName', input, maxLength)

summary

Ringkasan teks

AI_SENTIMENT

AI_SENTIMENT('modelName', input)

score, label, confidence

Analisis sentimen

AI_EXTRACT

AI_EXTRACT('modelName', input, schema)

extracted_json

Ekstraksi informasi terstruktur

AI_MASK

AI_MASK('modelName', input, entities)

masked_text, detected_entities

Penyembunyian informasi sensitif

Gunakan ['field_name'] untuk mengakses bidang hasil dalam ekspresi projection. Contohnya: AI_COMPLETE('mymodel', content, '')['result'].

Skenario 1: Anotasi risiko keluhan pelanggan

Gunakan AI_COMPLETE untuk melakukan anotasi risiko multidimensi pada teks tiket layanan pelanggan, termasuk tingkat keparahan keluhan, niat eksposur, dan kecenderungan pencemaran nama baik merek.

Contoh pekerjaan

Catatan

File dependensi dan konfigurasi tambahan diperlukan untuk penerapan. Untuk informasi selengkapnya, lihat Penerapan dan startup.

source:
  type: kafka
  name: Kafka Source
  properties.bootstrap.servers: <YOUR-KAFKA-BROKER>:9092
  topic: customer_complaints
  value.format: json
  scan.startup.mode: earliest-offset

# Output test results to console logs
sink:
  type: values

# sink:
#  type: paimon
#  catalog.properties.metastore: rest
#  catalog.properties.uri: <YOUR-DLF-ENDPOINT>
#  catalog.properties.warehouse: <YOUR-CATALOG-NAME>
#  catalog.properties.token.provider: dlf
#  table.properties.deletion-vectors.enabled: true

transform:
  - source-table: customer_complaints
    projection: >
      comment,
      AI_COMPLETE('mymodel', comment, '')['result'] as risk_label

pipeline:
  parallelism: 2
  model:
  - name: mymodel
    type: openai-compatible
    model-name: qwen3.6-flash
    system-prompt: 'Prompt:
      #You are an e-commerce customer complaint risk assessment expert. Perform objective annotation based on user review content.
      #Annotation rules
      1. Complaint severity level (choose one): Normal / Dissatisfied / Angry
      2. Explicit exposure intent (yes/no): Yes / No
      3. Brand defamation tendency (yes/no): Yes / No
      #Output (strictly follow this structure, one item per line)
      Complaint severity: xxx
      Explicit exposure intent: xxx
      Brand defamation tendency: xxx
      Confidence: 0.xx
      Annotation basis: xxx
      '

Contoh input dan output

Data input (format JSON):

{
    "comment": "It broke less than a month after purchase, customer service kept telling me to wait, waited two weeks with no response. If this isn't resolved, I'll post it online to expose you."
}    

Data output:

DataChangeEvent{
  tableId=customer_complaints,
  after=[
    The customer called to report that an air conditioner purchased in March 2024...,
    "Complaint severity: Angry
     Explicit exposure intent: Yes
     Brand defamation tendency: Yes
     Confidence: 0.95
     Annotation basis: If this isn't resolved, I'll post it online to expose you."
  ],
  op=INSERT, meta=()
}       
Catatan

Tipe data bidang output Fungsi AI adalah VARIANT, yang memudahkan akses konten terstruktur dalam format JSON. Jika konsumen downstream memerlukan tipe tertentu (seperti STRING atau INT), gunakan CAST untuk konversi eksplisit, misalnya CAST(risk_label AS STRING).

Skenario 2: Anotasi klasifikasi konten

Gunakan AI_CLASSIFY untuk secara otomatis mengklasifikasikan teks ulasan atau umpan balik pengguna ke dalam kategori yang telah ditentukan.

Contoh pekerjaan

Catatan

File dependensi dan konfigurasi tambahan diperlukan untuk penerapan. Untuk informasi selengkapnya, lihat Penerapan dan startup.

source:
  type: kafka
  name: Kafka Source
  properties.bootstrap.servers: <YOUR-KAFKA-BROKER>:9092
  topic: user_reviews
  value.format: json
  scan.startup.mode: earliest-offset

# Output test results to console logs
sink:
  type: values

# sink:
#  type: paimon
#  catalog.properties.metastore: rest
#  catalog.properties.uri: <YOUR-DLF-ENDPOINT>
#  catalog.properties.warehouse: <YOUR-CATALOG-NAME>
#  catalog.properties.token.provider: dlf
#  table.properties.deletion-vectors.enabled: true

transform:
  - source-table: user_reviews
    projection: >
      content,
      AI_CLASSIFY('mymodel', content, 'ARRAY[''Product quality'',''After-sales service'',''Logistics issues'',''Price disputes'']')['category'] as category,
      AI_CLASSIFY('mymodel', content, 'ARRAY[''Product quality'',''After-sales service'',''Logistics issues'',''Price disputes'']')['confidence'] as confidence

pipeline:
  parallelism: 2
  model:
  - name: mymodel
    type: openai-compatible
    model-name: qwen3.6-flash         

Contoh input dan output

Data input:

{"content": "The air conditioner is way too noisy. It buzzes as soon as it turns on, making it impossible to sleep."}       

Data output:

DataChangeEvent{
  tableId=user_reviews,
  before=[],
  after=[The air conditioner is way too noisy. It buzzes as soon as it turns on, making it impossible to sleep., "Product quality", 0.95],
  op=INSERT, meta=()
}

Skenario 3: Penyembunyian informasi sensitif

Gunakan AI_MASK untuk secara otomatis mengidentifikasi dan menyembunyikan informasi identitas pribadi (nama, nomor telepon, dan alamat) dalam data yang masuk ke data lake.

Contoh pekerjaan

Catatan

File dependensi dan konfigurasi tambahan diperlukan untuk penerapan. Untuk informasi selengkapnya, lihat Penerapan dan startup.

source:
  type: kafka
  name: Kafka Source
  properties.bootstrap.servers: <YOUR-KAFKA-BROKER>:9092
  topic: user_feedbacks
  value.format: json
  scan.startup.mode: earliest-offset

# Output test results to console logs
sink:
  type: values

# sink:
#  type: paimon
#  catalog.properties.metastore: rest
#  catalog.properties.uri: <YOUR-DLF-ENDPOINT>
#  catalog.properties.warehouse: <YOUR-CATALOG-NAME>
#  catalog.properties.token.provider: dlf
#  table.properties.deletion-vectors.enabled: true

transform:
  - source-table: user_feedbacks
    projection: >
      AI_MASK('mymodel', content, 'ARRAY[''name'',''phone number'',''ID number'',''address'']')['masked_text'] as masked_content,
      AI_MASK('mymodel', content, 'ARRAY[''name'',''phone number'',''ID number'',''address'']')['detected_entities'] as detected_entities

pipeline:
  parallelism: 2
  model:
  - name: mymodel
    type: openai-compatible
    model-name: qwen3.6-flash

Contoh input dan output

Data input:

{"content": "Customer Zhang San, phone number 13812345678, address 88 Jianguo Road, Chaoyang District, Beijing, reported that the refrigerator is not cooling."}         

Data output:

DataChangeEvent{
  tableId=user_feedbacks,
  before=[],
  after=["Customer Zhang*, phone number 138****5678, address Chaoyang District, Beijing **, reported that the refrigerator is not cooling.", [
  {"type":"name","value":"Zhang San"},
  {"type":"phone number","value":"13812345678"},
  {"type":"address","value":"88 Jianguo Road, Chaoyang District, Beijing"}
  ]],
  op=INSERT, meta=()
}

Penyebaran dan Permulaan

  1. Masuk ke Konsol Realtime Compute. Buat pekerjaan ingesti data YAML CDC dan tempel konfigurasi YAML untuk skenario Anda ke dalam editor. Untuk informasi selengkapnya, lihat Mengembangkan pekerjaan ingesti data Flink CDC.

  2. Unggah file dependensi tambahan. Di bagian Additional Dependencies draft pekerjaan, unggah paket JAR berikut:

    flink-cdc-pipeline-model-openai-compatible

  3. Lakukan penerapan dan mulai pekerjaan.

Pemantauan dan pembatasan laju

Pada versi saat ini, Anda dapat memantau penggunaan token Fungsi AI melalui Flink Web UI. Di Flink Dashboard, klik pekerjaan target dan pilih tab Metrics. Di daftar drop-down Add Metric, pilih metrik operator target (misalnya, ai_model_completion_tokens) untuk melihat nilai metrik saat ini.