Inferensys

Prompt

Source Metadata Enrichment Prompt Template

A practical prompt playbook for using Source Metadata Enrichment Prompt Template 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

Define the job, reader, and constraints for the Source Metadata Enrichment prompt.

This prompt is designed for a single, high-stakes job: repairing reference lists that are structurally valid but semantically incomplete. The ideal user is a backend engineer, data pipeline operator, or RAG product team member who has a list of citations that passed a basic schema check but is missing required metadata fields—such as DOIs, ISBNs, access dates, or publisher names—that a downstream academic, legal, or compliance system demands. The prompt assumes you already have a list of citation strings and access to a metadata source, such as the Crossref or OpenAlex API, which the model will be instructed to query via a tool. It is not for generating citations from scratch, nor for fixing broken JSON structure; it is for enriching existing, well-formed citations with authoritative external data.

You should use this prompt when your pipeline enforces a strict metadata contract and a citation fails validation because a field like doi or isbn is null. The prompt instructs the model to act as a meticulous metadata librarian: it must query the provided tool for each citation, extract the missing fields, and preserve the original citation text without alteration. It must also produce a structured enrichment report that flags any citation it could not resolve, including the specific fields that remain empty and the reason for the failure. This is a high-precision workflow, not a high-recall one; the prompt is optimized to avoid hallucinating metadata by requiring the model to cite the exact API response that provided each enriched field. If your use case can tolerate best-guess metadata without source grounding, a simpler extraction prompt will suffice.

Do not use this prompt when the input is a block of free text with inline references that haven't been parsed into a structured list. That is an extraction and normalization problem, not an enrichment one. Similarly, avoid this prompt if your metadata source is a static knowledge base rather than a live API; the tool-use instructions assume a real-time query pattern. Finally, this prompt is inappropriate for consumer-grade applications where a missing publication date is an aesthetic issue rather than a compliance blocker. The enrichment report it generates is designed for automated downstream processing and audit logging, not for direct display to end users. Before implementing, ensure your metadata API tool is robust to rate limits and that your evaluation suite includes test cases for ambiguous citations that match multiple records, as this is the most common production failure mode.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Source Metadata Enrichment Prompt Template works well and where it introduces risk. Use these cards to decide if this prompt fits your pipeline before you integrate it.

01

Good Fit: Downstream System Ingestion

Use when: reference lists are structurally valid but missing required fields like DOIs, ISBNs, or access dates that a downstream database or search index demands. Guardrail: define a strict required-fields schema before enrichment and reject records that remain incomplete after the prompt runs.

02

Bad Fit: Inventing Missing Metadata

Avoid when: the metadata source is unavailable or the model is expected to guess identifiers. Hallucinated DOIs or fabricated ISBNs break traceability. Guardrail: require the prompt to output an unresolvable_gaps array and never synthesize identifiers without a verified lookup.

03

Required Inputs

What you must provide: a citation list with at least partial fields (title, authors, year), access to a metadata source or API, and a target schema defining which fields are required. Guardrail: validate input completeness before enrichment—garbage citations produce garbage metadata.

04

Operational Risk: Silent Partial Enrichment

What to watch: the prompt enriches some fields but leaves others empty without flagging them, causing downstream systems to ingest incomplete records. Guardrail: require a per-record coverage report and block records that fall below a configurable completeness threshold.

05

Operational Risk: Metadata Source Drift

What to watch: the metadata source API changes its schema, rate limits, or response format, causing enrichment to silently fail or return stale data. Guardrail: version-lock the metadata source contract, monitor enrichment success rates, and alert on sudden drops in field coverage.

06

Human Review Trigger

What to watch: citations with ambiguous matches—multiple possible DOIs, author name variants, or conflicting publication dates. Guardrail: route records with match confidence below a defined threshold to a human review queue instead of auto-enriching with the top candidate.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for enriching citation metadata with missing DOIs, ISBNs, access dates, and publisher information.

This template is designed to be dropped into a post-generation repair loop. It takes a list of citations that have already passed basic format validation but are missing required metadata fields for downstream ingestion systems. The prompt instructs the model to query a provided metadata source, fill gaps where possible, and flag unresolvable enrichment failures rather than hallucinating plausible values. Use this when your reference pipeline requires complete records before citations can be stored, indexed, or displayed to users.

code
You are a citation metadata enrichment specialist. Your task is to repair incomplete reference records by filling missing metadata fields using the provided source database. You must never invent metadata. If a field cannot be resolved from the source, flag it explicitly.

## INPUT
[INPUT]

## SOURCE METADATA DATABASE
[SOURCE_DATABASE]

## REQUIRED FIELDS
[REQUIRED_FIELDS]

## OUTPUT SCHEMA
[OUTPUT_SCHEMA]

## CONSTRAINTS
[CONSTRAINTS]

## INSTRUCTIONS
1. Parse each citation from [INPUT] and identify which required fields from [REQUIRED_FIELDS] are missing or empty.
2. For each missing field, query [SOURCE_DATABASE] using available identifiers (title, author, year, existing partial identifiers).
3. If a match is found with high confidence, populate the field with the canonical value from the source.
4. If multiple candidates exist, select the best match and note the ambiguity in the `enrichment_notes` field.
5. If no match is found, leave the field as `null` and set the enrichment status to `unresolvable`.
6. For access dates, use the current date in ISO 8601 format unless a specific access date is provided in [INPUT].
7. Normalize all identifiers to their canonical forms (DOI as URL, ISBN-13 format, etc.).
8. Output the complete enriched citation list following [OUTPUT_SCHEMA] exactly.
9. Include a summary section listing all citations that still have unresolvable gaps.

## ENRICHMENT CONFIDENCE LEVELS
- `exact_match`: Identifier or title matched uniquely in source database.
- `high_confidence`: Multiple fields matched, no ambiguity.
- `moderate_confidence`: Partial match, best candidate selected.
- `low_confidence`: Weak match, field populated but should be reviewed.
- `unresolvable`: No match found, field left null.

## EXAMPLE
Input citation: Smith, J. (2020). Machine Learning Applications. Journal of AI Research.
Missing field: DOI
Source query result: Found DOI 10.1234/jair.2020.5678 with exact title match.
Enriched output includes DOI with `exact_match` confidence.

Now process the citations in [INPUT] against [SOURCE_DATABASE].

Adapt this template by replacing the placeholders with your specific inputs. [INPUT] should contain the citation list as structured JSON or a formatted reference block. [SOURCE_DATABASE] should include the metadata records available for lookup—this can be a JSON blob, an API response, or a pre-retrieved set of records from your catalog. [REQUIRED_FIELDS] defines which fields must be present (e.g., ["doi", "isbn", "access_date", "publisher"]). [OUTPUT_SCHEMA] should specify the exact JSON structure you need downstream, including enrichment status and confidence fields. [CONSTRAINTS] can include rules like "never guess a DOI" or "flag missing access dates for human review." After adapting, run this prompt through your eval suite using citations with known missing fields to verify that enrichment is accurate and that unresolvable gaps are flagged rather than fabricated.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Source Metadata Enrichment prompt. Each variable must be validated before the prompt is assembled to prevent downstream enrichment failures.

PlaceholderPurposeExampleValidation Notes

[REFERENCE_LIST]

The list of citations or references missing metadata fields

Must be a non-empty array of strings or objects. Reject if null, empty, or not parseable as a list.

[REQUIRED_FIELDS]

Metadata fields that must be present for each reference in the output

["DOI", "ISBN", "access_date", "publisher"]

Must be a non-empty array of valid field name strings. Reject if contains unsupported or ambiguous field names.

[METADATA_SOURCE]

The authoritative source or API to query for enrichment

"Crossref API" or "PubMed" or "internal_catalog_v2"

Must match a configured and reachable metadata source. Reject if source is unavailable or not in the allowed source list.

[SOURCE_ACCESS_CREDENTIALS]

API keys, tokens, or connection strings for the metadata source

"Bearer eyJhbG..." or "db://catalog/readonly"

Must be present and valid if the source requires authentication. Null allowed only for open-access sources. Validate connectivity before prompt execution.

[ENRICHMENT_TIMEOUT_MS]

Maximum time allowed per reference enrichment query

5000

Must be a positive integer. Reject if below 500ms or above 30000ms. Default to 5000ms if not provided.

[CONFIDENCE_THRESHOLD]

Minimum match confidence score to accept an enrichment result

0.85

Must be a float between 0.0 and 1.0. Enrichments below this threshold should be flagged as unresolvable rather than silently accepted.

[OUTPUT_SCHEMA]

The expected structure for enriched references

"{reference_id: string, enriched_fields: object, gaps: string[], confidence: float}"

Must be a valid JSON Schema or type definition. Reject if schema is missing required output fields or conflicts with [REQUIRED_FIELDS].

[MAX_RETRIES_PER_REFERENCE]

Number of retry attempts for failed enrichment queries

3

Must be a non-negative integer. Set to 0 to disable retries. Reject if greater than 10 to prevent runaway loops.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Source Metadata Enrichment prompt into a reliable application pipeline with validation, retries, and observability.

This prompt is designed to be called as a post-processing step after a primary generation or extraction pipeline has produced a reference list. The typical integration point is inside a structured output repair loop: the upstream model outputs a list of citations, a schema validator checks for required metadata fields (DOI, ISBN, access date, publisher), and any record missing those fields is routed to this enrichment prompt. The prompt expects a metadata source—either a live API (CrossRef, OpenLibrary, PubMed) or a pre-fetched cache—to be provided in the [METADATA_SOURCE] placeholder. Do not call this prompt without a concrete metadata source; the model cannot invent valid DOIs or ISBNs and will hallucinate if asked to do so.

Wire the prompt into a retry queue with a maximum of two enrichment attempts per record. On the first attempt, pass the full [METADATA_SOURCE] context. If the output still contains unresolvable fields, trigger a second attempt with a narrower [CONSTRAINTS] block that instructs the model to mark those fields as unresolvable rather than guessing. After two failures, escalate the record to a human review queue with the original citation, the attempted enrichments, and the metadata source response logged. Log every enrichment attempt with the input citation, the metadata source queried, the fields enriched, the fields flagged as unresolvable, and the model and prompt version used. This audit trail is essential for compliance-sensitive systems where source provenance must be traceable.

For model choice, prefer a model with strong instruction-following and low hallucination rates on structured extraction tasks—Claude 3.5 Sonnet or GPT-4o are good defaults. Avoid smaller or older models that are more likely to invent plausible-looking DOIs or ISBNs. If using a local or air-gapped deployment, ensure the metadata source is a static database snapshot rather than a live API, and include the snapshot date in the [CONTEXT] so downstream systems can assess freshness. The output schema should be validated programmatically: check that enriched fields match expected regex patterns (DOI: 10.\d{4,}/.+, ISBN: \d{3}-\d-\d{2,6}-\d{2,6}-\d), that no field contains placeholder text like 'N/A' or 'unknown' unless explicitly flagged as unresolvable, and that the enrichment_status field is present and set to one of the allowed enum values (enriched, partial, unresolvable, unchanged).

Before deploying, build a golden test set of 50 citations with known missing metadata and verified correct enrichments. Run the prompt against this set and measure field-level accuracy (did the DOI match?), unresolvable detection rate (did it correctly flag what it couldn't find?), and hallucination rate (did it invent any identifiers not present in the metadata source?). Set a release gate at ≥95% field accuracy and 0% hallucination rate on the golden set. In production, monitor the ratio of enriched to unresolvable outcomes; a sudden spike in unresolvable may indicate a metadata source outage or schema change. Wire these metrics into your existing prompt observability stack alongside token usage and latency.

IMPLEMENTATION TABLE

Expected Output Contract

The enriched reference list must conform to this schema. Each field is validated before the output is accepted by downstream metadata systems.

Field or ElementType or FormatRequiredValidation Rule

enriched_references

Array of objects

Must be a non-empty array. Each element must be a valid object.

enriched_references[].original_citation

String

Must exactly match the input citation string provided in [INPUT_CITATIONS].

enriched_references[].enriched_fields

Object

Must contain at least one key-value pair. Keys must be from the [TARGET_FIELDS] list.

enriched_references[].enriched_fields.doi

String or null

If present, must match DOI regex: 10.\d{4,9}/[-._;()/:A-Z0-9]+. Set to null if unresolvable.

enriched_references[].enriched_fields.isbn

String or null

If present, must be a valid ISBN-10 or ISBN-13 string. Set to null if unresolvable.

enriched_references[].enriched_fields.access_date

ISO 8601 date string or null

If present, must be in YYYY-MM-DD format. Set to null if not applicable.

enriched_references[].enriched_fields.publisher

String or null

If present, must be a non-empty string. Set to null if unresolvable.

enriched_references[].unresolvable_gaps

Array of strings

Must list every [TARGET_FIELDS] key that could not be resolved. Use an empty array if all fields were resolved.

enriched_references[].source_query_status

String

Must be one of: 'resolved', 'partial', 'not_found', 'error'. Indicates the outcome of querying [METADATA_SOURCE].

PRACTICAL GUARDRAILS

Common Failure Modes

Source metadata enrichment fails silently in production when the model cannot resolve a reference, invents plausible metadata, or returns partial records that break downstream ingestion. These cards cover the most frequent failure patterns and the guardrails that catch them before enriched data enters your system of record.

01

Hallucinated Identifiers

What to watch: The model invents plausible DOIs, ISBNs, or PubMed IDs when the source metadata service returns no match. These fabricated identifiers pass format validation but point to non-existent or wrong records. Guardrail: Require the prompt to output a resolution_source field per enrichment field, and post-process by querying the metadata service with the returned identifier to confirm it resolves to the expected record.

02

Partial Enrichment Without Flagging

What to watch: The model successfully enriches some fields but silently omits others that failed resolution, producing a record that looks complete to downstream parsers but is missing required metadata. Guardrail: Include a [REQUIRED_FIELDS] constraint in the prompt and demand an unresolved_fields array in the output schema. Validate that every required field is either enriched or explicitly listed as unresolved before ingestion.

03

Wrong Edition or Variant Mismatch

What to watch: The model matches a citation to the correct work but the wrong edition, format, or year variant, pulling metadata for the hardcover when the citation references the paperback or preprint. Guardrail: Include [CITATION_CONTEXT] with any available edition hints from the surrounding text. Require the prompt to output a match_confidence score and flag low-confidence matches for human review when edition-specific metadata matters.

04

Stale or Deprecated Metadata

What to watch: The metadata service returns outdated information, or the model caches and reuses stale enrichment from earlier requests without re-verifying. Access dates, publisher names, and URL status change over time. Guardrail: Require the prompt to include an access_date field in every enrichment record. Implement a TTL on enriched metadata in your application layer and re-query when the access date exceeds your freshness threshold.

05

Ambiguous Reference Resolution

What to watch: A citation like "Smith et al. 2023" matches multiple works by the same first author and year. The model guesses instead of surfacing the ambiguity, and the wrong metadata enters the system. Guardrail: Instruct the prompt to output an ambiguity_detected boolean and a candidate_matches array when multiple records match. Route ambiguous cases to a human review queue with the candidates presented for selection.

06

Format Drift in Enriched Output

What to watch: The model returns enriched metadata in inconsistent formats across records—mixing APA date formats with ISO 8601, or returning DOIs as bare strings in one record and as full URLs in another. Downstream parsers break on the inconsistency. Guardrail: Define an explicit [OUTPUT_SCHEMA] with field-level format constraints. Add a post-enrichment normalization step that coerces each field to the canonical format and rejects records that fail coercion.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality of enriched source metadata before the output is accepted by downstream systems. Each criterion should be tested programmatically or via a human-in-the-loop review for high-stakes records.

CriterionPass StandardFailure SignalTest Method

Unresolvable Gap Flagging

Every [INPUT_REFERENCE] with missing metadata after enrichment has an unresolvable_gaps array entry with a field and reason

Missing metadata field is silently dropped or filled with a hallucinated value

Parse output JSON; assert that for every required field not present in the source, a corresponding gap object exists

DOI/ISBN Format Validity

All enriched DOIs match 10.\d{4,}/.+ regex; ISBNs match ISBN-10 or ISBN-13 checksum

Enriched identifier fails format validation or checksum digit is incorrect

Regex validation on each enriched identifier; checksum verification for ISBNs

Source Grounding

Every enriched field value can be traced to a specific metadata source record or API response

Enriched value appears without a source_record_id or source_query reference

Spot-check 10% of enriched records against the metadata source; assert source_record_id is present and resolvable

Field Type Conformance

All enriched fields match the [OUTPUT_SCHEMA] type definitions (string, date, array, object)

Enriched field is wrong type (e.g., array instead of string) or null when required

JSON Schema validation against the defined [OUTPUT_SCHEMA]; reject on type mismatch

Access Date Format

All access_date fields are ISO 8601 strings (YYYY-MM-DD) and not in the future

Access date is missing, in wrong format, or set to a future date

Parse access_date fields; validate against ISO 8601 regex; assert date <= current date

Publisher Name Normalization

Publisher names are drawn from an authorized [PUBLISHER_AUTHORITY_LIST] or marked as unverified

Publisher name is a variant spelling, abbreviation, or hallucinated entity not in the authority list

Exact match or fuzzy match with threshold against [PUBLISHER_AUTHORITY_LIST]; flag unmatched names

Confidence Score Threshold

Every enriched record has a confidence_score >= [MIN_CONFIDENCE] (default 0.8)

Record has confidence_score below threshold or missing confidence field entirely

Parse confidence_score; assert numeric and >= [MIN_CONFIDENCE]; route low-confidence records to human review queue

No Overwriting of Existing Valid Data

Existing correct metadata in [INPUT_REFERENCE] is preserved; only missing or invalid fields are enriched

Enrichment overwrites a correct existing field with a different value from the metadata source

Diff input vs output; assert that fields present and valid in input are unchanged in output unless explicitly corrected with audit trail

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single metadata source and relaxed validation. Replace [METADATA_SOURCE] with a known API or database. Skip the enrichment gap report and return only the enriched reference list.

Watch for

  • Missing schema checks letting malformed DOIs through
  • Overly broad instructions causing the model to invent metadata instead of flagging gaps
  • No confidence scoring on enrichment quality
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.