|
13 | 13 | ">\n",
|
14 | 14 | "> #################################################################################\n",
|
15 | 15 | "\n",
|
16 |
| - "This notebook demonstrates how to use **Pro mode** in Azure AI Content Understanding to enhance your analyzer with multiple inputs and optional reference data. Pro mode is designed for advanced use cases, particularly those requiring multi-step reasoning, and complex decision-making (for instance, identifying inconsistencies, drawing inferences, and making sophisticated decisions). The pro mode allows input from multiple content files and includes the option to provide reference data at analyzer creation time.\n", |
| 16 | + "This notebook demonstrates how to use **Pro mode** in Azure AI Content Understanding to enhance your analyzer with multiple inputs and optional reference data. Pro mode is designed for advanced use cases, particularly those requiring multi-step reasoning, and complex decision-making (for instance, identifying inconsistencies, drawing inferences, and making sophisticated decisions). Pro mode allows input from multiple content files and includes the option to provide reference data at analyzer creation time.\n", |
17 | 17 | "\n",
|
18 | 18 | "In this walkthrough, you'll learn how to:\n",
|
19 |
| - "1. Create an analyzer with reference data.\n", |
| 19 | + "1. Create an analyzer with a schema and reference data.\n", |
20 | 20 | "2. Analyze your files using Pro mode.\n",
|
21 | 21 | "\n",
|
22 | 22 | "For more details on Pro mode, see the [Azure AI Content Understanding: Standard and Pro Modes](https://learn.microsoft.com/en-us/azure/ai-services/content-understanding/concepts/standard-pro-modes) documentation."
|
|
48 | 48 | "metadata": {},
|
49 | 49 | "source": [
|
50 | 50 | "## Analyzer template and local files setup\n",
|
51 |
| - "- **analyzer_template**: In this sample we define an analyzer template for invoice contract verification.\n", |
52 |
| - "- **input_docs**: We can have multiple input document files in one folder or designate a single document file location \n", |
53 |
| - "- **reference_dos**: During analyzer creation, we can provide documents that can aid in providing context that references the service at inference time. We will get ocr results for these files if needed, generate a reference jsonl file, and upload these files to a designated Azure blob storage.\n", |
| 51 | + "- **analyzer_template**: In this sample we define an analyzer template for invoice-contract verification.\n", |
| 52 | + "- **input_docs**: We can have multiple input document files in one folder or designate a single document file location. \n", |
| 53 | + "- **reference_docs**: During analyzer creation, we can provide documents that can aid in providing context that the analyzer references at inference time. We will get OCR results for these files if needed, generate a reference JSONL file, and upload these files to a designated Azure blob storage.\n", |
54 | 54 | "\n",
|
55 | 55 | "> For example, if you're looking to analyze invoices to ensure they're consistent with a contractual agreement, you can supply the invoice and other relevant documents (for example, a purchase order) as inputs, and supply the contract files as reference data. The service applies reasoning to validate the input documents according to your schema, which might be to identify discrepancies to flag for further review."
|
56 | 56 | ]
|
|
72 | 72 | "metadata": {},
|
73 | 73 | "source": [
|
74 | 74 | "## Create Azure content understanding client\n",
|
75 |
| - "> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is utility Class which contain the functions to interact with the Content Understanding server. Before Content Understanding SDK release, we can regard it as a lightweight SDK. Fill the constant **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, **AZURE_AI_API_KEY** with the information from your Azure AI Service.\n", |
| 75 | + "> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is utility class that contains the functions, Before the release of the Content Understanding SDK, please consider it a lightweight SDK., Fill in values for the constants **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, **AZURE_AI_API_KEY** with the information from your Azure AI Service.\n", |
76 | 76 | "\n",
|
77 | 77 | "> ⚠️ Important:\n",
|
78 | 78 | "You must update the code below to match your Azure authentication method.\n",
|
|
134 | 134 | "- Generate a reference `.jsonl` file.\n",
|
135 | 135 | "- Upload these files to the designated Azure blob storage.\n",
|
136 | 136 | "\n",
|
137 |
| - "We use **REFERENCE_DOC_SAS_URL** and **REFERENCE_DOC_PATH** that's set in the prerequisite step." |
| 137 | + "We use **REFERENCE_DOC_SAS_URL** and **REFERENCE_DOC_PATH** that's set in the Prerequisites step." |
138 | 138 | ]
|
139 | 139 | },
|
140 | 140 | {
|
|
155 | 155 | "metadata": {},
|
156 | 156 | "source": [
|
157 | 157 | "## Create analyzer with defined schema for Pro mode\n",
|
158 |
| - "Before creating the custom fields analyzer, you should fill the constant ANALYZER_ID with a business-related name. Here we randomly generate a name for demo purpose.\n", |
| 158 | + "Before creating the analyzer, you should fill in the constant ANALYZER_ID with a relevant name to your task. Here, we generate a unique suffix so this cell can be run multiple times to create different analyzers.\n", |
159 | 159 | "\n",
|
160 |
| - "We use **REFERENCE_DOC_SAS_URL** and **REFERENCE_DOC_PATH** that's set up in `.env` file and used in the previous step." |
| 160 | + "We use **REFERENCE_DOC_SAS_URL** and **REFERENCE_DOC_PATH** that's set up in the `.env` file and used in the previous step." |
161 | 161 | ]
|
162 | 162 | },
|
163 | 163 | {
|
|
177 | 177 | ")\n",
|
178 | 178 | "result = client.poll_result(response)\n",
|
179 | 179 | "if result is not None and \"status\" in result and result[\"status\"] == \"Succeeded\":\n",
|
180 |
| - " logging.info(f\"Here is the analyzer detail for {result['result']['analyzerId']}\")\n", |
| 180 | + " logging.info(f\"Analyzer details for {result['result']['analyzerId']}\")\n", |
181 | 181 | " logging.info(json.dumps(result, indent=2))\n",
|
182 | 182 | "else:\n",
|
183 |
| - " logging.info(\n", |
184 |
| - " \"Check your service please, may be some issues in configuration and deployment\"\n", |
| 183 | + " logging.warning(\n", |
| 184 | + " \"An issue was encountered when trying to create the analyzer. \"\n", |
| 185 | + " \"Please double-check your deployment and configurations for potential problems.\"\n", |
185 | 186 | " )"
|
186 | 187 | ]
|
187 | 188 | },
|
188 | 189 | {
|
189 | 190 | "cell_type": "markdown",
|
190 | 191 | "metadata": {},
|
191 | 192 | "source": [
|
192 |
| - "## Use created analyzer to do data analysis of the input documents\n", |
| 193 | + "## Use created analyzer to analyze the input documents\n", |
193 | 194 | "After the analyzer is successfully created, we can use it to analyze our input files.\n",
|
194 |
| - "> NOTE: Pro mode does multi-step reasoning and may take longer time to analyze." |
| 195 | + "> NOTE: Pro mode does multi-step reasoning and may take a longer time to analyze." |
195 | 196 | ]
|
196 | 197 | },
|
197 | 198 | {
|
|
211 | 212 | "metadata": {},
|
212 | 213 | "source": [
|
213 | 214 | "## Delete exist analyzer in Content Understanding Service\n",
|
214 |
| - "This snippet is not required, but it's only used to prevent the testing analyzer from residing in your service. The custom fields analyzer could be stored in your service for reusing by subsequent business in real usage scenarios." |
| 215 | + "This snippet is not required, but it's only used to prevent the testing analyzer from residing in your service. Without deletion, the analyzer will remain in your service for subsequent reuse." |
215 | 216 | ]
|
216 | 217 | },
|
217 | 218 | {
|
|
0 commit comments