मल्टी-स्टेप AI वर्कफ़्लो डिज़ाइन करना

Snowflake में Generative AI परिचय

James Cha-Earley

Senior Developer Advocate, Snowflake

Cortex समीक्षा वर्कफ़्लो

लक्ष्य: अंतरराष्ट्रीय गेस्ट फ़ीडबैक के लिए एक ऑटोमेटेड सिस्टम बनाना

$$

  • हर समीक्षा को English में ट्रांसलेट करें
  • मुख्य बिंदु का सार लिखें
  • सही टीम को रूटिंग के लिए कैटेगराइज़ करें
  • एक जवाब जनरेट करें
  • उसे मूल भाषा में वापस ट्रांसलेट करें

वर्कफ़्लो जहाँ समीक्षा प्राप्त होती है, ट्रांसलेट, समराइज़ और कैटेगराइज़ होती है, और एक जवाब भेजा जाता है

Snowflake में Generative AI परिचय

समीक्षाएँ निकालना

-- SQL cell
SELECT DESCRIPTION
FROM HOTELS.REVIEWS
WHERE LANGUAGE = 'es'
LIMIT 1;
# Python cell
df = cell1.to_pandas()
review_text = df["DECRIPTION"].iloc[0]
Snowflake में Generative AI परिचय

Spanish समीक्षा

print(review_text)
Buen hotel y bien situado pero desafortunadamente no me toco buena suerte con 
el servicio; el aire no servía; pedí la cama extra tres veces; la cafetera estaba
dañada; y me sacaron las maletas fuera porque argumentaron que no hice Check out;
siendo que era un día despues; pero su sistema lo marco antes; una total
descortesía hecharme del cuarto y cancelar mis llaves; regresar de caminar y darse
cuenta que han tomado tus cosas fuera es increíble y mas aun sin ninguna disculpa;
yo no volvería ahí aunque la vrd el hotel es bueno y su jubilación el trato
me decepciono
Snowflake में Generative AI परिचय

अनुवाद

translated = translate(
    text=review_text,
    from_language="es",
    to_language="en"
)

print(translated)
Good hotel and well located, but unfortunately, I didn't have good luck with the service; the air
conditioning didn't work; I asked for the extra bed three times; the coffee maker was broken; 
and they took my bags out because they argued that I hadn't checked out; even though it was a day
later; but their system marked it as checked out; a total discourtesy to throw me out of the room
and cancel my keys; returning from a walk and realizing they've taken your things out is
incredible and even more so without any apology; I wouldn't go back there even though the hotel
itself is good and their retirement the treatment disappoints me.
Snowflake में Generative AI परिचय

सारांश

summary = summarize(text=translated)

print(summary)
The hotel was well-located, but the service was disappointing. The air conditioning
didn't work, an extra bed was not provided despite multiple requests, and the coffee
maker was broken. The hotel staff took the complainant's bags and canceled their
keys despite a later checkout date, which was discourteous and left the complainant
feeling disappointed.
Snowflake में Generative AI परिचय

वर्गीकरण

topic = classify_text(
    text=summary,
    labels=["staff", "cleanliness", "pricing", "room", "food"]
)

print(topic)
{
  "label": "staff"
}
Snowflake में Generative AI परिचय

टेक्स्ट जनरेशन

response = complete(
        prompt=f"Write a brief and professional response to this review: {summary}",
        model='llama3.1-8b',
        options={'temperature':0.3, 'max_tokens':120})

print(response)
Thank you for sharing your feedback. While we're glad you found the location
convenient, we're truly sorry to hear about the service issues you experienced.
We understand how frustrating it must have been to face multiple inconveniences
during your stay. Your comments have been shared with the team to ensure these concerns
are addressed and do not recur.
Snowflake में Generative AI परिचय

जवाब का अनुवाद

translated_response = translate(
    text=response,
    from_language="en",
    to_language="es"
)

print(translated_response)
Gracias por compartir sus comentarios. Si bien nos alegra saber que encontró conveniente
la ubicación, lamentamos sinceramente los inconvenientes que experimentó con el servicio.
Entendemos lo frustrante que debió haber sido enfrentar múltiples inconvenientes durante
su estadía. Sus comentarios han sido compartidos con el equipo para asegurarnos de que
estas situaciones se aborden y no vuelvan a ocurrir.
Snowflake में Generative AI परिचय

Cortex कॉस्ट मॉडल

एक cortex वर्कफ़्लो जो दिखाता है कि इनपुट टोकन, compute, और आउटपुट टोकन सभी की लागत होती है

1 Image generated by ChatGPT-4o
Snowflake में Generative AI परिचय

लागत सीमित करना

$$

  • इनपुट ट्रिम करें, केवल प्रासंगिक टेक्स्ट प्रोसेस करें

  • आउटपुट आकार सीमित करें

  • टेम्परेचर घटाएँ

# complete की लागत सीमित करें
complete(prompt=prompt, 
         model='llama3.1-8b', 
         options={
            'max_tokens':120,

'temperature':0})
Snowflake में Generative AI परिचय

Cortex सर्वोत्तम प्रथाएँ

  • मॉडल्स को प्रभावी रूप से चेन करें
# कई डाउनस्ट्रीम फ़ंक्शंस कॉल हों तो पहले समराइज़ करें
summarize()
text_classify()
complete()
translate()
  • लॉगिंग
  • कैशिंग
  • बैच पाइपलाइंस
Snowflake में Generative AI परिचय

अभ्यास करते हैं!

Snowflake में Generative AI परिचय

Preparing Video For Download...