AI Model & Extraction Modes
Choosing an AI Model
The Assistant Config section lets you choose which AI model processes your documents and how it behaves.
Supported AI Providers
| Provider | Available Models | Strengths |
|---|---|---|
| OpenAI | gpt-4o, gpt-4o-mini, o4-mini | Best overall accuracy, strong multilingual support |
| Google Gemini | gemini-2.0-flash, gemini-2.5-pro | Fast processing, excellent for long documents |
| Anthropic | claude-sonnet-4-5, claude-haiku-4-5 | Strong reasoning, good at following complex instructions |
| DeepSeek | deepseek-chat, deepseek-reasoner | Cost-effective, good for structured extraction |
| Qwen | qwen-plus, qwen-turbo | Strong Chinese and multilingual documents |
| Kimi | moonshot-v1-8k, moonshot-v1-32k | Long document handling |
Writing Effective Instructions
The Instructions field is the most important configuration in your template. Write clear, specific directions for the AI:
Good example:
You are a Thai tax invoice data extraction assistant.
Extract all fields from the invoice exactly as they appear. Follow these rules:
- Dates must be in YYYY-MM-DD format. Thai Buddhist Era (B.E.) dates should be converted to C.E. (subtract 543).
- All monetary values must be numbers without commas or currency symbols.
- If a field is not present in the document, return null for that field.
- For vendor and customer tax IDs, extract the 13-digit Thai tax identification number.
- Line items should include every row in the items table, even if quantities are unclear.Avoid vague instructions like:
Extract the invoice data.Instruction Writing Tips
- State the document type — Tell the AI what kind of document it is processing.
- Specify output rules — Date formats, number formats, null handling.
- Handle edge cases — What should the AI do when a field is missing or ambiguous?
- Language guidance — If documents are in Thai, mention it. Tell the AI whether to translate or preserve original text.
- Validation rules — "The total_amount must equal subtotal + vat_amount."
TIP
Be as specific as possible in your instructions. Instead of "extract the date", write "extract the invoice issue date and return it in YYYY-MM-DD format; convert Thai Buddhist Era dates by subtracting 543." Specificity directly improves extraction consistency.
Temperature and TopP
These parameters control AI output randomness:
| Parameter | Range | Recommendation |
|---|---|---|
| Temperature | 0.0 – 2.0 | Use 0.1 – 0.3 for extraction tasks. Lower values = more deterministic, consistent results. |
| TopP | 0.0 – 1.0 | Leave at 1.0 unless you have a specific reason to change it. |
For document extraction, always use a low temperature (0.1 to 0.3). High temperature causes the AI to "hallucinate" field values that are not in the document.
NOTE
For data extraction tasks, set temperature to 0.1–0.3. This makes the AI deterministic and repeatable — the same document processed twice will return the same result. Reserve higher temperatures (0.7+) only for creative or generative tasks, not for structured extraction.
Extraction Modes
Ocriva supports two extraction modes that control how the AI returns results.
Structured Mode
The AI returns a JSON object matching your defined schema exactly. This is the default and recommended mode for most use cases.
When to use Structured Mode:
- You need machine-readable data for a database or API
- You want consistent field names across all processed documents
- You are using JSON, CSV, XML, or DOCX output formats
- You need to compare or aggregate data from multiple documents
How it works: The AI is given your JSON Schema and instructed to fill it with values found in the document. Missing fields return null. The output is always valid JSON matching your schema shape.
Free Text Mode
The AI returns a plain text response without any schema constraints. This is equivalent to asking the AI to summarize or describe the document in natural language.
When to use Free Text Mode:
- You need a human-readable summary
- The document structure is unpredictable
- You are generating narrative descriptions rather than data
- You are using the
textorhtmloutput format
How it works: The AI processes the document with only your instructions as guidance. The response is unstructured text.
How Result Format Affects Extraction Mode
The output format you select automatically determines the extraction mode. Formats that require a defined schema use Structured Mode; formats that produce free-form output use Free Text Mode.
| Result Format | Extraction Mode | Field Definition |
|---|---|---|
json | Structured | JSON Schema (19 presets available) |
csv | Structured | Column names |
text | Free Text | Not required |
pdf | Free Text | Not required |
docx | Free Text | Not required |
xml | Free Text | Not required |
html | Free Text | Not required |
image | Image Generation | Image options |
Structured formats (JSON, CSV) require you to define a schema — a list of fields and their types. The AI reads the document and fills each field with the value it finds. This produces consistent, machine-readable output every time.
Free Text formats (Text, PDF, DOCX, XML, HTML) do not require a schema. You provide instructions, and the AI generates content freely based on what it finds in the document. Even though XML is traditionally considered a structured format, Ocriva uses Free Text mode for XML output because the AI generates the XML markup from your instructions rather than mapping values to a predefined schema.
NOTE
When you select Text, PDF, DOCX, XML, or HTML as the result format, the system automatically switches to Free Text extraction mode — no field schema is needed. The AI responds based solely on your instructions.
TIP
If you need structured data extraction, use JSON or CSV as your result format. These formats enforce a schema that ensures consistent, machine-readable output across all documents. For detailed format configuration options, see Result Formats & Output.
Choosing Between Modes
| Situation | Recommended Mode |
|---|---|
| Extracting the same fields from every document (e.g., invoices, receipts) | Structured (JSON or CSV) |
| Documents vary widely in structure or content | Free Text |
| You need summaries, translations, or narrative descriptions | Free Text |
| Output will be consumed by an API, database, or spreadsheet | Structured (JSON or CSV) |
| You need printable reports or human-readable documents | Free Text (PDF or DOCX) |
Use Structured Mode when you need the same fields extracted from every document — for example, processing invoices where you always need invoice_number, date, and total_amount. The schema enforces consistency and makes downstream processing predictable.
Use Free Text Mode when documents vary too widely for a consistent schema, or when you need the AI to produce summaries, translations, or narrative descriptions rather than filling discrete fields.
Starting recommendation: Begin with JSON format and Structured Mode for most use cases. Switch to Free Text only when your documents are too varied for a consistent schema, or when the output is meant for human reading rather than machine processing.
