You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a feature suggestion, I would love if this could allow you to plug in an LLM (such as GPT-4o) where images that are included in the content could be sent to the LLM for further understanding. For example, if it was say a bar chart or graph, it would be sent to convert that to a Markdown table and be integrated in the final Markdown output.
Reacted by Gary Williams, Gagan Bansal, Carlo Lucibello, Václav Černý, Deepak Kumar, JP Caparas, Ajjay Kannan, Md. Almas Ali and Adi Koch
I could see something coming back giving us markers of where that content should appear along with the source content in a way that we could handle it as we please. Ex: Send to LLM, upload to a server and link, etc.
As a feature suggestion, I would love if this could allow you to plug in an LLM (such as GPT-4o) where images that are included in the content could be sent to the LLM for further understanding. For example, if it was say a bar chart or graph, it would be sent to convert that to a Markdown table and be integrated in the final Markdown output.
It's already supported, here you go. You need an openai key.
ImageSize: 388x368
# Description:
This image illustrates a comparison of decision accuracy with and without explanations. On the left, there's a computer icon connected to a user symbol, suggesting human-computer interaction. The vertical axis represents the "Accuracy of decisions," ranging from 0.0 to 1.0.
Two dotted lines extend horizontally: one labeled "R only" and another higher up labeled "R+Explanation." A red arrow points upward from "R only" to "R+Explanation," indicating an increase in accuracy with the addition of explanations. The red delta symbol (∆) signifies the improvement, which is greater than zero. A blue question mark next to it suggests uncertainty or inquiry related to this improvement.
At the bottom, the label "B Ours" signifies that this concept is part of the author's work or findings. Overall, the diagram emphasizes the value of explanations in enhancing decision-making accuracy in human-computer interactions.
Reacted by Shaurita D. Hutchins, Steffan Røstvig, Alejandro Latorre, Ivan Shcheklein, Andrii Syrokomskyi and Hokuto Joel Ide
@gagb Would be great to have this as an example in the README! Thanks.
Agreed. IMO, a PDF based example would be best where it is able to do the text in the normal way, but any images in the PDF are sent to the LLM. I think this is a more compelling example to organizations then just PNG's.
Reacted by Shaurita D. Hutchins, Gagan Bansal, Václav Černý, hidara2000 and Piotr Krawiec
As a feature suggestion, I would love if this could allow you to plug in an LLM (such as GPT-4o) where images that are included in the content could be sent to the LLM for further understanding. For example, if it was say a bar chart or graph, it would be sent to convert that to a Markdown table and be integrated in the final Markdown output.
It's already supported, here you go. You need an openai key.
from markitdown import MarkItDown
from openai import OpenAI
This image illustrates a comparison of decision accuracy with and without explanations. On the left, there's a computer icon connected to a user symbol, suggesting human-computer interaction. The vertical axis represents the "Accuracy of decisions," ranging from 0.0 to 1.0.
Two dotted lines extend horizontally: one labeled "R only" and another higher up labeled "R+Explanation." A red arrow points upward from "R only" to "R+Explanation," indicating an increase in accuracy with the addition of explanations. The red delta symbol (∆) signifies the improvement, which is greater than zero. A blue question mark next to it suggests uncertainty or inquiry related to this improvement.
At the bottom, the label "B Ours" signifies that this concept is part of the author's work or findings. Overall, the diagram emphasizes the value of explanations in enhancing decision-making accuracy in human-computer interactions.
Hi! Maybe I did not find the way and is already implemented but that looks more like the description of the image rather than the text extraction for example. Is there any way to customize the prompt?
As a feature suggestion, I would love if this could allow you to plug in an LLM (such as GPT-4o) where images that are included in the content could be sent to the LLM for further understanding. For example, if it was say a bar chart or graph, it would be sent to convert that to a Markdown table and be integrated in the final Markdown output.
This image illustrates a comparison of decision accuracy with and without explanations. On the left, there's a computer icon connected to a user symbol, suggesting human-computer interaction. The vertical axis represents the "Accuracy of decisions," ranging from 0.0 to 1.0.
Two dotted lines extend horizontally: one labeled "R only" and another higher up labeled "R+Explanation." A red arrow points upward from "R only" to "R+Explanation," indicating an increase in accuracy with the addition of explanations. The red delta symbol (∆) signifies the improvement, which is greater than zero. A blue question mark next to it suggests uncertainty or inquiry related to this improvement.
At the bottom, the label "B Ours" signifies that this concept is part of the author's work or findings. Overall, the diagram emphasizes the value of explanations in enhancing decision-making accuracy in human-computer interactions.
Hi! Maybe I did not find the way and is already implemented but that looks more like the description of the image rather than the text extraction for example. Is there any way to customize the prompt?
It can customize prompt, just pass the mlm_prompt to convert method.
Like this:
# ...prompt="extract the objects in the picture, and only output keywords, separated by commas."result=markitdown.convert("path/to/example.jpg", mlm_prompt=prompt)
But the latest version cannot apply the param properly when trying to convert an url file, and I just created a pr to fix it. #48
@gagb Would be great to have this as an example in the README! Thanks.
Agreed. IMO, a PDF based example would be best where it is able to do the text in the normal way, but any images in the PDF are sent to the LLM. I think this is a more compelling example to organizations then just PNG's.
Exactly this. We could use something like PyMuPDF4LLM to extract images and classify them with VLM later, but if this could be done in one step during pdf->md conversion, that would be brilliant!
Agreed. IMO, a PDF based example would be best where it is able to do the text in the normal way, but any images in the PDF are sent to the LLM. I think this is a more compelling example to organizations then just PNG's.
Completely agree.
Basically, in pseudocode:
take in a PDF
go through it and for each image
send the image to an LLM for semantic understanding/text parsing (task TBD by the user)
replace the LLM output in the markdown (inline)
This way, the tool would be really useful, and the last issue to be resolved would be proper table parsing (from pdf)
Reacted by Gagan Bansal, Václav Černý and Ajjay Kannan
In general I would love the ability to use hooks when converting any document containing images.
Every time the converter finds an image, call me back with the byte[] so that I can handle the converstion of the image to text by myself. This may also happen with a local model and not just GPT.
The point is replacing the images with their description in any type of document. I mean that replacement implies keeping the sequence of text/image parts.
Agreed. IMO, a PDF based example would be best where it is able to do the text in the normal way, but any images in the PDF are sent to the LLM. I think this is a more compelling example to organizations then just PNG's.
Completely agree. Basically, in pseudocode:
take in a PDF
go through it and for each image
send the image to an LLM for semantic understanding/text parsing (task TBD by the user)
replace the LLM output in the markdown (inline)
This way, the tool would be really useful, and the last issue to be resolved would be proper table parsing (from pdf)
If I could make one additional suggestion to this excellent pseudocode, it would be to include the ability to get the page number. Very likely this would be possible with the pseudocode, but I point it out because of the importance of this from a citation perspective. When doing RAG, you want to allow a user to go directly in the document to where the answer was generated. Since markdown does not have a concept of page numbers, you need to be able to let them go to something like the original PDF, and having the page number makes that a lot more efficient.
If I could make one additional suggestion to this excellent pseudocode, it would be to include the ability to get the page number.
Liam Cavanagh (@liamca) You should never need that. You can store the page and even more details in the payload that you then associate to the embedding.
Embeddings should never go further than a page and in many cases the amount of text is way too much to get decent results.
I have sketched some of the code that takes care of passing the image to the LLM from the original PDF.
However, the main problem is that in many circumstances pdfminer is unable to properly parse images in the document.
Agreed. IMO, a PDF based example would be best where it is able to do the text in the normal way, but any images in the PDF are sent to the LLM. I think this is a more compelling example to organizations then just PNG's.
Completely agree. Basically, in pseudocode:
take in a PDF
go through it and for each image
send the image to an LLM for semantic understanding/text parsing (task TBD by the user)
replace the LLM output in the markdown (inline)
This way, the tool would be really useful, and the last issue to be resolved would be proper table parsing (from pdf)
Perfect case why we need this feature. As an example, let's look at this slide from a PDF. This md extraction is no where a representation of what the slide conveys
For anyone building RAG pipelines that ingest mixed-content PDFs, the image→LLM→inline-markdown pattern is very useful in production. A few patterns worth sharing:
Using Claude instead of GPT-4o for image understanding:
importanthropicfrommarkitdownimportMarkItDown# Wrap the Anthropic client to match the OpenAI-compatible interface MarkItDown expectsclassAnthropicMLMClient:
def__init__(self):
self.client=anthropic.Anthropic()
defchat_completions_create(self, model, messages, **kwargs):
# adapt from OpenAI format to Anthropic format# ...pass# Or use the native mlm_client if it supports Anthropic protocol
The mlm_prompt parameter already solves the "description vs. extraction" question — you can specify "Convert this chart to a Markdown table with exact values" vs. the default descriptive output.
Page-level citation metadata:
For RAG use cases, the chunk metadata matters as much as the chunk content. The suggestion about page numbers is important — when indexing into pgvector (or any vector store), you want each chunk tagged with at minimum {file, page, element_type} so the retrieval layer can surface the exact source location. Right now markitdown's output is a single flat string — a structured output mode (list of {page, content, element_type}) would make it much more RAG-friendly downstream.
Is there an existing issue tracking structured/segmented output as a feature request? If not, happy to open one.
Activity
dolbex commentedon Dec 13, 2024
I could see something coming back giving us markers of where that content should appear along with the source content in a way that we could handle it as we please. Ex: Send to LLM, upload to a server and link, etc.
janzheng commentedon Dec 13, 2024
maybe as an MCP server? That wouldn't be too hard
gagb commentedon Dec 13, 2024
Relevant: https://github.com/microsoft/markitdown/blob/main/src/markitdown/_markitdown.py#L755
Ive tested an older version of it, but not the new version.
gagb commentedon Dec 13, 2024
It's already supported, here you go. You need an openai key.
Output
ImageSize: 388x368 # Description: This image illustrates a comparison of decision accuracy with and without explanations. On the left, there's a computer icon connected to a user symbol, suggesting human-computer interaction. The vertical axis represents the "Accuracy of decisions," ranging from 0.0 to 1.0. Two dotted lines extend horizontally: one labeled "R only" and another higher up labeled "R+Explanation." A red arrow points upward from "R only" to "R+Explanation," indicating an increase in accuracy with the addition of explanations. The red delta symbol (∆) signifies the improvement, which is greater than zero. A blue question mark next to it suggests uncertainty or inquiry related to this improvement. At the bottom, the label "B Ours" signifies that this concept is part of the author's work or findings. Overall, the diagram emphasizes the value of explanations in enhancing decision-making accuracy in human-computer interactions.sdhutchins commentedon Dec 13, 2024
Gagan Bansal (@gagb) Would be great to have this as an example in the README! Thanks.
liamca commentedon Dec 14, 2024
Agreed. IMO, a PDF based example would be best where it is able to do the text in the normal way, but any images in the PDF are sent to the LLM. I think this is a more compelling example to organizations then just PNG's.
alejlatorre commentedon Dec 14, 2024
Hi! Maybe I did not find the way and is already implemented but that looks more like the description of the image rather than the text extraction for example. Is there any way to customize the prompt?
Soulter commentedon Dec 16, 2024
It can customize prompt, just pass the
mlm_prompttoconvertmethod.Like this:
But the latest version cannot apply the param properly when trying to convert an url file, and I just created a pr to fix it. #48
vaclcer commentedon Dec 18, 2024
Exactly this. We could use something like PyMuPDF4LLM to extract images and classify them with VLM later, but if this could be done in one step during pdf->md conversion, that would be brilliant!
tinosai commentedon Dec 18, 2024
Completely agree.
Basically, in pseudocode:
This way, the tool would be really useful, and the last issue to be resolved would be proper table parsing (from pdf)
gagb commentedon Dec 18, 2024
Fortunato Nucera (@tinosai) Lets move the pdf specific ideas to #131
raffaeler commentedon Dec 25, 2024
In general I would love the ability to use hooks when converting any document containing images.
Every time the converter finds an image, call me back with the byte[] so that I can handle the converstion of the image to text by myself. This may also happen with a local model and not just GPT.
The point is replacing the images with their description in any type of document. I mean that replacement implies keeping the sequence of text/image parts.
liamca commentedon Jan 7, 2025
If I could make one additional suggestion to this excellent pseudocode, it would be to include the ability to get the page number. Very likely this would be possible with the pseudocode, but I point it out because of the importance of this from a citation perspective. When doing RAG, you want to allow a user to go directly in the document to where the answer was generated. Since markdown does not have a concept of page numbers, you need to be able to let them go to something like the original PDF, and having the page number makes that a lot more efficient.
raffaeler commentedon Jan 7, 2025
Liam Cavanagh (@liamca) You should never need that. You can store the page and even more details in the payload that you then associate to the embedding.
Embeddings should never go further than a page and in many cases the amount of text is way too much to get decent results.
tinosai commentedon Jan 7, 2025
I have sketched some of the code that takes care of passing the image to the LLM from the original PDF.
However, the main problem is that in many circumstances pdfminer is unable to properly parse images in the document.
We need to replace pdfminer IMHO.
AjjayK commentedon May 1, 2025
Perfect case why we need this feature. As an example, let's look at this slide from a PDF. This md extraction is no where a representation of what the slide conveys
IgnazioDS commentedon Jun 8, 2026
For anyone building RAG pipelines that ingest mixed-content PDFs, the image→LLM→inline-markdown pattern is very useful in production. A few patterns worth sharing:
Using Claude instead of GPT-4o for image understanding:
The
mlm_promptparameter already solves the "description vs. extraction" question — you can specify"Convert this chart to a Markdown table with exact values"vs. the default descriptive output.Page-level citation metadata:
For RAG use cases, the chunk metadata matters as much as the chunk content. The suggestion about page numbers is important — when indexing into pgvector (or any vector store), you want each chunk tagged with at minimum
{file, page, element_type}so the retrieval layer can surface the exact source location. Right now markitdown's output is a single flat string — a structured output mode (list of{page, content, element_type}) would make it much more RAG-friendly downstream.Is there an existing issue tracking structured/segmented output as a feature request? If not, happy to open one.