Document Intelligence analyze batch documents - InternalServerError

Sergiy Fomkin 0 Reputation points
2025-02-07T13:17:13.14+00:00

Hello. I'am trying to use Azure DocumentIntelligence Batch analysis to anazyle documents that stored in container.

I use js code from [https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest]

When i run it with "prebuilt-layout" model - everything ok and document will be analyzed (I'am trying it on one document).
BUT when i run it with my custom model id (extraction model) - i got an error Error: {code: 'InternalServerError', message: 'An unexpected error occurred.'}.
If I get a list of models, my model will be on the list.

What i'am doing wrong?
Do the custom models supports batch analysis?

Thank You.

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. Prashanth Veeragoni 0 Reputation points Microsoft Vendor
    2025-02-10T04:42:37.37+00:00

    Hi Sergiy Fomkin,

    Welcome to Azure ML Q and A forum. Thank you for posting your query.

    Azure Document Intelligence supports batch analysis for certain models, but not all custom models can process multiple documents at once.

    Before using batch analysis, check if your custom model works on a single document:

    const { DocumentIntelligenceClient } = require("@azure/ai-document-intelligence-rest");
    // Replace with your Azure endpoint and API key
    const endpoint = "https://<your-resource-name>.cognitiveservices.azure.com/";
    const apiKey = "<your-api-key>";
    const modelId = "<your-custom-model-id>"; 
    const documentUrl = "<your-document-url>"; 
    const client = new DocumentIntelligenceClient(endpoint, new AzureKeyCredential(apiKey));
    async function analyzeSingleDocument() {
        try {
            const poller = await client.beginAnalyzeDocument(modelId, documentUrl);
            const result = await poller.pollUntilDone();
            console.log("Analysis Result:", result);
        } catch (error) {
            console.error("Error analyzing document:", error);
        }
    }
    analyzeSingleDocument();
    
    

    If this works, but batch analysis fails, your model may not support batch processing.

    If this fails, check if your model is properly trained and deployed.

    Also Check with model Capabilities:

    To verify if your model supports batch analysis, run this command to list models and their capabilities:

    const models = await client.listModels();
    for await (const model of models) {
        console.log(`Model ID: ${model.modelId}, Status: ${model.status}, Model Type: ${model.modelType}`);
    }
    

    Prebuilt models (e.g., "prebuilt-layout") support batch analysis.

    Custom models (e.g., extraction models) may not support batch analysis.

    Please refer to below document: Document Intelligence Model Support for further clarifications

    https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/overview?view=doc-intel-4.0.0

    And also, Batch document processing may require specific API versions.

    Check the Azure API version in your request URL.

    Use the latest SDK version:

    npm install @azure/ai-document-intelligence-rest
    

    You need to Ensure you are using a REST API version that supports batch processing.

    Azure Document Intelligence only supports certain file formats and sizes. If your document doesn't meet these criteria, it can cause an InternalServerError.

    Supported Formats Unsupported Formats

    PDF (.pdf) Microsoft Word (.docx)

    JPEG (.jpg) Excel (.xlsx)

    PNG (.png) Text (.txt)

    TIFF (.tiff) CSV (.csv)

    If your document is in an unsupported format, convert it before sending it to Azure.

    You need to validate your file size too before deploying your model

    Maximum file size: 50MB

    Maximum page limit: 500 pages per document

    If your file is too large, try compressing it.

    Please refer below document - File Size Limits

    https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/overview?view=doc-intel-4.0.0#limits

    Hope this helps. Do let us know if you any further queries.  

     

    ------------- 

    If this answers your query, do click Accept Answer and Yes for was this answer helpful.

    Thank you.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.