Getting Started with Azure OpenAI Embeddings Models

Author

Reads 1.1K

An artist’s illustration of artificial intelligence (AI). This image depicts the potential of AI for society through 3D visualisations. It was created by Novoto Studio as part of the Visua...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image depicts the potential of AI for society through 3D visualisations. It was created by Novoto Studio as part of the Visua...

Azure OpenAI Embeddings Models are a powerful tool for developers, allowing them to harness the power of AI and machine learning in their applications.

To get started, you'll need to have an Azure subscription and a basic understanding of Python programming.

The Azure OpenAI Embeddings Models can be accessed through the Azure Cognitive Services Text Analytics API, which provides a simple and intuitive interface for working with embeddings.

You can get started by creating a Text Analytics API resource in the Azure portal and then installing the required Python SDK using pip.

Readers also liked: Azure Open Ai Api

Prerequisites

To get started with Azure OpenAI embeddings models, you'll need a few things in place. First, you'll need an Azure subscription - you can create one for free.

You'll also need an Azure OpenAI resource with the text-embedding-ada-002 (Version 2) model deployed. This model is currently only available in certain regions, so be sure to check that first.

For coding, you'll need Python 3.8 or later version installed. You'll also need to have the following Python libraries: openai, num2words, matplotlib, plotly, scipy, scikit-learn, pandas, and tiktoken.

Credit: youtube.com, Azure OpenAI Service - Embeddings Tutorial

Finally, you'll want to have Jupyter Notebooks available for working with the model.

Here's a quick rundown of the prerequisites:

  • An Azure subscription - Create one for free
  • An Azure OpenAI resource with the text-embedding-ada-002 (Version 2) model deployed
  • Python 3.8 or later version
  • The following Python libraries: openai, num2words, matplotlib, plotly, scipy, scikit-learn, pandas, tiktoken
  • Jupyter Notebooks

Setting Up

Before diving into the world of Azure OpenAI Embeddings Models, let's set up our environment properly.

To store our API key securely, we should create and assign persistent environment variables for our key and endpoint, and never post it publicly.

First, we need to read our csv file and create a pandas DataFrame. After the initial DataFrame is created, we can view the contents of the table by running df. This will give us a solid foundation to work with.

Environment Variables

Environment Variables are a crucial part of setting up your project.

Store your API key securely, such as in Azure Key Vault, to avoid posting it publicly. This is a best practice for AI services security.

Don't include your API key directly in your code to keep it safe.

For more information, see Authenticate requests to Azure AI services.

You might enjoy: Azure Openai Key

Create Resources in Same Region

An Artificial Intelligence Illustration on the Wall
Credit: pexels.com, An Artificial Intelligence Illustration on the Wall

When setting up your integrated vectorization, it's essential to create resources in the same region. This ensures that your text embedding model and Azure AI Search are in the same location, which is crucial for integrated vectorization to work properly.

Here are the key steps to follow:

  1. Check the regions available for your text embedding model.
  2. Find the same region for Azure AI Search.
  3. For hybrid queries or machine learning model integration, select an Azure AI Search region that offers those features.

By following these simple steps, you'll be able to create resources in the same region, which will help you set up integrated vectorization smoothly.

Next Steps

Now that you've set up Azure OpenAI Service, it's time to take your document search to the next level.

You can store your embeddings in a database for quicker retrieval, making it easier to access and analyze your data.

Consider using Azure services like Azure Cosmos DB or Azure Cognitive Search for efficient vector-based searching capabilities.

These services can help you scale your search functionality and improve the overall user experience.

Here are some options to consider:

  • Store your embeddings in a database for quicker retrieval.
  • Use Azure services like Azure Cosmos DB or Azure Cognitive Search for efficient vector-based searching capabilities.

By experimenting with different models and parameters, you can optimize your search results and get the most out of your Azure OpenAI Service setup.

Using Embeddings

Credit: youtube.com, Deploy Text Embedding Model in Azure Open AI Studio | Azure OpenAI Service embeddings tutorial

You can generate embeddings with Azure OpenAI using a user-friendly API and tools that simplify the process.

Azure OpenAI offers access to pre-trained embedding models, like “text-embedding-ada-002,” which have been trained on massive amounts of text data.

These pre-trained models save you time and resources, as you don't need to train your models from scratch.

Embeddings offer a powerful tool for document search, allowing you to retrieve documents based on their semantic similarity.

You can use embeddings for downstream tasks, such as retrieving documents with similar meanings.

Here are some key benefits of using embeddings:

  • Pre-trained Models: Access to pre-trained embedding models like “text-embedding-ada-002”
  • Text embedding: Models designed for natural language understanding
  • Ease of Use: User-friendly API and tools
  • Scalability: Scale your embedding workloads efficiently with Azure cloud infrastructure
  • Security and Compliance: Rigorous security standards and compliance certifications

Skill Configuration

Configuring your Azure OpenAI Embeddings models requires attention to a few key settings. You can adjust the model type to suit your needs, choosing from options like text-davinci-003 or text-curie-001.

The embedding dimension determines the size of the vector output, with a higher dimension generally resulting in more accurate but slower processing.

Azure OpenAI Embeddings models can be fine-tuned with your own data, which can improve performance by adapting the model to your specific use case.

Expand your knowledge: Azure Openai Embedding Api

Skill Parameters

Two people working on laptops in a modern office setting. Technology focus.
Credit: pexels.com, Two people working on laptops in a modern office setting. Technology focus.

When configuring a skill, it's essential to understand the parameters involved. Parameters are case-sensitive, so be sure to enter them exactly as they appear.

The resourceUri parameter is required and must be a URL with the openai.azure.com domain. If your Azure OpenAI endpoint has a URL with the cognitiveservices.azure.com domain, you'll need to create a custom subdomain with openai.azure.com.

The apiKey parameter is used to access the model, and if you provide a key, you should leave authIdentity empty. If you set both the apiKey and authIdentity, the apiKey will be used on the connection.

The deploymentId parameter is also required and must be the name of the deployed Azure OpenAI embedding model. You can find supported models in the List of Azure OpenAI models.

Here are the required parameters for a skill:

The dimensions parameter is optional and allows you to specify the dimensions of embeddings you'd like to generate. Currently, only the text-embedding-3 model series supports a range of dimensions, and the default is the maximum dimensions for each model.

Skill Outputs

An artist’s illustration of artificial intelligence (AI). This image depicts how AI could assist in genomic studies and its applications. It was created by artist Nidia Dias as part of the...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image depicts how AI could assist in genomic studies and its applications. It was created by artist Nidia Dias as part of the...

The skill output is a crucial aspect of configuring your skills. It determines what kind of data is produced by the skill, and how it's used in the search index.

One type of skill output is the vectorized embedding, which is a vector representation of the input text. This output is particularly useful for tasks that require semantic understanding, such as search and recommendations.

To work with vectorized embedding outputs, you'll need to define an outputFieldMapping in the indexer. This mapping allows you to send the output to a specific field in the search index, like the content_vector field.

The outputFieldMapping should look something like this: outputFieldMapping in indexer should map the vectorized embedding output to the content_vector field.

For your interest: Llama Index Azure Openai

Best Practices and Cleanup

To get the most out of your Azure OpenAI embeddings model, consider the following best practices:

If you're hitting your Azure OpenAI TPM (Tokens per minute) limit, check the quota limits advisory to adjust accordingly. Refer to the Azure OpenAI monitoring documentation for more information about your instance performance.

Credit: youtube.com, Working with Azure OpenAI Embeddings & Completion

Your Azure OpenAI instance should be in the same region or at least geographically close to the region where your AI Search service is hosted, to reduce latency and improve data transfer speed.

If you have a larger than default Azure OpenAI TPM limit, open a support case with the Azure AI Search team to have it adjusted accordingly, and avoid unnecessary slowdowns in your indexing process.

Here are some key considerations to keep in mind:

Best Practices

If you're hitting your Azure OpenAI TPM (Tokens per minute) limit, consider the quota limits advisory so you can address accordingly.

It's essential to understand your Azure OpenAI instance performance, and you can find more information about this in the Azure OpenAI monitoring documentation.

To optimize performance, it's best to have the Azure OpenAI embeddings model deployment separate from the deployment used for other use cases, including the query vectorizer.

This allows each deployment to be tailored to its specific use case, making it easier to identify traffic from the indexer and the index embedding calls.

Take a look at this: Azure Openai Deployment Name

Diverse team of professionals collaborating on a project in a modern office setting, using laptops and 3D modeling technology.
Credit: pexels.com, Diverse team of professionals collaborating on a project in a modern office setting, using laptops and 3D modeling technology.

Your Azure OpenAI instance should be in the same region or at least geographically close to the region where your AI Search service is hosted to reduce latency and improve data transfer speed.

If you have a larger than default Azure OpenAI TPM limit, open a support case with the Azure AI Search team to adjust it accordingly and prevent unnecessary slowdowns in your indexing process.

Here are some key considerations to keep in mind:

  • Separate Azure OpenAI embeddings model deployment from other use cases.
  • Host Azure OpenAI instance in the same region as your AI Search service.
  • Adjust your Azure OpenAI TPM limit if you have a larger than default limit.
  • Monitor your Azure OpenAI instance performance regularly.

Clean Up Resources

Cleaning up resources is a crucial step in any project. If you created an Azure OpenAI resource solely for testing, you'll need to delete your deployed models.

Deleting those models is a straightforward process. You can then delete the resource or associated resource group if it's dedicated to your test resource.

Deleting the resource group will also delete any other resources associated with it. This is a good opportunity to remove any unnecessary resources and keep your project organized.

Intriguing read: Azure Ai Models

Tiffany Kozey

Junior Writer

Tiffany Kozey is a versatile writer with a passion for exploring the intersection of technology and everyday life. With a keen eye for detail and a knack for simplifying complex concepts, she has established herself as a go-to expert on topics like Microsoft Cloud Syncing. Her articles have been widely read and appreciated for their clarity, insight, and practical advice.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.