7 Augmenting data with outputs from large language models

 

This chapter covers

  • Understanding external network access
  • Configuring external network access
  • Calling API endpoints from Snowpark
  • Retrieving customer reviews from websites like Yelp
  • Deriving customer review sentiments
  • Interpreting emails using large language models to save time

Snowflake’s external network access functionality enables data engineers to access network locations external to Snowflake. This opens countless opportunities to access data by calling API endpoints from Snowflake stored procedures or user-defined functions (UDFs). For example, data engineers can retrieve external data that augments the data already stored in Snowflake. With the proliferation of generative AI capabilities and large language models (LLMs), data engineers can incorporate the outputs of such models by calling the Snowflake Cortex LLM functions.

In this chapter, we will learn how to retrieve customer reviews from an external website and store them in Snowflake tables for further analysis. We will call an LLM to help us understand the reviews and classify their sentiment. We will also use an LLM to help us interpret unstructured text from the body of an email and derive structured information from it.

7.1 Configuring external network access

7.2 Calling an API endpoint from a Snowpark function

7.2.1 Constructing the UDF that retrieves customer reviews

7.2.2 Interpreting the results from the UDF

7.2.3 Storing the customer reviews in a table

7.3 Deriving customer review sentiments

7.4 Interpreting order emails using LLMs to save time

7.4.1 Creating a stored procedure that interprets customer emails

7.4.2 Constructing the prompt

7.4.3 Saving the CSV result to a table

7.4.4 Evaluating the output

Summary