Loading Academy Hub...
Integrate foundation generative AI models into Snowflake data pipelines: Snowflake Cortex AI in-database functions (`COMPLETE`, `EMBED_TEXT_768`), Cortex Search service, and semantic search queries.
[!NOTE] Snowflake Cortex AI provides fully managed, secure AI capabilities directly inside Snowflake's security perimeter. Engineers execute LLM completions, translations, and vector embedding generation natively in SQL without moving data outside Snowflake.
SNOWFLAKE.CORTEX.COMPLETE(): Calls leading foundation models (Mistral, Llama 3, Claude 3.5 Sonnet) directly inside SQL statements.SNOWFLAKE.CORTEX.EMBED_TEXT_768(): Generates 768-dimensional dense vector embeddings from text columns.Cortex LLM Functions): Execute SNOWFLAKE.CORTEX.COMPLETE(), SUMMARIZE(), SENTIMENT(), and EMBED_TEXT_768() / 1024() directly inside governed SQL/Dynamic Tables—customer sensitive data never leaves your Snowflake security boundary to unapproved public endpoints.Managed Hybrid RAG): Point a Cortex Search Service at any chunked Silver/Gold table and get automatic incremental embeddings + hybrid vector + keyword search + semantic reranking exposed as a low-latency API for Streamlit / LangGraph / Cortex Analyst agents with RBAC honored automatically.SPCS): Deploy custom GPU vLLM models, PyTorch inference microservices, or custom FastAPI/Streamlit apps inside managed OCI containers right next to your Snowflake tables without shipping petabytes out over public internet.Review the production code, company interview Q&As, incident traces, and comprehension quiz inside this lesson.
-- 1. In-database LLM Sentiment Extraction
SELECT
review_id,
customer_text,
SNOWFLAKE.CORTEX.COMPLETE(
'llama3.1-70b',
CONCAT('Extract sentiment (POSITIVE/NEGATIVE/NEUTRAL) and return ONLY the label: ', customer_text)
) AS sentiment_label
FROM lakehouse_dw.marketing.customer_reviews
LIMIT 10;
-- 2. Generate Dense Vector Embeddings for Semantic RAG Search
CREATE OR REPLACE TABLE lakehouse_dw.marketing.review_vectors AS
SELECT
review_id,
customer_text,
SNOWFLAKE.CORTEX.EMBED_TEXT_768('snowflake-arctic-embed-m', customer_text) AS text_vector
FROM lakehouse_dw.marketing.customer_reviews;SQL execution error: The query was terminated because the account exceeded the Cortex LLM token consumption quota.