AI-900 Microsoft Azure AI Fundamentals – Describe features of Natural Language Processing and Conversational AI workloads Part 2

  1. Lab – Speech Service – Text to speech

Now, similar to generating text from speech, you can also go ahead and use the speech service to go ahead and convert text into speech. So over here in this net program, I’m going ahead and basically using the same service that I have over here. So again, this is the same end point and the same key, and it’s very simple. Over here, I’m ensuring that this text, “Welcome to this course on artificial intelligence,” is converted into speech and then generated into a new wave file. So if I can go ahead and run this particular program, it will go ahead and generate that new wave file. So, if I go to the TEM directory and open the new Bay file, welcome to this artificial intelligence course. So here you can see that the file has been generated, and you can see that it has gone ahead and converted that text into speech.

  1. Language Understanding Intelligence Service

Hi, and welcome back. Now in this chapter, I just want to give a quick introduction when it comes to the Language Understanding Intelligence Service, or Lewis. So over here, we could see this service being quite frequently used when it comes to catboats or social media sites. So over here, we are using an intelligence system to go ahead and understand what a user wants. I mean, basically, respond back to the user based on the information the user requires.

So, for example, let’s say that you have a chat service in place on a site. Let’s say this is a site that is used for booking flights. So let’s say that a user comes onto the site, and then you have a chatbot in place. So let’s say the user wants to go ahead and book a flight. So the chatbot, based on its intelligence, might first go ahead and ask the user. So thank you for your request. Can I know from where and to where you want to travel? Then probably the user will go ahead and ask the responder, “Can I say from Dubai to London?” Then again, the chatbot might intelligently go ahead and ask for some further information from the user.

So this is the basis of the Language Understanding Intelligent Service: to go ahead and understand what the user wants and to respond back to the user in the most intelligent way possible. So, in the foundation of the Language Understanding Intelligence Service, or Lewis, the first step is to always understand what the user’s intent is. Over here, the intent of the user is to go ahead and book a flight. There is also something known as entities in Lewis, so entities just help to go ahead and further understand what the user wants to do. So over here, just a quick overview or quick understanding of the Lewis service We are actually going to go into labs to see how we could go ahead and work with the Language Understanding Intelligence Service that is available in Azure.

  1. Lab – Working with LUIS – Using pre-built domains

Hi, and welcome back. Now in the next set of chapters, we’ll see how to work with the Lewis service that is available. Now there is a separate web interface that is available for Lewis. So let’s go on to it. Now that we’re over here, let’s go ahead and sign in. So we can sign in using the same account as yours. So since I am already logged in via another tab with my Azure account, it’ll go ahead and automatically log me in to the Lewis service. So over here, I can go ahead and select my subscription. Now over here, it’s asking me to go ahead and create something known as an authoring resource. So this will be a separate Lewis resource that will be created in Azure.

So let me go ahead and click on “create an authoring resource.” So over here, I can go ahead and select my resource group. So let me go and choose the learning group. Allow me to introduce myself over here. So it’s going to go ahead and create a new Azure Cognitive Services account. So let me go ahead and give the name of a resource name. Over here, I can go ahead and leave the location as it is, and let me go ahead and hit Done. So over here in this Lewis web interface, it is going to go ahead and create a Cognitive Services account that is required for Lewis in Azure itself. Now that we have our authoring resources in place, let’s go ahead and create a new conversation-based application. So let me go in and click on the new app. Now over here, let me go ahead and give a name for our application.

So your application can be based on different domains. So let’s say you want to build an application for, say, a restaurant. You might create a new app for that. Let’s say you want to create an application for, say, another type of company. You can go ahead and create a separate application for that. So let me go ahead and just give the application a name. I’ll go ahead and choose English as the culture. Now, in case you are not getting any culture over here, just go ahead and refresh this page for the applications on the Lewis web portal. You should be able to get the culture of English over here. Now we also need one more service or resource when it comes to making predictions. But when creating the application, we don’t need a prediction resource as of now. So for now, let me go ahead and just click on “Done” so that we have our application in place. Now that we have our application in place, it will give us some information on how to go ahead and create an effective Lewis-based application. Let me go ahead and close this. Some of the main things we have over here are, first and foremost, intense. So this is the most important thing. So over here, we have to go ahead and train Lewis on what the different intents of the user are. So let’s say you’re building this Lewis application for a site that is used for booking flights. So over there, you have to go ahead and add what would be the different intents of the user. Does the user want to go ahead and search for a particular flight? Does the user want to go ahead and book a particular flight? These are all intentions. Then we also have entities, which I’ll go through a little bit later on.

This basically helps to go ahead and segregate the keywords into separate entities. This is based on your intents, and you also have pre-built domains in place. And that’s what we’re going to do. Firstly, let’s go ahead and use a prebuilt domain, and then in the subsequent chapters, we’ll go ahead and create intents from scratch. We’ll go ahead and create entries from scratch. So if I go on to the prebuilt domains over here, you already have prebuilt domains in place. And what do I mean by these prebuilt domains? So, take a look at Let’s see if I scroll down onto the to-do domain. So this is used for handling requests from users when it comes to a task list. So if I go ahead and click “add domain,” is that what I’ll do? So that is done. Now, if I go on to intents now, over here, you’ll see there are a lot of intents that have been put into place. These are in different categories. So, if I continue with the intent of doing add to, if I continue with that over here, we have different intentions. So, over here, it’s basically taking into account the various types of user input that can be expected when adding something to a tour list.

So, for example, adding something to a shopping list creates all sorts of things that can be added to a list. So again, this is a prebuilt domain that you can actually make use of, right? So over here, we’ve got our intentions in place. Now let me go in and just refresh this page again. So I basically want to load the application again basically.So I want to have the ability now to go ahead and train this model—this Lewis model—on the intents of this prebuilt domain. So, despite the fact that we have a prebuilt domain here, it has only gone ahead and added the intents. So, in this domain model, the user essentially intends to ask So over here, we start to go ahead and train our model on these different user intents on these different entities. So, despite the fact that these are pre-programmed intents, we begin to train our models on them. So let me go ahead and click on “train.” So over here, we are training the Lewis model on, basically, this sort of application, which is based on a tour list, on adding something to a tour list.

And this is based on all of these user intents. Now, once the training is complete, we can go ahead and click on Test. And over here, you can go ahead and test a particular intent. So as a user, let’s say I’m going to add a gym workout for Tuesday. Let me enter. So over here, it has gone ahead and understood that this is something that needs to be added to a tour list. If you go ahead and click on Inspect over here, you can see what the intent is. So it has gone ahead and looked at the intent, and it has gone ahead and understood what is the best intent that matches what the user wants to do. So the entire purpose of language understanding is to go ahead and understand what the user wants to do based on their conversation. Over here, it’s gone ahead and been understood that the gym workout is nothing but a task. So this is an entity; it has gone ahead and taken the gym workout; it is an entity that can be added to a list, right? So in this chapter, I just want to kind of give you an example of creating a Lewis-based application. This was based on a prebuilt domain that is available in Lewis itself.

  1. Lab – Working with LUIS – Adding our own intents

Now, in the previous chapter, I had shown you how to use the built-in domain that Lewis provides. But let’s say you want to go ahead and add your own specialisation when it comes to building your own application in Lewis. So let’s go ahead and see how to do this. So first, in my case, let me go ahead and create a new application. So I’m going to start a new application. So let me say I’m building an application for buying courses.

So let’s say I have a website that is going ahead and selling video courses, and I want to go ahead and basically have some sort of language understanding when it comes to understanding what users want when it comes to buying courses. So over here, let me go ahead and click on “Done.” So let me go ahead and close this. Now that we’ve arrived, we must begin moving forward and forming our intentions. Now over here I just have some very simple intents in place, so let me go ahead and add those intents. So first, let’s say there’s an intent to search for a course. So over here, let me go ahead and hit on Create. So I’ll give it a name and then click “Done.” As a result, it will now proceed with that search.

And over here, I want to go ahead and add an example of user input, which basically maps onto this particular intent. So if someone wants to go in and search for “course,” if it’s based on this intent, you have to go in and add what the user might actually ask Lewis. So over here, we have to go ahead and add some utterances from the user. So let’s say I was looking for a course. So let me go ahead and add that. I’ll just go ahead and hit Enter. So it’ll go ahead and add that utterance over here. Next, I want to give more information on a course, so let me go ahead and add all of these. So I was interested in the course, and, finally, do you have this course? Now, similarly, let me go back onto the app assets, and then let me go ahead and create another intent. So it will be for the same reason. So, similarly to the greeting intent, let me add some user input. At any point in time, if you feel you have gone ahead and made a mistake, you can go ahead and click on “Editor.” You can then go ahead and delete the example user input.

So let me go ahead and quickly add all of the different intents along with the user input. So now I’ve gone ahead and added all of the intents and all of the example user input. Now, based on all of this intensity, let me go ahead and train the lowest model. So this takes some time; let’s come back once the training is complete. Now, once the training is complete, I can go ahead and take the test. And over here, I can go ahead and add some example user input. Let me go ahead and enter. So over here, it’s gone ahead and added this to the search course intent. Now, if I go ahead and add something that was a little bit more confusing, I was looking to buy a course. So over here we have the word “buy,” and we have the word “looking” as well. But here the intent might be to go ahead and actually buy a course. But over here, it’s mapped it onto the search course. So again, you have to go ahead and add as many examples of user input as possible and then map them to the right intent so that Lewis understands what the user actually wants. Right. So in this chapter, I just want to go through the concept of adding intent to Lewis on your own application.

  1. Lab – Working with LUIS – Adding Entities

Now, we have already gone ahead and seen how to work with intentions in Lewis. Now, you could also go ahead and make use of entities as well. So again, over here, you can go ahead and tell Lewis to go ahead and extract data from the utterances so that you can go ahead and label them as entities. So this is not mandatory. This is only true if the calling application actually wants to make use of those extracted entities. So I’ll quickly go ahead and show you how to create these entities in Lewis. So in Lewis, if you actually go on to your intent, let’s go on to the search course intent, so over here, let me go ahead and add another example user. Input: So over here, I’m actually giving a name for the course, right? And over here, I want to go ahead and map this as the entity, so I can just go ahead and click over here and click at the end of that keyword, and I can go in and just give an entity name, and I can go ahead and hit on Enter.

This will actually go ahead and create a new entity name. Now, when you go ahead and create entry names, it’s always good to go ahead and use the machine-learning entities. This can go ahead and be learned from the context itself. So let me go ahead and hit on Create now. In order to make sure that this NT is basically part of our model, we have to go ahead and again hit on train let mego on to now test once training is complete so let mejust say by the AI 900 course, hit on Enter.So over here, it’s gone on to search for the course. If you go on to inspect over here, it’s gone ahead and taken AI 900, which is the course name. Now, I could have actually gone ahead and put this as part of the purchase intent. This is an example showing you how you can actually create an entity. There are only built-in entities. So for example, if I go ahead and open the prebuilt entry pane over here, you have entities for the age, for date, for time, for dimension, for email, et cetera. So all of this can be extracted from the utterances of the user.

  1. Lab – Working with LUIS – Publishing your model

Now, in the last chapter, I showed you how you can basically work with entities in Lewis. Now, let’s say you want to go ahead and publish your model. So just like any other machine learning model, if you want to go ahead and consume the model, you need to go ahead and publish the model. So over here, let’s go ahead and click on the “Publish” button. Now over here, you can go ahead and choose a staging slot. So, if you want to test your model, you can either deploy it to the staging slot or choose a production slot. Let me go ahead and hit “done.” So it’s gone ahead and published the Lewis application. You can go ahead and access your endpoint URLs. Now over here, we don’t have an endpoint URL in place because we don’t have a prediction-based resource in place. So over here, you can go ahead and now add a prediction resource.

This will add the prediction resource to Azure. Now over here, you can go ahead and select a prediction resource, or you can go ahead and create a new one. Over here, you can go ahead and select your subscription and your resource group. Over here, go ahead and give a name to the resource. You can go ahead and use a location as it is. And again, I’ll choose the free pricing tier and hit “done.” So now we have the prediction resource in place. Now over here, you can go ahead and copy the entire example query URL. You can go on to a new tab, you can replace it over here, and you can also add your query over here. So, say, by the AI 900 course. So now over here, you can see the top intent search course with a confidence score of zero point.So it’s basically close to 90%. So over here, now you’ve seen how you have the ability to go ahead and work with a Lewis-based application. We have seen how to create intents, how to build entities, and how to publish your application.

  1. QnA Maker service

Hi, and welcome back. Now in this chapter, I just want to give a quick introduction to the Q&A and Maker services. So this service helps to provide a natural conversational layer over your data. And in this case, your data is your information knowledge base. So you might have a knowledge base of questions and answers in place. The entire purpose of the Q&A Maker is to make sure that this knowledge base of information has features such as the ability to go ahead and import pre-built questions and answers and also to help in searching for answers based on the questions posed by users. So with a Q&A Maker, you can go ahead and import your questions and answers into the knowledge base. With the help of the service, you can also go ahead and decide on the type of data that you want to import. So this could be FAQs, product manuals, spreadsheets, or a web page. When we go ahead and actually create a resource based on the Q and A Maker, we will also create various other resources. Again, this is all going to be managed by the Q&A Maker service.

So there’s a Q and then there’s the maker. This is used for authoring purposes and for query prediction. Then you have the cognitive search feature. This is basically used for data storage and searching. So you need to have an effective way to go ahead and search for answers based on the questions and answers that are already part of the Q&A Maker. And this can be achieved with the cognitive search feature. This is yet another service offered by Azure. Then you have the app service. This is used for creating an end point for query prediction, and then you have application insight. So this is basically a mounting tool. This helps to have telemetry over the query prediction. So if you want to go ahead and see metrics about the prediction of the queries, you can go ahead and make use of this Application Insights resource. So please know that all of these resources will be managed by Azure itself. Your job is to go ahead and just ensure that you have the questions and answers in place in the Q&A Maker.

  1. Lab – QnA Maker service

Now that we’ve had an introduction to the QNA Maker service, let’s see how we can make use of this service. Again, just to reiterate the importance of having a knowledge base in place, because that’s the entire purpose of the Q&A Maker. So, if you look at a site like Stackoverflow, this site is full of questions and answers from various people. So over here, the first important aspect is to go ahead and have that knowledge base of questions and answers. And the other important part is to go ahead and have these searching capabilities. Because you have so many questions and answers in place, you need to have a good search algorithm or search engine in place to go ahead and search for relevant questions that users want to see. So these are some of the important aspects when it comes to a web application that wants to make use of a knowledge base and wants to make use of a Q&A service. So even on my own website, I’m actually trying to go ahead and implement this sort of searching capability on my basically all-content pages.So even over here on my side, if I want to go ahead and basically look at content that’s pertinent to virtual machines, I can go ahead and search it.

From here and over here, I basically get the different lists of items that are pertinent onto virtual machines. So let’s go ahead and see how to work with the Q&A Maker service. Remember, that service is mainly meant for building your knowledge base. You’ll then have an application that actually makes use of this knowledge base in the end.Now, there is a separate site that is used for the Q&A Maker service, so let’s go on to it. This is a web interface that allows you to go ahead and easily interact with the Q&A Maker service. So over here, let me go ahead and sign in. So it will proceed to set up my account in the same manner as yours. Since I’ve already logged in from here, it’ll go ahead and basically log me in with my same account. Now, currently, I don’t have any knowledge bases in place, so I could go ahead and create a knowledge base.Now, for this, the first step is to go ahead and create a Q&A service. So this is actually going to go ahead and create a Q&A resource in Azure for your Azure account. So over here, let me go ahead and hit on “Create Q&A Service.” So again, this will redirect us onto the Azure Portal, and it will go ahead and actually prompt us to enter the information for creating a Q&A resource.

So over here, I can go ahead and choose my subscription, and I can go ahead and choose my resource group. Over here, I can go ahead and give a name to the pricing tier. Let me go ahead and choose the free pricing tier. This should be good enough for our particular demo. Now over here, I said that in addition to the Q&A Maker service, we also have the Azure Search service. So this makes it easier to go ahead and search for content in the Knowledge Base. So over here, let me go ahead and leave the location as it is. Now that I’ve established the various pricing tiers, I can proceed to select the free pricing tier. So in the free pricing tier, you basically have three indices. That means you can go ahead and create two knowledge bases. If you want to go ahead and create more knowledge bases, you basically have to choose the high pricing tier when it comes to Azure Search. But for the purpose of our demo, all of this should be fine. The app service is then available. So this provides the underlying compute engine for the Q and A Maker queries. so I’ll go ahead and leave it hazardous. And then we have application insights, which are used for telemetry to see how the Q&A Maker service is actually performing. So let me go to tags and then view and create. So let me go ahead and create the Q and A Maker resource.

Now, this will take around four to five minutes. Let’s come back once we have this in place. Now, once we have the resource in place, you can go ahead and access it, but what we’re going to do is go on to the Q and AMaker API and let’s go ahead and refresh this page. So, over here, it should now go ahead and load our Q and A services so we can choose our subscription and service. So over here, it’s saying there are no end-point keys in place. So we just need to go and actually wait for some time. So let’s come back after around five to ten minutes. Now, after waiting for around five to ten minutes, let me go ahead and hit Refresh. Now let me go ahead and select my service again. So now I can go ahead and select my language. I can go ahead and scroll down. I can go ahead and give the knowledge base a name for the Knowledge Base.If you want, you can actually go ahead and populate your knowledge base. This could be done by extracting data from a URL, a PDF file, or even a Word document. Or you can also go ahead and add a file. So, if you have a PDF file or an Excel-based file with your question answers already in place, you can add those files as well as those questions and answers. Onto the knowledge base over here in terms of chitchat. So if you have more questions, like, “Hello, how are you?”

And if you want to ensure that the conversational part of the knowledge base responds in, let’s say, a professional way or a friendly way, So you can actually incorporate these built-in intuitions into the Q&A Maker itself. But for now, let me go ahead and just leave it blank, and let me go ahead and create the knowledge base. Now, once you have a knowledge base in place, you can start adding question and answer pairs. Please note that, as I said before, you can also go ahead and upload files like Excel sheets that already have your question and answers. So over here, let’s say a user is asking a question about prior AI experience for the AI 900 exam, and then you can go ahead and answer the question. So you basically have a way to go ahead and add some structure to your answer over here. So over here, you could also go ahead and add pictures.

You can go ahead and add tables. So there’s a lot of flexibility when it comes to the way you want to go ahead and present the answer to the user. So you can go ahead and give the answer. And please know that you can go ahead and add alternate phrasing to the question. So there could be a different way that the user can actually go ahead and ask this question. So the more questions that you actually add over here, the more intuitive it will be. Basically, this Q&A maker will be able to go ahead and answer a user. Then, once you have your Q and A question in place, you can go ahead and click on Save and Train. So you’re going out and training the Q&A model based on the questions and answers that you have. Remember, you will have thousands of questions in your knowledge base. Over here, I’m just giving a very simple example of how you can add a simple question and answer to your knowledge base. Once you’ve gone ahead and clicked on “Save and Train,” you can go ahead and click on “Test.” And over here, you can go ahead and type the message. So I’ll say, is it required to have prior AI experience for the AI 900 exam? I’ll go ahead and hit Enter.

So over here, it’s giving you the answer, saying, “No, this is not required.” So over here, based on the questions in the knowledge base, it’s trying to find the appropriate question and then give you the answer. If you actually go on to the settings over here, you have the ability to go ahead and basically export your knowledge base and also import your knowledge base from, say, Excel-based files. If you go on to publish, you can actually go ahead and publish your knowledge base so that it can be used as an external endpoint by applications. We’ve already seen this with a lot of resources. So first you build your content, then you train your model, and then you go ahead and hit “Publish,” right? So this marks the end of this chapter. I just want to give an idea. when it comes to the maker service Q&A.

  1. Bot Framework

Hi, and welcome back. Now in this chapter, I just want to give a quick introduction when it comes to the bot framework. So we might be very familiar with the use of chatbots when it comes to websites. So over here, if you go on to the Postman site itself for the download of the tool, So over here, you can see that you have a chatbot in place. So this bot could also be using the lure service to go ahead and understand what the user wants to convey and then give an adequate response.

Remember, over here, you mostly won’t be dealing with a real user who is actually answering these queries. You actually have artificial intelligence. You have a bot in place that is starting to go ahead and understand how it can help you and basically respond to your queries. So over here, if you want to go ahead and create bots for your applications, you can actually go ahead and make use of the bot framework. So, if you go on to the bot itself, keep in mind that these are all conversations taking place by something intelligent on the other side. So remember, over here you have a machine on the other side that has built-in intelligence to go ahead and understand what a user might want.

So it’s like conversing with another human being. But over here, we have a machine on the other side. So in order to go ahead and actually develop such bots, you can actually go ahead and make use of the bot framework that is available in Azure. So a bot is an application that interacts with users in a conversational way. So you can go ahead and use the bot framework along with the Azure bot service to go ahead, build, test, and deploy intelligent bots. You can also use Natural Language Processing with the assistance of Lewis. You can also go ahead and make sure that the bot can answer commonly asked questions with the help of the Q and A service. So in this chat, I just want to give a quick introduction when it comes to the bot framework.

  1. Example of Bot Framework in Azure

Now, in order to go ahead and actually implement the bot framework, you need to have coding expertise in place. But from the perspective of the exam, it’s not required to know coding. It’s not required to understand the bot framework in detail. It is good enough to understand the entire purpose of the bot framework and the bot service.

So in Azure, we can just quickly go ahead and create a bot resource just to see how it works. So over here, in all resources, let me go ahead and click on “Add.” Over here, if I go ahead and search for the bot over here, I can go ahead and choose the Web App bot that is available. Let me go ahead and hit Create. So, over here, we must go ahead and assign a distinct bot handle. I have to then go ahead and choose my subscription and my resource group. I’ll leave the location hazardous for the pricing tier. I can go ahead and choose the free pricing tier. Over here, it’s going to go ahead and create an Azure Web App with the same name as our bot handle. Now, it’s going to go ahead and use a C# bot template to deploy a very simple bot over here. Over here, we have an app service plan. The app service plan is actually used for hosting the Azure Web App itself. Again, we don’t have to go into details.

Allow me to proceed and simply press the Create button. So this will go ahead and create a bot service in an Azure web app bot service. This will just take a couple of minutes. Let’s come back once you have this in place. Now, once the deployment is complete, if you go to your notifications, you can go directly onto the resource. And over here, you can actually go on to test in Web Chat. And over here, actually, you’ll get the interface for the bot itself. Over here, you can go ahead and type a message to the bot. And this is based on the simple Echo bot framework. So over here, you can go ahead and start chatting with the bot. So what it does is that it just goes ahead and echoes whatever you’re basically sending to the bot. This is basically a very simple bot template. However, the whole point of you as a beginner in the world of AI is to recognise that you do have this capability. In Azure, you have this bot framework, which is also available, that allows you to go ahead and build bot-based applications.

img