Tutorial

Using OpenAI to categorize text: a beginners' guide to using Search Embeddings

  • 9 May 2023
  • 2 replies
  • 2281 views
Using OpenAI to categorize text: a beginners' guide to using Search Embeddings
Userlevel 7
Badge +12

If you’ve been tinkering with the OpenAI Zapier integration, you may have come across the ‘Search embeddings’ action. This article covers the fundamentals of what embeddings are in AI and explains how to set up an OpenAI Search Embedding step in your Zap. 

In simple terms, embedding in AI compares how similar two (or more) pieces of data are to each other. For example, the word “dog” and “wolf” would both be closely related to the word “canine”, but if the embedding we use is “pet” then dog will be a much closer match. 

Embedding is commonly used in apps to do things like compare your search question to useful answers or show you products that might be relevant to other things you’ve looked at. If you want to learn more about the theory behind embeddings, I found this video really helpful:

 

Using Embeddings with OpenAI in Zapier

In Zapier, you can add text as the input of an embedding step and ask the action to compare that a list of categories. The input of the action is called the ‘Query’, and the list of categories are called ‘Documents’.
 

 

The output of a search embeddings step is a ranked list of how close a match the query is to the different documents (categories). When you test the Search Embeddings action, the action gives you the best match and a list of the other matches ranked by closeness:

For example, using the query above, you get:
 

Image showing the output when you test an Open AI Search Embeddings step. It shows that the output includes the best match, as well as a list of the other matches, ranked. 

You’ll notice that cat ranks as a closer match for ‘large animal’ than wolf does. This highlights a limitation of using embeddings. The action looks at the text and ranks the matches according to how associated the words are. In this case ‘large animal’ and ‘cat’ might be more closely related because we often refer to lions and tigers as ‘big cats’. If you use the Search Embeddings action in your Zap, take some time to test your documents against different queries to make sure that you’re reliably finding the best match. 

 

A Search Embeddings use case

Let’s look at an example of how you could use the Search Embeddings step in your Zap. I’ll describe what the Zap does and explain how to set it up. 

Imagine that you’re a small business owner, and customers email you about their orders. If a customer isn’t happy with the product or service, you need to know right away so you can put it right. You can use the Search Embeddings action to alert you immediately if you have an unhappy customer.Here’s the outline of the Zap:
 

Trigger - Gmail New Email
Action - Open AI search embeddings
Action - Filter 
Action - Send SMS

 

The magic happens in the OpenAI step. Here’s how you need to set it up:

  1. In the Query field, add the body of the email
  2. Add the different categories in the Documents field, one category on each
Image of the Search Embeddings action. The body of an email is the ‘query’ and the ‘documents’ are different sentiments/feelings. 

The filter step only allows the Zap to continue if the Best Match Value from the OpenAI step is ‘Angry’ 

💡 To make the Search Embeddings action more robust, use categories that are different from each other, and only use as many categories as you need.

 

Finally, if the message is deemed to be ‘Angry’ and passes the Filter, the Zap will send you a text message using SMS by Zapier. You can customize this message and I set it up so that the text message includes the name of the customer and a link to their email.
 

Set up of SMS by Zapier action

 

Put all that together and whenever I get an email from an unhappy customer, I get a text message and can go straight to the email to take action. 


I hope you enjoyed this introduction to using the Search Embeddings action for OpenAI. We covered what embeddings are and how to set up a Search Embeddings step. In this article, ee looked at using fixed values for the documents, where you type something into the fields. The next stage of using this action would be to dynamically add them from a previous step in your Zap. If you’d like to know more about that let us know if you’d like to see an article that dives into that!
 


2 replies

Userlevel 1

If you’ve been tinkering with the OpenAI Zapier integration, you may have come across the ‘Search embeddings’ action. This article covers the fundamentals of what embeddings are in AI and explains how to set up an OpenAI Search Embedding step in your Zap. 

In simple terms, embedding in AI compares how similar two (or more) pieces of data are to each other. For example, the word “dog” and “wolf” would both be closely related to the word “canine”, but if the embedding we use is “pet” then dog will be a much closer match. 

Embedding is commonly used in apps to do things like compare your search question to useful answers or show you products that might be relevant to other things you’ve looked at. If you want to learn more about the theory behind embeddings, I found this video really helpful:

 

Using Embeddings with OpenAI in Zapier

In Zapier, you can add text as the input of an embedding step and ask the action to compare that a list of categories. The input of the action is called the ‘Query’, and the list of categories are called ‘Documents’.
 

 

The output of a search embeddings step is a ranked list of how close a match the query is to the different documents (categories). When you test the Search Embeddings action, the action gives you the best match and a list of the other matches ranked by closeness:

For example, using the query above, you get:
 

Image showing the output when you test an Open AI Search Embeddings step. It shows that the output includes the best match, as well as a list of the other matches, ranked. 

You’ll notice that cat ranks as a closer match for ‘large animal’ than wolf does. This highlights a limitation of using embeddings. The action looks at the text and ranks the matches according to how associated the words are. In this case ‘large animal’ and ‘cat’ might be more closely related because we often refer to lions and tigers as ‘big cats’. If you use the Search Embeddings action in your Zap, take some time to test your documents against different queries to make sure that you’re reliably finding the best match. 

 

A Search Embeddings use case

Let’s look at an example of how you could use the Search Embeddings step in your Zap. I’ll describe what the Zap does and explain how to set it up. 

Imagine that you’re a small business owner, and customers email you about their orders. If a customer isn’t happy with the product or service, you need to know right away so you can put it right. You can use the Search Embeddings action to alert you immediately if you have an unhappy customer.Here’s the outline of the Zap:
 

Trigger - Gmail New Email
Action - Open AI search embeddings
Action - Filter 
Action - Send SMS

 

The magic happens in the OpenAI step. Here’s how you need to set it up:

  1. In the Query field, add the body of the email
  2. Add the different categories in the Documents field, one category on each
Image of the Search Embeddings action. The body of an email is the ‘query’ and the ‘documents’ are different sentiments/feelings. 

The filter step only allows the Zap to continue if the Best Match Value from the OpenAI step is ‘Angry’ 

💡 To make the Search Embeddings action more robust, use categories that are different from each other, and only use as many categories as you need.

 

Finally, if the message is deemed to be ‘Angry’ and passes the Filter, the Zap will send you a text message using SMS by Zapier. You can customize this message and I set it up so that the text message includes the name of the customer and a link to their email.
 

Set up of SMS by Zapier action

 

Put all that together and whenever I get an email from an unhappy customer, I get a text message and can go straight to the email to take action. 


I hope you enjoyed this introduction to using the Search Embeddings action for OpenAI. We covered what embeddings are and how to set up a Search Embeddings step. In this article, ee looked at using fixed values for the documents, where you type something into the fields. The next stage of using this action would be to dynamically add them from a previous step in your Zap. If you’d like to know more about that let us know if you’d like to see an article that dives into that!
 

Hi there I loved this really great article.i don't know where everyone else is at but yet please go on! 

Userlevel 7
Badge +11

Welcome to the Community, @Captures! 🎉

Really pleased you enjoyed the article here! I can’t make any promises around when a follow up article might be published, but we’ll be sure to share a link to it here once it is!

In the meantime, I’d recommend checking out our AI Resource Hub and the Zapier blog which have lots of helpful AI related content that you may find interesting too! 🙂

Reply