Producing Clean, Grounded Document Representations for RAG and Agents
This lesson explains how Content Understanding produces Markdown that preserves document structure and links content to its source, avoiding the lost headings, scrambled columns and broken tables of raw extracted text.
Learning outcomes
After completing this lesson, you will be able to:
- Explain why Markdown suits retrieval and language models.
- Use spans and structural elements to ground content in its source.
- Describe the prebuilt analyzers designed for RAG.
- Fix common document representation problems at ingestion.
Why Markdown
A PDF stores characters and their positions on a page, not the reading order or the structure that a person sees. When plain text is extracted from it, a two-column page can come out as alternating half-lines from each column, a table becomes a run of numbers without row or column labels, and headings look like ordinary sentences. A model that receives this text has to guess at the structure, and a chunker that splits it by length cuts through tables and sections. Both problems lower answer quality before retrieval or generation even begins.
Markdown keeps a document's structure in plain text: headings (#, ##), lists, tables in pipe format and figure placeholders or descriptions. Language models read Markdown well, chunkers can split it at headings, and tables remain intact as single units. A clean representation also removes page headers, footers and page numbers that would otherwise repeat in every chunk.
The following screenshot shows the Markdown tab for the same invoice. Headings, key-value lines and the line-item table keep their structure, so a chunk of this text still shows which value belongs to which label.

Grounding information
Content Understanding returns, alongside the Markdown, structural elements (pages, paragraphs, sections, tables, figures) and spans that map each element to its offset in the Markdown and its position in the source document. When content is chunked and indexed with these page and position details, an answer can cite "Contract 2291, page 7, section 4.2" and link to the exact region. Fields carry the same grounding, so an extracted value can be shown with its source.
Prebuilt analyzers for RAG
An analyzer is the Content Understanding configuration that defines what to extract from a type of content. Prebuilt analyzers are supplied by Microsoft and need no configuration. Some target business fields, such as invoice totals, while the search analyzers target retrieval: they produce a clean, structured representation of the whole file that can be chunked and indexed for RAG and agents.
prebuilt-documentSearch is designed for retrieval: it returns Markdown with layout, descriptions of figures (charts and diagrams described in text) and a document summary. The image, audio and video search analyzers do the same for other modalities. The following list shows how the output is used.
-
Analyze
Analyze each new document with the search analyzer.
-
Chunk
Split the Markdown at headings into chunks, keeping tables whole.
-
Index
Index chunks with the summary, title, page numbers and source path.
-
Retrieve and cite
Agents and RAG applications retrieve chunks and cite page and section.
The following screenshot shows the prebuilt-documentSearch analyzer on a two-column résumé. The Markdown follows the reading order, keeping each column's headings and paragraphs together instead of mixing lines from both columns.

Common representation problems
Poor document representations are a frequent root cause of weak RAG answers, and they are easier to fix at ingestion than at query time. Each typical problem has a recognizable symptom and a standard fix. The following table lists them.
| Problem | Symptom | Fix |
|---|---|---|
| Repeated headers and footers | Many chunks share the same boilerplate text and rank highly for unrelated queries | Use layout output that labels and removes page headers and footers |
| Tables split across chunks | Answers miss values or mix rows from different tables | Chunk at headings and keep each table whole |
| Charts and diagrams ignored | Questions about figures return nothing | Use an analyzer that generates figure descriptions |
| Multi-column text out of order | Sentences from different columns are joined | Use layout analysis that reads columns in order |
| No page or section metadata | Answers cannot cite their source location | Index spans, page numbers and section headings with each chunk |
Fix the representation
An agent that reads uploads
Users upload 50-page technical reports to an agent and ask questions about their tables and charts. The agent's answers about charts are often wrong because the extracted text contains only axis labels.
Process uploads with prebuilt-documentSearch (exposed to the agent as a tool or run on upload), so charts are described in text and tables are preserved in Markdown, and give the agent the Markdown with page references. Increasing the model size would not recover information missing from the extracted text.
Why convert documents to Markdown for RAG?
Show answer
Markdown keeps headings and tables, which helps chunking and lets models read the structure.
Exam Tips
Remember for the exam
- Markdown preserves headings and tables for chunking and model reading.
- Spans and page numbers let answers cite exact sources.
- prebuilt-documentSearch adds figure descriptions and a summary for RAG.