Tag: cortex

  • AI Data Agent Guide 2025: Snowflake Cortex Tutorial

    AI Data Agent Guide 2025: Snowflake Cortex Tutorial

    The world of data analytics is changing. For years, accessing insights required writing complex SQL queries. However, the industry is now shifting towards a more intuitive, conversational approach. At the forefront of this revolution is agentic AI—intelligent systems that can understand human language, reason, plan, and automate complex tasks.

    Snowflake is leading this charge by transforming its platform into an intelligent and conversational AI Data Cloud. With the recent introduction of Snowflake Cortex Agents, they have provided a powerful tool for developers and data teams to build their own custom AI assistants.

    This guide will walk you through, step-by-step, how to build your very first AI data agent. You will learn how to create an agent that can answer complex questions by pulling information from both your database tables and your unstructured documents, all using simple, natural language.

    What is a Snowflake Cortex Agent and Why Does it Matter?

    First and foremost, a Snowflake Cortex Agent is an AI-powered assistant that you can build on top of your own data. Think of it as a chatbot that has expert knowledge of your business. It understands your data landscape and can perform complex analytical tasks based on simple, conversational prompts.

    This is a game-changer for several reasons:

    • It Democratizes Data: Business users no longer need to know SQL. Instead, they can ask questions like, “What were our top-selling products in the last quarter?” and get immediate, accurate answers.
    • It Automates Analysis: Consequently, data teams are freed from writing repetitive, ad-hoc queries. They can now focus on more strategic initiatives while the agent handles routine data exploration.
    • It Provides Unified Insights: Most importantly, a Cortex Agent can synthesize information from multiple sources. It can query your structured sales data from a table and cross-reference it with strategic goals mentioned in a PDF document, all in a single response.

    The Blueprint: How a Cortex Agent Works

    Under the hood, a Cortex Agent uses a simple yet powerful workflow to answer your questions. It orchestrates several of Snowflake’s Cortex AI features to deliver a comprehensive answer.

    Whiteboard-style flowchart showing how a Snowflake Cortex Agent works by using Cortex Analyst for SQL and Cortex Search for documents to provide an answer.
    1. Planning: The agent first analyzes your natural language question to understand your intent. It figures out what information you need and where it might be located.
    2. Tool Use: Next, it intelligently chooses the right tool for the job. If it needs to query structured data, it uses Cortex Analyst to generate and run SQL. If it needs to find information in your documents, it uses Cortex Search.
    3. Reflection: Finally, after gathering the data, the agent evaluates the results. It might ask for clarification, refine its approach, or synthesize the information into a clear, concise answer before presenting it to you.

    Step-by-Step Tutorial: Building a Sales Analysis Agent

    Now, let’s get hands-on. We will build a simple yet powerful sales analysis agent. This agent will be able to answer questions about sales figures from a table and also reference goals from a quarterly business review (QBR) document.

    Hand-drawn illustration of preparing data for Snowflake, showing a database and a document being placed into a container with the Snowflake logo.

    Prerequisites

    • A Snowflake account with ACCOUNTADMIN privileges.
    • A warehouse to run the queries.

    Step 1: Prepare Your Data

    First, we need some data to work with. Let’s create two simple tables for sales and products, and then upload a sample PDF document.

    Run the following SQL in a Snowflake worksheet:

    -- Create our database and schema
    CREATE DATABASE IF NOT EXISTS AGENT_DEMO;
    CREATE SCHEMA IF NOT EXISTS AGENT_DEMO.SALES;
    USE SCHEMA AGENT_DEMO.SALES;
    
    -- Create a products table
    CREATE OR REPLACE TABLE PRODUCTS (
        product_id INT,
        product_name VARCHAR,
        category VARCHAR
    );
    
    INSERT INTO PRODUCTS (product_id, product_name, category) VALUES
    (101, 'Quantum Laptop', 'Electronics'),
    (102, 'Nebula Smartphone', 'Electronics'),
    (103, 'Stardust Keyboard', 'Accessories');
    
    -- Create a sales table
    CREATE OR REPLACE TABLE SALES (
        sale_id INT,
        product_id INT,
        sale_date DATE,
        sale_amount DECIMAL(10, 2)
    );
    
    INSERT INTO SALES (sale_id, product_id, sale_date, sale_amount) VALUES
    (1, 101, '2025-09-01', 1200.00),
    (2, 102, '2025-09-05', 800.00),
    (3, 101, '2025-09-15', 1250.00),
    (4, 103, '2025-09-20', 150.00);
    
    -- Create a stage for our unstructured documents
    CREATE OR REPLACE STAGE qbr_documents;

    Now, create a simple text file named QBR_Report_Q3.txt on your local machine with the following content and upload it to the qbr_documents stage using the Snowsight UI.

    Quarterly Business Review – Q3 2025 Summary

    Our primary strategic goal for Q3 was to drive the adoption of our new flagship product, the ‘Quantum Laptop’. We aimed for a sales target of over $2,000 for this product. Secondary goals included expanding our market share in the accessories category.

    Step 2: Create the Semantic Model

    Next, we need to teach the agent about our structured data. We do this by creating a Semantic Model. This is a YAML file that defines our tables, columns, and how they relate to each other.

    # semantic_model.yaml
    model:
      name: sales_insights_model
      tables:
        - name: SALES
          columns:
            - name: sale_id
              type: INT
            - name: product_id
              type: INT
            - name: sale_date
              type: DATE
            - name: sale_amount
              type: DECIMAL
        - name: PRODUCTS
          columns:
            - name: product_id
              type: INT
            - name: product_name
              type: VARCHAR
            - name: category
              type: VARCHAR
      joins:
        - from: SALES
          to: PRODUCTS
          on: SALES.product_id = PRODUCTS.product_id

    Save this as semantic_model.yaml and upload it to the @qbr_documents stage.

    Step 3: Create the Cortex Search Service

    Now, let’s make our PDF document searchable. We create a Cortex Search Service on the stage where we uploaded our file.

    CREATE OR REPLACE CORTEX SEARCH SERVICE sales_qbr_service
        ON @qbr_documents
        TARGET_LAG = '0 seconds'
        WAREHOUSE = 'COMPUTE_WH';

    Step 4: Combine Them into a Cortex Agent

    With all the pieces in place, we can now create our agent. This single SQL statement brings together our semantic model (for SQL queries) and our search service (for document queries).

    CREATE OR REPLACE CORTEX AGENT sales_agent
        MODEL = 'mistral-large',
        CORTEX_SEARCH_SERVICES = [sales_qbr_service],
        SEMANTIC_MODELS = ['@qbr_documents/semantic_model.yaml'];

    Step 5: Ask Your Agent Questions!

    The agent is now ready! You can interact with it using the CALL command. Let’s try a few questions.

    A hand-drawn sketch of a computer screen showing a user asking questions to a Snowflake Cortex Agent and receiving instant, insightful answers.

    First up: A simple structured data query.

    CALL sales_agent('What were our total sales?');

    Next: A more complex query involving joins.

    CALL sales_agent('Which product had the highest revenue?');

    Then comes: A question for our unstructured document.

    CALL sales_agent('Summarize our strategic goals from the latest QBR report.');
    

    Finally , the magic: The magic! A question that combines both.

    CALL sales_agent('Did we meet our sales target for the Quantum Laptop as mentioned in the QBR?');

    This final query demonstrates the true power of a Snowflake Cortex Agent. It will first query the SALES and PRODUCTS tables to calculate the total sales for the “Quantum Laptop.” Then, it will use Cortex Search to find the sales target mentioned in the QBR document. Finally, it will compare the two and give you a complete, synthesized answer.

    Conclusion: The Future is Conversational

    You have just built a powerful AI data agent in a matter of minutes. This is a fundamental shift in how we interact with data. By combining natural language processing with the power to query both structured and unstructured data, Snowflake Cortex Agents are paving the way for a future where data-driven insights are accessible to everyone in an organization.

    As Snowflake continues to innovate with features like Adaptive Compute and Gen-2 Warehouses, running these AI workloads will only become faster and more efficient. The era of conversational analytics has arrived, and it’s built on the Snowflake AI Data Cloud.


    Additional materials

  • Revolutionizing Finance: A Deep Dive into Snowflake’s Cortex AI

    Revolutionizing Finance: A Deep Dive into Snowflake’s Cortex AI

    The financial services industry is in the midst of a technological revolution. At the heart of this change lies Artificial Intelligence. Consequently, financial institutions are constantly seeking new ways to innovate and enhance security. They also want to deliver personalized customer experiences. However, they face a significant hurdle: navigating fragmented data while adhering to strict compliance and governance requirements. To solve this, Snowflake has introduced Cortex AI for Financial Services, a groundbreaking suite of tools designed to unlock the full potential of AI in the sector.

    What is Snowflake Cortex AI for Financial Services?

    First and foremost, Snowflake Cortex AI is a comprehensive suite of AI capabilities. It empowers financial organizations to unify their data and securely deploy AI models, applications, and agents. By bringing AI directly to the data, Snowflake eliminates the need to move sensitive information. As a result, security and governance are greatly enhanced. This approach allows institutions to leverage their own proprietary data alongside third-party sources and cutting-edge large language models (LLMs). Ultimately, this helps them automate complex tasks and derive faster, more accurate insights.

    Key Capabilities Driving the Transformation

    Cortex AI for Financial Services is built on a foundation of powerful features. These are specifically designed to accelerate AI adoption within the financial industry.

    • Snowflake Data Science Agent: This AI-powered coding assistant automates many time-consuming tasks for data scientists. For instance, it handles data cleaning, feature engineering, and model prototyping. This, in turn, accelerates the development of crucial workflows like risk modeling and fraud detection.
    • Cortex AISQL: With its AI-powered functions, Cortex AISQL allows users to process and analyze unstructured data at scale. This includes market research, earnings call transcripts, and transaction details. Therefore, it transforms workflows in customer service, investment analytics, and claims processing.
    • Snowflake Intelligence: Furthermore, this feature provides business users with an intuitive, conversational interface. They can query both structured and unstructured data using natural language. This “democratization” of data access means even non-technical users can gain valuable insights without writing complex SQL.
    • Managed Model Context Protocol (MCP) Server: The MCP Server is a true game-changer. It securely connects proprietary data with third-party data from partners like FactSet and MSCI. In addition, it provides a standardized method for LLMs to integrate with data APIs, which eliminates the need for custom work and speeds up the delivery of AI applications.

    Use Cases: Putting Cortex AI to Work in Finance

    The practical applications of Snowflake Cortex AI in the financial services industry are vast and transformative:

    • Fraud Detection and Prevention: By training models on historical transaction data, institutions can identify suspicious patterns in real time. Consequently, this proactive approach helps minimize losses and protect customers.
    • Credit Risk Analysis: Cortex Analyst, a key feature, can analyze vast amounts of transaction data to assess credit risk. By building a semantic model, for example, financial institutions can enable more accurate and nuanced risk assessments.
    • Algorithmic Trading Support:While not a trading platform itself, Snowflake’s infrastructure supports algorithmic strategies. Specifically, Cortex AI provides powerful tools for data analysis, pattern identification, and model development..
    • Enhanced Customer Service: Moreover, AI agents powered by Cortex AI can create sophisticated customer support systems. These agents can analyze customer data to provide personalized assistance and automate tasks, leading to improved satisfaction.
    • Market and Investment Analysis: Cortex AI can also analyze a wide range of data sources, from earnings calls to market news. This provides real-time insights that are crucial for making informed and timely investment decisions.

    The Benefits of a Unified AI and Data Strategy

    By adopting Snowflake Cortex AI, financial institutions can realize a multitude of benefits:

    • Enhanced Security and Governance: By bringing AI to the data, sensitive financial information remains within Snowflake’s secure and governed environment.
    • Faster Innovation: Automating data science tasks allows for the rapid development and deployment of new products.
    • Democratization of Data: Natural language interfaces empower more users to access and analyze data directly.
    • Reduced Operational Costs: Finally, the automation of complex tasks leads to significant cost savings and increased efficiency.

    Getting Started with Snowflake Cortex AI

    For institutions ready to begin their AI journey, the path is clear. The Snowflake Quickstarts offer a wealth of tutorials and guides. These resources provide step-by-step instructions on how to set up the environment, create models, and build powerful applications.

    The Future of Finance is Here

    In conclusion, Snowflake Cortex AI for Financial Services represents a pivotal moment for the industry. By providing a secure, scalable, and unified platform, Snowflake is empowering financial institutions to seize the opportunities of tomorrow. The ability to seamlessly integrate data with the latest AI technology will undoubtedly be a key differentiator in the competitive landscape of finance.


    Additional Sources