This prompt is for engineering teams building structured extraction pipelines that require spatial grounding. Use it when you must extract form fields with their content, labels, types, states, and precise bounding box coordinates across multi-page documents. The prompt produces field-level extraction with coordinate normalization, making it suitable for downstream validation, human review routing, and integration with document annotation systems. The ideal user is a developer or ML engineer who already has page images or rendered pages with a coordinate system available and needs to move beyond simple key-value extraction into layout-aware field mapping.
Prompt
Form Field Extraction with Bounding Box Prompt

When to Use This Prompt
Determine if spatial form field extraction is the right tool for your document pipeline.
The required context for this prompt includes page images with a known coordinate space (e.g., pixel dimensions at a specific DPI), a defined schema for the fields you expect to extract, and a clear understanding of which field states matter for your workflow (filled, empty, checked, signed). You should also know your coordinate normalization strategy upfront—whether you need coordinates normalized to [0,1] for resolution independence, or absolute pixel values tied to a specific rendering. The prompt assumes you can provide either the image directly to a multimodal model or a structured representation of the page layout with text and spatial information. Without this spatial context, the prompt cannot produce bounding boxes, and you should use a simpler text-only extraction approach.
Do not use this prompt for simple key-value extraction without spatial requirements, or when the document has no visual layout to reference (e.g., plain text transcripts, markdown files, or linearized PDF text streams). It is also the wrong tool when you only need field content without location data—the bounding box computation adds latency and token cost that provides no value if coordinates are unused. If your documents are entirely digital forms with tagged PDF structure and reliable logical hierarchy, consider using a direct structural parser instead, reserving this prompt for cases where visual layout is the ground truth. Before implementing, verify that your evaluation pipeline can measure bounding box accuracy on rotated, skewed, and irregular form layouts, as spatial extraction failures are often silent and propagate into downstream field association errors.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if spatial field extraction is the right tool for your document pipeline.
Good Fit: Structured Forms with Spatial Variance
Use when: You need to extract fields from forms where the layout is consistent but field positions shift slightly between scans or versions. Guardrail: The prompt requires coordinate normalization across pages. Always validate bounding boxes against page dimensions before downstream use.
Bad Fit: Free-Form Documents Without Field Boundaries
Avoid when: The document has no visual field structure (e.g., prose letters, narrative reports, unstructured emails). Guardrail: If there are no boxes, underlines, or spatial cues to anchor extraction, use a schema-driven extraction prompt instead. Bounding box prompts hallucinate regions on boundary-less content.
Required Inputs: Rendered Page Images with Metadata
Risk: Sending raw PDF bytes or text-only representations will cause the model to guess coordinates or refuse. Guardrail: Always provide rendered page images with explicit page dimensions (width, height, page number). Normalize coordinates to a consistent origin (top-left, pixel units) in your preprocessing layer.
Operational Risk: Coordinate Drift on Rotated or Skewed Pages
Risk: Scanned documents with rotation, skew, or perspective distortion produce bounding boxes that don't align with the original page geometry. Guardrail: Run deskew detection before extraction. If deskew isn't possible, flag the page for human review and suppress low-confidence coordinate outputs.
Operational Risk: Multi-Page Field Continuity Breaks
Risk: Fields that span page breaks (e.g., continued tables, carryover signatures) get extracted as separate, unlinked entities. Guardrail: Use page-span detection logic in post-processing. If a field region touches a page edge, query the adjacent page for continuation before finalizing the extraction record.
Bad Fit: Real-Time or Streaming Document Ingestion
Avoid when: You need sub-second extraction latency on high-throughput document streams. Guardrail: Bounding box prompts require vision model inference, which adds latency. For real-time pipelines, pre-classify documents and route only form-heavy pages to this prompt; use faster text-only extraction for the rest.
Copy-Ready Prompt Template
A reusable prompt for extracting form fields with spatial grounding, ready for adaptation into your document processing pipeline.
This prompt template is designed for extraction pipelines that need more than raw text—they require spatial grounding. It instructs the model to return each form field's content, label, type, state, bounding box coordinates, and page number. The square-bracket placeholders let you inject your specific document content, output schema, and operational constraints without rewriting the core instruction set. Use this template when you need field-level extraction that downstream systems can map back to pixel locations on the original document image.
textYou are a precise document form field extractor. Your task is to analyze the provided document page and extract every form field present. For each field you identify, return a structured object containing: - `field_id`: A unique identifier for the field on this page (e.g., "field_01"). - `label`: The text of the question or prompt associated with the field. If no label is visually present, use null. - `content`: The user-entered or pre-filled text/value within the field. If the field is empty, use null. - `type`: The visual type of the field. Must be one of: "text", "checkbox", "radio", "signature", "dropdown", "list", "stamp", "barcode", "other". - `state`: The completion state. Must be one of: "filled", "empty", "checked", "unchecked", "indeterminate". - `bounding_box`: The spatial coordinates of the field in the format [x1, y1, x2, y2] where (x1,y1) is the top-left corner and (x2,y2) is the bottom-right corner. All coordinates must be normalized to a range of 0.0 to 1000.0, representing a percentage of the page width and height. - `page_number`: The page number where the field appears, starting from 1. - `confidence`: A score from 0.0 to 1.0 indicating your confidence in the extraction. [OUTPUT_SCHEMA] Return the extracted fields as a single JSON object with a key "fields" containing an array of field objects. [CONSTRAINTS] - Do not extract purely decorative elements, watermarks, or background graphics as fields. - If a field's content is illegible, set `content` to null and `confidence` to a value below 0.5. - For checkboxes and radio buttons, the `content` field should be null, and the `state` should reflect its visual status. - Normalize all bounding box coordinates to a 0-1000 scale relative to the page dimensions. [INPUT] The document page image to analyze is provided below.
To adapt this template, replace the placeholders with your specific requirements. The [OUTPUT_SCHEMA] placeholder is critical for integration: replace it with a strict JSON Schema definition that matches your application's data contract. The [CONSTRAINTS] section should be updated to reflect your domain-specific rules, such as ignoring certain form regions or handling custom field types. The [INPUT] placeholder is where your application will inject the base64-encoded image or a reference to the document page. For high-stakes workflows, always pair this prompt with a post-processing validation step that checks bounding box ranges, required field presence, and confidence thresholds before the data enters your system of record.
Prompt Variables
Required inputs for the Form Field Extraction with Bounding Box prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to verify the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DOCUMENT_IMAGE] | Base64-encoded image or raw bytes of the form page to extract fields from | data:image/png;base64,iVBORw0KGgo... | Check MIME type is image/png, image/jpeg, or image/tiff. Reject if payload exceeds 20MB. Validate base64 decodes without error. |
[PAGE_NUMBER] | Integer page index within the multi-page document, used for coordinate normalization and cross-page field tracking | 3 | Must be a positive integer. Null allowed only for single-page documents. If provided, must not exceed total page count from [TOTAL_PAGES]. |
[TOTAL_PAGES] | Total number of pages in the source document, used to normalize bounding box coordinates across pages | 12 | Must be a positive integer greater than or equal to [PAGE_NUMBER]. Required when [PAGE_NUMBER] is provided. Used to compute normalized y-offset for multi-page coordinate systems. |
[FIELD_SCHEMA] | JSON Schema or field definition list specifying which fields to extract, their expected types, and required vs. optional status | {"fields": [{"name": "borrower_name", "type": "string", "required": true}]} | Must be valid JSON. Each field entry requires name, type, and required keys. Type must be one of: string, checkbox, signature, date, radio, dropdown. Reject if schema is empty or contains duplicate field names. |
[COORDINATE_SYSTEM] | Specification of the bounding box coordinate origin and unit system for the output | "pixel_absolute" | Must be one of: pixel_absolute, normalized_0_to_1, pdf_points. If pixel_absolute, image DPI metadata must be present. If normalized_0_to_1, all output coordinates must fall within [0,1] range. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for field extraction results to be included in output; fields below threshold are routed to [LOW_CONFIDENCE_QUEUE] | 0.65 | Must be a float between 0.0 and 1.0. Values below 0.5 produce noisy extractions. Values above 0.95 may suppress valid fields in degraded documents. Default 0.7 if not specified. |
[LOW_CONFIDENCE_QUEUE] | Identifier for the review queue where fields below [CONFIDENCE_THRESHOLD] are routed for human verification | "form-review-pending" | Must be a non-empty string matching an existing queue name in the review system. Null allowed if no review queue is configured, but then low-confidence fields will be silently dropped. |
[OUTPUT_FORMAT] | Desired output structure for extracted fields, controlling whether results include raw bounding boxes, normalized coordinates, or both | "full_with_bbox" | Must be one of: full_with_bbox, content_only, bbox_only. content_only suppresses coordinate output. bbox_only suppresses extracted text content. Default full_with_bbox if not specified. |
Implementation Harness Notes
How to wire the form field extraction prompt into a production document pipeline with validation, retries, and human review.
Integrating the Form Field Extraction with Bounding Box prompt into a production system requires more than a single API call. The prompt expects a pre-processed page image and a JSON schema as input, and it returns structured field data with spatial coordinates. The application layer must handle image preparation, coordinate normalization, output validation, and routing for low-confidence results. This section covers the implementation harness needed to make the prompt reliable at scale, including model selection, validation logic, retry strategies, and human review integration.
Input Preparation and Model Selection: Before calling the prompt, convert each document page into a high-resolution image (at least 200 DPI for forms with small fields). Pass the page image and the target [OUTPUT_SCHEMA] as inputs. For model selection, use a vision-capable model that supports structured output and bounding box prediction. GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro are strong defaults. If processing sensitive documents, prefer models available in private deployments or with zero-data-retention policies. For high-volume pipelines, implement a model router that sends straightforward forms to a faster, cheaper model and escalates complex layouts (dense fields, rotated text, irregular grids) to a more capable model.
Output Validation and Coordinate Normalization: The prompt returns field-level bounding boxes in page-relative coordinates. Validate every output against the expected schema before ingestion. Check that all required fields are present, field types match the schema, and bounding box coordinates fall within page dimensions. Normalize coordinates to a consistent origin (top-left, in pixels or normalized 0-1 range) across all pages in a multi-page document. If the document was deskewed or rotated during preprocessing, apply the inverse transformation to map coordinates back to the original page. Implement a validation layer that flags outputs with missing required fields, coordinates outside page bounds, or type mismatches. Log every validation failure with the page image and raw model output for debugging.
Retry and Escalation Logic: When validation fails, implement a retry loop with a maximum of two additional attempts. On retry, include the validation error messages in the prompt context so the model can self-correct. If the model consistently fails on a specific field, escalate to a fallback strategy: try a different model, apply a specialized single-field extraction prompt, or route to human review. For low-confidence fields (confidence below a configurable threshold, typically 0.7), flag them for human review rather than silently ingesting uncertain data. Build a review queue that presents the original page image with the extracted field highlighted, the model's output, and the confidence score. Human reviewers can accept, correct, or reject each flagged field, and their corrections should be logged as training data for future fine-tuning.
Logging, Monitoring, and Continuous Improvement: Log every extraction request with the document ID, page number, model used, latency, token count, validation results, and any human corrections. Monitor extraction accuracy over time by sampling outputs and comparing against ground truth. Track failure modes: which field types produce the most validation errors, which layouts cause bounding box drift, and which documents require the most human review. Use this data to refine the prompt, adjust confidence thresholds, and build few-shot examples for edge cases. When you accumulate enough human-corrected examples, consider fine-tuning a smaller vision model on your specific form types to reduce cost and latency while maintaining accuracy.
Expected Output Contract
Validate every extracted field against this contract before accepting the model response. Use these rules to build a post-processing validator that rejects malformed outputs and routes low-confidence fields for human review.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
fields | array of objects | Must be a non-empty array. Reject if null, empty, or not an array. | |
fields[].label | string | Must be non-empty string. Reject if null or whitespace-only. Trim leading/trailing whitespace. | |
fields[].content | string | null | Must be present. Allow null for empty fields. Reject if undefined. Trim if string. | |
fields[].type | enum: text, checkbox, radio, dropdown, signature, date, list, other | Must match one of the allowed enum values. Reject unknown types. Default to 'other' if confidence below threshold. | |
fields[].state | enum: filled, empty, partially_filled, illegible, redacted | Must match one of the allowed enum values. Reject if missing. Map 'erased' or 'blank' to 'empty'. | |
fields[].bounding_box | object with x, y, width, height, page | All coordinates must be positive numbers. page must be integer >= 1. Reject if any coordinate is negative or page is 0. | |
fields[].confidence | number between 0.0 and 1.0 | Must be a float in range [0.0, 1.0]. Reject if outside range. Route fields with confidence < [CONFIDENCE_THRESHOLD] to human review queue. | |
fields[].page | integer | Must match the page number in bounding_box.page. Reject if inconsistent. Must be <= [TOTAL_PAGES] from document metadata. |
Common Failure Modes
What breaks first when extracting form fields with bounding boxes and how to guard against it.
Coordinate Drift on Rotated Documents
What to watch: Bounding box coordinates shift or misalign when documents are scanned at an angle, skewed, or have page rotation applied. The model may produce coordinates relative to the visual text orientation rather than the page origin, causing downstream cropping and field association to fail. Guardrail: Normalize coordinates to the page media box origin. Pre-process with deskewing or pass explicit rotation metadata in the prompt context. Validate that all bounding boxes fall within page dimensions.
Adjacent Field Boundary Bleed
What to watch: Bounding boxes for tightly packed fields overlap or capture content from neighboring fields, especially in dense forms with minimal padding. This corrupts extracted values when a box meant for 'City' also captures part of 'State'. Guardrail: Add a post-extraction overlap check. If two bounding boxes intersect beyond a threshold, flag both for review. Prompt for explicit boundary evidence (lines, whitespace, label proximity) rather than relying on implicit spatial reasoning.
Multi-Page Coordinate Confusion
What to watch: The model returns bounding box coordinates without consistent page indexing, or uses page-relative coordinates that collide across pages. A field on page 3 may have the same coordinates as a field on page 1, breaking deduplication and field tracking. Guardrail: Require page number in every field output. Normalize coordinates to a document-global system (page_height * page_index + y_offset) or enforce page-anchored coordinates with explicit page dimension metadata per page.
Empty Field Box Collapse
What to watch: The model fails to return bounding boxes for empty or unfilled fields because there is no visible content to anchor the detection. This silently drops required fields from the extraction output, making completeness audits impossible. Guardrail: Prompt explicitly for empty field detection with bounding boxes derived from label proximity, form lines, or placeholder regions. Validate that the count of extracted fields matches the expected field count from the form schema when available.
Checkbox and Radio Group Atomization
What to watch: Individual checkboxes or radio buttons within a group are extracted as separate, unassociated fields with no group identifier. The output loses the relationship between options, making it impossible to determine which set of choices a selection belongs to. Guardrail: Prompt for group association by spatial proximity or shared label. Return a group identifier and option index for each selectable element. Validate that mutually exclusive groups (radio) have at most one selection.
Handwritten Content Misalignment
What to watch: Handwritten entries extend beyond the printed field boundaries, causing the bounding box to either clip the content or expand to capture irrelevant surrounding marks. This produces truncated extracted text or contaminated field values. Guardrail: Use a two-pass approach: first detect the printed field boundary, then expand the extraction region for handwriting detection within a tolerance zone. Flag fields where extracted content extends beyond the original boundary for human review.
Evaluation Rubric
Criteria for testing bounding-box extraction quality before shipping. Use these checks to calibrate spatial accuracy, handle edge cases, and decide when to route outputs for human review.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Bounding Box Coordinate Accuracy | Predicted [BBOX] coordinates overlap ground-truth region with IoU >= 0.85 for at least 95% of fields | IoU < 0.70 on more than 10% of fields; systematic offset in one direction; zero-area boxes | Run against a golden dataset of 50+ annotated forms with known bounding boxes; compute per-field IoU and aggregate pass rate |
Field Label-Value Association | Every extracted [FIELD_VALUE] is paired with the correct [FIELD_LABEL] for 98% of fields in standard layouts | Label-value swaps in dense form sections; orphaned values with no label; values assigned to adjacent field labels | Test on forms with varying label positions (left, above, inline); verify label-value pairs against ground-truth mapping |
Multi-Page Coordinate Normalization | [PAGE_NUMBER] is correct for all fields; coordinates are normalized to page dimensions with origin consistency | Page number off-by-one errors; coordinates from page 2 reported as page 1; origin flip between pages | Feed multi-page PDFs with fields spanning pages; verify page index and coordinate system consistency across all pages |
Field State Classification | [FIELD_STATE] correctly identifies filled, empty, partially filled, and illegible states for 95% of fields | Empty fields classified as filled due to pre-printed text; faint pencil marks missed; checkbox state confusion | Test on forms with mixed fill states including edge cases: light pencil, erased marks, gray pre-printed text |
Rotated and Skewed Document Handling | Extraction accuracy remains within 90% of baseline when documents are rotated up to 15 degrees or skewed up to 10 degrees | Bounding box drift proportional to rotation angle; text extraction fails on rotated regions; confidence scores drop without flagging | Apply synthetic rotations and skews to golden dataset; compare extraction quality against unrotated baseline |
Confidence Score Calibration | [CONFIDENCE] scores below 0.70 correlate with actual extraction errors; scores above 0.90 have error rate below 2% | High confidence on hallucinated content; low confidence on clearly legible fields; confidence not monotonic with difficulty | Bin predictions by confidence decile; compute actual error rate per bin; check calibration curve against expected error distribution |
Irregular Layout Boundary Detection | Field boundaries correctly identified for borderless fields, merged cells, and non-rectangular regions in 90% of cases | Boundary bleed between adjacent borderless fields; merged cells split incorrectly; irregular regions approximated with oversized boxes | Test on form set with borderless layouts, merged header cells, and non-standard field shapes; verify boundary precision |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Add schema validation, coordinate normalization, confidence thresholds, and multi-page handling. Include explicit instructions for page-number tracking and coordinate normalization relative to page dimensions. Wire in a post-processing validator that rejects malformed bounding boxes and fields with confidence below [CONFIDENCE_THRESHOLD]. Add retry logic with error-specific prompts when validation fails.
codeFor each page in [DOCUMENT_PAGES], extract form fields. Normalize all bbox coordinates to [0.0-1.0] relative to page width and height. Include page_number, confidence (0.0-1.0), and uncertainty_reason if confidence < [CONFIDENCE_THRESHOLD]. Output must conform to [OUTPUT_SCHEMA].
Watch for
- Silent format drift when model changes output field names
- Coordinate normalization errors on pages with non-standard dimensions
- Missing human review queue for low-confidence fields
- Retry loops that mask systemic extraction failures with repeated attempts

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us