PolarDB for AI mengintegrasikan model bahasa besar (LLM) Qwen ke dalam PolarDB for MySQL. Anda dapat menjalankan analisis sentimen, ringkasan teks, terjemahan, dan tugas chat langsung dari SQL pada data yang tersimpan di database Anda.
Sintaksis SQL
Semua model menggunakan awalan komentar /*polar4ai*/ untuk mengaktifkan PolarDB for AI dan fungsi PREDICT untuk mengarahkan kueri ke model tertentu.
/*polar4ai*/SELECT * FROM PREDICT (MODEL <model_name>, SELECT <column> FROM <table> [WHERE <kondisi>]) WITH ();Model yang tersedia
| Nama model | Tugas | Deskripsi |
|---|---|---|
_polar4ai_tongyi | Chat / completion | Menghasilkan tanggapan berdasarkan teks input. Mendukung data tabel maupun teks inline. |
_polar4ai_tongyi_sa | Analisis sentimen | Mengevaluasi nada emosional suatu kalimat. Mengembalikan label seperti Positive, Negative, atau Neutral. |
_polar4ai_tongyi_summarize | Ringkasan | Menghasilkan ringkasan singkat dari teks yang lebih panjang. |
_polar4ai_tongyi_tran_2_en | Terjemahan (ke Bahasa Inggris) | Menerjemahkan teks Bahasa Tionghoa ke Bahasa Inggris. |
_polar4ai_tongyi_tran_2_zh | Terjemahan (ke Bahasa Tionghoa) | Menerjemahkan teks dari bahasa tertentu seperti Bahasa Inggris ke Bahasa Tionghoa. |
_polar4ai_tongyi_p_comment | Pembuatan komentar positif | Menghasilkan komentar positif berdasarkan konten input. |
_polar4ai_tongyi_n_comment | Pembuatan komentar negatif | Menghasilkan komentar negatif berdasarkan konten input. |
Batasan
Inferensi online memproses satu entri data dalam satu waktu. Inferensi offline menangani beberapa entri data dalam batch.
Panjang input maksimum adalah 8.000 token. Jika model tidak dapat menghasilkan output dalam waktu 10 detik, tidak ada hasil yang dikembalikan. Tambahkan node AI untuk meningkatkan performa.
Prasyarat
Sebelum memulai, pastikan Anda telah:
Menambahkan node AI ke kluster PolarDB for MySQL Anda, dengan akun database yang dikonfigurasi untuk node tersebut. Untuk informasi selengkapnya, lihat Aktifkan fitur PolarDB for AI.
Jika Anda menambahkan node AI saat membeli kluster, konfigurasikan akun untuk node AI agar dapat terhubung langsung ke database.
Membuat koneksi ke kluster PolarDB melalui cluster endpoint. Untuk informasi selengkapnya, lihat Hubungkan ke kluster menggunakan Titik akhir kluster untuk menggunakan fitur PolarDB for AI.
Persiapkan data sampel
Contoh berikut menggunakan tabel textinfo. Buat tabel dan masukkan data sampel sebelum menjalankan kueri model.
Buat tabel bernama
textinfo.CREATE TABLE IF NOT EXISTS textinfo ( id INT NOT NULL, content TEXT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;Masukkan data sampel.
INSERT INTO textinfo (id, content) VALUES (1, "This product appears good but has poor performance. I do not recommend that you buy it."); INSERT INTO textinfo (id, content) VALUES (2, "The Mate 60 Pro, the latest mobile phone developed by Huawei, has been highly popular and in strong demand since its launch and is now out of stock. Guo Mingji, a well-known analyst, posted on Monday that he has significantly raised the shipment expectations for the Mate 60 Pro. He emphasized that the influence of Huawei on the technology industry and stock market is undeniable and the company is making a strong comeback."); INSERT INTO textinfo (id, content) VALUES (3, "In recent years, the Chinese film market has increasingly favored realistic themes. In 2018, Dying to Survive became the summer box office champion with 3.1 billion yuan in sales. Films including The White Storm 2: Drug Lords, Raging Fire, and Chinese Doctors also achieved significant success. This summer, realistic-themed movies such as Lost in the Stars, Never Say Never, and No More Bets gained immense popularity, which reflects the interest of the audience in close-to-life content."); INSERT INTO textinfo (id, content) VALUES (4, "Who are you?"); INSERT INTO textinfo (id, content) VALUES (5, "This item only looks decent; the actual experience is very poor. I do not recommend purchasing it.");
Analisis sentimen
Model analisis sentimen mengevaluasi nada emosional atau sikap yang diekspresikan dalam suatu kalimat. Kasus penggunaan umum mencakup analisis ulasan e-commerce, deteksi bias dalam pelaporan berita, dan pemantauan opini publik.
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_sa, SELECT content FROM textinfo WHERE id = 1) WITH ();Contoh output:
NegativeHasilkan komentar positif dan negatif
Model pembuatan ulasan menghasilkan ulasan positif atau negatif berdasarkan konten input.
Hasilkan ulasan positif:
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_p_comment, SELECT content FROM textinfo WHERE id = 2) WITH ();Contoh output:
The Huawei Mate 60 Pro has been selling extremely well since its launch, which demonstrates strong consumer recognition and support for the Huawei brand. As a well-known technology company in China, Huawei has always attracted significant attention in the smartphone market. The post of Guo Mingji further confirms the influence of Huawei in the technology industry and stock market, which indicates that Huawei is gradually regaining its prominent position in these areas. The influence of Huawei extends beyond product sales. Huawei also plays a key role in driving advancements in the broader technology sector and influencing the stock market. We must encourage and support excellent enterprises like Huawei to promote the sustained development of the science and technology industry in China.Hasilkan ulasan negatif:
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_n_comment, SELECT content FROM textinfo WHERE id = 2) WITH ();Contoh output:
The strong sales performance of the Huawei Mate 60 Pro has come as a surprise, but it also reflects that consumer recognition and support for the Huawei brand remain high. However, this success may also be related to the current instability in the global technology market. As a Chinese company, Huawei has faced significant political and economic pressures in international markets, which may potentially impact its sales performance in the long term. In addition, the comments of Guo Mingji, a well-known analyst, may be overly optimistic and ignore the challenges and difficulties that Huawei faces. In conclusion, although the influence of Huawei is returning, the future market performance of the brand requires a more thorough analysis.Ringkas teks
Model ringkasan menghasilkan ringkasan singkat untuk teks yang lebih panjang.
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_summarize, SELECT content FROM textinfo WHERE id = 3) WITH ();Contoh output:
In recent years, the Chinese film market has increasingly favored realistic themes. In 2018, Dying to Survive became the summer box office champion with 3.1 billion yuan in sales. Films including The White Storm 2: Drug Lords, Raging Fire, and Chinese Doctors also succeeded. This summer, realistic-themed movies such as Lost in the Stars, Never Say Never, and No More Bets gained immense popularity, which reflects the interest of the audience in content close to life.Terjemahkan teks
Terjemahkan teks Bahasa Tionghoa ke Bahasa Inggris:
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_tran_2_en, SELECT content FROM textinfo WHERE id = 1) WITH ();Contoh output:
This product appears good but has poor performance. I do not recommend that you buy it.Terjemahkan teks Bahasa Inggris ke Bahasa Tionghoa:
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_tran_2_zh, SELECT content FROM textinfo WHERE id = 5) WITH ();Contoh output:
这件商品看起来还不错,实际体验却很差。 我不推荐购买。Chat dengan model
Model chat menghasilkan tanggapan berdasarkan teks input. Model ini menerima data kolom tabel maupun teks biasa inline.
Kueri dari tabel:
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi, SELECT content FROM textinfo WHERE id = 4) WITH ();Contoh output:
I am a large language model of Alibaba Cloud. You can call me Qwen.Kueri dengan teks inline:
/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi, SELECT 'Who are you?') WITH ();Contoh output:
I am a large language model of Alibaba Cloud. You can call me Qwen.