In the most current release, Microsoft demonstrated how easy it is to create your own chatbot assistant based on the information you have and train existing models from the Azure Open AI service. In this post, we will take a use case of EV cars from a car manufacturer and train the assistant to solely answer inquiries about those EV vehicles. The remaining questions should not be answered. Let's see how we can do it.
Now that Azure Open AI is in Preview mode, it is available to the entire public, allowing us to use the services, add intelligence, and make our apps more powerful. In this essay, we will cover the following topics.
It is necessary that the following additional services be built:.
Let's see how it works
Download training data from here : Training Data
Creating Storage
For his tutorial, I understand you have Azure Storage account ready.
Once you are inside the storage account, under ‘Data Storage', click on ‘Containers’.
Name the new container ‘aitrainingdata’. Click on ‘Create’.
Click on the 'aitrainingdata' container to submit the training data markdown file. In this example, I've attached the file GMEVTrainingData.md. This is sample data, which is already included in this article.
Creating Azure Open AI service
(1) Go to the Azure portal and search for ‘Azure Open AI’.
(2) Select the Azure OpenAI service you get and click on Create Azure OpenAI.
(3) Enter the following details in the ‘Basics’ tab, as shown in the image:
(4) In the ‘Networks’ tab, please leave the default, which is ‘All networks, including the internet, can access this resource.
(5) You can provide the Tags, relevant to your project.
(6) In the ‘Review + Submit’ section, click on ‘Create’.
(1) From the Azure AI Services, click on ‘Cognitive search’ and click on ‘Create’.
(2) Choose the resource group that you previously created for this task. In this case, it is ‘teamsai-rg’.
(3) Click on 'Review + Create’ and once the message ‘Validation Success’ appears, click on Create.
Creating the Index
To generate the index, the data must be imported from the data source. We now have the training data stored in Azure storage; all we need to do is connect the storage account data to cognitive search. After a few minutes, it generates the index.
(1) From the Cognitive search ‘Overview’ page, click on ‘Import Data’.
(2) In the ‘Connect to your data’ page, select ‘Azure Bob Storage’.
(3) In the next ‘Add cognitive skills’ section, leave the defaults.
(4) Next, click on the button ‘Skip to: Customize target index’.
(5) Leave the defaults and click on ‘Create an indexer’.
(6) In the ‘Create an indexer’ section, leave all the options default.
(7) Finally, click on ‘Submit’
(1) Under the search management in quick launch, click on ‘Indexes’
(2) Click on the index name; in this case, it is ‘azureblob-index’.
Note. The easiest way to check if the index succeeded or not, you see the document count and storage size should have a value other than 0. Since I am indexing only one document, it is showing the document count as 1 and the respective storage, which is 8.9 kb.
(3) Type a query string that is present in the training data. In this case, I am entering as ‘EV’.
(4) Enter one term is not present in training data. I am entering as ‘Open AI’. You can see the value is null since the term is not present in the data.
In this section, we will examine how we can use an existing service 'as is' and observe the results of the model. For the purpose of simplicity, I've chosen the gpt 35-turbo.
(1) Go to the Open AI service that was created from the previous section and click on ‘Model Deployments’.
(2) Click on ‘Manage Deployments’.
(3) Now you would be taken to portal https://oai.azure.com. From the ‘Deployments’ page, click on ‘Create new deployment’.
(4) For this article, I have chosen gpt-35-turbo and named it gpt35demo and leave the model version to default and clicked on ‘Create’.
(5) Once, the model deployment is successful, Click on the model instance. In this case, it's 'gpt35demo', and you'll be taken to the model page, which should look like this. It basically displays the deployment's properties and status, as well as links to 'Open in Playground', where you can test and train the model for your individual needs.
Click 'Open in Playground'. This will give you alternatives for testing how the AI Conversational model works.
Interacting with Service Model in ‘As-Is’ mode:
In this scenario, we are using the service 'As Is' without any training and will monitor the results.
(1) In the Playground ‘Assistant setup’ section, select the ‘Default’ template under the ‘Use a system message template’.
(2) In the ‘Chat session’, enter the following questions and observe the result set.
1. User Message : Hello
It gives the default response.
(2) User message: Who is the director of the movie ‘Titanic’?
User Message : What are GM electric cars in the market?
As you have noted, it provides the majority of the necessary information for the queries you have posed. The preceding steps conclude interaction with the OOTB service model GPT-35-Turbo.
The concept here is that Azure Open AI includes a few different service types.
In brief, GPT-4 and GPT-3 understand natural language and respond to queries in a conversational fashion. DALL-E interprets normal language and creates visuals. Codex recognises and converts natural language into code. Embeddings: A code format that machine language learning models can understand. To learn more about the service models, please see the references section.
For this demonstration, I used the gpt-35-turbo model to test the discussion. Please keep in mind that previous GPT 3 models are text in and text out, which means they accept input strings and produce the same string outputs as in training. The gpt35-turbo is the conversation in and message out device, which means it accepts the conversation, understands the intent, and outputs the message.
Use Case
Let's try to create a use-case. My specific use case is to leverage the GPT-35-Turbo service model that we created in the previous section, but I want the chat service to only respond to a specific application. Any additional queries not related to the application should be ignored and responded to as if I was unable to answer them. Let's see how we can accomplish this.
The solution's architecture is shown below.
The storage account and cognitive search have previously been configured in previous sections. All that remains is to integrate the services with Azure Open AI models. Let's proceed to the next part for those integration stages.
(1) If you are following the previous section, clear chat and make sure no previous responses are present.
(2) Now in the ‘Chat Session’, you would be seeing the below screen that says ‘Test your assistant by sending queries below’.
(3) In the ‘Assistant setup’, click on ‘Add your data (preview).
(4) You will be getting another button that says ‘Add a data source’.
(5) After clicking 'Add a data source', you will be taken to a new page. The free tier cannot be used to add your own data. If you already have a cognitive search, the selection will be prepopulated. For this demonstration, I'm using an existing cognitive search that's been configured using the procedures outlined above. When you click the check box that confirms your account will be charged for utilising the Azure cognitive search service, the next button will appear.
(6) Leave all options as default; click on ‘Next’. In the search type, select ‘simple’ and click on ‘Next’.
(7) In review and finish, review the information and click on ‘Save and close’.
(8) In the assistant setup, make sure the option ‘Limit responses to your data content’ is checked.
(9) Type the question 'Who is the director of the movie Titanic' in the chat session. The conversation model should indicate that the required information was not found.
The procedures outlined above confirm that the model is training on your training data.
The training data is supported in the following format.
For this article, I used the 'Mark Down' file. You can download the markdown from the attachment. After selecting the file, click 'Upload'.
Please keep in mind that after deploying the cognitive search service, you must wait at least 5 minutes for the Azure post-configuration to complete.
Delete the custom deployment.
Download training data from here : Training Data
We trained the data using the techniques outlined below, limiting the model to answering inquiries and queries based solely on the training data and its own natural flow.