Inferensys

Prompt

Hallucinated Date and Number Detection Prompt

A practical prompt playbook for using Hallucinated Date and Number Detection Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and clear boundaries for deploying the hallucinated date and number detection prompt in a production pipeline.

This prompt is designed for reporting and analytics pipelines where model-generated dates, timestamps, numeric values, and statistics must be verified against source data before they enter databases, dashboards, or downstream systems. Use it as a post-generation validation step when a model has produced a summary, report, or analysis that includes quantitative claims. The prompt instructs the model to act as an auditor, cross-referencing every date and number in the output against the provided input context, flagging unsupported values with confidence scores, and suggesting corrections when evidence exists. This is not a prompt for generating content. It is a repair and validation prompt that belongs after generation, before ingestion.

The ideal user is a data engineer, ML engineer, or backend developer responsible for an automated reporting pipeline. The required context is a pair of inputs: the original source data or document that grounds the facts, and the model-generated output that needs auditing. Without both, the prompt cannot perform its cross-reference function. The output is a structured audit report—ideally JSON—containing each flagged value, its location in the text, a confidence score for hallucination, the evidence (or lack thereof) from the source, and a suggested correction when possible. This structured output is designed to be consumed by a downstream validation harness, not read in isolation.

Do not use this prompt when the source data is unavailable, when the output contains only qualitative claims, or when the model's generation step already has perfect grounding guarantees. It is also inappropriate for real-time chat applications where latency constraints prevent a secondary validation pass. In high-risk domains such as financial reporting or clinical documentation, this prompt is a necessary but not sufficient control—always pair it with human review for flagged items above a defined severity threshold. For maximum reliability, implement this as a gating step: if the audit report returns any high-confidence hallucinations, block the output from downstream ingestion and route it for manual correction.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Hallucinated Date and Number Detection Prompt works and where it introduces risk. Use this prompt when you need to validate temporal and numeric claims against source data before they enter reporting pipelines or analytics databases.

01

Good Fit: Post-Generation Validation in Analytics Pipelines

Use when: model output containing dates, timestamps, statistics, or numeric values must be verified against input data before ingestion into dashboards, reports, or databases. Guardrail: run this prompt as a mandatory validation step after generation and before downstream consumption, with automated rejection of unverifiable values.

02

Bad Fit: Real-Time Streaming with Tight Latency Budgets

Avoid when: sub-second response times are required and the validation prompt adds unacceptable latency. Guardrail: use a lightweight regex-based pre-filter for obvious fabrications, then batch-validate with this prompt asynchronously. Flag streams for retrospective correction rather than blocking real-time delivery.

03

Required Inputs: Source Data and Model Output Pair

What to watch: the prompt cannot detect hallucination without access to the original input data that the model was supposed to reference. Guardrail: always pass both the source document or context and the model-generated output as paired inputs. Missing source data should trigger an immediate escalation, not a best-guess validation.

04

Operational Risk: False Confidence in Ambiguous Matches

What to watch: the model may assign high confidence to dates or numbers that partially match source data but are semantically wrong—such as a correct year with a fabricated month. Guardrail: require the prompt to output explicit match evidence for each validated value, not just a confidence score. Log low-evidence matches for human spot-checking.

05

Operational Risk: Silent Normalization of Fabricated Values

What to watch: the prompt may incorrectly 'correct' a hallucinated value by finding a nearby source value and treating it as a match, masking the fabrication. Guardrail: instruct the prompt to distinguish between exact matches, approximate matches, and no-match conditions. Require explicit reason codes for each correction and flag approximate matches for review.

06

Scale Limit: High-Volume Batch Processing Without Triage

What to watch: running this prompt on every output in a high-throughput pipeline can become expensive and slow. Guardrail: pre-filter outputs using deterministic checks—such as date format validation or numeric range checks—and only route suspicious outputs to this prompt. Maintain a sampling strategy for quality monitoring on passed outputs.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for detecting hallucinated dates and numbers in model output, ready to copy into your orchestration layer.

This prompt template is designed to be dropped directly into your prompt library or orchestration code. It accepts a block of model-generated text and the original source input, then returns a structured audit of every date, timestamp, numeric value, and statistic that cannot be traced back to the source. Use it as a post-generation validation step in reporting pipelines, analytics systems, or any workflow where fabricated temporal or quantitative data would corrupt downstream decisions.

text
You are an output auditor specialized in detecting hallucinated dates, timestamps, numeric values, and statistics in AI-generated text.

Your task is to compare the [OUTPUT_TEXT] against the [SOURCE_INPUT] and identify every date, timestamp, numeric value, or quantitative claim in the output that cannot be traced to evidence in the source.

## Input

**Source Input (ground truth):**
[SOURCE_INPUT]

**Model Output (to audit):**
[OUTPUT_TEXT]

## Instructions

1. Extract every date, timestamp, numeric value, percentage, monetary amount, statistic, or quantitative claim from the model output.
2. For each extracted value, search the source input for supporting evidence.
3. Classify each value as one of:
   - **GROUNDED**: The exact value or a mathematically derivable equivalent appears in the source.
   - **PARTIALLY_GROUNDED**: The value is consistent with source data but not explicitly stated (e.g., a sum of stated figures, an inferred date range).
   - **HALLUCINATED**: The value has no traceable basis in the source input.
   - **CONTRADICTED**: The value directly conflicts with source data.
4. For each HALLUCINATED or CONTRADICTED value, provide a corrected value if the source contains evidence for one. If no correction is possible, set the corrected_value to null.
5. Assign a confidence score from 0.0 to 1.0 for each classification.

## Output Schema

Return a JSON object with this exact structure:

{
  "audit_summary": {
    "total_values_extracted": <integer>,
    "grounded_count": <integer>,
    "partially_grounded_count": <integer>,
    "hallucinated_count": <integer>,
    "contradicted_count": <integer>,
    "overall_hallucination_rate": <float 0.0-1.0>
  },
  "findings": [
    {
      "value": "<the extracted value as it appears in output>",
      "value_type": "<date | timestamp | percentage | currency | integer | float | statistic | duration | other>",
      "location_in_output": "<surrounding context or sentence fragment>",
      "classification": "<GROUNDED | PARTIALLY_GROUNDED | HALLUCINATED | CONTRADICTED>",
      "confidence": <float 0.0-1.0>,
      "source_evidence": "<quoted evidence from source input, or null if none found>",
      "corrected_value": "<correct value from source, or null>",
      "correction_rationale": "<explanation of correction, or null>"
    }
  ],
  "requires_human_review": <boolean>,
  "review_triggers": ["<list of reasons human review is recommended, empty if none>"]
}

## Constraints

- Do not flag values that are clearly marked as hypothetical, projected, or estimated in the output text if the source contains the basis for those projections.
- Treat relative date expressions ("last quarter," "next month") as values requiring source grounding against a reference date.
- If the source input is empty or contains no quantitative data, classify all extracted values as HALLUCINATED.
- If [RISK_LEVEL] is "high," set requires_human_review to true for any finding with confidence below 0.9.
- Preserve the exact formatting of extracted values in the "value" field.

## Risk Level
[RISK_LEVEL]

Adaptation notes: Replace [SOURCE_INPUT] with the original document, retrieved context, or database record that the model was supposed to work from. Replace [OUTPUT_TEXT] with the model-generated text you need to audit. Set [RISK_LEVEL] to "low", "medium", or "high" to control the human-review threshold. For high-stakes pipelines like financial reporting or clinical documentation, keep [RISK_LEVEL] at "high" and route flagged outputs to a review queue before they reach consumers. If your source input is structured data rather than free text, pre-serialize it into a text representation that preserves all quantitative fields and their relationships.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Validate each before sending the prompt. Missing or malformed inputs are the most common cause of false negatives in hallucination detection.

PlaceholderPurposeExampleValidation Notes

[MODEL_OUTPUT]

The generated text to scan for hallucinated dates and numbers

The Q3 revenue reached $2.4M on 15-Oct-2024 according to the earnings call.

Required. Must be non-empty string. Truncate at 32K tokens if longer. Check for encoding artifacts before passing.

[SOURCE_CONTEXT]

The ground-truth documents, data, or text the model was supposed to use

Q3 FY2024 Earnings Call Transcript: ... revenue of $2.4 million ... October 15, 2024 ...

Required. Must be non-empty string. If multiple sources, concatenate with clear delimiter and source labels. Null or empty context makes all dates and numbers unverifiable.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for flagging a value as hallucinated

0.7

Required. Float between 0.0 and 1.0. Values below threshold are marked as uncertain rather than hallucinated. Default 0.7 if not provided. Validate range before prompt assembly.

[DATE_FORMAT_SPEC]

Expected date format for corrected values when input evidence exists

ISO 8601 (YYYY-MM-DD)

Optional. String enum: ISO8601, US_MDY, EU_DMY, UNIX_MS, or null. If null, output uses original format from source context. Validate against allowed enum values.

[NUMERIC_PRECISION]

Decimal places or significant figures for corrected numeric values

2

Optional. Integer 0-6 or null. If null, preserve precision from source context. Validate as integer in range. Controls rounding of corrected values only, not detection sensitivity.

[OUTPUT_SCHEMA]

Expected structure for the detection report

JSON array of flagged items with field, value, confidence, evidence, corrected_value

Required. Must be a valid JSON Schema or structured format name. Validate parseable before prompt assembly. Schema mismatch causes downstream integration failures.

[ALLOW_PARTIAL_MATCH]

Whether to accept fuzzy date matches as grounded

Optional. Boolean. If true, 'Oct 15' matches 'October 15, 2024'. If false, requires exact string match. Validate as boolean. Set false for audit and compliance use cases.

[MAX_FLAGGED_ITEMS]

Upper limit on flagged items returned to prevent response bloat

50

Optional. Integer 1-500. If null, return all flagged items. Validate range. Use when output feeds into rate-limited downstream systems or human review queues.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the hallucinated date and number detection prompt into a production data pipeline with validation, retries, and audit logging.

This prompt is designed to sit in a post-generation validation layer within your analytics or reporting pipeline. After a model produces output containing dates, timestamps, numeric values, or statistics, route that output—along with the original input data—through this detection prompt before the values enter any downstream database, dashboard, or user-facing report. The prompt expects two inputs: the model-generated text and the source input data that should have grounded those values. Without both inputs, the detection logic cannot function, and the prompt will correctly flag most values as unverifiable.

Integration pattern: Implement this as an asynchronous validation step. After your primary generation call completes, extract all date and numeric fields from the output, package them alongside the source context, and send both to this prompt. Parse the JSON response into a structured validation record. For each flagged value, log the confidence score, the reason code, and any corrected value the prompt suggests. If the confidence score for a hallucination flag exceeds your threshold (start with 0.7), either auto-correct the value using the prompt's suggested correction or quarantine the record for human review. Never silently drop flagged values—always preserve the original output, the flag, and the correction in an audit log so you can measure false positive rates over time.

Model choice and retries: Use a model with strong instruction-following and JSON output capabilities (GPT-4o, Claude 3.5 Sonnet, or equivalent). Set temperature=0 to minimize variance in detection results. If the prompt returns malformed JSON or missing required fields, implement a single retry with the error message appended to the prompt context. After two failures, escalate the record to a human review queue rather than looping indefinitely. For high-throughput pipelines, batch multiple output segments into a single prompt call, but keep each batch under 8,000 tokens of combined input to avoid attention dilution on individual values.

Validation and monitoring: Before deploying, run this prompt against a golden dataset of 50–100 examples containing known hallucinated dates and numbers alongside correctly grounded values. Measure precision (what fraction of flagged values were truly hallucinated) and recall (what fraction of actual hallucinations were caught). Track these metrics in production by sampling flagged outputs weekly and having a subject-matter expert review them. Common failure modes include false positives on paraphrased values (the model flags a date that is semantically equivalent but formatted differently) and missed hallucinations in nested JSON structures where the value is buried inside a larger string field. If your pipeline handles regulated data, require human approval on any auto-correction before it reaches external consumers.

IMPLEMENTATION TABLE

Expected Output Contract

Schema contract for the hallucination detection report. Every field must be validated before the report enters a downstream pipeline or user-facing surface.

Field or ElementType or FormatRequiredValidation Rule

report_id

string (UUID v4)

Must parse as valid UUID v4. Generated by the prompt harness, not the model.

input_hash

string (SHA-256 hex)

Must match SHA-256 hash of the [INPUT_TEXT] provided. Compute post-generation to detect input drift.

findings

array of finding objects

Must be a JSON array. Empty array is valid when no hallucinations detected. Reject if null or missing.

findings[].value

string

Must be a non-empty substring extractable from the model output under audit. Reject if value not found in [MODEL_OUTPUT].

findings[].type

enum: date | timestamp | number | statistic

Must be one of the four allowed enum values. Reject unknown types. Map 'percentage' and 'ratio' to 'statistic'.

findings[].confidence

number (0.0 to 1.0)

Must be a float between 0.0 and 1.0 inclusive. Values outside range trigger a coercion attempt; reject if uncoercible.

findings[].grounding_status

enum: grounded | ungrounded | partially_grounded

Must be one of the three allowed enum values. 'partially_grounded' requires a non-null corrected_value.

findings[].corrected_value

string or null

Required when grounding_status is 'partially_grounded'. Must be null when grounding_status is 'grounded'. Reject if constraint violated.

PRACTICAL GUARDRAILS

Common Failure Modes

Hallucinated dates and numbers are especially dangerous because they look plausible, pass basic type checks, and flow directly into reports, dashboards, and financial calculations. These failures break trust in analytics pipelines and are harder to spot than invented names or URLs.

01

Plausible but Untraceable Dates

What to watch: The model outputs a specific date like 2024-03-15 that fits the narrative but cannot be found in any input document. These dates pass format validation and look reasonable in context. Guardrail: Require every extracted date to carry a source pointer. If no source span can be cited, flag the date as ungrounded and either drop it or mark it for human review before it enters a reporting pipeline.

02

Fabricated Numeric Precision

What to watch: The model invents exact figures like $247,392.18 or 37.4% increase when the source only contains rounded estimates or qualitative descriptions. The precision creates false confidence. Guardrail: Compare the significant digits in model output against the precision available in source data. If the output has more precision than any input field, truncate to match source granularity and flag the discrepancy.

03

Temporal Relationship Hallucination

What to watch: The model asserts ordering relationships like 'Q2 revenue exceeded Q1 by 12%' when the input only contains raw quarterly figures without comparison language. The relationship is invented even if individual numbers are correct. Guardrail: Separate extraction from interpretation. First extract raw values with source grounding, then run a separate comparison step that only asserts relationships derivable from the extracted values. Flag any comparison not computable from grounded extractions.

04

Aggregate Value Fabrication

What to watch: The model outputs sums, averages, or totals like 'total revenue of $12.3M across all regions' when no such aggregate exists in the input. The model computes a plausible total from partial data and presents it as a fact. Guardrail: Never accept model-computed aggregates as grounded. Require aggregates to either appear explicitly in source data or be computed in application code from individually grounded values. Flag any aggregate not traceable to an explicit source statement.

05

Confidence Score Overstatement

What to watch: The model assigns high confidence scores to hallucinated dates and numbers, making automated filtering unreliable. A fabricated date may get a 0.95 confidence score because it fits the surrounding context well. Guardrail: Do not rely solely on model self-reported confidence. Cross-validate by attempting to locate each extracted value in the input using string matching or embedding similarity. Only accept confidence scores when backed by successful source retrieval.

06

Timezone and Format Drift

What to watch: The model normalizes dates into a consistent format but silently shifts timezones or misinterprets ambiguous formats like 01/02/2024. The output looks clean but the values are wrong. Guardrail: Require explicit timezone and format context in the prompt harness. When input format is ambiguous, flag the value rather than guessing. Include a canonicalization step that preserves the original string alongside the normalized value for auditability.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a golden dataset of 50-100 examples where you know which values are grounded and which are hallucinated. Use this rubric to measure precision, recall, and behavioral correctness before shipping the prompt to production.

CriterionPass StandardFailure SignalTest Method

Hallucinated date recall

= 0.95 recall on known hallucinated dates in golden set

Prompt misses fabricated dates that a human annotator flagged

Run against golden set with pre-labeled hallucinated dates; compute recall = true_positives / (true_positives + false_negatives)

Hallucinated number recall

= 0.95 recall on known hallucinated numeric values in golden set

Prompt fails to flag invented statistics, counts, or monetary values

Run against golden set with pre-labeled hallucinated numbers; compute recall separately from date recall

Grounded value precision

= 0.90 precision on values flagged as hallucinated

Prompt incorrectly flags source-grounded dates or numbers as fabricated

Run against golden set; compute precision = true_positives / (true_positives + false_positives) for each value type

Confidence score calibration

Mean confidence for correct flags >= 0.80; mean confidence for incorrect flags <= 0.50

Prompt assigns high confidence to false positives or low confidence to true positives

Bucket confidence scores by correctness; compute mean confidence per bucket across golden set

Corrected value accuracy

= 0.85 of corrected values match the source-grounded value exactly

Prompt provides a correction that is itself incorrect or fabricated

Compare [CORRECTED_VALUE] field against known grounded value from source document for each true positive

Source citation presence

= 0.95 of flagged items include a non-empty [SOURCE_EVIDENCE] field

Prompt flags a value but provides null or empty source evidence

Count flagged items with non-null, non-empty [SOURCE_EVIDENCE]; divide by total flagged items

Null handling for absent data

Prompt returns empty array or explicit null when no hallucinated values exist

Prompt fabricates flags when input contains no dates or numbers to check

Test with 10 clean inputs containing zero hallucinated values; expect zero false positives

Output schema compliance

100% of responses parse against the expected JSON schema without errors

Response contains extra fields, missing required fields, or wrong types

Validate every golden-set response with a JSON Schema validator; fail on any parse error

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small set of known-clean input records. Remove the confidence scoring schema initially and ask the model to return a simple JSON array of {"field": "...", "value": "...", "status": "HALLUCINATED"|"GROUNDED"} objects. Use a lightweight script to diff the flagged fields against your input source.

code
Analyze the following model output and identify any dates, timestamps, numeric values, or statistics that cannot be traced to the provided [INPUT_DATA]. Return only fields that appear fabricated.

Watch for

  • False positives on rounded or reformatted numbers that are semantically equivalent
  • Missing detection of hallucinated relative dates ("next quarter", "last month")
  • Model treating all formatted dates as hallucinated when input uses a different format
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.