Inferensys

Prompt

Null vs Missing Value Confidence Prompt

A practical prompt playbook for distinguishing absent, empty, and unreadable values in production extraction pipelines.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise job, ideal user, and operational constraints for the Null vs Missing Value Confidence Prompt.

This prompt is for data quality engineers and pipeline builders who need to move beyond binary extraction. The core job is to classify every target field into one of three states: present with a value, present but empty/null, or genuinely absent from the source text. A simple extraction that returns null for both a missing field and an empty field creates a data quality nightmare downstream—you can't tell if the source was silent or explicitly blank. This prompt forces the model to make that distinction and provide a confidence score and evidence span for its classification.

Use this prompt when you are ingesting semi-structured or unstructured text into a system of record where null semantics matter. For example, a contract review pipeline needs to know if a 'termination date' field is missing from the document (high risk, needs escalation) versus present but left blank (explicitly open-ended). The prompt requires a defined [FIELD_SCHEMA] with field names and descriptions, the [SOURCE_TEXT] to analyze, and a [CONFIDENCE_THRESHOLD] for flagging uncertain classifications. It is designed to be wired into a validation harness that checks for conflation errors—specifically, that a missing field is never classified as empty, and an empty field is never classified as missing without explicit evidence.

Do not use this prompt for simple key-value extraction where null semantics are irrelevant, or when you cannot tolerate the extra token cost of tri-state classification. It is also not a replacement for a full entity resolution pipeline; it classifies the presence state of a field, not the identity of an entity. If your downstream system cannot distinguish between a missing value and an empty string, this prompt adds complexity without value. Before deploying, ensure your eval suite includes test cases for all three states, edge cases like whitespace-only values, and adversarial examples where the source text implies a value without stating it directly. Human review is mandatory for any classification that falls below the configured confidence threshold, especially for fields with regulatory or financial impact.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Null vs Missing Value Confidence Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your extraction pipeline before you invest in integration.

01

Good Fit: Strict Schema Ingestion

Use when: downstream systems require explicit differentiation between a field that is absent, empty, or unreadable. Guardrail: validate that the output tri-state enum matches your database column constraints before insertion.

02

Good Fit: Audit-Ready Extraction

Use when: you need to prove that a missing value was genuinely absent from the source, not a model hallucination or extraction failure. Guardrail: always include the evidence span in the output so reviewers can verify the classification independently.

03

Bad Fit: High-Volume Streaming

Avoid when: latency budgets are under 200ms and every millisecond counts. Tri-state classification with evidence spans adds token overhead. Guardrail: benchmark response times and consider a simpler binary present/absent prompt if speed dominates accuracy requirements.

04

Bad Fit: Unstructured Free-Text Only

Avoid when: the source text has no schema, no expected fields, and no concept of 'missing' versus 'empty.' The tri-state distinction collapses when there is no field contract. Guardrail: use this prompt only when you have a defined field list with expected presence rules.

05

Required Inputs

Must provide: a defined field schema with field names and expected types, the raw source text, and a clear definition of what 'absent,' 'empty,' and 'unreadable' mean in your domain. Guardrail: include domain-specific examples of each tri-state category in the prompt to reduce ambiguity.

06

Operational Risk: Conflation of Null Types

What to watch: the model may classify a genuinely absent field as 'empty' or an unreadable value as 'absent.' This conflation corrupts downstream analytics. Guardrail: run eval checks with known-answer test cases for each tri-state category and measure per-category precision before production deployment.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for classifying extracted fields as genuinely absent, present but empty, or present with an unreadable value, with confidence and evidence spans.

The following prompt template is designed to be copied directly into your prompt management system, IDE, or orchestration layer. It uses square-bracket placeholders for all dynamic inputs, making it safe to store in version control and inject at runtime. The template forces a strict tri-state classification—NULL (genuinely absent), EMPTY (present but empty), or UNREADABLE (present with unreadable content)—for each target field, preventing the common production failure where missing data and empty strings are conflated in downstream ingestion pipelines.

text
You are a data quality classifier for extraction pipelines. Your task is to analyze the source text and determine the state of each target field.

## INPUT
Source Text:
"""
[SOURCE_TEXT]
"""

Target Fields:
[FIELD_LIST]

## CLASSIFICATION RULES
For each target field, classify its state as exactly one of:
- `NULL`: The field is genuinely absent from the source text. No mention, no implication, no placeholder exists.
- `EMPTY`: The field is present in the source but contains no meaningful value (e.g., an empty form field, a blank line, a placeholder like "N/A" or "--").
- `UNREADABLE`: The field is present but the value cannot be reliably read due to garbled text, OCR errors, corruption, truncation, or encoding issues.

## CONFIDENCE SCORING
For each classification, provide a confidence score from 0.0 to 1.0 where:
- 0.9-1.0: Clear, unambiguous evidence supports the classification.
- 0.7-0.89: Strong evidence with minor ambiguity.
- 0.5-0.69: Plausible classification but significant ambiguity exists.
- Below 0.5: Do not classify; mark as `AMBIGUOUS` with a note.

## EVIDENCE REQUIREMENT
For every classification, you MUST provide:
- An `evidence_span`: The exact substring from the source text that supports your classification, or an empty string if the evidence is the absence of any mention.
- An `evidence_rationale`: A one-sentence explanation of why this span supports the classification.

## OUTPUT SCHEMA
Return a JSON object with this exact structure:
{
  "fields": [
    {
      "field_name": "string",
      "classification": "NULL" | "EMPTY" | "UNREADABLE" | "AMBIGUOUS",
      "confidence": 0.0,
      "evidence_span": "string",
      "evidence_rationale": "string"
    }
  ],
  "overall_confidence": 0.0,
  "escalation_required": true | false,
  "escalation_reason": "string or null"
}

## CONSTRAINTS
[CONSTRAINTS]

## EXAMPLES
[EXAMPLES]

## RISK LEVEL
[RISK_LEVEL]

Adaptation guidance: Replace [SOURCE_TEXT] with the raw document or snippet under analysis. [FIELD_LIST] should be a JSON array of field names to classify, or a structured schema if your pipeline expects typed output. Use [CONSTRAINTS] to inject domain-specific rules—for example, "Treat the string 'N/A' as EMPTY, not NULL" or "Fields marked as PII require confidence >= 0.9." The [EXAMPLES] placeholder should contain 2-4 few-shot examples demonstrating the distinction between NULL, EMPTY, and UNREADABLE for your specific document type. Set [RISK_LEVEL] to HIGH for regulated domains, which should trigger mandatory human review when escalation_required is true. Before deploying, validate that your pipeline correctly handles the AMBIGUOUS classification—many downstream systems only expect the three primary states and will fail silently on unexpected values.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Null vs Missing Value Confidence Prompt. Each placeholder must be populated before the prompt is assembled. Validation notes describe how to check that the input is well-formed and safe before it reaches the model.

PlaceholderPurposeExampleValidation Notes

[SOURCE_TEXT]

The raw text span or document snippet being analyzed for field presence

"The contract was signed by Jane Doe on . The notary seal is present."

Must be a non-empty string. Truncate to the model's context window minus prompt overhead. Check for encoding issues if copied from PDF or HTML.

[TARGET_FIELD_NAME]

The semantic name of the field being checked for presence, absence, or emptiness

"signature_date"

Must be a single field identifier string. Use a schema-validated enum or allowlist to prevent prompt injection via field names.

[FIELD_DESCRIPTION]

A natural language description of what the field represents and its expected format

"The date the contract was signed, expected in YYYY-MM-DD format"

Must be a non-empty string. Avoid embedding executable instructions or schema logic here; keep it descriptive. Review for PII leakage if field descriptions reference sensitive data patterns.

[NULL_DEFINITION]

A precise definition of what constitutes a genuinely absent value for this field in this domain

"The source text contains no date-like token or reference to a signing date anywhere in the document"

Must be a non-empty string. Should be domain-specific and testable. Ambiguous null definitions cause conflation with empty-string cases. Validate against a set of known edge-case examples before production use.

[EMPTY_DEFINITION]

A precise definition of what constitutes a present-but-empty value for this field

"A date field is present in the document structure but contains no value, e.g., 'Date: ______' or 'Signed on: [blank]'"

Must be a non-empty string. Should explicitly distinguish structural presence from semantic absence. Test against documents with blank form fields, whitespace-only values, and placeholder characters.

[UNREADABLE_DEFINITION]

A precise definition of what constitutes a present-but-unreadable value

"A date value exists in the source but is illegible due to scan quality, redaction, or corrupted characters, e.g., 'Signed on: 2##3-01-15'"

Must be a non-empty string. Should cover OCR artifacts, redaction marks, and corrupted encoding. Validate that the definition does not overlap with null or empty definitions.

[OUTPUT_SCHEMA]

The exact JSON schema the model must produce, including the tri-state classification field, confidence score, and evidence span

{"status": "present", "value": "2023-01-15", "confidence": 0.97, "evidence_span": "signed on 2023-01-15"}

Must be a valid JSON Schema or a concrete example object. Validate that the schema includes required fields: status (enum: null, empty, unreadable, present), confidence (number 0-1), evidence_span (string or null). Reject schemas missing these fields before prompt assembly.

[CONFIDENCE_THRESHOLD]

The minimum confidence score required for the classification to be considered reliable enough for automated downstream use

0.85

Must be a float between 0.0 and 1.0. Validate that the threshold is appropriate for the domain risk tolerance. Values below 0.7 often indicate the prompt or extraction task needs redesign rather than a lower threshold.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the tri-state null classification prompt into a production extraction pipeline with validation, retries, and audit logging.

The Null vs Missing Value Confidence Prompt is designed to sit between raw text ingestion and structured record assembly. It should be called once per field per document, or batched as a single request with multiple field evaluations if your latency budget allows. The prompt expects a source text span and a target field name, and it returns a tri-state classification (NULL, EMPTY, VALUE) with a confidence score and an evidence span. This output is not a final record—it is a metadata annotation that downstream assembly logic uses to decide whether to populate, leave blank, or escalate a field.

Validation and Retry Logic: The model output must be validated against a strict JSON schema before it enters your pipeline. The schema should enforce that classification is exactly one of the three allowed strings, confidence is a float between 0.0 and 1.0, and evidence_span is a non-empty string that can be located in the original source text. If validation fails, implement a single retry with the error message injected into the prompt context. If the retry also fails, log the raw output and escalate the entire field to a human review queue rather than guessing. For high-volume pipelines, add a circuit breaker that halts processing if the validation failure rate exceeds 5% in a rolling window—this usually indicates a prompt drift or model behavior change.

Model Choice and Tool Use: This prompt works well with smaller, faster models (e.g., Claude Haiku, GPT-4o-mini) because the task is narrow and classification-focused. Avoid using large reasoning models unless you are also asking for a detailed justification. The prompt does not require external tools, retrieval, or function calling—it is a pure text-to-JSON classification task. However, you should wrap the call in application-level code that performs the evidence span lookup: after receiving the response, your harness should verify that the returned evidence_span substring exists in the original source text. If it does not, treat the result as a hallucination and escalate. This check is cheap, deterministic, and catches one of the most common failure modes: the model inventing a plausible but absent span.

Logging and Audit Trail: Every classification result should be logged with the input source text, the field name, the model's full response, the validation result, and the outcome (accepted, retried, escalated). This log becomes your audit trail for downstream consumers who need to understand why a field was populated, left null, or flagged as empty. For regulated domains, also log the model version and the prompt template hash so that every decision is traceable to a specific configuration. Do not rely on the model's confidence score alone for auditability—the evidence span and the application-level substring check provide the verifiable ground truth.

Integration with Record Assembly: After classification, your record assembly step should use the tri-state result to decide field population: VALUE classifications proceed to extraction and normalization; NULL classifications leave the field unpopulated with a missing annotation; EMPTY classifications populate the field with an empty string or domain-appropriate empty sentinel. Fields with confidence below your threshold (typically 0.7–0.85, depending on risk tolerance) should be routed to a review queue with the classification, evidence span, and source context attached. Avoid the common mistake of treating low-confidence NULL and low-confidence EMPTY the same way—they represent different underlying conditions and may require different reviewer instructions.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the tri-state classification payload, per-field confidence structure, and validation rules for the Null vs Missing Value Confidence Prompt. Use this contract to validate model output before ingestion.

Field or ElementType or FormatRequiredValidation Rule

classification

enum: ["VALUE_PRESENT", "VALUE_EMPTY", "VALUE_MISSING", "VALUE_UNREADABLE"]

Must be exactly one of the four enum values. Reject any other string.

extracted_value

string or null

Must be null when classification is VALUE_MISSING or VALUE_UNREADABLE. Must be a non-null string when classification is VALUE_PRESENT. Must be an empty string when classification is VALUE_EMPTY.

confidence

number

Float between 0.0 and 1.0 inclusive. Must be present for every classification. Reject if missing or out of range.

evidence_span

object

Must contain start_char and end_char integer fields. Both must be >= 0. end_char must be > start_char unless classification is VALUE_MISSING, in which case both must be 0.

evidence_span.start_char

integer

Integer >= 0. Must be 0 when classification is VALUE_MISSING.

evidence_span.end_char

integer

Integer >= 0. Must be 0 when classification is VALUE_MISSING. Must be > start_char for all other classifications.

alternative_interpretations

array or null

If present, each element must be an object with value (string) and confidence (number 0.0-1.0). Required when classification is VALUE_UNREADABLE. Null allowed for other classifications.

field_name

string

Must match the [TARGET_FIELD] placeholder value exactly. Case-sensitive match required. Reject on mismatch.

PRACTICAL GUARDRAILS

Common Failure Modes

Production failures when distinguishing null, empty, and unreadable values—and how to prevent them before they corrupt downstream systems.

01

Conflating Null with Empty String

What to watch: The model treats a genuinely absent field (no mention in source) identically to a field present but left blank. Downstream systems interpret both as the same state, losing critical data quality signals. Guardrail: Require a strict tri-state enum (NULL, EMPTY, VALUE) in the output schema and validate that every field explicitly declares its state before ingestion.

02

Unreadable Value Treated as Null

What to watch: The model encounters garbled text, OCR artifacts, or redacted content and classifies it as NULL (absent) instead of UNREADABLE. This silently drops information that a human reviewer could potentially recover. Guardrail: Add a dedicated UNREADABLE state with an evidence_span field. Test with intentionally corrupted inputs to verify the model distinguishes corruption from absence.

03

Confidence Score Divergence Across States

What to watch: The model assigns high confidence to a NULL classification when the source text is ambiguous about whether the field was omitted or simply not discussed. False certainty propagates through automation gates. Guardrail: Require separate confidence scores for the state classification and the value extraction. Flag any NULL classification with confidence below 0.9 for human review.

04

Evidence Span Missing for Negative Findings

What to watch: The model correctly identifies a field as absent but fails to cite the source span that supports this negative finding. Auditors cannot verify why the model concluded the field was missing. Guardrail: Require an evidence_span for NULL and EMPTY classifications, citing the document region that was searched. Test with documents where fields appear in unexpected sections.

05

Schema Drift Under Partial Extraction

What to watch: When only some fields are extractable, the model omits low-confidence fields entirely rather than returning them with UNREADABLE or NULL states. Downstream parsers break on missing keys. Guardrail: Enforce a strict output contract where every field in the schema must appear in the response. Validate response completeness before any downstream processing.

06

Empty String Misclassified as Present Value

What to watch: The model extracts an empty string and reports it as a valid VALUE state with moderate confidence, bypassing null-handling logic. This creates phantom records in databases that expect non-empty values. Guardrail: Add a post-extraction validator that rejects VALUE state when the extracted content is whitespace-only or zero-length. Route these to the EMPTY classification path.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating whether the prompt correctly distinguishes null, missing, and empty values before shipping to production.

CriterionPass StandardFailure SignalTest Method

Null vs Missing Classification

Field correctly classified as null (present but empty), missing (absent from source), or unreadable (present but illegible) in at least 95% of test cases

Null and missing conflated in output; empty string treated as missing; unreadable classified as null

Run against golden dataset with 50 labeled examples spanning all three states; measure per-class accuracy

Confidence Score Assignment

Confidence score between 0.0 and 1.0 provided for every field classification; scores correlate with actual correctness across 100+ samples

Confidence always 1.0 or always 0.5; confidence high on known misclassifications; missing confidence field

Binned confidence calibration check: group predictions by confidence decile and verify accuracy matches within 10% tolerance

Evidence Span Extraction

Source text span cited for every classification decision; span boundaries match the exact text supporting the null/missing/unreadable determination

Missing evidence span; span points to wrong sentence; span is entire document instead of specific text; hallucinated span not in source

Character-offset comparison between output spans and annotated ground-truth spans; require exact match or overlap > 90%

Empty String Handling

Empty string in source correctly classified as null (present but empty) with high confidence, never misclassified as missing

Empty string classified as missing; empty string triggers unreadable classification; confidence drops incorrectly on empty strings

Test suite with 20 empty-string source fields; require null classification with confidence > 0.8 for all cases

Unreadable Value Detection

Garbled text, encoding errors, or truncated values correctly classified as unreadable with evidence span pointing to the problematic segment

Unreadable text classified as null or missing; unreadable classification used for legible but ambiguous values; no evidence span

Inject 15 unreadable-value examples (mojibake, truncation, encoding artifacts); require unreadable classification rate > 90%

Tri-State Output Schema Compliance

Output strictly follows the defined tri-state schema with no extra fields, missing required fields, or type violations

Extra fields appear in output; required fields missing; confidence is string instead of float; evidence_span is object instead of string

JSON Schema validation against the output contract; reject any output that fails schema validation

Cross-Field Independence

Classification of one field does not incorrectly influence classification of another field in the same document

All fields in a document receive identical classification when source evidence differs; null propagation across unrelated fields

Test with documents containing mixed null/missing/unreadable fields; verify per-field independence in classification decisions

Edge Case: Whitespace-Only Values

Whitespace-only source values (spaces, tabs, newlines) classified as null with evidence span showing the whitespace

Whitespace-only classified as missing; whitespace triggers unreadable; confidence drops on whitespace-only fields

Test suite with 10 whitespace-only field examples; require null classification with confidence > 0.8

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base tri-state classification prompt. Use a simple JSON output schema without strict validation. Accept null, "", and "[UNREADABLE]" as the three states. Skip evidence spans initially.

code
Classify the field [FIELD_NAME] from the source text as one of:
- "present_and_populated": value is [EXTRACTED_VALUE]
- "present_but_empty": field exists but contains no readable value
- "absent": field is not mentioned in the source

Return JSON: {"state": "...", "confidence": 0.0-1.0}

Watch for

  • Conflating empty strings with absent fields when the source mentions the field but leaves it blank
  • Overconfident scores on ambiguous spans
  • No distinction between "" and whitespace-only values
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.