Bug: DocumentIntelligenceClient, MARKDOWN table Output differs from document intelligence studio table output
output_content_format=ContentFormat.MARKDOWN
- Package Name: azure.ai.documentintelligence
- Package Version: newest
- Operating System: Windows
- Python Version: 3.11.9
Describe the bug We use Document Intelligence Layout Modell to analyze orders. In that case we had today two bugs. The Markdown result differs from the result in the document intelligence studio interface. The difference is that the table columns are not the same. How can we get a markdown with the table columns we see in the document studio interface?
To Reproduce Steps to reproduce the behavior:
- Use our testdocument (PDF) here and look the table: https://documentintelligence.ai.azure.com/studio/layout (See Screenshot)
- Use our testdokument with: output_content_format=ContentFormat.MARKDOWN an look at the table. (See Screenshot) Columns are not the same.
Expected behavior
We expect the table we see in the document intelligence interface from microsoft.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context 2E_Val_240605_VALSP2224A_TECHN_05133305_geschwärzt.pdf
Add any other context about the problem here.
Thanks for the feedback, we’ll investigate asap.
Thank you!!!!! Unfortunately, our customers are currently dissatisfied.
Hi @MyaLeoni , we need more info before further investigation: Are you using the same API version as in SDK in studio? Can you share the http request details in SDK?
Thanks
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @bojunehsu @vkurpad.
In the second screenshot of the Studio result, you are using 2022-08-31. The latest result using 2024-07-31-preview is slightly different due to continuous refinements we make to our models to improve the overall quality. In this case, neither result is perfect. I get the same result whether I request text or markdown as the output format.
However, there may be another issue here. It appears that you are using a custom rendering solution in your first screenshot, which appears to support non-standard markdown since "-->" is rendered as an arrow instead of treating that entire line as a HTML comment. Please view the result using another Markdown viewer.
Finally, please make sure you are using 2024-07-31-preview. Since standard Markdown tables do not support merged cells, earlier versions returned tables with merged cells in MultiMarkdown format which most viewers do not support. In the latest version, we switched to rendering tables as HTML.
Hi @MyaLeoni. 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.
We use Document intelligence as first step of a long AI Agent/ Flow. After the import we use the markdown result for llm calls. The LLM Calls we run with langchain. If we use the html table, we need more tokens. Is this a long term decision?
def use_azure_original_docload(self, url, api_model) -> str:
document_intelligence_client = DocumentIntelligenceClient(endpoint=os.environ["DOCUMENT_LOADER_API_ENDPOINT"], credential=AzureKeyCredential(os.environ["DOCUMENT_LOADER_API_KEY"]))
poller = document_intelligence_client.begin_analyze_document(
api_model,
AnalyzeDocumentRequest(url_source=url),
output_content_format=ContentFormat.MARKDOWN,
)
result: AnalyzeResult = poller.result()
Hi @MyaLeoni , we need more info before further investigation: Are you using the same API version as in SDK in studio? Can you share the http request details in SDK?
Thanks
I am not sure if i understand your question. We tested the same model in Studio as in python. The results are different. In the studio all models give the right table output. In the python code not. api_model="prebuilt-layout" #of the AzureDocumentLoader
wen have updates to 2024-07-31 preview. Now everything is working. In 2023-07-31 (3.1 General Availability) Microsoft has no docx und xlsx support. We used it because of this information: "Document Intelligence public preview releases provide early access to features that are in active development. Features, approaches, and processes may change, prior to General Availability (GA), based on user feedback."
https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/concept-layout?view=doc-intel-4.0.0&tabs=sample-code
Question: Do we get xlsx und docx support in the next GA Version? @YalinLi0312
Yes, the next GA version will support docx and xlsx in the same way as 2024-07-31-preview.
Yes, we will be switching to HTML tables in Markdown as the longer-term solution. We are aware that it consumes more tokens. But given all the limitations of Markdown tables, as you encountered above, we believe this is the best option.
Thanks a lot for the help and information! Can you recommend a news fedd for the future, where we get such information as soon as possible?
We aim to document such changes at What's New, but may not always describe the changes to such level of details. Please feel free to continue asking questions in this forum.