Owen
Owen

Reputation: 47

Is there a way of tagging custom extraction models via the Azure Document Intelligence Studio UI?

Or even updating an existing model with tags via the FormRecognizer or DocumentIntelligence SDKs?

I noticed that the Azure.AI.FormRecognizer.DocumentAnalysis.DocumentModelSummary exposes a Tags collection which would be super useful for filtering my models so this is what I'm trying to set, however I don't see any way of tagging the models to begin with.

I've hunted around numerous versions of both the FormRecognizer or DocumentIntelligence SDKs, and spent a lot of time googling to no avail.

Upvotes: 0

Views: 196

Answers (1)

Suresh Chikkam
Suresh Chikkam

Reputation: 3413

however I don't see any way of tagging the models to begin with.

The DocumentModelSummary class indeed exposes the Tags property, allowing developers to manage tags associated with a document model.

  1. Initialize a FormRecognizerClient object.
  2. Retrieve the existing model summary using the GetModelSummaryAsync method.
  3. Update the Tags property of the model summary with the desired tags. The tags are represented as a dictionary where the key is the tag name, and the value is a ModelTag object.
  4. Call the UpdateModelAsync method to apply the changes to the model.

Code:

using Azure;
using Azure.AI.FormRecognizer;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Create a new FormRecognizerClient
        var client = new FormRecognizerClient(new Uri("<YOUR_ENDPOINT>"), new AzureKeyCredential("<YOUR_API_KEY>"));

        // Get the existing model summary
        var modelSummary = await client.GetModelSummaryAsync("<MODEL_ID>");

        // Update the tags
        modelSummary.Value.Tags = new Dictionary<string, ModelTag>
        {
            { "InvoiceNumber", new ModelTag("InvoiceNumber") },
            { "Date", new ModelTag("Date") },
            { "TotalAmountDue", new ModelTag("TotalAmountDue") }
        };

        // Update the model
        await client.UpdateModelAsync("<MODEL_ID>", modelSummary.Value);
    }
}

Reference:

Upvotes: 0

Related Questions