This prompt is designed for document intake engineers and automation architects who need to detect, classify, and extract content from official marks—such as approval stamps, date stamps, notary seals, and corporate chops—in high-volume document pipelines. The primary job is to identify whether a document contains a stamp, determine its type, extract any text it carries, and report its location with a confidence score. This is a critical step in workflows like loan processing, government form intake, and contract execution verification, where the presence or absence of a stamp directly determines downstream routing, compliance checks, or human review requirements.
Prompt
Stamp Detection and Classification Prompt

When to Use This Prompt
Defines the job-to-be-done, the ideal user, required inputs, and the boundaries where this prompt should not be applied.
Use this prompt when you have a pre-processed page image or a high-resolution scan and you need structured output that can be consumed by an application. The prompt expects a clear image input and an output schema that defines the fields you need—typically stamp_type, bounding_box, extracted_text, and confidence. It is built to handle overlapping stamps, faint impressions, and color variations, but it is not a substitute for a dedicated OCR engine. You should only use this prompt after the document has been rasterized and, if necessary, enhanced for contrast. The prompt works best when paired with a validation layer that checks for common failure modes, such as confusing a dark logo with a stamp or misclassifying a printed border as a notary seal.
Do not use this prompt for general object detection, signature verification, or handwritten annotation classification—those are separate, specialized tasks. It is also not suitable for real-time video streams or low-resolution images below 150 DPI, where stamp details are illegible. If your workflow involves legally binding decisions based on stamp presence, you must route low-confidence detections (e.g., confidence < 0.85) to a human review queue and log the model's output alongside the source image for auditability. The next step after reading this section is to prepare your image preprocessing pipeline and define the exact JSON schema your downstream system expects.
Use Case Fit
Where stamp detection works reliably and where it introduces risk. Use these cards to decide if this prompt fits your document pipeline before integrating it.
Good Fit: Official Mark Verification
Use when: documents require proof of approval, notarization, or regulatory review via stamps. Why it works: stamps have consistent visual patterns (circular borders, date fields, emblem placement) that the model can recognize even with color and contrast variation. Guardrail: pair detection with a completeness check that flags documents missing expected stamps before downstream processing.
Bad Fit: Real-Time Video Streams
Avoid when: processing live video frames or low-resolution surveillance footage for stamp detection. Risk: motion blur, poor lighting, and non-document backgrounds produce high false-positive rates on circular objects like logos, coins, and badges. Guardrail: restrict this prompt to static document images at 150 DPI or higher with controlled lighting.
Required Inputs
Must provide: document image or PDF page with sufficient resolution to distinguish stamp edges from printed borders. Critical dependency: the model needs visible contrast between stamp ink and document background—faint impressions on dark paper will fail silently. Guardrail: add a pre-processing contrast check that rejects images below a minimum ink-to-background ratio before calling the prompt.
Operational Risk: Watermark Confusion
What to watch: the model confuses large watermarks, embossed seals, and decorative borders with official stamps. Why it happens: circular watermarks and embossed impressions share edge patterns and placement conventions with approval stamps. Guardrail: run a watermark detection prompt first and exclude watermark regions from stamp classification to reduce false positives.
Operational Risk: Overlapping Stamps
What to watch: multiple stamps overlapping on the same document region cause missed detections and merged text extraction. Why it happens: overlapping ink creates ambiguous boundaries where the model cannot separate individual stamp instances. Guardrail: flag overlapping-stamp regions for human review rather than accepting low-confidence merged output that corrupts stamp count and text fields.
Operational Risk: Faded and Partial Impressions
What to watch: light stamp impressions, partial ink coverage, and stamps cut off at page edges produce false negatives. Why it happens: the model relies on edge continuity and text legibility—degraded impressions fall below detection thresholds. Guardrail: set a confidence floor and route detections below 0.7 confidence to a manual review queue with the original image region highlighted.
Copy-Ready Prompt Template
A reusable prompt for detecting, classifying, and extracting text from stamps, seals, and official marks in document images.
This template provides a complete instruction set for stamp detection and classification. It is designed to be dropped into a system prompt or a single-turn user message where the document image is provided alongside the instruction. The prompt enforces structured JSON output, requires bounding box coordinates, and explicitly separates stamp content from surrounding document text to prevent extraction bleed. Use this template as your starting point, then tune the confidence thresholds, stamp type taxonomy, and coordinate normalization to match your document pipeline's requirements.
textYou are a document analysis system specialized in detecting and classifying stamps, seals, and official marks on document pages. ## INPUT You will receive a single document page as an image. The page may contain zero or more stamps. ## TASK Detect all stamps on the page. For each detected stamp, provide: - Classification of the stamp type - Bounding box coordinates - All text content extracted from within the stamp region - A confidence score ## STAMP TYPE TAXONOMY Classify each stamp into exactly one of the following types: - [STAMP_TYPE_TAXONOMY] ## OUTPUT SCHEMA Return a JSON object with this exact structure: { "page_number": [PAGE_NUMBER], "stamps_detected": [STAMP_COUNT], "stamps": [ { "stamp_id": "string", "stamp_type": "string from taxonomy", "confidence": 0.0-1.0, "bounding_box": { "x": number, "y": number, "width": number, "height": number, "unit": "pixels" }, "text_content": "string extracted from stamp", "text_confidence": 0.0-1.0, "visual_characteristics": ["list of observed features"], "overlaps_other_stamp": boolean, "illegible": boolean } ], "processing_notes": ["any warnings about image quality, ambiguity, or edge cases"] } ## CONSTRAINTS [CONSTRAINTS] ## EXAMPLES [EXAMPLES] ## IMPORTANT - Distinguish stamps from watermarks, logos, printed borders, and pre-printed form elements. - If a stamp is faint, partially obscured, or overlapping another stamp, note this in visual_characteristics and reduce confidence accordingly. - Extract text only from within the stamp boundary. Do not include surrounding document text. - If stamp text is partially illegible, set illegible to true and include whatever characters you can read in text_content. - If no stamps are detected, return stamps_detected as 0 and an empty stamps array. - For color stamps, note the ink color in visual_characteristics. - Do not hallucinate stamps. If you are uncertain whether a mark is a stamp, set confidence below 0.5 and explain in processing_notes.
To adapt this template, replace the square-bracket placeholders with your specific requirements. [STAMP_TYPE_TAXONOMY] should contain your domain's stamp categories—common values include approval_stamp, date_stamp, notary_seal, received_stamp, confidential_stamp, certified_copy, void_stamp, and custom. [CONSTRAINTS] is where you add domain-specific rules such as minimum confidence thresholds for auto-acceptance, coordinate system requirements (normalized vs. pixel), or multi-language text extraction preferences. [EXAMPLES] should contain one-shot or few-shot examples showing correct outputs for stamps your system commonly encounters, including edge cases like overlapping stamps or faint impressions. If you are integrating this into a production pipeline, add a post-processing validation step that checks bounding box coordinates are within page dimensions, stamp_id values are unique, and confidence scores are within the 0.0-1.0 range before the output reaches downstream systems.
Prompt Variables
Required and optional inputs for the Stamp Detection and Classification Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to check the input before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DOCUMENT_IMAGE] | Base64-encoded image or raw bytes of the document page to analyze | iVBORw0KGgoAAAANSUhEUgAA... (truncated base64) | Validate MIME type is image/png, image/jpeg, or image/tiff. Reject if payload exceeds 20MB. Check image dimensions are at least 300x300 pixels. |
[PAGE_NUMBER] | Integer indicating which page of a multi-page document this image represents | 3 | Must be a positive integer. Null allowed for single-page documents. Used for citation in output location references. |
[DOCUMENT_ID] | Unique identifier for the parent document to enable cross-page stamp tracking | doc_2025_0042_invoice | Must be a non-empty string. Used to group stamp detections across pages. Reject if null or whitespace. |
[STAMP_CATEGORIES] | Array of stamp types the system should classify, in priority order | ["APPROVED", "REJECTED", "RECEIVED", "CONFIDENTIAL", "DRAFT", "NOTARY_SEAL", "DATE_STAMP", "OTHER"] | Must be a non-empty array of strings. Each category must be uppercase with no spaces. Validate against allowed enum. If null, use default category set. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score (0.0-1.0) for a detection to be included in output | 0.65 | Must be a float between 0.0 and 1.0. Default to 0.5 if not provided. Lower values increase false positives; higher values miss faint stamps. |
[INCLUDE_TEXT_EXTRACTION] | Boolean flag controlling whether OCR text within stamp regions is extracted | Must be true or false. When true, adds latency and token cost. Set false for presence-only detection pipelines. | |
[OVERLAP_RESOLUTION_STRATEGY] | Rule for handling stamps that overlap or are nested within each other | SEPARATE_AND_RANK | Must be one of: SEPARATE_AND_RANK, HIGHEST_CONFIDENCE_ONLY, MERGE_AS_SINGLE. SEPARATE_AND_RANK returns all detections ordered by confidence. MERGE_AS_SINGLE combines overlapping regions. |
[KNOWN_WATERMARKS] | Array of known watermark patterns to exclude from stamp detection to reduce false positives | ["CONFIDENTIAL_WATERMARK_DIAGONAL", "COMPANY_LOGO_BOTTOM"] | Optional. If provided, must be an array of strings matching predefined watermark identifiers. Null allowed. Helps distinguish stamps from repeating background elements. |
Implementation Harness Notes
How to wire the stamp detection prompt into a production document intake pipeline with validation, retries, and human review.
The stamp detection prompt is designed to operate as a focused extraction step within a larger document processing pipeline, not as a standalone application. It expects pre-processed page images or high-quality OCR text with spatial metadata as input. The ideal integration point is after document classification and page splitting, but before downstream field extraction or completeness auditing. This ordering ensures that stamp regions are identified and can be excluded from text extraction zones, preventing stamp text from being misinterpreted as form field content. The prompt should be called once per page for multi-page documents, with results aggregated at the document level.
Wire the prompt into your application using a structured API call with explicit JSON schema enforcement. The model should be configured with response_format set to a strict JSON object matching the expected output schema: an array of stamp objects, each containing stamp_type (enum: official_seal, approval_stamp, date_stamp, notary_seal, received_stamp, other), bounding_box (normalized coordinates), extracted_text, confidence (0.0-1.0), and overlap_flag (boolean). Implement a validation layer that checks for schema compliance, coordinate range validity, and confidence threshold enforcement. Stamps with confidence below 0.7 should be routed to a human review queue with the cropped image region attached. Add a retry loop with a maximum of two attempts: if the model returns malformed JSON or missing required fields, re-send the same image with an error message appended to the prompt context specifying the validation failure. Log every attempt, validation result, and final disposition for auditability.
For high-volume production use, batch pages and process them concurrently with rate limiting aligned to your model provider's tier. Cache results keyed by page hash to avoid re-processing identical pages during retries or re-ingestion. The most common failure mode in production is stamp-watermark confusion, so implement a post-processing heuristic that checks detected stamp regions against known watermark patterns in your document corpus. If a detected stamp region overlaps with a known watermark location by more than 50%, downgrade the confidence and flag for review rather than silently accepting the misclassification. Do not use this prompt for signature verification or legal validity assessment—those require separate, specialized workflows with human-in-the-loop approval gates.
Expected Output Contract
Defines the required fields, types, and validation rules for the stamp detection and classification prompt output. Use this contract to build downstream parsers and validation logic before integrating the prompt into a production pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
stamp_detected | boolean | Must be true if any stamp is found; false otherwise. Validate as strict boolean, not string. | |
stamps | array of objects | Must be present even if empty. Schema check: array exists and each element matches stamp object contract. | |
stamps[].stamp_type | enum string | Must be one of: official_seal, notary_seal, date_stamp, approval_stamp, received_stamp, custom_text_stamp, other. Reject unknown values. | |
stamps[].location | object | Must contain page_number (integer >=1), bounding_box (object with x, y, width, height as floats 0-1 normalized), and region_label (string). Schema validation required. | |
stamps[].extracted_text | string or null | Null allowed if stamp contains no extractable text. If present, must be non-empty string. Validate length > 0 when not null. | |
stamps[].confidence | number | Float between 0.0 and 1.0 inclusive. Validate range. Values below 0.5 should trigger human review routing. | |
stamps[].overlap_flag | boolean | True if stamp overlaps another detected stamp or annotation. Used to route complex cases for manual resolution. | |
stamps[].color_hint | string or null | If detectable, one of: red, blue, black, green, purple, other. Null if color cannot be determined. Validate against allowed enum. |
Common Failure Modes
Stamp detection models fail in predictable ways. These are the most common production failure modes and the concrete guardrails that catch them before they corrupt downstream document processing.
Watermark Confusion
What to watch: The model classifies faint background watermarks, logos, or pre-printed letterhead as official stamps, producing false positives that trigger incorrect routing or approval flags. This is especially common with embossed-style watermarks and grayscale document scans where contrast is low. Guardrail: Add a dedicated watermark detection pre-pass before stamp classification. Require the stamp classifier to output a distinguishing_from_watermark confidence field and route any detection below 0.85 confidence to human review.
Overlapping Stamp Blindness
What to watch: When two or more stamps overlap, the model extracts only the topmost stamp and misses the partially occluded stamp beneath. This causes undercounting on multi-stamp pages such as notarized documents with both a notary seal and a date stamp in the same region. Guardrail: Prompt the model to return all detected stamps as an array rather than a single best match. Add a post-processing check that flags pages where detected stamp bounding boxes overlap by more than 20% and requests re-analysis with an overlap-aware prompt variant.
Faint Impression Misses
What to watch: Lightly inked stamps, faded impressions, or stamps applied at an angle with uneven pressure produce low-contrast regions that the model skips entirely. This is the most common cause of false negatives in production, particularly on scanned documents from low-quality office scanners. Guardrail: Implement a pre-processing contrast enhancement step before stamp detection. Set a minimum recall threshold in eval and monitor false negative rate by stamp contrast quartile. Route pages with detected low-contrast regions but zero stamp detections to human review.
Printed Border Misclassification
What to watch: Decorative borders, certificate frames, and pre-printed rectangular elements on official forms are misclassified as stamp impressions, especially when the border uses ink colors similar to common stamp colors such as red or blue. Guardrail: Include negative examples of printed borders in few-shot demonstrations. Add a post-classification shape analysis check that flags perfectly rectangular detections with aspect ratios matching common page borders and routes them for re-evaluation.
Color Variation Overfitting
What to watch: The model relies too heavily on color as a signal and fails on black-and-white scans, grayscale documents, or stamps in non-standard ink colors such as green, purple, or metallic. This causes systematic failures on archival documents and monochrome fax transmissions. Guardrail: Train eval sets to include equal representation of color, grayscale, and black-and-white documents. Prompt the model to use shape, texture, and placement cues alongside color. Monitor per-color-mode accuracy in production and alert on divergence.
Text Extraction from Stylized Stamps
What to watch: Curved text, circular stamp layouts, and heavily stylized fonts inside official seals produce garbled or incomplete text extraction. The model may extract partial text or hallucinate characters to fill gaps in low-resolution stamp regions. Guardrail: Return extracted text with a per-character confidence score. Flag any stamp where extracted text confidence falls below 0.7 for human transcription. Use a validation check that compares extracted text against expected stamp text patterns such as date formats or department names when available.
Evaluation Rubric
Test criteria for stamp detection output quality before shipping. Run these checks on a golden dataset of 50+ documents containing official stamps, logos, watermarks, and printed borders to calibrate thresholds.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Stamp presence accuracy | F1 >= 0.95 on stamp vs. non-stamp classification across all pages | False positives on logos, watermarks, or printed borders exceed 5% of non-stamp pages | Confusion matrix on labeled page-level ground truth with balanced stamp and non-stamp samples |
Stamp type classification | Top-1 accuracy >= 0.90 across [STAMP_TYPE_TAXONOMY] categories | Approval stamp misclassified as date stamp or notary seal in more than 10% of cases | Per-class precision and recall on 20+ examples per stamp type, including edge cases with faint impressions |
Overlapping stamp separation | Detects all stamps in overlapping clusters with count accuracy >= 0.85 | Two overlapping stamps reported as single stamp or one stamp missed entirely | Synthetic overlays of known stamp pairs; compare detected count and bounding boxes to ground truth |
Text content extraction from stamp | Character error rate (CER) <= 0.05 on extracted stamp text | Date digits transposed, organization name truncated, or circular text read in wrong order | String similarity between extracted text and manually transcribed ground truth for 30+ stamps |
Bounding box precision | IoU >= 0.85 between predicted and ground truth bounding boxes | Bounding box covers less than 70% of stamp area or extends more than 20% beyond stamp edge | Intersection-over-Union calculation on pixel-level annotated stamp regions across varied scan resolutions |
Confidence score calibration | Expected calibration error (ECE) <= 0.08 on confidence scores | High confidence (>0.9) assigned to false positives or low confidence (<0.5) on clear stamps | Reliability diagram plotting confidence bins against observed accuracy; require monotonic trend |
Color and contrast robustness | Recall >= 0.90 on stamps with low contrast, faded ink, or non-black colors | Blue or red ink stamps missed while black ink stamps detected; faint impressions below 30% contrast ignored | Test set stratified by contrast ratio and ink color with equal representation across bins |
Artifact rejection | False positive rate <= 0.02 on pages containing only watermarks, logos, and printed borders | Company logo in letterhead classified as stamp with confidence > 0.5 | Dedicated negative test set of 100+ pages with known confusers but zero true stamps |
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
Use the base prompt with a single model call and relaxed output validation. Focus on getting stamp type, location, and text content extraction working before adding complexity. Replace [MODEL] with your frontier model of choice and test with 10-20 sample documents.
codeYou are a document stamp detector. Analyze the provided document image and identify all stamps, seals, and official marks. For each stamp found, return: - stamp_type: [official_seal|approval_stamp|date_stamp|notary_seal|received_stamp|other] - location: bounding box coordinates - text_content: extracted text from the stamp - confidence: 0.0 to 1.0 Document: [DOCUMENT_IMAGE]
Watch for
- Missing schema checks leading to inconsistent JSON shapes
- Overly broad stamp_type classification without clear boundaries
- No handling of overlapping stamps or faint impressions
- Confidence scores that are arbitrary rather than calibrated

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