Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.25k stars 4.58k forks source link

FormRecognizer SDK not returning the correct value. [BUG] #42505

Open ameenabdullah opened 6 months ago

ameenabdullah commented 6 months ago

Library name and version

Azure.AI.FormRecognizer (4.1.0.0)

Describe the bug

When analyzing the document (custom model) via SDK, it's not returning the correct value. However, when using Studio, it analyzes the values properly. As an example: The value on the document is "Republic of X", which is being analyzed correctly using the Studio, however the SDK returns only "Republic" and missing the rest of the value.

Expected behavior

The SDK should return the value as being shown in the Studio.

Actual behavior

The SDK is not returning the full value.

Reproduction Steps

Upload a document in Document Intelligence Studio and analyze the values. Use SDK to extract the values from same document.

Environment

No response

jsquire commented 6 months ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

tjoudeh commented 6 months ago

To add to the same issue reported by @ameenabdullah, the Content property returned in the Azure.AI.FormRecognizer.DocumentAnalysis.AnalyzeResult contains the correct value "Republic of Turkiye" but the Content property returned in the Azure.AI.FormRecognizer.DocumentAnalysis.DocumentField containes the value "Republic". You can check the debug values in the image below:

image
kinelski commented 6 months ago

Hello.

Please note that Azure.AI.FormRecognizer 4.1.0 targets service version 2023-07-31 by default. Could you confirm if that's the same version you're using in the Studio?

github-actions[bot] commented 6 months ago

Hi @ameenabdullah. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

kinelski commented 6 months ago

In case you need to target newer service versions (2023-10-31-preview or 2024-02-29-preview), you'll need to migrate to the new Azure.AI.DocumentIntelligence package. Azure.AI.FormRecognizer won't be updated anymore.

For more information: README Also check our migration guide: Migration Guide

ihabdamen commented 6 months ago

Hello @kinelski,

To add to the same issue faced by @ameenabdullah

We are using the studio version is 2023-07-31 and the SDK is 4.1.0, The Model is a template Model because Neural model is not supported yet in Qatar Region

image

kinelski commented 6 months ago

To add to the same issue reported by @ameenabdullah, the Content property returned in the Azure.AI.FormRecognizer.DocumentAnalysis.AnalyzeResult contains the correct value "Republic of Turkiye" but the Content property returned in the Azure.AI.FormRecognizer.DocumentAnalysis.DocumentField containes the value "Republic". You can check the debug values in the image below: image

I'm just double checking in case you haven't noticed this, but the images show two different parts of the response.

In the REST API response you're looking at analyzeResult.Content, which in the SDK would be equivalent to doing:

AnalyzeDocumentOperation operation = client.AnalyzeDocument(...);
AnalyzeResult result = operation.Value;

// print the raw content
Console.Write(result.Content);

In the SDK print you're extracting the value from AnalyzeResult.Documents[...].Fields["Nationality"].Content.

Can you confirm that you're getting a different response in the Studio when looking into the returned fields? If the SDK behavior is correct, the JSON response should look like this:

{
  ...
  "analyzeResult": {
    ...
    "documents": [
      {
        ...
        "fields": {
          ...
          "Nationality": {
            "type": "string",
            "content": "Republic",
            ...
          }
        }
      }
    ]
  }
}
ameenabdullah commented 5 months ago

Hello @kinelski Below please find the response from JSON extracted from the Studio:

image image image

and the screenshot from Studio:

Screenshot 2024-03-18 125519