Skip to content

LlamaParse - Document Parsing for RAG Cheatsheet

LlamaParse - Document Parsing for RAG Cheatsheet

LlamaParse is a document parsing service from the LlamaIndex team, built specifically for LLM and RAG pipelines. Its focus is the hard case: PDFs with complex tables, multi-column layouts, figures, and embedded charts that generic text extractors flatten into unusable text. It outputs clean Markdown that preserves structure, and its distinguishing feature is natural-language parsing instructions — you describe how the document is laid out and what to do with it, rather than configuring extraction rules.

LlamaParse is a hosted service with a free tier (API key required). For fully local parsing see Docling or Marker.

Installation

MethodCommand
pippip install llama-parse
With LlamaIndexpip install llama-index llama-parse
API keyexport LLAMA_CLOUD_API_KEY="llx-..."
Verifypython -c "from llama_parse import LlamaParse; print('ok')"

Basic Parsing

from llama_parse import LlamaParse

parser = LlamaParse(result_type="markdown")
documents = parser.load_data("./report.pdf")
print(documents[0].text)
ParameterPurpose
result_type"markdown" (structure-preserving) or "text"
num_workersParallel page processing
verboseProgress output
languageDocument language hint
parsing_instructionNatural-language guidance (below)

Parsing Instructions (the differentiator)

parser = LlamaParse(
    result_type="markdown",
    parsing_instruction="""
    This is a financial report. Preserve all tables as Markdown tables.
    For each chart, write a one-paragraph description of the trend it shows.
    Ignore page headers and footers.
    """,
)

You describe the document and desired handling in plain language rather than writing extraction code — useful for domain-specific layouts (invoices, scientific papers, legal contracts) where generic parsers do poorly.

Async & Batch

import asyncio

async def parse_many(paths):
    parser = LlamaParse(result_type="markdown", num_workers=8)
    return await parser.aload_data(paths)

docs = asyncio.run(parse_many(["a.pdf", "b.pdf", "c.pdf"]))
MethodUse
load_data(path)Single file, synchronous
aload_data([paths])Async, multiple files
get_json_result(path)Structured JSON with page metadata
get_images(...)Extract embedded images

Supported Inputs

FormatNote
PDFPrimary target, including scanned (OCR)
DOCX / PPTX / XLSXOffice formats
HTMLWeb documents
ImagesPNG/JPEG via OCR

Wiring into a RAG Pipeline

from llama_parse import LlamaParse
from llama_index.core import VectorStoreIndex
from llama_index.core.node_parser import MarkdownElementNodeParser

docs = LlamaParse(result_type="markdown").load_data("./manual.pdf")

# Markdown-aware chunking keeps tables and sections intact
node_parser = MarkdownElementNodeParser()
nodes = node_parser.get_nodes_from_documents(docs)

index = VectorStoreIndex(nodes)

Pairing Markdown output with a Markdown-aware node parser is the point: tables survive parsing and chunking, which is where most RAG pipelines lose tabular facts.

Handling Tables Well

TechniqueWhy
result_type="markdown"Tables become Markdown grids
Parsing instruction for tablesForce consistent table handling
MarkdownElementNodeParserKeeps a table in one chunk
Row-per-sentence serializationMakes individual rows retrievable

Cost & Practical Notes

ConsiderationDetail
Hosted serviceDocuments are sent to LlamaCloud
Free tierLimited pages per day
CachingRe-parsing the same file can reuse results
PrivacyFor sensitive documents prefer local parsers

LlamaParse vs Local Parsers

AspectLlamaParseDoclingMarker
HostingCloud serviceLocalLocal
Complex tablesVery strongStrongGood
Custom instructionsNatural languageConfigConfig
PrivacyData leaves your machineFully localFully local
Best forHard layouts, quick resultsSelf-hosted RAG ingestionGPU bulk conversion

For privacy-sensitive corpora use Docling; for bulk local conversion use Marker.

Resources