Hello @ajo , Thanks for sharing detailed infromation.
I have reproduced the same on my end with pre-built Layout
model using 2023-10-31-preview version
and I was able to successfully extract key-value pairs using Document Intelligence studio and python SDK.
Make sure to install the Azure AI Document Intelligence client library for Python with pip:
pip install azure-ai-documentintelligence==1.0.0b1
Here is the sample code to enable keyValuePair
feature:
from azure.core.credentials import AzureKeyCredential
from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.ai.documentintelligence.models import DocumentAnalysisFeature, AnalyzeResult
poller = document_intelligence_client.begin_analyze_document(
"prebuilt-layout", analyze_request=f, features=[DocumentAnalysisFeature.KEY_VALUE_PAIRS], content_type="application/octet-stream"
)
print("----Key-value pairs found in document----")
if result.key_value_pairs:
for kv_pair in result.key_value_pairs:
if kv_pair.key:
print(f"Key '{kv_pair.key.content}' found within " f"'{kv_pair.key.bounding_regions}' bounding regions")
if kv_pair.value:
print(
f"Value '{kv_pair.value.content}' found within "
f"'{kv_pair.value.bounding_regions}' bounding regions\n"
)
Output:
To analyze add-on capabilities, you can refer this sample code: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_analyze_addon_languages.py
The document you are processing may not contain any key-value
pairs: you can try enabling the keyValuePairs
option under the Analyze options for the Layout model in the DI studio. This option is available as an optional detection feature and needs to be selected in order to extract key-value pairs from the document.
I hope this helps.
Regards,
Vasavi
-Please kindly accept the answer and vote 'yes' if you feel helpful to support the community, thanks.