Inferensys

Prompt

Handwritten Annotation vs. Printed Text Prompt

A practical prompt playbook for using Handwritten Annotation vs. Printed Text Prompt in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for separating handwritten annotations from printed text in document processing pipelines.

This prompt is designed for document automation engineers who need to reliably separate original printed content from added handwriting in forms, contracts, reports, and scanned documents. The core job-to-be-done is per-region classification: for each text region on a page, determine whether it is printed, handwritten, or mixed, and extract the text content for both layers with bounding boxes and confidence scores. This is not a general OCR prompt—it assumes you already have text regions detected and need to classify their origin. The ideal user is building a document processing pipeline where downstream actions depend on knowing what was originally printed versus what was added later, such as extracting filled form values, detecting unauthorized annotations, or preserving the original document layer for archival purposes.

Use this prompt when you have documents with overlapping annotations, margin notes, mixed ink colors, or handwriting that intersects with printed text. It handles cases where a single bounding box contains both printed and handwritten content by producing separate extraction results for each layer. The prompt requires input regions with bounding box coordinates and the document image or extracted text for context. You should not use this prompt for documents where the distinction between print and handwriting is irrelevant to your workflow, or when you need character-level rather than region-level classification. It is also not suitable for real-time video streams or documents where handwriting is the only content type present—those scenarios require different prompt architectures.

Before deploying this prompt, you must define your confidence thresholds for routing to human review. The prompt produces confidence scores per classification, and you should establish a calibration set of documents with known ground truth to determine at what threshold misclassifications become unacceptable. Common failure modes include stylized fonts (especially script and decorative typefaces) being misclassified as handwriting, and light pencil annotations on dark backgrounds being missed entirely. Plan for these by including counterexamples in your few-shot demonstrations and implementing a human review queue for low-confidence regions. If your pipeline processes regulated documents, such as medical forms or legal contracts, human review of all handwriting classifications is strongly recommended until you have validated performance on your specific document population.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Handwritten Annotation vs. Printed Text Prompt works, where it fails, and the operational conditions required before putting it into a document processing pipeline.

01

Good Fit: Mixed-Origin Form Processing

Use when: documents contain a clear printed base layer (forms, contracts, invoices) with handwritten additions such as signatures, margin notes, checkmarks, or filled fields. Why: the prompt is designed to separate these two layers for downstream routing—printed text to extraction, handwriting to review or OCR.

02

Bad Fit: Stylized or Decorative Fonts

Avoid when: the document uses highly stylized printed fonts (script, calligraphic, or decorative typefaces) that mimic handwriting. Risk: the model misclassifies printed script as handwritten annotation, inflating false positives. Guardrail: pre-filter documents with font metadata when available, or add a confidence threshold below which regions are flagged for human review.

03

Required Inputs

Minimum inputs: a high-resolution document image or PDF page (≥200 DPI recommended), a region-of-interest list or full-page flag, and an output schema specifying bounding box format and confidence score range. Without these: the prompt cannot produce spatially grounded, confidence-weighted results suitable for production pipelines.

04

Operational Risk: Light Handwriting on Dark Backgrounds

What to watch: faint pencil, light ink, or thin strokes on dark printed backgrounds or shaded form fields. Risk: low contrast causes missed annotations (false negatives) that downstream systems treat as empty fields. Guardrail: implement a pre-processing contrast-enhancement step and set a low-confidence flagging threshold that routes uncertain regions to human review.

05

Operational Risk: Overlapping Annotations

What to watch: handwriting that crosses printed text, stamps that overlay signatures, or dense margin notes. Risk: the model may merge overlapping regions into a single classification or drop one layer entirely. Guardrail: request per-pixel classification confidence in the output schema and add a post-processing overlap resolver that splits ambiguous regions for re-evaluation.

06

When to Escalate Instead of Classify

Escalate when: the document contains mixed ink colors without clear printed/handwritten separation, or when the confidence score for a region falls below the production threshold. Guardrail: define an escalation path that routes low-confidence pages to a human review queue rather than silently accepting a classification that could corrupt downstream extraction.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for classifying document regions as handwritten annotations or printed text, with extracted content and bounding boxes.

This prompt template separates handwritten annotations from printed text in document images. It is designed for document processing pipelines that must distinguish original printed content from added handwriting—such as margin notes, filled form fields, corrections, and signatures. The template expects a document image as input and produces per-region classification with extracted text for both layers, bounding box coordinates, and confidence scores. Use this prompt when you need structured, machine-readable output that can be validated and routed downstream. Do not use this prompt for full OCR of clean digital-born documents; a standard text extraction pipeline is more appropriate for that case.

text
You are a document analysis system that separates handwritten annotations from printed text in document images.

Analyze the provided document image and classify each text region as either `handwritten` or `printed`. For each region, extract the text content and provide bounding box coordinates.

[INPUT]
- Document image: [DOCUMENT_IMAGE]
- Page number: [PAGE_NUMBER]

[OUTPUT_SCHEMA]
Return a JSON object with the following structure:
{
  "page_number": [PAGE_NUMBER],
  "regions": [
    {
      "region_id": "string",
      "classification": "handwritten | printed",
      "content": "string",
      "bounding_box": {
        "x": number,
        "y": number,
        "width": number,
        "height": number,
        "unit": "pixel"
      },
      "confidence": number (0.0 to 1.0),
      "characteristics": ["string"]
    }
  ],
  "overlap_regions": [
    {
      "region_ids": ["string", "string"],
      "overlap_type": "handwritten_over_printed | printed_over_handwritten | adjacent",
      "notes": "string"
    }
  ],
  "uncertain_regions": [
    {
      "region_id": "string",
      "reason": "string",
      "suggested_review": "string"
    }
  ]
}

[CONSTRAINTS]
1. Classify each distinct text region independently. Do not merge regions with different classifications.
2. For overlapping annotations (e.g., handwriting on top of printed text), include both regions and add an entry to `overlap_regions`.
3. Set `confidence` below 0.7 for any region where classification is ambiguous. Add such regions to `uncertain_regions` with a specific reason.
4. In the `characteristics` array, include relevant observations such as `cursive`, `all_caps`, `stylized_font`, `light_ink`, `colored_ink`, `margin_note`, `strikethrough`, `underline`, `circle`, `arrow`.
5. For stylized fonts that resemble handwriting (e.g., script typefaces), classify as `printed` and note `stylized_font` in characteristics.
6. For light handwriting on dark backgrounds, note `light_ink` and `low_contrast` in characteristics. Flag in `uncertain_regions` if contrast is below readable threshold.
7. Include margin notes, interlinear additions, and text outside the main content area.
8. Do not classify stamps, watermarks, or printed decorations as handwritten.

[EXAMPLES]
Example characteristics for handwritten regions:
- ["cursive", "margin_note", "blue_ink"]
- ["all_caps", "pencil", "light_ink"]
- ["mixed_case", "interlinear", "black_ink"]

Example characteristics for printed regions:
- ["serif_font", "bold"]
- ["stylized_font", "italic", "resembles_handwriting"]
- ["monospace", "small_size"]

[RISK_LEVEL]
Medium. Misclassification can cause data loss in downstream extraction pipelines. Route `uncertain_regions` to human review before final ingestion.

Adapt this template by replacing [DOCUMENT_IMAGE] with your image input method—base64-encoded data, a pre-signed URL, or a file path reference depending on your model's multimodal capabilities. Replace [PAGE_NUMBER] with the actual page index if processing multi-page documents. If your use case does not require overlap detection, remove the overlap_regions field from the output schema. For high-volume production pipelines, add a [BATCH_SIZE] parameter and adjust the output schema to handle multiple pages in a single request. Always validate the JSON output against the schema before passing results downstream; malformed bounding boxes or missing region_id values are common failure modes.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Handwritten Annotation vs. Printed Text Prompt. Validate these before calling the model to prevent runtime failures and silent misclassification.

PlaceholderPurposeExampleValidation Notes

[DOCUMENT_IMAGE]

Base64-encoded image or URL of the document page to analyze

data:image/png;base64,iVBORw0KGgo...

Validate MIME type is image/png, image/jpeg, or image/tiff. Reject PDFs; rasterize before passing. Minimum 150 DPI recommended for handwriting detection.

[PAGE_NUMBER]

Integer page reference for multi-page document tracking

3

Must be a positive integer. Used for bounding box coordinate context and error attribution in output. Null allowed for single-page documents.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for classification output

0.75

Float between 0.0 and 1.0. Regions below this threshold are flagged as UNCERTAIN rather than forced into a class. Lower thresholds increase false positives on stylized fonts.

[REGION_TYPE_FILTER]

Optional filter to return only specific annotation types

["handwritten", "printed"]

Must be a JSON array of strings from allowed enum: handwritten, printed, mixed, stamp, artifact. Null or empty array returns all types. Invalid values cause schema rejection.

[OUTPUT_SCHEMA_VERSION]

Schema version for output contract compatibility

2.1

String matching semantic version pattern. Used to select the correct output parser and validator. Mismatch between prompt and parser produces deserialization failures.

[INK_COLOR_HANDLING]

Strategy for distinguishing annotations by ink color

separate_by_color

Allowed values: ignore_color, separate_by_color, flag_color_only. When separate_by_color is selected, output includes per-color region groups. Requires adequate image color depth.

[OVERLAP_RESOLUTION]

Rule for resolving regions where handwriting overlaps printed text

split_and_classify

Allowed values: split_and_classify, flag_as_mixed, prioritize_handwritten, prioritize_printed. split_and_classify requires the model to attempt pixel-level separation. flag_as_mixed is safer for dense overlap.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Handwritten Annotation vs. Printed Text Prompt into a production document processing pipeline.

This prompt is designed to be called as a single step within a larger document processing pipeline, not as a standalone chat interaction. The primary integration point is after page-level OCR and layout analysis have completed but before structured field extraction. The pipeline should pass the pre-processed page image (or a cropped region) along with the OCR text layer and bounding boxes as [CONTEXT]. The model receives both visual and textual evidence, which allows it to disambiguate cases where OCR has merged handwritten and printed text into a single line. The prompt expects a structured JSON output conforming to [OUTPUT_SCHEMA], which downstream field extraction and validation steps will consume.

Wire the prompt into an application by wrapping it in a thin service function that handles image encoding, schema validation, and retry logic. The function should accept a page image (base64-encoded PNG or JPEG), an OCR result object containing word-level bounding boxes and text, and an optional region-of-interest mask. Before calling the model, validate that the image resolution meets a minimum threshold (e.g., 150 DPI) and that the OCR confidence scores are available for each word. After receiving the model response, validate the JSON against the expected schema: each region must have classification (one of handwritten, printed, mixed), extracted_text, bounding_box (four normalized coordinates), and confidence. Reject responses with malformed coordinates or missing required fields and trigger a retry with the validation error message appended to [CONSTRAINTS]. For high-stakes workflows such as legal document review or medical form processing, route any region with confidence below 0.85 or classification of mixed to a human review queue before downstream extraction proceeds.

Model choice matters here. Use a multimodal model with strong vision-language capabilities (e.g., GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro) because the task requires joint reasoning over pixel-level handwriting cues and OCR text. Avoid text-only models even if provided with OCR output; they cannot detect faint pencil marks, erasures, or overlapping ink colors that are visually obvious. Set temperature to 0 or a very low value (0.1) to maximize output consistency across repeated runs on the same document. Log every request and response, including the raw image hash, OCR input, model output, validation result, and any retry attempts. This audit trail is essential for debugging misclassifications—particularly the known failure mode where stylized printed fonts (e.g., cursive or script typefaces) are misclassified as handwritten. When you observe this failure in production, add the misclassified region to a few-shot example set and include it in [EXAMPLES] for future calls.

Do not use this prompt for real-time user-facing annotation tools that require sub-second latency; the multimodal model call plus validation adds 2–5 seconds per page. Instead, run it as an asynchronous preprocessing step whose results are cached and served to the UI. If your pipeline processes documents with known templates (e.g., standard government forms), consider pre-computing the printed text regions from the template and skipping the model call for those areas entirely—use the prompt only for regions where annotations are expected. Finally, pair this prompt with the Form Field Completeness Audit Prompt downstream: once you have separated handwritten annotations from printed text, the audit prompt can verify that all required handwritten fields (signatures, dates, initials) are present and legible before the document proceeds to the next stage.

IMPLEMENTATION TABLE

Expected Output Contract

The structured output schema for the Handwritten Annotation vs. Printed Text Prompt. Use this contract to validate the model's JSON response before it enters downstream processing pipelines.

Field or ElementType or FormatRequiredValidation Rule

regions

array of objects

Must be a non-empty array. Each element must conform to the region object schema defined in the subsequent rows.

regions[].region_id

string

Must be a unique identifier within the response, formatted as 'region-XXX' where X is a digit.

regions[].bounding_box

object

Must contain 'x', 'y', 'width', 'height' as numbers. Coordinates must be normalized to [0.0, 1.0] relative to page dimensions.

regions[].classification

string

Must be one of: 'handwritten', 'printed', 'mixed'. If 'mixed', the 'overlap_details' field must be present.

regions[].extracted_text

string

Must be a non-empty string. If classification is 'mixed', this should contain the concatenated text from both layers.

regions[].confidence

number

Must be a float between 0.0 and 1.0. If below 0.7, the 'low_confidence_reason' field must be populated.

regions[].handwritten_layer

object or null

If present, must contain 'text' (string) and 'ink_color' (string). Required when classification is 'handwritten' or 'mixed'.

regions[].printed_layer

object or null

If present, must contain 'text' (string) and 'font_style' (string). Required when classification is 'printed' or 'mixed'.

PRACTICAL GUARDRAILS

Common Failure Modes

Handwritten vs. printed text classification breaks in predictable ways. These are the most common failure modes in production document pipelines and how to guard against them.

01

Stylized Fonts Misclassified as Handwriting

What to watch: Script fonts, cursive typography, and decorative typefaces trigger false positives for handwriting. Italic serif fonts with ligatures and calligraphic drop caps are especially prone to misclassification. Guardrail: Include a font-ambiguity confidence flag in the output schema. Route regions with medium confidence and script-like printed text to a secondary verification prompt that checks for repeating glyph patterns, uniform stroke width, and baseline consistency—all indicators of machine text.

02

Light Handwriting on Dark Backgrounds

What to watch: Pencil annotations on dark paper, colored ink on dark form fields, or faint notes in shadowed scan regions produce false negatives. The model defaults to treating low-contrast marks as background noise. Guardrail: Apply adaptive contrast normalization as a preprocessing step before classification. Add a dedicated low-contrast region detector that flags areas where foreground-background delta falls below a configurable threshold, routing those regions for human review regardless of model confidence.

03

Overlapping Annotation and Printed Text

What to watch: Handwriting directly on top of printed text—common in margin notes, inline corrections, and filled form fields—causes the model to merge both layers into a single region or misattribute text to the wrong layer. Guardrail: Require per-pixel layer separation in the output schema with explicit overlap bounding boxes. When overlap exceeds 20% of either region, flag for manual review and extract both text layers independently with spatial relationship metadata.

04

Mixed Ink Colors in Single Annotations

What to watch: Annotations written with multiple pens, color-coded markups, or ink that changes density mid-stroke are split into separate regions or partially classified as printed artifacts. Guardrail: Implement spatial proximity clustering in post-processing. Merge adjacent handwritten regions within a configurable pixel distance that share stroke-width similarity, then reclassify the merged region. Log merge decisions for audit trails.

05

Scanner Artifacts Confused with Annotations

What to watch: Bleed-through from reverse-page handwriting, staple holes, binding shadows, and dust specks on scanner glass are classified as annotations. This is the highest-volume false positive source in batch scanning pipelines. Guardrail: Add an artifact-classification prefilter that identifies known scanner noise patterns before the handwriting classifier runs. Maintain a reference library of common artifact signatures per scanner model and flag regions matching those patterns as low-priority for annotation review.

06

Confidence Drift Across Document Quality Tiers

What to watch: The same model produces high confidence on clean 300 DPI scans but collapses to low confidence or random classification on fax-quality documents, mobile photos of paper forms, or heavily compressed PDFs. Teams discover this only after deploying to real-world intake channels. Guardrail: Calibrate confidence thresholds per quality tier using a representative eval set that spans your actual input distribution. Implement quality-gated routing: high-quality scans proceed automatically, medium-quality get secondary verification, low-quality are routed to human review with the model's best-guess classification as a hint.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Handwritten Annotation vs. Printed Text Prompt before deploying it to production. Each criterion targets a known failure mode for this specific classification task.

CriterionPass StandardFailure SignalTest Method

Stylized Font Misclassification

Printed cursive or decorative fonts (e.g., script logos) are classified as printed_text with confidence >= 0.85

Output classifies stylized printed fonts as handwriting

Run prompt against a golden set of 20 documents containing script, italic, and decorative printed fonts. Assert precision >= 0.95 on printed_text label for these samples.

Light Handwriting on Dark Backgrounds

Handwriting in white or light ink on dark or photographic backgrounds is detected with recall >= 0.90

Output misses light-on-dark annotations or classifies them as printed_text or artifact

Test with 15 samples containing white ink, light pencil on dark paper, and annotations over photos. Measure recall for handwriting class.

Overlapping Annotation Separation

When handwriting overlaps printed text, both layers are extracted as separate regions with distinct text content and bounding boxes

Output merges overlapping regions into a single classification or extracts only one layer's text

Use 10 samples with intentional overlap (strikethroughs, margin notes crossing text, filled forms). Assert that each sample returns >= 2 distinct regions with correct per-layer text.

Margin Note Detection

Handwritten notes in document margins are classified as handwriting with bounding boxes that do not include adjacent printed body text

Margin notes are missed entirely or bounding boxes bleed into printed columns

Test with 12 documents containing margin annotations at varying distances from text blocks. Assert IoU >= 0.85 for each annotation bounding box against ground truth.

Mixed Ink Color Handling

Documents with multiple ink colors produce per-region classification that is color-agnostic; blue, black, and red handwriting are all classified as handwriting

Output classifies non-black ink as printed_text or artifact, or confidence drops significantly for colored handwriting

Run against 8 samples with multi-color annotations. Assert recall >= 0.92 for handwriting class across all ink colors.

Confidence Calibration on Ambiguous Marks

Regions with genuinely ambiguous classification (e.g., neat handwriting resembling a monospace font) receive confidence <= 0.75 and are flagged for human review

Ambiguous regions receive high confidence for the wrong class or confidence is uniformly low across all outputs

Use 10 deliberately ambiguous samples. Assert that regions with human-annotated ambiguity have confidence <= 0.75 and that the requires_review flag is true for those regions.

Empty Page Handling

Documents with no handwriting return an empty regions array and a summary indicating no annotations detected

Output hallucinates handwriting regions on blank pages or returns a non-empty array with low-confidence noise

Test with 5 pages containing only printed text and 3 completely blank pages. Assert regions array is empty and annotation_summary.total_handwritten_regions equals 0.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single representative document. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with vision capabilities. Skip bounding box validation initially—focus on whether the model correctly separates handwritten from printed regions in plain text output. Use a simple JSON schema with region_type, content, and confidence fields.

code
Analyze this document image. For each text region, classify as [HANDWRITTEN] or [PRINTED].
Return JSON: [{"region_type": "handwritten|printed", "content": "...", "confidence": 0.0-1.0}]

Watch for

  • Stylized fonts (script, italic serifs) misclassified as handwriting
  • Light pencil annotations missed entirely
  • Overlapping text regions merged into a single classification
  • No confidence differentiation between clear and ambiguous cases
Prasad Kumkar

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.