This prompt is designed for data engineers and backend developers who need to map free-text, user-provided, or machine-generated descriptions to a controlled vocabulary stored in a database lookup table. The core job-to-be-done is resolving a fuzzy input like 'the big apple' or 'NY' to a canonical foreign key reference, such as city_id: 3 for 'New York City'. It is a critical component in data ingestion pipelines, ETL workflows, and AI-assisted data entry forms where downstream analytics, joins, and application logic depend on strict referential integrity, not approximate string matches.
Prompt
Enum and Lookup Table Value Resolution Prompt Template

When to Use This Prompt
Define the job, ideal user, and constraints for the Enum and Lookup Table Value Resolution prompt.
Use this prompt when you have a predefined set of canonical values (an enum or a lookup table) and you need the model to act as an intelligent mapper, not a classifier that invents new categories. It is ideal when the input is messy—containing typos, synonyms, abbreviations, or multilingual variants—and a simple LIKE or Levenshtein distance function fails. The prompt should be integrated into a pipeline where the model's output is a structured JSON object containing the resolved ID, the canonical value, and a confidence score. This allows the calling application to automatically process high-confidence matches and route low-confidence ones to a human review queue. Do not use this prompt for open-ended tagging, generating new taxonomy terms, or when the lookup table has millions of rows that exceed the model's context window; in those cases, a retrieval-augmented generation (RAG) approach that pre-filters candidates is required before invoking this resolution step.
The primary constraint is that the model must never hallucinate a foreign key that does not exist in the provided lookup table. The prompt template enforces this by requiring the full lookup context to be injected into the prompt at runtime. Before deploying, you must implement a post-generation validation step that confirms the returned resolved_id is present in your source-of-truth lookup table. A common failure mode is the model correctly identifying the canonical concept but returning an ID from its pre-training data instead of the one you provided. Your harness must catch this mismatch and either retry with a stricter prompt or escalate for manual mapping. The next section provides the exact template to implement this controlled resolution.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the Enum and Lookup Table Value Resolution template fits your current task.
Good Fit: Fuzzy to Canonical Mapping
Use when: You have free-text descriptions, user-entered labels, or legacy codes that must map to a controlled vocabulary or lookup table. Guardrail: Provide the full list of canonical values in the prompt. The model resolves fuzzy inputs to exact matches better than regex.
Bad Fit: Real-Time Code Generation
Avoid when: You need the model to generate new enum values or extend a vocabulary dynamically. This prompt is for resolution, not creation. Guardrail: If new values are possible, route to a separate classification or creation workflow with human review before updating the lookup table.
Required Inputs
What you need: A complete canonical value list, the free-text input to resolve, and a confidence threshold. Guardrail: Always include a 'not_found' or 'other' fallback value in your schema. Without it, the model may hallucinate a match for truly out-of-vocabulary inputs.
Operational Risk: Silent Mismatches
Risk: The model confidently maps a vague input to the wrong canonical value, especially with short or ambiguous text. Guardrail: Require a confidence score in the output. Route low-confidence results to a human review queue or log them for auditing before writing to the database.
Operational Risk: Vocabulary Drift
Risk: The canonical value list changes in your application but the prompt still references an old version, causing valid new values to be rejected. Guardrail: Treat the canonical list as a template variable injected at runtime. Add a regression test that fails if the prompt's enum list doesn't match the source of truth.
Scale Limit: Large Lookup Tables
Risk: Providing thousands of canonical values in the prompt consumes context and degrades accuracy. Guardrail: If the lookup table exceeds ~200 values, pre-filter candidates using a fast embedding or keyword search before passing the top-K candidates to this prompt for final resolution.
Copy-Ready Prompt Template
A reusable prompt template for mapping free-text values to canonical enum or lookup table entries with confidence scores and fallback handling.
This template resolves fuzzy, inconsistent, or abbreviated free-text inputs into controlled vocabulary values suitable for foreign key references in a database. It is designed for data engineering pipelines where raw user input, third-party data, or legacy system values must be normalized before insertion. The prompt expects a target lookup table schema, a list of valid canonical values, and the raw input to resolve. It returns a structured object with the best match, a confidence score, and explicit handling for out-of-vocabulary cases.
textYou are a data normalization assistant. Your task is to map a free-text input value to the most appropriate canonical value from a controlled vocabulary. ## INPUT Free-text value: [RAW_INPUT] ## CONTEXT Lookup table: [LOOKUP_TABLE_NAME] Canonical values (valid enum members): [VALID_VALUES_LIST] Additional resolution rules: [RULES] ## OUTPUT_SCHEMA Return a JSON object with exactly these fields: { "canonical_value": string | null, // The matched canonical value, or null if no match "confidence": number, // 0.0 to 1.0 "match_type": "exact" | "synonym" | "abbreviation" | "fuzzy" | "no_match", "reasoning": string, // Brief explanation of the match decision "fallback_action": "use_default" | "flag_for_review" | "reject" | null } ## CONSTRAINTS - Only return canonical values that appear exactly in the provided list. - If the input is ambiguous, return the most likely match and set confidence below 0.8. - If no reasonable match exists, set canonical_value to null, confidence to 0.0, and match_type to "no_match". - Do not invent new canonical values. - For abbreviations, expand to the full canonical form. - Handle common misspellings and case differences. ## EXAMPLES [EXAMPLES] ## RISK_LEVEL [RISK_LEVEL]
To adapt this template, replace each square-bracket placeholder with concrete values from your pipeline. [RAW_INPUT] receives the free-text string to resolve. [VALID_VALUES_LIST] should be a complete, copy-pasted list of allowed enum members or lookup table display values. [RULES] can include domain-specific resolution logic, such as "map 'NYC' to 'New York'" or "prefer the most specific category." [EXAMPLES] should contain 2-4 few-shot demonstrations showing correct resolution, including at least one no-match case. Set [RISK_LEVEL] to "low", "medium", or "high" to control downstream behavior: high-risk workflows should route no-match and low-confidence results to a human review queue rather than silently inserting a default value.
Prompt Variables
Required inputs for the Enum and Lookup Table Value Resolution prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to verify the input is well-formed.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FREE_TEXT_INPUT] | The raw, unnormalized text value that needs to be resolved to a canonical enum or lookup table entry. | "Enterprise Plus (Annual)" | Must be a non-empty string. Check for leading/trailing whitespace and normalize before passing to the prompt if your application layer handles basic cleaning. |
[LOOKUP_TABLE] | The controlled vocabulary or enum definition containing all valid canonical values, optionally with synonyms, descriptions, or foreign key IDs. | ["starter", "professional", "enterprise", "custom"] | Must be a valid JSON array of strings or an array of objects with 'value' and 'synonyms' keys. Validate JSON.parse() succeeds before prompt assembly. |
[LOOKUP_TABLE_NAME] | A human-readable label for the lookup table, used in the prompt to help the model understand the domain context. | "Subscription Plan Tier" | Must be a non-empty string. Avoid special characters that could confuse the model's parsing of the schema section. |
[OUTPUT_SCHEMA] | The exact JSON schema or field specification the model must return, including the resolved value, confidence score, and fallback indicator. | {"resolved_value": "string", "confidence": "float", "is_fallback": "boolean"} | Must be a valid JSON Schema object or a clear text description of required fields. Validate that the schema includes a field for the resolved value and a confidence indicator. |
[FALLBACK_STRATEGY] | Instruction for how to handle inputs that cannot be confidently mapped to any value in the lookup table. | "Return null for resolved_value, set confidence to 0.0, and set is_fallback to true." | Must be an explicit instruction string. Check that it covers all three required output fields. Ambiguous fallback instructions cause the model to hallucinate mappings. |
[CONFIDENCE_THRESHOLD] | The minimum confidence score below which the resolution should be treated as a fallback or flagged for human review. | 0.85 | Must be a float between 0.0 and 1.0. Validate parseFloat() succeeds. If null, the prompt should specify a default threshold or require the model to always return a score. |
[MAX_CANDIDATES] | The maximum number of top candidate matches the model should return before selecting the best one, useful for audit trails. | 3 | Must be a positive integer. Validate parseInt() succeeds. If null or 1, the prompt should instruct the model to return only the single best match without alternatives. |
[CONTEXT_HINT] | Optional surrounding context that helps disambiguate the free-text input, such as adjacent fields, user role, or source system. | "Field: billing_plan | Source: Salesforce Opportunity" | Can be null or empty string. If provided, must be a non-empty string. Validate that context hints do not accidentally leak PII or sensitive system information into the prompt. |
Implementation Harness Notes
How to wire the enum resolution prompt into a production data pipeline with validation, retries, and fallback handling.
The enum resolution prompt is designed to be called as a stateless function within a data ingestion or cleaning pipeline. Each call receives a single free-text value and a controlled vocabulary, returning a canonical match or a structured fallback. This makes it straightforward to integrate into ETL jobs, API request handlers, or batch processing scripts. The prompt should be treated as a deterministic mapping service with a confidence score, not as a conversational agent. Wrap the prompt call in a thin application function that accepts (input_text, enum_list, context) and returns a typed result object containing the resolved value, confidence, and any fallback flags.
Validation and retry logic is critical because downstream systems often reject out-of-vocabulary values. After receiving the model response, validate the JSON structure against a strict schema that requires resolved_value to be either null or present in the provided enum list. If the model returns a value not in the list, treat it as a low-confidence fallback rather than accepting it. Implement a single retry with a more explicit instruction when confidence is below your threshold (e.g., < 0.85). On the retry, include the original input, the rejected output, and a directive like: The previous response contained a value not in the allowed list. Return the closest match or set resolved_value to null. If the retry also fails, log the input, the enum list, and both responses for later review. For high-volume pipelines, consider caching resolved values in a lookup table to avoid repeated LLM calls for identical inputs.
Model choice and latency matter here. This task requires precise instruction following and low hallucination, not creative reasoning. Use a fast, instruction-tuned model such as gpt-4o-mini, claude-3-haiku, or a fine-tuned open-weight model if you have a large corpus of historical mappings. Avoid models with high latency or verbose reasoning tendencies unless you explicitly need chain-of-thought for ambiguous cases. Set temperature=0 to maximize reproducibility. For batch processing, parallelize calls with a concurrency limit appropriate for your API tier. If processing millions of rows, pre-filter exact string matches before calling the LLM to reduce cost and latency.
Observability and human review are essential for out-of-vocabulary inputs. Every time the model returns fallback_required: true or confidence below your threshold, write a structured log entry with the input, the enum list, the model's suggestion, and the pipeline stage. Route these logs to a review queue where a data steward can approve the mapping, add a new enum value, or mark the input as intentionally unmappable. Over time, this review queue becomes a training dataset for fine-tuning or for expanding your controlled vocabulary. Do not silently drop unmapped values—missing foreign keys in downstream analytics are harder to debug than explicit nulls with audit trails.
Integration pattern: In a typical Python pipeline, wrap the prompt call in a function like resolve_enum(input_text, valid_enums, context_hint) that constructs the prompt, calls the model, parses the JSON response, validates the result against the enum list, and returns a dataclass with fields resolved_value, confidence, fallback_used, and raw_response. Use this function as a .map() operation over a DataFrame column or as a step in an Airflow task. For real-time APIs, cache the function result with a TTL and expose a separate admin endpoint for the review queue. This keeps the LLM call isolated, testable, and replaceable without touching the rest of the pipeline.
Common Failure Modes
Enum and lookup table resolution fails in predictable ways. Free-text inputs drift, confidence scores mislead, and out-of-vocabulary terms silently corrupt downstream data. These cards cover the most common failure patterns and how to guard against them in production.
Silent Mismatch on Near-Match Terms
Risk: The model maps 'Colorad' to 'Colorado' without flagging the typo, or resolves 'Senior Engineer II' to 'Senior Engineer' and drops the level. Partial matches that skip human review create dirty lookup keys. Guardrail: Require a confidence score threshold below which the prompt must output an explicit unmatched token. Route sub-threshold matches to a review queue instead of auto-resolving.
Out-of-Vocabulary Inputs Forced to a Valid Enum
Risk: The model receives 'Cybersecurity Lead' but the lookup table only has 'Security Engineer' and 'IT Manager'. The model picks the closest match instead of returning null, creating a false positive that corrupts analytics. Guardrail: Include an explicit OTHER or UNKNOWN enum value in the schema. Instruct the model to use it when no canonical match exists, and log these cases for vocabulary expansion.
Confidence Score Inflation
Risk: The model assigns 0.95 confidence to a guess when the input is genuinely ambiguous, such as mapping 'Director' to either 'Director of Engineering' or 'Board Director' without enough context. High confidence on wrong answers bypasses review gates. Guardrail: Add a second-pass verification prompt that asks the model to justify its mapping in one sentence. If the justification is weak or contradictory, downgrade the confidence score programmatically before ingestion.
Context-Ignorant Resolution
Risk: The prompt resolves 'Java' to the programming language when the surrounding context indicates the user meant the Indonesian island. The model ignores available context and pattern-matches on the term alone. Guardrail: Always include surrounding context fields in the prompt template, such as department, location, or adjacent column values. Instruct the model to weigh context above surface string similarity when disambiguating.
Schema Drift After Lookup Table Updates
Risk: The lookup table adds 'ML Engineer' and removes 'Data Scientist'. The prompt template still references the old enum list, causing the model to hallucinate removed values or miss new ones. Guardrail: Dynamically inject the current enum list into the prompt at runtime from a source of truth. Never hardcode enum values. Add a pre-flight validation check that the model's output only contains values present in the injected list.
Batch Inconsistency Across Records
Risk: The same input value 'Sr. Product Manager' resolves to 'Senior Product Manager' in record one and 'Product Manager' in record seven. Inconsistent mapping breaks aggregation and reporting downstream. Guardrail: For batch processing, include a few-shot example section with canonical mappings for the top 10-20 ambiguous terms. Cache resolved mappings within a session and prepend them as fixed examples for subsequent records.
Evaluation Rubric
Use this rubric to test the output quality of the Enum and Lookup Table Value Resolution prompt before shipping. Each criterion targets a specific failure mode common to fuzzy value resolution.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Canonical Value Match | Resolved value exactly matches a canonical value in the provided [LOOKUP_TABLE] for unambiguous inputs. | Output contains a value not present in the lookup table, or a near-miss string (e.g., 'Street' vs 'St'). | Parse the output and assert the resolved value exists in the provided lookup table list. |
Confidence Score Calibration | Confidence score is >= 0.9 for exact string matches and between 0.5-0.9 for fuzzy matches requiring normalization. | Confidence is 1.0 for a fuzzy match or < 0.5 for a clear synonym. | Extract the numeric confidence field and validate it falls within the expected range based on input ambiguity. |
Out-of-Vocabulary Handling | Inputs with no reasonable match in [LOOKUP_TABLE] are mapped to the [FALLBACK_VALUE] with a confidence score of 0.0. | A hallucinated value is returned, or a low-confidence guess is made without using the fallback. | Provide an input completely unrelated to the lookup domain and assert the output uses the exact [FALLBACK_VALUE]. |
Null/Empty Input Handling | Null or empty [INPUT_TEXT] returns the [FALLBACK_VALUE] with a confidence of 0.0 and no error. | The model refuses to respond, throws a parsing error, or returns a non-fallback value. | Pass an empty string and a null value for [INPUT_TEXT] and check for the correct fallback structure. |
Output Schema Compliance | Output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and correctly typed. | The JSON is malformed, a required field like 'resolved_value' is missing, or the type is wrong (e.g., string for confidence). | Validate the raw output string against the [OUTPUT_SCHEMA] using a JSON Schema validator. |
Case and Whitespace Normalization | Inputs with leading/trailing whitespace or inconsistent casing resolve to the correct canonical value. | Input ' active ' fails to resolve to 'ACTIVE' or a case-insensitive match is missed. | Run a batch of inputs with deliberate case and whitespace variations and assert a 100% match rate. |
Synonym and Abbreviation Resolution | A known synonym or abbreviation defined in [SYNONYM_MAP] correctly resolves to the canonical value. | A common abbreviation like 'NY' fails to resolve to 'New York' despite being in the mapping context. | Provide a test pair from the [SYNONYM_MAP] and assert the output matches the target canonical value. |
Ambiguous Input Handling | An input matching multiple lookup values returns the single best match with a confidence score below 0.8. | The model arbitrarily picks one match with high confidence or returns an error. | Provide an ambiguous input like 'Java' (island vs. language) and check for a low confidence score and a single, reasonable selection. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a small lookup table (5-10 values). Use a simple JSON output with resolved_value, lookup_key, and confidence. Skip strict schema validation during early testing.
codeLookup Table: [TABLE] Input: [INPUT] Return JSON: {"resolved_value": "<canonical>", "lookup_key": "<matched_key>", "confidence": <0.0-1.0>}
Watch for
- Overconfident matches on ambiguous inputs
- Missing fallback for out-of-vocabulary terms
- Case sensitivity mismatches between input and lookup keys

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us