Skip to main content
The extraction JSON schema defines what data to extract from documents using AI. It uses a group-first approach where extractions are organized into logical groups that can be processed in parallel based on their dependencies.

Schema Structure

The schema consists of three main sections:
Documents are automatically processed using VLM (Vision Language Model) parsing with per-page chunking for optimal extraction quality across all document types.

Global Configuration

The config section defines default settings that apply to all groups unless overridden.

Configuration Options

reasoning_enabled is template-level only and cannot be overridden at the group level. It applies to all groups uniformly.

Groups

Groups are the primary organizing principle for extractions. Each group contains its own fields and can override template-level configuration.
All fields within a group are extracted together in a single LLM call, sharing the same document chunks. This makes groups ideal for semantically related fields — information that tends to appear together in the same sections of your documents.

Group-Level Configuration

Each group can have a config object with these options:

Group-Level Properties

Properties available directly at the group level (outside config):

Page-by-Page Groups

Use execution_mode: "per_page" for a repeated table or list that must be read consistently across a whole document, for example bank-statement transactions. Raydocs runs the group’s schema and prompt once per page. The model receives only that page’s parsed chunks, rather than retrieved chunks from elsewhere in the document.
The group result stays flat and preserves page provenance:
Page records are ordered by the input document order, then by page. Their source.document_id and source.page_number always identify the original source page; the internal batch ordinal is not exposed. A source page with no matching items is retained with the schema’s empty value. An inserted blank page in a composed document view has no source provenance and is skipped. Page boundaries are best effort: a row split across pages is not reconstructed in this mode. per_page cannot be combined with iterates_on. A page-by-page group may depend on a normal group, but normal groups and other page-by-page groups cannot depend on a page-by-page group’s list result.

Definitions

The definitions section contains reusable schema components:
Reference definitions in your fields using $ref:

Dependencies and Parallel Processing

Dependencies between groups are automatically computed based on:
  • Field references using mentions (@{group.field})
  • Iteration dependencies (iterates_on)
  • Page-by-page group dependencies (execution_mode: "per_page" may depend on a normal group)
Groups are processed in parallel when their dependencies are satisfied.

Field References (Mentions)

Fields can reference values from other groups:

Iteration

Groups can iterate over arrays using iterates_on:

Reasoning Mode

When enabled, reasoning mode enhances extraction quality by wrapping fields with metadata that records reasoning and sources.

Enabling Reasoning Mode

Field Structure in Reasoning Mode

Eligible fields are wrapped with metadata:

Atomic Fields

The atomic flag controls how fields are wrapped when reasoning mode is enabled.

Default Atomicity Rules

Wrapped by default unless atomic: false
Not wrapped by default unless atomic: true, but their simple fields are wrapped
Not wrapped by default unless atomic: true, but their simple items are wrapped
Follow the atomicity rule of their target types, unless overridden with atomic flag

Examples

When to Use Atomicity Flags

Use atomic: true when

  • Treating a complex object or array as a single unit
  • Needing reasoning about the entire structure
  • The field represents a cohesive concept

Use atomic: false when

  • You don’t need reasoning metadata for a specific field
  • Optimizing output size
  • The field value is straightforward

Writing Effective Search Queries

The search_query property is used by RAG to find relevant document chunks. Writing effective queries is critical for extraction quality.
Write short, dense semantic phrases — NOT natural language sentences. Embedding models compute similarity based on meaning, and unnecessary grammar reduces signal-to-noise ratio.

Best Practices

1

Use Concise Noun Phrases

Avoid imperative verbs like “Find”, “Get”, “Extract” and question phrasing.
2

Remove Stopwords

Words like “the”, “in”, “for”, “of” have negligible embedding value.
3

Add Domain Keywords

Include domain-specific terms for disambiguation.
4

Keep Queries Short (3-10 words)

Anything longer becomes noisy. Anything shorter lacks discriminative power.

Quick Reference

Complex Schema Best Practices

When working with nested objects, arrays, or multiple $ref definitions:

Split Complex Groups

Use atomic: true for Complex Definitions

Complete Example