AI Builder

AI Builder is a tool within the Power Platform that allows you to add Artificial Intelligence (AI) to your apps and flows without needing to be a data scientist or having to write code. AI Builder supports several Machine Learning (MLmodels that allow you to extract information from text and images to enhance your data and make predictions from your data. With AI Builder, you can gain insights from your data and enable the users of your apps to make better decisions. 

This chapter describes how to create AI Builder models based on your data stored in the Common Data Service. By using AI, you can classify new data captured in your apps, and make predictions based on historical data.

The following topics will be covered in this chapter:

  • Introducing AI Builder
  • Building an AI Builder model
  • Preparing data for a model
  • Training and testing a model
  • Using AI Builder models

By the end of this chapter, you will be able to create AI models, and use those models in Power Apps and Power Automate.

Introducing AI Builder

AI Builder is a component of the Power Platform solution that allows you to easily add AI to predict outcomes to help improve business performance without writing code. You do not need to understand ML or learn Python to use AI Builder. Microsoft makes it easy both to create AI models and then to consume those models in the Power Platform.

ML is a technique used to create predictive models based on relationships in data. Normally, to use ML, you need to understand the different algorithms, how the algorithms can be applied to data, and become an expert at making sure your model performs well with different data. Microsoft Azure provides many tools for AI, including AutoML, ML Designer, Azure Databricks, and Cognitive Services. 

The learning curve to be able to use Azure AI tools and services is very steep. AI Builder eliminates this learning curve. AI Builder is a software-as-a-service solution that simplifies building and using ML models in business scenarios. AI Builder addresses common requirements in business applications, such as classifying data and predicting outcomes.

AI Builder lets you add AI capabilities to the flows and apps you create. You can do either of the following:

  • Use one of the prebuilt AI models supplied with AI Builder.
  • Build and train your own AI model using your own data.

We will first look at the several types of models you can build.

Identifying AI Builder model types

AI Builder addresses some of the common requirements for AI in business applications. You don't need to choose the correct algorithm when using AI Builder; AI Builder uses its own ML functionality to find the best algorithm for your data. You simply choose the type of model and AI Builder then creates an AI model for you.

AI Builder has five model types for prediction, vision, and language:

  • Category classification: Performs Natural Language Processing (NLP) on text data. Category classification can be used to identify sentiment or meaning within the text. For instance, you can use category classification to determine the importance of an email message, or whether an email message is a request for action, a complaint, or just an acknowledgment.
  • Entity extraction: Recognizes specific data in text data. Entity extraction transforms unstructured text into structured data that can be used in apps and flows. You can use entity extraction to identify terms used in your industry or organization.
  • Form processing: Reads and extracts information from documents such as invoices and purchase orders. Many organizations process documents, re-keying information from the documents they receive. Form processing can be used with Power Automate to remove the need for manual processing of such documents.
  • Object detection: Finds objects within images. You could use object detection within a repair scenario to identify a piece of equipment from a photograph.
  • Prediction: Analyzes patterns in historical data to predict the outcome of new data. You can use predictions to forecast the volume of phone calls your call center will receive, or which product a customer might be interested in.

The following screenshot shows the five model types in AI Builder:

Figure 18.1 – AI Builder model types

To use these model types, you will need to provide data and train the model. AI Builder includes trained models that you can just add to your apps and flows.

Introducing AI Builder prebuilt models

AI Builder prebuilt models are ML models that Microsoft has trained with vast amounts of data to meet specific business scenarios. Data scientists at Microsoft have evaluated these models for accuracy and verified that they perform well with a vast range of disparate data. You can use these models without having to prepare data and train the models.

AI Builder has the following pre-trained models:

  • Category Classification (Preview): Classifies text into categories associated with customer feedback, such as compliments, issues, and pricing. 
  • Entity Extraction: Recognizes and extracts standard business objects in data, such as dates, countries, names of people, phone numbers, and email addresses.
  • Key Phrase Extraction: Identifies the main talking points from a piece of text. You could use keyphrase extraction to find important phrases from customer feedback comments.
  • Language Detection: Identifies the language used in a piece of text.
  • Sentiment analysis: Detects whether the message in a piece of text has a positive or negative emotional sentiment.
  • Text translation: Translates text from one language into another language. 
  • Business Card Reader: Extracts information from an image of a business card, including the name, email address, company, and job title.
  • Text Recognition: Extracts words from documents and images. Text recognition uses Optical Character Recognition (OCR) on printed and handwritten documents.
  • Receipt Processing (preview): Extracts details from pictures of printed and handwritten receipts. You can use this to extract information from a photo of a receipt and add the data to your expenses system.

The following screenshot shows the prebuilt models in AI Builder:

Figure 18.2 – AI Builder prebuilt models

The prebuilt models are aimed at specific business scenarios. If your scenario does not match that of the existing models, you can create your own model using one of the five model types listed in the previous section.

Building an AI Builder model

The prebuilt AI Builder models have been created to meet common business scenarios. You can build and train your own custom model in AI Builder to meet your business scenario if the models included with AI Builder do not support your needs.

You build and manage models from the Power Apps maker portal (https://make.powerapps.com). To view and build models, click on AI Builder | Models as shown in the following screenshot:

Figure 18.3 – AI Builder in the Power Apps maker portal

AI Builder requires a Common Data Service database in your environment.

A 30-day free trial of AI Builder is available. You can start your trial from the AI Builder area in the Power Apps maker portal.

To build a custom model, click on + Build a model as shown at the top of Figure 18.3 and choose the type of model from the tiles shown in Figure 18.1.

Each model type has slightly different steps when building a model, but they follow the same high-level process:

    • Choose the model type.
    • Name the model.
    • Select or add examples of data or documents.
    • Choose the field that you want to analyze/predict.
    • Train the model.
    • Publish the model.
    • Share the model.

AI Builder uses a wizard to assist you in building a custom model. The following screenshot shows the wizard for the object detection model type:

Figure 18.4 – Building a custom object detection model

The preceding screenshot shows the steps for building a model on the left-hand side of the page. 

You should review the steps for each model type by creating a model for each type and stepping through the wizard. There is sample data available for each model type.

The key to building a successful model is gathering the data you will use to train and test your model. 

Preparing data for a model

ML models are very dependent upon the datasets used to train and test the given model. A frequent problem in ML is overfitting. Overfitting means that the model does not generalize well from training data to unseen data, especially data that is unlike the training data. Common causes include the presence of  bias in the training data, meaning the model cannot distinguish between the signal and the noise.

AI Builder implements many techniques to avoid such problems, but you will need to supply AI Builder with enough data to be able to create a model. The more data and the more varied the data, the better the model will behave.

AI Builder requires the training and test data to be stored in entities in the Common Data Service. If the data does not reside in the Common Data Service, you will need to import the data. You may need to create a custom entity for this data.

AI Builder provides a set of examples and labs with sample data that you can use to learn how to import data and train models. The labs are available at https://docs.microsoft.com/ai-builder/learn-ai-builder

After building your model, you must train the model, and then evaluate the model's performance.

Training and testing a model

Before you can use your model, you must train the model. Training is the automated process by which AI Builder analyzes the data for patterns, determines the algorithm to use, and validates the model.

You train the model from the Model summary page. The following screenshot shows the model summary for an entity extraction model:

Figure 18.5 – Model summary

To train a model, click on the Train button. 

Training a model can take a long time. You can close the portal and view the results later.

When training is complete, you can view the details page for the model, as shown in the following screenshot for an entity extraction model:

Figure 18.6 – Model details

On the model details page, you can perform your own quick tests on the model. In the previous screenshot, you can see some text entered under Test your model. The entity extraction model has identified two products: AI and Common Data Service.

If your model needs refinement, you can use the Edit model button. If you want to use the model, you must publish it first.

After you publish your AI Builder model, only you can use it in your apps and flows. To make your model available to other users, you must share your model. You share the model by clicking the Share button as shown at the top of Figure 18.6.

Using AI Builder models

AI Builder lets you add AI capabilities to the flows and apps you create. The AI models you build allow you to enhance your solutions with AI to extract data from text, recognize objects, and predict outcomes.

In this section, we will look at how you use both the prebuilt models and your custom models in the Power Platform.

Consuming a model using canvas apps

Canvas apps can use prebuilt models and custom models to enhance data. You could use an AI Builder model to analyze text that a user has entered. You can take a picture with a canvas app and use an AI Builder model to extract the text from the image or to detect objects in the image. 

You can use AI Builder models in two ways:

  • By adding AI Builder model controls to a screen
  • By using AI Builder models through the formula bar

The following screenshot shows the AI Builder models you can add as controls to a canvas app screen:

Figure 18.7 – AI Builder controls in Power Apps Studio

These controls are easy to use. The outputs from the controls can be referenced like any other canvas app control. 

The following screenshot shows the screenshot from Figure 18.7 analyzed with the Text recognizer control. The control has identified the text instances in the screenshot and drawn a rectangle around them, as shown in the following figure: 

Figure 18.8 – Text recognizer control in a canvas app

The result from the text recognizer control is a list of detected lines of text. To use AI Builder models from the formula bar, use the AIBuilder  formula, select the model, and then specify the text to analyze. The following example shows how to write a formula to find the sentiment for text entered in a TextInput  control:

AIBuilder.AnalyzeSentiment(TextInput1).sentiment

The next screenshot shows results from several of the AI Builder formulas using the text entered in the input control at the top of the screen. The results from sentiment, language detection, category classification, and key phrase extraction models are shown:

Figure 18.9 – Text AI Builder formula results in a canvas app

The following table shows where you can use custom models in canvas apps:

Model type Control Formula bar
Category Classification - Yes
Entity Extraction - Yes
Form Processing Yes -
Object Detection Yes -
Prediction  - -
The prediction model cannot be used directly in canvas apps. However, the prediction model sets a field with the prediction value. This outcome field can be displayed in a canvas app.

The following table shows where you can use prebuilt models in canvas apps:

Prebuilt model Control Formula bar
Category Classification - Yes
Entity Extraction - Yes
Key phrase Extraction - Yes
Language Detection - Yes
Sentiment Analysis - Yes
Text Translation  - -
Business Card Reader Yes -
Text Recognition Yes -
Receipt Processing Yes -
Text translation is not available with Power Apps. You can use the text translation model with Power Automate.

You can also use a limited set of AI Builder capabilities in model-driven apps.

Consuming a model using model-driven apps

Model-driven apps do not have the same capabilities as canvas apps when it comes to using AI Builder models. Only the Business Card Reader control can be used in a model-driven app.

The business card reader is available in the Dynamics 365 Sales app, in the Quick create form of the Lead entity.

The prediction model cannot be used directly in a model-driven app. However, the prediction model sets a field with the prediction value. This outcome field can be displayed in a model-driven app.

If you need to include AI in a model-driven app, add the AI Builder model to a canvas app and embed the canvas app in a model-driven app form.

Portal apps cannot use AI Builder models, but a data change made to the Common Data Service by a portal user could trigger a Power Automate flow that uses an AI Builder model.

You can use AI Builder with Power Automate to automatically enhance data created and updated in a model-driven app.

Consuming a model using Power Automate

Power Automate can use all the prebuilt models and any custom models in AI Builder to enhance data. You can trigger a Power Automate flow when a record is created, or an image stored. The flow can then use AI models. For example, Power Automate can categorize a new record or predict what will happen to a newly created record.

There is an AI Builder connector that you add to a flow to access the models. The AI Builder connector does not have any triggers but has actions for prebuilt as well as custom models. The following actions are available:

  • Analyze positive or negative sentiment in some text.
  • Classify text into categories with the standard model.
  • Classify text into categories with one of your custom models.
  • Detect and count objects in images.
  • Detect the language being used in some text.
  • Extract entities from the text with the standard model.
  • Extract entities from the text with one of your custom models.
  • Extract the key phrases from the text.
  • Predict.
  • Process and save information from forms.
  • Process and save information from receipts.
  • Read business card information.
  • Recognize text in an image.
  • Translate text into another language.

The following screenshot shows a Power Automate flow that triggers the creation of a record in the Common Data Service and then uses a custom entity extraction model as a step in the flow:

Figure 18.10 – Using an AI Builder model in Power Automate
You can use any of the dedicated actions for each model in AI Builder, or you can use the Predict action. The Predict action allows you to dynamically choose a model using the output of a previous step in the flow.

Congratulations on finishing this chapter! Using AI with the Common Data Service is a new and exciting capability. As it's an example of new functionality, you should make sure you are familiar with the options and processes associated with AI Builder.

Summary

This chapter described the different model types and showed you how to build AI models with AI Builder.

You are now able to build AI models, and use those models in Power Apps and Power Automate. These skills enable you to enhance your data and make predictions using the models you have created.

In the next chapter, we will look at integrating the Power Platform with Microsoft 365; specifically, Microsoft Teams, Word, and Excel. 

Questions

After reading this chapter, test your knowledge with these questions. You will find the answers to these questions in the Assessments chapter at the end of the book:

  1. Which of the following is a model type you can use to create a custom AI Builder model?

A) Business Card Reader
B) Receipt Processing
C) Sentiment Analysis
D) Text Recognition
E) Form Processing

  1. Which AI Builder model type allows you to create a model to forecast a numerical value?

A) Object Detection
B) Sentiment Analysis
C) Prediction
D) Entity Extraction

  1. You have published an AI Builder model and used it in your Power Automate flow. Other users are not able to use the model. What should you do?

A) Publish the model.
B) Share the model.
C) Train the model.
D) Edit the model.

  1. Which AI Builder prebuilt model is available in Dynamics 365 Sales?

A) Business Card Reader
B) Receipt Processing
C) Text Translation
D) Text Recognition

Further reading

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.72.224