Introduction à l'IA générative dans 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)
L'hôtel a dépassé les attentes grâce à des vues superbes, un personnel exceptionnel,
des lits confortables et d'excellents restaurants sur place, pour un séjour parfait
hautement recommandé.


from snowflake.cortex import completeprompt = f"Write a short response to this hotel review: {latest_review}."# Pass the prompt response = complete(prompt=prompt,
from snowflake.cortex import completeprompt = f"Write a short response to this hotel review: {latest_review}."# Spécifier le modèle response = complete(prompt=prompt, model='llama3.1-8b',
from snowflake.cortex import completeprompt = f"Write a short response to this hotel review: {latest_review}."# Régler la température – contrôle la prévisibilité de la sortie 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}."# Limiter le nombre de jetons avec max_tokens response = complete(prompt=prompt, model='llama3.1-8b', options={ 'temperature':0.3, 'max_tokens':150 } )
print(response)
Merci beaucoup d'avoir partagé votre superbe expérience au Hyatt Nice !
Nous sommes ravis d'apprendre que votre séjour s'est très bien déroulé.
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() est prêt à l'emploi-- Coder dans des cellules SQL
AI_COMPLETE(
'llama3.1-8b',
PROMPT('Write a short response
to this hotel review: {0}.',
DESCRIPTION),
{'temperature': 0.3,
'max_tokens': 150}
)
# Coder dans des cellules 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}
)
Introduction à l'IA générative dans Snowflake