Extraction with Pea
Pea provides document extraction alongside decisions. It reads a text document and extracts developer-defined fields by pointing directly to evidence spans.
Pea capability · Hosted Beta API · Weights private
Realtime context: 96K · Batch context: 2K tokens per row for Pea and Pea Pod. Context limits.
What it does
Pea extracts structured data from text without generating sentences or scoring token sequences. You pass a text document, an optional reference date and a schema of up to 64 typed fields with brief instructions.
For each field, Pea locates the exact evidence substring in the original text, reporting half-open Unicode code point offsets [start, end). Deterministic code then parses the evidence span into typed data. When a field is probably absent, value is null.
How it works
Pea extraction uses a 2B text backbone with upper-layer parameter-efficient adaptations and specialized task heads. It runs strictly in prefill mode:
- Independent field passes: Inference evaluates one field per pass as an independent
document + fieldrow. Batched execution handles multiple fields concurrently, with state encoding explicitly repeated for each field. There is no cross-field attention or shared-state shortcut. - Dedicated task heads: A presence head predicts whether evidence exists in the document; bilinear start and end heads predict exact span bounds; and a B/I/O token head identifies items for list fields. There is no vocabulary projection head or token generator.
- Typed parsing in code: Numbers, dates, times, durations and lists are parsed from the cited evidence span by standard library code, so a returned number or date always corresponds to text in the document.
- Absence handling: When a field is probably absent (head null probability
p_null ≥ null_threshold, default 0.5) or if evidence does not parse into the type, the returnedvalueisnull. The conditional guess and span-confidence score remain visible for inspection.
Field types
Pea extraction supports seven field types. Every non-null value is parsed directly from the identified evidence span.
| Type | Output value | Supported options | Notes |
|---|---|---|---|
text |
String | instructions, null_threshold |
Direct substring of the document at cited offsets. |
number |
JSON number | integer (bool), decimals (0–6), unit (string) |
Parses integers or decimal numbers from evidence. No arithmetic computation. |
date |
String (YYYY-MM-DD) |
instructions, null_threshold |
Dates are returned as YYYY-MM-DD. An optional top-level reference_date (YYYY-MM-DD) can be supplied. |
time |
String (HH:MM) |
instructions, null_threshold |
24-hour clock time. |
datetime |
String (YYYY-MM-DDTHH:MM) |
instructions, null_threshold |
Combined date and time timestamp. |
duration |
JSON number | unit (seconds, minutes, hours, days, weeks, months, years) |
Parsed duration normalized to the requested unit (seconds by default). |
list |
Array of strings | items: "text" (required) |
Returns array of text items with individual span offsets. Number and date lists are not supported. |
Note: estimate and forecast field types are rejected with HTTP 400; values come only from evidence in the text, so there is no arithmetic (no totals computed from line items). Images are rejected with HTTP 400.
Hosted API & curl example
Pea extraction is live in Beta on the hosted API at POST https://api.itsvej.com/v1beta/extract. It also provides a Clairic-compatible endpoint at POST /client/v4/accounts/{account_id}/ai/run/@cf/cloudflare/clairic. Both require an API key with inference scope. The hosted extraction API currently uses the model identifier pea-pod-1.
Extracting fields from an invoice
curl -sS https://api.itsvej.com/v1beta/extract \
-H "Authorization: Bearer $VEJ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "pea-pod-1",
"state": "Invoice 2026-0412\nDate: 3 October 2026\nTotal due: €1,240.50",
"reference_date": "2026-10-21",
"fields": {
"invoice_number": {"type": "text", "instructions": "The invoice number."},
"invoice_date": {"type": "date", "instructions": "The date the invoice was issued."},
"total": {"type": "number", "decimals": 2, "instructions": "The total amount due."},
"po_number": {"type": "text", "instructions": "The purchase order number."}
}
}'
Illustrative response
Illustrative response for the English invoice above. Values are normalized from the cited evidence spans; probabilities and token counts are illustrative.
{
"model": "pea-pod-1",
"answers": {
"invoice_number": {"type": "text", "value": "2026-0412", "guess": "2026-0412", "p_null": 0.001, "confidence": 0.99, "span": [8, 17]},
"invoice_date": {"type": "date", "value": "2026-10-03", "guess": "2026-10-03", "p_null": 0.002, "confidence": 0.98, "span": [24, 38]},
"total": {"type": "number", "value": 1240.5, "guess": 1240.5, "p_null": 0.001, "confidence": 0.98, "span": [51, 59]},
"po_number": {"type": "text", "value": null, "guess": null, "p_null": 0.97, "confidence": 0.5}
},
"truncated": false,
"usage": {"state_tokens": 30, "image_tokens": 0, "schema_tokens": 40, "input_tokens": 200, "output_tokens": 0, "passes": 4},
"metadata": {"calibrated": true, "offsets": "code_points"}
}
Understanding the answer object
value: Returned whenp_null < null_threshold(default 0.5) and cited evidence parses into the requested type. Whenp_null ≥ null_threshold(the field is deemed absent) or when parsing fails (the cited evidence cannot be normalized to the declared type),valueisnull. A non-null value does not guarantee that the cited evidence or extraction is factually correct.guess: The parsed prediction conditional on candidate evidence, regardless of the null threshold. If no candidate span is found or if candidate evidence fails type parsing,guessisnull.p_null: Probability of evidence absence. Lower numbers indicate evidence is present.metadata.calibratedreports whether a checkpoint-bound presence fit is applied.confidence: Uncalibrated head score for the candidate evidence span.span/spans: Half-open Unicode code point offsets[start, end)intostate. The gateway returns singularspan(a two-element array[start, end]) for scalar fields and pluralspans(an array of offset pairs[[s, e], ...]) forlistfields whenever aguessexists. When a field hasvalue: nulldue top_null ≥ null_threshold, it may still report a conditionalguessand itsspanorspans. When no candidate evidence exists or type parsing fails (soguessisnull),spanandspansare omitted.po_number: Illustrates an absent field wherep_null(0.97) exceedsnull_threshold, yieldingvalue: null. Hereguess: nullreflects that no valid candidate parsed; if candidate evidence had been detected above the threshold, its conditionalguessandspanwould remain inspectable.
Token accounting and privacy
Usage reports actual executed work: passes equals the field count (4 passes above); state_tokens measures document length once (30 tokens above); schema_tokens sums rendered field instructions (40 tokens); and input_tokens sums actual row tokens across all passes (200 tokens). output_tokens is always 0 because no text is generated.
Zero retention: State, instructions, evidence and answers are not logged or retained.
Development results & caveats
The following metrics are development results measured on 3,000 locked test documents from Vej’s synthetic and benchmark extraction dataset. They are reported run results, not a qualification of production accuracy on real documents or a guarantee of calibration.
| Metric | Score | Measurement basis |
|---|---|---|
| Presence accuracy | 95.8% | Present vs. missing, across all sampled fields. |
| Text exact match | 80.4% | Conditional on rows where field is gold-present with an evidence span. |
| Typed exact match | 99.8% | Conditional on rows where field is gold-present with an evidence span. |
| List F1 | 0.399 | List F1 on list fields. |
Caveats and limitations
- Not end-to-end: Text and typed exact match are conditional on rows where the field is gold-present with an evidence span; they do not measure end-to-end presence-and-value accuracy.
- Calibration scope:
p_nulluses a held-out presence fit whenmetadata.calibratedis true;confidenceremains a span/tag score. This does not guarantee calibrated frequencies on your documents or permission to execute unverified actions. Recheck custom null thresholds after a calibration update. - Lists and receipts remain weak: List extraction is experimental (F1 0.399). Dense receipts and tabular documents with complex formatting remain challenging for Pea extraction.
- Real-world quality: Performance on specific private business documents has not been measured; evaluate on your own document distribution before automating workflows.
Usage limits & constraints
- Input token limit
- Hosted realtime Pea Pod: 96K (98,304) tokens per fully rendered document-plus-field row. Batch: 2K (2,048) tokens per row. Framing and field instructions count toward the limit. Offline checkpoint defaults remain 2,048. Longer-context quality is user-attested, without a new accuracy or calibration measurement here. Requests exceeding this limit fail closed with HTTP 400
input_too_long; the server never silently truncates. - Presence calibration
- The current presence fit covers rows up to 2K (2,048) tokens. Longer requests report
metadata.calibrated=false; span confidence remains uncalibrated. - Field capacity
- 1 to 64 fields per request in request order. Field names must match
^[A-Za-z_][A-Za-z0-9_.\-]{0,63}$. - Document modality
- Text only (1 to 1,048,576 Unicode code points; JSON body up to 16 MiB). Non-empty images are rejected with HTTP 400.
- Offsets unit
- Offsets are half-open Python Unicode code point indices
[start, end). In JavaScript or runtimes indexing UTF-16 code units, convert offsets when text contains non-BMP characters like emoji. - Weights status
- Private weights. Extraction weights are not published to Hugging Face, and public self-hosting is not offered. Served exclusively via the hosted API. Pea 1 decision weights on Hugging Face support decisions only.
- Beta service terms
- Formats may change during Beta. Serving capacity is limited with no uptime guarantee yet.
- MCP extraction tool
- Extraction has no MCP tool. API access is via HTTP requests.
How to get access
Pea extraction is served live on the hosted API in Beta under the same console account system as Pea decisions:
- Register an account: Sign up at app.itsvej.com/sign-up.
- Manual approval: Every account is manually reviewed and approved by the Vej team. While waiting, you can enroll a passkey or authenticator app.
- Create an API key: Once approved, generate an API key with
inferencescope in the console. - Send requests: Call
POST https://api.itsvej.com/v1beta/extractwith your API key.