Tạo văn bản

Giới thiệu về Generative AI trong Snowflake

James Cha-Earley

Senior Developer Advocate, Snowflake

Quản lý phản hồi đánh giá khách sạn

Khách sạn ven biển lúc hoàng hôn

1 Hình ảnh được tạo bằng Google Gemini 2.5 Pro
Giới thiệu về Generative AI trong Snowflake

summarize()

long_review = """
This hotel was nothing short of amazing. The best views; the best location;
and the best staff. It's clean; conveniently located to other restaurants
on the strip; although we ate at the restaurants on site and each was so good
there's really no reason to leave. Ohhh the views. The beach was free of seaweed; 
amazingly clean and plenty of space; it wasn't crowded at all. 
Stay here; you will not regret it. Did I mention how comfortable the beds were. 
Yes save yourself trouble and stay here. It's really perfect.
"""

from snowflake.cortex import summarize summarized_review = summarize(text=long_review)
Giới thiệu về Generative AI trong Snowflake

In bản tóm tắt

print(summarized_review)
Khách sạn vượt mong đợi với tầm nhìn đẹp, nhân viên xuất sắc,
Giường thoải mái và ẩm thực tại chỗ tuyệt hảo, là kỳ nghỉ hoàn hảo
và rất đáng khuyến nghị.
Giới thiệu về Generative AI trong Snowflake

Trích xuất từ cơ sở dữ liệu

Truy vấn SQL trong ô 1

Mã Python trong ô 2

Giới thiệu về Generative AI trong Snowflake

Tạo phản hồi

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# Truyền prompt response = complete(prompt=prompt,
Giới thiệu về Generative AI trong Snowflake

Tạo phản hồi

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# Chỉ định mô hình response = complete(prompt=prompt, model='llama3.1-8b',
Giới thiệu về Generative AI trong Snowflake

Tạo phản hồi

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# Đặt temperature - kiểm soát tính dự đoán của đầu ra response = complete(prompt=prompt, model='llama3.1-8b', options={ 'temperature':0.3,
Giới thiệu về Generative AI trong Snowflake

Tạo phản hồi

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# Giới hạn số token với max_tokens response = complete(prompt=prompt, model='llama3.1-8b', options={ 'temperature':0.3, 'max_tokens':150 } )
Giới thiệu về Generative AI trong Snowflake

Xem phản hồi

print(response)
Cảm ơn bạn đã chia sẻ trải nghiệm tuyệt vời tại Hyatt Nice!
Chúng tôi rất vui khi biết bạn đã có kỳ nghỉ tuyệt vời cùng chúng tôi.
  • Nhanh, linh hoạt, tự nhiên
Giới thiệu về Generative AI trong Snowflake

Tạo văn bản với AI_COMPLETE()

SELECT
  DESCRIPTION,
  AI_COMPLETE(

'llama3.1-8b',
PROMPT('Write a short response to this hotel review: {0}.', DESCRIPTION),
{'temperature': 0.3, 'max_tokens': 150}
) AS completion FROM HOTELS.REVIEWS ORDER BY date DESC LIMIT 1;
Giới thiệu về Generative AI trong Snowflake

Đầu ra trong sổ tay Snowflake

Đầu ra AI_COMPLETE() trong sổ tay Snowflake

  • AI_COMPLETE() có sẵn ngay
Giới thiệu về Generative AI trong Snowflake

Tạo văn bản trong Snowflake

-- Viết mã trong ô SQL
AI_COMPLETE(
  'llama3.1-8b',
  PROMPT('Write a short response 
          to this hotel review: {0}.', 
          DESCRIPTION),
  {'temperature': 0.3, 
   'max_tokens': 150}
    )
  • Tạo văn bản cho nhiều hàng
# Viết mã trong ô Python
complete(
    model='llama3.1-8b', 
    prompt = f"""Write a short response
        to this hotel review: 
        {latest_review}.""",
    options={'temperature':0.3,
             'max_tokens':150}
    )
  • Dùng để xâu chuỗi quy trình nhiều bước
Giới thiệu về Generative AI trong Snowflake

Ayo berlatih!

Giới thiệu về Generative AI trong Snowflake

Preparing Video For Download...