Inferensys

Prompt

Lookup Table Reference Prompt for Value Mapping

A practical prompt playbook for using Lookup Table Reference Prompt for Value Mapping in production AI workflows.
Elegant overhead shot of a polished wooden communal table in a sun-drenched WeWork lounge, laptops and tablets displaying AI workflow dashboards, plants and pendant lights in background.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Lookup Table Reference Prompt.

This prompt is for ETL developers and data engineers who need to map a source value to a canonical target value using a provided reference lookup table. The core job is to accept a raw input string and a structured mapping context, then return the correct target value, a confidence indicator, and actionable diagnostics when the mapping is missing, ambiguous, or stale. This is not a prompt for building the lookup table itself, nor is it for fuzzy entity resolution against a knowledge base—it assumes you already have a defined mapping table and need the model to apply it consistently.

Use this prompt when your pipeline encounters values that must be translated before they can enter a downstream system with a strict contract—for example, mapping legacy department codes to a new chart of accounts, normalizing free-text country names to ISO codes, or converting internal product names to SKU identifiers. The prompt is designed to be wired into a data pipeline as a transformation step, where the lookup table is injected as context at inference time. It is most effective when the mapping table is small enough to fit in the prompt context window and when the mapping rules are deterministic, not based on complex semantic similarity. For large-scale entity resolution against millions of records, use a vector search or dedicated matching service instead, and reserve this prompt for the final disambiguation or human-review step.

Do not use this prompt when the mapping logic requires real-time access to an external system of record, when the lookup table changes faster than you can update the prompt context, or when the cost of a wrong mapping is high and you cannot afford a human review loop. In regulated environments—such as financial transaction coding or clinical data mapping—always pair this prompt with a confidence threshold that routes low-confidence results to a human review queue. The prompt includes instructions to flag missing mappings and suggest candidates, but it should never be the sole authority for high-stakes transformations without an audit trail and approval step. Before you copy the template, define your target schema, your confidence thresholds, and your escalation path for unmapped values.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Lookup Table Reference Prompt delivers reliable value mapping and where it introduces operational risk.

01

Good Fit: Deterministic Mapping with a Known Table

Use when: you have a stable, curated lookup table and need to map source values to canonical targets. Guardrail: Provide the full lookup table inline or via a tool. The model should only match, never invent mappings.

02

Bad Fit: High-Cardinality or Rapidly Changing Tables

Avoid when: the lookup table has thousands of rows or changes hourly. Guardrail: Offload matching to a vector store or database query. Use the prompt only for ambiguous matches or candidate disambiguation that require semantic judgment.

03

Required Inputs: Source Value and Table Context

Risk: Without the full table, the model hallucinates plausible mappings. Guardrail: Always pass the source value, the complete lookup table (or a relevant slice), and explicit instructions to return a missing flag when no match exists.

04

Operational Risk: Silent Mismatches

Risk: The model maps a value to a similar-looking but incorrect target without flagging low confidence. Guardrail: Require a confidence score and a mapping_status field (exact_match, fuzzy_match, missing). Route fuzzy matches to a human review queue.

05

Operational Risk: Stale Reference Data

Risk: The lookup table embedded in the prompt becomes outdated, causing systematic mapping errors. Guardrail: Version your lookup tables. Include a table_version and effective_date in the prompt context. Log the version used with every mapping result.

06

Pattern: Candidate Suggestion for New Values

Use when: a source value has no exact match and you need to propose new entries for the lookup table. Guardrail: Instruct the model to suggest candidates based on pattern matching against existing keys, but always flag them as proposed_new_entry and never auto-commit.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for mapping source values to target entries using a provided lookup table, with handling for missing, ambiguous, and stale mappings.

This prompt template is designed to be wired directly into an ETL pipeline or data normalization service. It accepts a raw source value and a serialized lookup table as context, then returns a structured JSON object containing the mapped target value, a confidence score, and a clear status flag. The template uses square-bracket placeholders for all dynamic inputs, making it safe to parameterize in code before sending to the model. The primary goal is to offload deterministic string matching to a lookup table while using the model's reasoning only for fuzzy matching, ambiguity resolution, and suggesting new candidate mappings when no exact match exists.

text
You are a precise data mapping engine. Your task is to map a source value to a target value using the provided lookup table. Do not invent mappings. If a mapping is missing, ambiguous, or appears stale, you must indicate this clearly.

## INPUT
Source Value: [SOURCE_VALUE]

## LOOKUP TABLE CONTEXT
[LOOKUP_TABLE]

## OUTPUT SCHEMA
You must respond with a single JSON object conforming to this schema:
{
  "status": "matched" | "missing" | "ambiguous" | "stale_candidate",
  "source_value": "string (the original input)",
  "mapped_value": "string | null (the resolved target value)",
  "confidence": 0.0-1.0,
  "candidate_mappings": [
    {
      "target_value": "string",
      "match_type": "exact" | "fuzzy" | "abbreviation" | "pattern",
      "rationale": "string"
    }
  ],
  "rationale": "string (brief explanation of the mapping decision)"
}

## CONSTRAINTS
- If an exact match is found in the lookup table, set status to "matched" and confidence to 1.0.
- If multiple potential matches exist, set status to "ambiguous", confidence to 0.5 or lower, and list all candidates with match types.
- If no match is found, set status to "missing", confidence to 0.0, and suggest up to three candidate mappings based on pattern similarity to existing keys.
- If a match is found but the lookup table entry is flagged as deprecated or has an expiration date that has passed, set status to "stale_candidate".
- Never hallucinate a target value that does not derive from the lookup table or a reasonable pattern match against its keys.
- Preserve the original source value in the output for auditability.

## EXAMPLES
[EXAMPLES]

## RISK LEVEL
[RISK_LEVEL]

To adapt this template, replace each placeholder with production data. [SOURCE_VALUE] is the raw string from your source system. [LOOKUP_TABLE] should be a serialized representation of your reference data, such as a JSON object or a markdown table of key-value pairs, including any metadata like deprecation flags or expiration dates. The [EXAMPLES] placeholder should be populated with 2-3 few-shot demonstrations that show the model how to handle exact matches, missing values, and ambiguous cases specific to your domain. The [RISK_LEVEL] placeholder accepts a value like low, medium, or high to adjust the model's caution; for high-risk domains such as finance or healthcare, the system should be instructed to default to status: "missing" and route to a human review queue when confidence is below 0.9. After copying this template, validate that the output JSON parses correctly and that the status field drives the correct branching logic in your application code.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Lookup Table Reference Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to check the input before execution.

PlaceholderPurposeExampleValidation Notes

[SOURCE_VALUE]

The raw value to be mapped

US

Check that the value is not null or an empty string. Trim whitespace before passing.

[LOOKUP_TABLE]

The reference data mapping source to target values

{"US": "United States", "GB": "United Kingdom"}

Must be valid JSON. Parse check before prompt assembly. Reject if table is empty or malformed.

[TARGET_COLUMN_NAME]

The semantic name of the target field for context

country_name

Must be a non-empty string. Used to help the model understand the mapping domain.

[DEFAULT_VALUE]

Fallback value when no mapping is found

UNMAPPED

Can be null if missing mappings should be flagged instead of defaulted. Must match target schema type.

[CONFIDENCE_THRESHOLD]

Minimum similarity score for fuzzy matching before flagging for review

0.85

Must be a float between 0.0 and 1.0. If null, exact match is required. Validate range before execution.

[CANDIDATE_LIST]

Existing canonical values for suggesting new mappings

["United States", "Canada", "Mexico"]

Must be a valid JSON array of strings. Can be empty if no suggestion is needed. Parse check required.

[STALENESS_WINDOW_DAYS]

Number of days after which a mapping is considered stale

90

Must be a positive integer or null. If null, staleness check is skipped. Validate type before passing.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the lookup table reference prompt into a reliable ETL pipeline with validation, retries, and human review.

The lookup table reference prompt is not a standalone script; it is a transformation step inside a larger data pipeline. Wire it as a stateless function that receives a source value and a serialized lookup table context, then returns a structured mapping result. The application layer is responsible for fetching the correct lookup table slice, formatting it into the prompt's [LOOKUP_TABLE] placeholder, and parsing the model's JSON output into the next stage of the pipeline. Do not rely on the model to remember mappings across invocations—each call should be self-contained with its own lookup context to prevent cross-record leakage and hallucinated mappings.

Build a thin wrapper that handles three concerns before and after the model call. First, input validation: confirm the source value is a non-empty string and the lookup table is a valid JSON array of objects with at least source_value and target_value keys. Reject malformed inputs before they reach the model. Second, output validation: parse the model's JSON response and verify it contains the required mapped_value, mapping_status (one of exact_match, fuzzy_match, no_match, stale_mapping), and confidence fields. If the output fails schema validation, retry once with a repair prompt that includes the validation error. Third, routing: if mapping_status is no_match or confidence is below your threshold (e.g., <0.85), route the record to a human review queue with the original value, the lookup table context, and any candidate_mappings the model suggested. For stale_mapping results, flag the lookup table itself for maintenance rather than the individual record.

Choose a model that performs reliably on structured JSON extraction with low latency, since this prompt typically runs on high-volume record streams. GPT-4o or Claude 3.5 Sonnet work well for complex fuzzy matching; for simple exact-match lookups where the model adds no value, skip the prompt entirely and use a deterministic hash map in application code. Log every mapping decision—input value, lookup table hash, model version, mapped output, confidence, and status—so you can audit mapping quality over time and detect when a lookup table update causes regression in downstream systems. Never let an unmapped value silently pass through; always either map it, queue it for review, or write an explicit unmapped sentinel to the target field.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structure, types, and validation rules for the JSON object returned by the Lookup Table Reference Prompt. Use this contract to parse the model's response, validate it before ingestion, and route failures to a repair or review queue.

Field or ElementType or FormatRequiredValidation Rule

mapped_value

string | null

Must be a string if mapping found; must be null if no mapping exists. Empty string is not allowed.

mapping_status

enum: 'exact_match', 'fuzzy_match', 'no_match', 'stale_match'

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

confidence_score

float between 0.0 and 1.0

Must be a number. If mapping_status is 'exact_match', score must be >= 0.95. If 'no_match', score must be 0.0.

source_value

string

Must exactly match the [SOURCE_VALUE] provided in the prompt input. Used for downstream audit reconciliation.

lookup_table_id

string

Must match the [TABLE_ID] provided in the prompt context. Reject if missing or mismatched.

candidate_mappings

array of objects

Required only if mapping_status is 'no_match'. Each object must have 'candidate_value' (string) and 'similarity_score' (float). Array must not be empty if present.

stale_since

ISO 8601 date string | null

Required only if mapping_status is 'stale_match'. Must be a valid date string indicating when the mapping was marked stale. Null otherwise.

resolution_notes

string | null

Must be a non-empty string explaining the match logic, ambiguity, or reason for no match. Must be null only if explicitly disallowed by [INCLUDE_NOTES] flag set to false.

PRACTICAL GUARDRAILS

Common Failure Modes

Lookup table prompts fail silently when mappings are missing, ambiguous, or stale. These are the most common production failure modes and how to guard against them before they corrupt downstream systems.

01

Silent Mapping Failures

What to watch: The model returns a plausible-looking target value that isn't actually in the lookup table, or hallucinates a mapping when no match exists. This corrupts downstream analytics and master data without any error signal. Guardrail: Require the prompt to return an explicit match_type field (exact, fuzzy, none) and validate that matched values exist in the source lookup table before ingestion. Reject any output where match_type is missing or the returned value isn't in the approved set.

02

Ambiguous Match Collapse

What to watch: Multiple lookup entries are near-matches for the same input (e.g., 'Apple' matching both 'Apple Inc.' and 'Apple Bank'). The model picks one arbitrarily, losing the ambiguity signal that a human should resolve. Guardrail: Instruct the prompt to return all candidates above the similarity threshold, not just the top match. Add a candidates array to the output schema and route any result with multiple high-confidence candidates to a human review queue instead of auto-ingesting.

03

Stale Lookup Table Drift

What to watch: The lookup table embedded in the prompt becomes outdated as reference data changes—new products launch, companies rebrand, or taxonomies evolve. The model confidently maps to deprecated entries because it has no awareness of freshness. Guardrail: Include a lookup_table_version and last_updated field in the prompt context. Add a validation step that checks whether the returned mapping's source entry is still active in the current reference data system before accepting the result.

04

Case and Whitespace Sensitivity

What to watch: Exact string matching fails because the input has trailing spaces, inconsistent casing, or Unicode variants that don't match the lookup keys. The model treats these as unmappable when a simple normalization would resolve them. Guardrail: Pre-process inputs with whitespace trimming, case normalization, and Unicode normalization (NFC/NFD) before passing them to the prompt. Include a normalized_input field in the output so operators can verify what the model actually matched against.

05

Context Window Exhaustion

What to watch: Large lookup tables (thousands of entries) consume the context window, leaving insufficient room for instructions, examples, and output schema. The model truncates or ignores parts of the table, producing incomplete mappings. Guardrail: Keep lookup tables in the prompt under 500 entries. For larger reference sets, move the lookup to a retrieval step (vector search or database query) before the prompt, and pass only the top-N candidates as context. Monitor token usage per call and alert when approaching limits.

06

Unmapped Value Blindness

What to watch: The model returns a confident mapping for every input, even when no reasonable match exists. This hides gaps in the reference data and prevents the team from discovering new values that should be added to the taxonomy. Guardrail: Require a mapping_status field with values mapped, unmapped, or needs_review. Set a minimum similarity threshold and reject any output where the model claims mapped but the confidence score falls below it. Route unmapped values to a taxonomy gap report for manual curation.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the lookup table reference prompt before deploying it into a production ETL pipeline. Each criterion targets a specific failure mode common to value mapping workflows.

CriterionPass StandardFailure SignalTest Method

Exact Match Resolution

Returns the correct [TARGET_VALUE] when [SOURCE_VALUE] matches an existing lookup table entry exactly (case-insensitive where specified).

Output contains a wrong target value, a hallucinated mapping, or returns 'no match' for an entry present in the provided [LOOKUP_TABLE].

Run 20 known exact-match cases from the reference data. Assert output matches expected target value for all 20.

Missing Mapping Detection

Returns a structured 'no mapping found' indicator (e.g., null, 'UNMAPPED') with confidence=0 when [SOURCE_VALUE] has no entry in [LOOKUP_TABLE].

Hallucinates a plausible target value, returns a near-match without flagging it as a suggestion, or returns a target value from a different row.

Provide 10 source values absent from the lookup table. Assert output indicates no mapping exists and does not contain a fabricated target value.

Candidate Suggestion Quality

When no exact match exists, suggests 1-3 candidate mappings from [LOOKUP_TABLE] based on substring, abbreviation, or phonetic similarity, each with a similarity score.

Suggests candidates that share no structural similarity with the source value, omits an obvious near-match present in the table, or provides scores that don't correlate with edit distance.

Provide 5 source values with known near-matches in the table (e.g., 'IBM Corp' vs 'International Business Machines'). Assert the known near-match appears in the candidate list with a higher score than unrelated entries.

Staleness Flag Behavior

Flags the mapping as 'stale' when the lookup table row metadata includes a [LAST_UPDATED] timestamp older than the configured [STALENESS_THRESHOLD_DAYS].

Returns a stale mapping without the staleness flag, applies the staleness flag to a recently updated row, or omits the flag entirely when the schema requires it.

Provide a lookup table with one row updated 400 days ago and [STALENESS_THRESHOLD_DAYS]=365. Assert the output for that row includes a staleness warning. Assert a row updated 10 days ago has no staleness flag.

Output Schema Compliance

Returns valid JSON matching the defined [OUTPUT_SCHEMA] with all required fields present and correctly typed.

Missing required fields (e.g., 'confidence'), wrong types (string instead of float for confidence), or extra fields not in the schema.

Parse the output with a JSON schema validator using the expected schema. Assert no validation errors across 30 varied inputs.

Confidence Score Calibration

Assigns confidence=1.0 for exact matches, 0.0 for confirmed missing mappings, and a score between 0.5 and 0.95 for fuzzy candidate suggestions proportional to similarity.

Returns confidence=1.0 for a fuzzy match, confidence=0.0 for an exact match, or confidence scores that are inconsistent across similar-distance pairs.

Test 5 exact matches (expect 1.0), 5 missing (expect 0.0), and 5 fuzzy matches with known edit distances. Assert confidence values are monotonic with similarity.

Case Sensitivity Handling

Respects the [CASE_SENSITIVE] flag: performs case-insensitive matching when false, exact-case matching when true.

Fails to match 'APPLE' to 'Apple' when [CASE_SENSITIVE]=false, or incorrectly matches 'apple' to 'Apple' when [CASE_SENSITIVE]=true.

Run the same 5 source values with [CASE_SENSITIVE]=true and [CASE_SENSITIVE]=false. Assert matches differ according to the flag setting.

Empty or Null Input Handling

Returns a clear error or null output with an error reason when [SOURCE_VALUE] is null, empty string, or whitespace-only.

Hallucinates a mapping for empty input, crashes, or returns a valid-looking target value with no indication that the input was invalid.

Provide null, '', and ' ' as source values. Assert the output indicates invalid input and does not contain a mapped target value.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a small lookup table embedded directly in the prompt. Keep the table under 50 rows. Skip confidence scoring and audit fields. Accept the first match returned.

code
Lookup table:
[SOURCE_VALUE] -> [TARGET_VALUE]
...

Map this value: [INPUT_VALUE]

Watch for

  • Ambiguous matches when source values overlap (e.g., 'US' vs 'USA')
  • Model inventing mappings not present in the table
  • No indication when a value is unmapped
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.