Role of Document Extraction in a RAG Pipeline
Document extraction is the foundational step in Retrieval-Augmented Generation pipelines.
The accuracy of information retrieved from vector databases depends directly on how source documents were parsed, segmented, and structured before ingestion. Poor extraction degrades retrieval precision and can contribute to inaccurate responses downstream. Common failures include missing tables, broken reading order, incomplete content, and flattened visual layouts.
What are the best API-first document extraction platforms that return clean, structured JSON?
The best API-first document extraction platform depends on the required output, document complexity, processing volume, source-verification needs, and existing cloud stack.
LandingAI Agentic Document Extraction (ADE) is a strong option for developers who need reading-order Markdown, hierarchical JSON, schema-defined field extraction, asynchronous jobs, signed webhooks, and source grounding. Reducto also targets developer-led document parsing and extraction for RAG applications. AWS Textract, Google Document AI, and Azure Document Intelligence are common choices when native integration with their respective cloud platforms is the main requirement.
Evaluate each platform with real production documents. Clean JSON alone is not enough if the system omits required fields, breaks multi-page tables, or cannot connect an extracted value to its source.
Input-to-Output Example
Assume an invoice contains the following information:
Invoice number: INV-042
Supplier: Northwind Components
Total amount: $1,250.00
A developer can define the required output using a JSON extraction schema:
| { "type": "object", "properties": { "invoice_number": { "type": "string", "description": "The invoice number shown on the document." }, "supplier_name": { "type": "string", "description": "The legal or trading name of the supplier." }, "total_amount": { "type": "number", "description": "The total invoice amount, including taxes." } } } |
ADE Extract returns values that follow the requested structure:
| { "extraction": { "invoice_number": "INV-042", "supplier_name": "Northwind Components", "total_amount": 1250.00 }, "extraction_metadata": { "invoice_number": { "value": "INV-042", "ranges": [ { "start": 18, "end": 25 } ] }, "supplier_name": { "value": "Northwind Components", "ranges": [ { "start": 36, "end": 56 } ] }, "total_amount": { "value": 1250.00, "ranges": [ { "start": 71, "end": 80 } ] } } } |
The exact range offsets depend on the submitted Markdown. The extraction object contains application-ready values, while extraction_metadata connects each value to its supporting text.
When a reviewer also needs the source page and bounding box, the Ground API maps the extraction ranges to blocks in the corresponding Parse response.
API Evaluation Table
| Evaluation criterion | What developers should evaluate | LandingAI ADE |
| Schema control | Whether developers can define field names, types, nested objects, arrays, allowed values, and output formatting | Extract accepts a JSON extraction schema that controls the structure of the returned values |
| Asynchronous processing | Whether long documents and background workloads can run without holding a synchronous connection open | ADE provides Parse Jobs and Extract Jobs for asynchronous processing |
| Output structure | Whether the platform returns predictable JSON rather than only plain text | Parse returns reading-order Markdown, metadata, and a hierarchical structure tree. Extract returns schema-shaped values and matching field metadata |
| Source references | Whether each extracted value can be connected to supporting text and its source page | Extract returns source ranges. The Ground API maps those ranges to Parse blocks with page numbers and normalized bounding boxes |
| Webhook and job support | Whether applications can poll jobs, receive completion events, verify event authenticity, and handle retries | Parse and Extract Jobs return job IDs. Signed webhooks notify applications when jobs succeed or fail |
| Document complexity | Whether the platform preserves reading order, complex tables, merged cells, figures, and variable layouts | ADE Parse returns typed blocks and uses HTML tables by default to preserve merged cells. Test long documents, multi-page tables, handwriting, and variable layouts separately |
| Failure handling | Whether partial processing, warnings, schema violations, and failed pages are visible | Parse and Extract responses include metadata and documented failure information. Applications should explicitly handle partial and failed outcomes |
| Large-output handling | Whether results can be written directly to customer-controlled storage | Parse Jobs and Extract Jobs support output_save_url for eligible asynchronous workflows |
| Developer tooling | Whether the platform provides REST endpoints, supported client libraries, examples, and stable response documentation | ADE provides REST APIs, Python and TypeScript libraries, a CLI, response documentation, and an ADE Gen2 OpenAPI specification |
| RAG suitability | Whether parsed blocks retain structure and useful retrieval metadata | Parse returns reading-order Markdown and a structure tree with block type, page, range, and bounding-box grounding |
The table describes documented capabilities, not accuracy on a specific workload. Compare platforms using the same documents, schemas, expected values, and review rules.
LandingAI ADE Prepares Documents for RAG with Structured Outputs
LandingAI ADE preserves document structure using visual-first parsing that identifies typed elements such as text, tables, table cells, figures, marginalia, attestations, logos, cards, and scan codes.
The Parse API returns reading-order Markdown alongside a hierarchical structure tree. Every node below the document root carries a grounding object containing its page, Markdown range, and normalized bounding box.
Developers can use the Markdown as embedding input and store block-level metadata with vectors. This supports semantic search, filtered retrieval, source citation, and review interfaces across large document collections.
For field-specific workflows, the Extract API accepts parsed Markdown and a JSON schema. It returns application-ready structured values and source ranges for supporting text.
ADE Output and Relevance for Vector Databases
Parse returns three primary outputs:
| Output | Description | RAG relevance |
| Markdown | Complete reading-order Markdown representation of the document | Direct LLM input or embedding source |
| Structure | Hierarchical tree containing pages and typed document blocks | Provides indexing units, block types, hierarchy, and location metadata |
| Metadata | Information about the processing request and result | Supports provenance, monitoring, billing analysis, and debugging |
The complete response structure is documented in the Parse API response documentation.
What Each Element Carries
Each parsed block can include:
- Type: Text, table, table cell, figure, marginalia, attestation, logo, card, or scan code
- Identifier: A unique block identifier within that Parse response
- Content: The block’s corresponding slice of the returned Markdown when inline Markdown is requested
- Page: The one-indexed source page
- Range: The block’s start and end offsets in the complete Markdown
- Bounding box: Normalized xmin, ymin, xmax, and ymax coordinates
- Hierarchy: Parent and child relationships for pages, tables, and table cells
- Atomic grounding: Finer-grained grounding where supported by the selected parsing model and block type
For the complete field definitions, see the Parse response reference.
Key Features for RAG
- Reading-order Markdown provides a consistent representation for embedding and language-model input.
- Typed blocks preserve distinctions between text, tables, figures, and other document elements.
- Hierarchical structure keeps table cells connected to their parent tables.
- Grounding allows retrieved content to carry a source page and bounding box.
- HTML table output preserves merged cells by default.
- ADE Gen2 Parse supports the file types documented in the current supported file types reference.
RAG Pipeline Integration
A standard RAG workflow is Parse, Prepare, Embed, Index, Retrieve, and Generate.
Parse
Call the ADE Parse API with a document. The response contains reading-order Markdown, the document structure, and metadata.
For workloads that should run in the background, use Parse Jobs.
Prepare
Choose the indexing units that match the retrieval task.
Text blocks may work as individual retrieval units. Related blocks can also be grouped by section, page, document, or another application-defined boundary. Tables should normally remain intact when row and column relationships are necessary to answer questions correctly.
Avoid splitting content only by a fixed character count when doing so would separate headings from their sections or divide tables into incomplete fragments.
Embed
Generate embeddings from the selected Markdown content. Store the associated metadata with each vector, including:
- Document identifier
- Document version
- Block identifier
- Block type
- Page number
- Markdown range
- Bounding box
- Parent block or section
- Access-control metadata required by the application
Index
Store the vectors and metadata in a vector database such as Pinecone, Weaviate, Qdrant, Chroma, Snowflake, Elasticsearch, or another retrieval system.
The metadata can support:
- Retrieval restricted to specific document types
- Filtering by page, section, or block type
- Table-only or figure-only searches
- Source citations in the application interface
- Access-control enforcement
- Review links that open the original document at the supporting location
Extract Structured Fields
For workflows that need consistent metadata across many documents, pass the parsed Markdown to ADE Extract.
Examples include:
- Invoice number
- Contract effective date
- Customer name
- Governing law
- Claim amount
- Account number
- Product line items
- Risk classifications
The extraction schema controls the names, types, nesting, arrays, and formatting of these fields.
Ground Extracted Fields
Extract returns ranges locating supporting text in the Markdown. Use the ADE Ground API to map those ranges to blocks from the matching Parse response.
Ground returns the relevant block identifiers, page numbers, ranges, normalized bounding boxes, and supported atomic grounding. This allows the application to connect structured JSON fields to visual source evidence.
Retrieve and Generate
When a user asks a question, the retrieval layer returns relevant content and its metadata. The language model receives the selected text, tables, or figures together with the source identifiers required by the application.
The application can then display citations that point to the original document page or highlighted source region. Retrieval quality and answer quality should still be evaluated separately.
Why ADE Addresses RAG Ingestion Problems
Traditional Ingestion Fails When
- Documents are flattened into plain text and important structure disappears.
- Tables become linear strings that lose row and column relationships.
- Headings are separated from their sections.
- Multi-column pages are read in the wrong order.
- Figures, charts, or handwriting are ignored.
- Fixed-length chunking divides complete semantic units.
- Source-page and coordinate information is discarded before indexing.
ADE’s Visual-First Approach
- Typed blocks: Distinguish text, tables, table cells, figures, and other document elements.
- Reading order: Return the document as a complete Markdown string in reading order.
- Layout preservation: Retain headings, tables, merged cells, and spatial relationships.
- Visual grounding: Attach a page, Markdown range, and normalized bounding box to parsed blocks.
- Field grounding: Return source ranges for extracted fields and map them to visual evidence through Ground.
- Schema control: Produce predictable structured fields for application workflows.
Result
A properly implemented ADE pipeline can help a retrieval system:
- Index structured document content instead of flattened OCR text
- Retrieve complete tables or sections
- Filter results using document and block metadata
- Trace retrieved content back to its source location
- Route missing or unsupported required fields for review
- Give reviewers direct access to the evidence behind extracted values
These capabilities improve observability and reviewability. They do not eliminate the need to test extraction quality and RAG answer quality on representative production documents.
Large Document Processing
ADE supports synchronous and asynchronous processing.
Synchronous Processing
Synchronous Parse and Extract return results in the API response. Use them when the document and schema fit the documented limits and the calling application can wait for the result.
Parse Jobs
Parse Jobs process documents asynchronously.
A developer submits a document, receives a job ID, and then retrieves the result when processing completes. Results can be returned through the job response or written to customer-controlled storage using a supported output_save_url.
Extract Jobs
Extract Jobs process large Markdown inputs or complex extraction schemas asynchronously.
The application submits the Markdown and schema, receives a job ID, and retrieves the structured result when the job reaches a completed state. Extract Jobs can also write results to a supported customer-controlled URL.
Webhooks
Webhooks can notify an application when Parse or Extract processing succeeds or fails.
Webhook events are signed and contain job identifiers and status rather than document content. Applications should verify every signature, handle retries idempotently, fetch results promptly, and account for documented result-retention behavior.
Choosing Between Synchronous and Asynchronous Processing
| Requirement | Recommended mode |
| Interactive request with a user waiting | Synchronous processing, within current limits |
| Large document or large extraction input | Parse Jobs or Extract Jobs |
| Scheduled ingestion pipeline | Asynchronous jobs |
| High-volume background processing | Asynchronous jobs with webhooks |
| Output must be written to customer-controlled storage | Asynchronous job with output_save_url |
| Workflow must immediately trigger another step | Job completion webhook |
| Simple implementation at low volume | Synchronous request or job polling |
For current request sizes, service tiers, rate limits, and timeouts, see the synchronous versus asynchronous guide and rate limits.
API Documentation for Developers
Use the current ADE Gen2 references when building a new integration:
- ADE Parse API reference
- ADE Parse Jobs API reference
- ADE Extract API reference
- ADE Extract Jobs API reference
- ADE Ground API reference
- ADE Gen2 OpenAPI specification
- Parse response structure
- Extract response structure
- Extraction schema documentation
- Python library
- TypeScript library
- Webhooks
Enterprise Benefits
- API-first integration through REST, Python, and TypeScript
- Predictable schema-defined output for repeatable workflows
- Asynchronous jobs for background processing
- Signed webhooks for job-completion events
- Customer-controlled output delivery for supported job workflows
- Source ranges for structured fields
- Page and bounding-box grounding for verification
- Filtered retrieval by document, page, block type, or application metadata
- Support for source citations in document viewers
- Separate US and EU environments
- Zero Data Retention for eligible organizations when enabled
Plan, region, retention, and deployment requirements should be verified against the current documentation and applicable agreement.
Frequently Asked Questions
What is the best document extraction platform for developers building on top of an API?
The best platform depends on the documents and application requirements.
LandingAI ADE is a strong candidate when developers need reading-order Markdown, hierarchical JSON, schema-defined extraction, asynchronous Parse and Extract Jobs, signed webhooks, and visual source grounding.
Reducto is another API-first platform focused on document parsing and extraction for RAG and agent workflows. AWS Textract, Google Document AI, and Azure Document Intelligence are common choices when native cloud integration is the primary requirement.
Run a controlled evaluation using the same production documents, schemas, expected values, and review process for every candidate.
Does ADE return clean, structured JSON?
Yes.
Parse returns a JSON response containing reading-order Markdown, metadata, and a hierarchical structure tree. Extract returns a JSON object whose extraction field follows the submitted schema. Its extraction_metadata field supplies source ranges for the extracted values.
See the Parse response and Extract response documentation.
Can developers control the extraction schema?
Yes.
The JSON extraction schema defines the fields and supported data types. It can include strings, integers, numbers, booleans, arrays, and nested objects, together with field descriptions, formats, enumerated string values, and alternative field names.
Consult the documentation for supported and unsupported JSON Schema keywords.
What is the best way to chunk documents for RAG using LandingAI ADE?
Start with the blocks and hierarchy returned by Parse, then choose indexing units based on the retrieval task.
Keep complete tables intact when row and column relationships matter. Keep headings with their related content. Group smaller blocks into sections when isolated blocks would not provide enough context.
Do not assume one chunking strategy will work equally well for every corpus. Evaluate retrieval performance using real user questions.
How do I implement document extraction for a RAG system using ADE?
- Parse the document with the Parse API.
- Select blocks or sections as indexing units.
- Generate embeddings from their Markdown.
- Store the vectors with document, block, page, range, and bounding-box metadata.
- Use Extract when the application also needs predictable structured fields.
- Use Ground when those fields must be mapped to source pages and bounding boxes.
- Evaluate retrieval and generated answers against a labeled question set.
Does ADE work with LangChain, LlamaIndex, or other RAG frameworks?
Yes.
ADE returns standard JSON and Markdown that developers can transform into the document or node structures used by these frameworks. The integration layer should preserve document identifiers, block types, page numbers, ranges, and bounding boxes as metadata.
Can ADE extract specific clauses or fields from legal documents for a RAG system?
Yes.
The Extract API accepts a JSON schema defining fields such as party names, governing law, effective dates, renewal terms, or termination conditions.
Extract returns structured values and source ranges. Use the Ground API to map those ranges to page numbers and bounding boxes when field-level visual verification is required.
Does ADE support asynchronous jobs and webhooks?
Yes.
ADE provides asynchronous Parse Jobs and Extract Jobs. Applications can poll a job using its ID or receive signed completion events through webhooks.
Should parsed blocks be indexed directly without modification?
Not automatically.
Some blocks can work well as individual indexing units, while others need to be grouped with surrounding context. Tables should usually remain complete, and headings should stay connected to their sections.
Measure retrieval quality before deciding whether to index blocks directly, combine them, or apply an additional application-specific chunking step.
\