The Document Intelligence general document model is now deprecated with the 2023-10-31 preview, and the documentation specifies that I should use the Layout model with the optional query string parameter features=keyValuePairs enabled if I want to extract key-value pairs, selection marks, text, tables, and structure from documents. I am using the document intelligence Java SDK, and I am not sure how to do this.
I tried the following, but I get an error saying the model was not found:
SyncPoller < OperationResult, AnalyzeResult > analyzeDocumentPoller = client.beginAnalyzeDocumentFromUrl("prebuilt-layout?features=keyValuePairs", "insert-document-url-here");
Here's the error code:
Exception in thread "main" com.azure.core.exception.HttpResponseException: Status code 404, "{"error":{"code":"NotFound","message":"Resource not found.","innererror":{"code":"ModelNotFound","message":"The requested model was not found."}}}"
at com.azure.ai.formrecognizer.documentanalysis.implementation.util.Transforms.getHttpResponseException(Transforms.java:351)
at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.analyzeDocument(DocumentAnalysisClient.java:612)
at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.lambda$analyzeActivationOperation$4(DocumentAnalysisClient.java:555)
at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.lambda$beginAnalyzeDocumentFromUrlSync$0(DocumentAnalysisClient.java:247)
at com.azure.core.util.polling.SimpleSyncPoller.<init>(SimpleSyncPoller.java:65)
at com.azure.core.util.polling.SyncPoller.createPoller(SyncPoller.java:127)
at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.beginAnalyzeDocumentFromUrlSync(DocumentAnalysisClient.java:239)
at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.beginAnalyzeDocumentFromUrl(DocumentAnalysisClient.java:222)
at com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient.beginAnalyzeDocumentFromUrl(DocumentAnalysisClient.java:178)
at FormRecognizer.main(FormRecognizer.java:35)
If I use the regular "prebuilt-layout" model id, the code runs and analyzes the document, but it doesn't return the key-value pairs.
where can I specify features=keyValuePairs so that the model can detect the key value pairs of the document as well?
you need to use the Layout model and set the features parameter correctly. Try this code andnhopefully it works.