Giới thiệu về Generative AI trong Snowflake
James Cha-Earley
Senior Developer Advocate, Snowflake

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)
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ị.


from snowflake.cortex import completeprompt = f"Write a short response to this hotel review: {latest_review}."# Truyền prompt response = complete(prompt=prompt,
from snowflake.cortex import completeprompt = f"Write a short response to this hotel review: {latest_review}."# Chỉ định mô hình response = complete(prompt=prompt, model='llama3.1-8b',
from snowflake.cortex import completeprompt = 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,
from snowflake.cortex import completeprompt = 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 } )
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.
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;

AI_COMPLETE() có sẵn ngay-- 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}
)
# 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}
)
Giới thiệu về Generative AI trong Snowflake