Bad parsing of tables and multi-column PDFs is a common hidden cause of wrong RAG answers.
Simple PDF readers extract text in reading order and often scramble tables, multi-column pages, charts and scanned pages. The RAG system then retrieves garbled chunks, and answers suffer.
LlamaParse is LlamaIndex's hosted document platform. Its docs present several products under one API key:
- Parse: converts PDFs, scans and Office files into clean Markdown or JSON, including tables.
- Extract: pulls fields matching a schema you define.
- Classify and Split: sort documents by type and split combined files.
- Index: managed ingestion, embedding and retrieval for RAG.
Older material calls the platform LlamaCloud and uses the llama-parse or llama-cloud-services packages; the current Python SDK is llama-cloud, imported as llama_cloud, and reads the LLAMA_CLOUD_API_KEY environment variable. Parse and Extract have moved to a v2 API, so check the docs for current parameters. It is a paid service with a free allowance; pricing changes, so check the website.
When to use it:
- Many tables, forms, financial reports, slides or scanned pages.
- When parsed text from
SimpleDirectoryReaderlooks wrong on inspection.
When not to: plain text, Markdown or simple PDFs parse fine locally and for free. Also check data policies, because documents are uploaded to a third party.
Whatever parser you use, print a few parsed pages before indexing. Five minutes of looking at parser output can save days of prompt tuning.
The Markdown output works well with MarkdownNodeParser, which keeps table and section structure together.
Example
# pip install llama-cloud ; export LLAMA_CLOUD_API_KEY=llx-...
from llama_cloud import LlamaCloud
from llama_index.core import Document
client = LlamaCloud() # reads LLAMA_CLOUD_API_KEY
file = client.files.create(file="annual_report.pdf", purpose="parse")
result = client.parsing.parse(
file_id=file.id,
tier="agentic", # parsing quality tier
version="latest",
expand=["markdown"],
)
pages = [p.markdown for p in result.markdown.pages]
print(pages[0][:200]) # | Quarter | Revenue | ... (tables as Markdown)
docs = [Document(text=md, metadata={"file_name": "annual_report.pdf", "page": i + 1})
for i, md in enumerate(pages)]
# then: MarkdownNodeParser / SentenceSplitter -> VectorStoreIndexRemember
- LlamaParse parses complex PDFs, tables and scans into Markdown/JSON
- Current SDK:
llama-cloudwithLLAMA_CLOUD_API_KEY; older docs say LlamaCloud/llama-parse - Inspect parsed output before indexing, whatever parser you use
Watch out for
- Uploading confidential documents to a hosted parser without checking your organisation's data policy.