텍스트 생성

Snowflake에서 시작하는 생성형 AI

James Cha-Earley

Senior Developer Advocate, Snowflake

호텔 리뷰 응답 관리

일몰의 해안가 호텔

1 Google Gemini 2.5 Pro로 생성된 이미지
Snowflake에서 시작하는 생성형 AI

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)
Snowflake에서 시작하는 생성형 AI

요약 출력하기

print(summarized_review)
The hotel exceeded expectations with stunning views, exceptional staff,
comfortable beds, and top-notch on-site dining, making it a perfect and 
highly recommended stay.
Snowflake에서 시작하는 생성형 AI

데이터베이스에서 추출하기

셀1의 SQL 쿼리

셀2의 Python 코드

Snowflake에서 시작하는 생성형 AI

답글 생성하기

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# 프롬프트 전달 response = complete(prompt=prompt,
Snowflake에서 시작하는 생성형 AI

답글 생성하기

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# 모델 지정 response = complete(prompt=prompt, model='llama3.1-8b',
Snowflake에서 시작하는 생성형 AI

답글 생성하기

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# temperature 설정 - 출력 예측 가능성 제어 response = complete(prompt=prompt, model='llama3.1-8b', options={ 'temperature':0.3,
Snowflake에서 시작하는 생성형 AI

답글 생성하기

from snowflake.cortex import complete


prompt = f"Write a short response to this hotel review: {latest_review}."
# max_tokens로 토큰 수 제한 response = complete(prompt=prompt, model='llama3.1-8b', options={ 'temperature':0.3, 'max_tokens':150 } )
Snowflake에서 시작하는 생성형 AI

응답 확인하기

print(response)
Thank you so much for sharing your wonderful experience at the Hyatt Nice! 
We're thrilled to hear that you had a fantastic stay with us.
  • 빠름, 유연함, 자연스러움
Snowflake에서 시작하는 생성형 AI

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;
Snowflake에서 시작하는 생성형 AI

Snowflake 노트북의 출력

Snowflake 노트북의 AI_COMPLETE() 출력

  • AI_COMPLETE()는 기본 제공됩니다
Snowflake에서 시작하는 생성형 AI

Snowflake에서 텍스트 생성

-- SQL 셀에서 코딩
AI_COMPLETE(
  'llama3.1-8b',
  PROMPT('Write a short response 
          to this hotel review: {0}.', 
          DESCRIPTION),
  {'temperature': 0.3, 
   'max_tokens': 150}
    )
  • 여러 행에 대해 일괄 생성
# 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}
    )
  • 다단계 워크플로우 연결에 활용
Snowflake에서 시작하는 생성형 AI

Ayo berlatih!

Snowflake에서 시작하는 생성형 AI

Preparing Video For Download...