Inferensys

Prompt

Cross-Lingual Entity Normalization Prompt Template

A practical prompt playbook for mapping named entities in user queries to canonical, language-independent identifiers for precise cross-lingual retrieval in enterprise RAG systems.
Developer working on RAG retrieval system, document chunks visible on screen, technical workspace with code editor.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for cross-lingual entity normalization.

This prompt is for enterprise RAG teams that operate multilingual knowledge bases where the same real-world entity—a person, organization, product, or location—appears under different names, spellings, or translations across languages. The job-to-be-done is mapping a named entity mentioned in a user's source-language query to a single, language-independent canonical identifier before retrieval executes. Without this normalization step, a query for 'International Business Machines' in English might miss German documents that reference 'IBM' or Japanese documents that use 'アイ・ビー・エム,' causing retrieval gaps that no amount of synonym expansion or query translation can fix on its own.

The ideal user is a search engineer, RAG architect, or platform developer who already has a canonical entity store (a knowledge graph, entity resolution service, or authoritative ID system) and needs the LLM to perform the disambiguation and mapping step. Required context includes the source query text, the detected source language, a list of candidate entities extracted from the query, and access to entity metadata such as known aliases, language variants, and canonical IDs. This prompt is not a replacement for a production entity resolution system; it is a pre-retrieval normalization layer that reduces the problem space before the query hits your indexes. Do not use this prompt when you lack a canonical entity store to map into, when the query contains no named entities, or when your retrieval backend already performs fuzzy entity matching natively.

This prompt is also inappropriate for real-time, sub-50ms retrieval paths where an LLM call would add unacceptable latency. In those cases, precompute entity mappings offline or use a fast, rules-based alias dictionary. Additionally, if your entity store is incomplete or untrusted, the prompt will produce mappings that look confident but are wrong—always validate the canonical ID against your ground-truth system after the LLM returns. For high-stakes domains like legal or healthcare, require human review of any entity mapping where the LLM's confidence is below a defined threshold or where multiple candidate entities have similar scores. The next section provides the copy-ready prompt template you can adapt and wire into your retrieval pipeline.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the Cross-Lingual Entity Normalization template fits your retrieval architecture.

01

Good Fit: Canonical Entity Resolution

Use when: your knowledge base has a pre-built entity index (people, orgs, products) with canonical IDs, and user queries mention these entities in any language. Guardrail: always provide the entity catalog as [ENTITY_CATALOG] in the prompt context; without it, the model will hallucinate identifiers.

02

Good Fit: Multilingual Knowledge Bases

Use when: documents exist in multiple languages and a user query in one language must retrieve documents in others by matching on entity identity, not just translated text. Guardrail: pair this prompt with a separate translation step for the non-entity portions of the query to avoid losing contextual meaning.

03

Bad Fit: Ad-Hoc or Unstructured Corpora

Avoid when: your documents lack consistent entity tagging or you have no canonical entity store. The prompt cannot invent stable identifiers from raw text. Guardrail: invest in an entity extraction and deduplication pipeline before applying this prompt; otherwise, fall back to cross-lingual synonym expansion.

04

Bad Fit: Real-Time or High-Volume Streams

Avoid when: you need sub-50ms retrieval latency or are processing a firehose of user queries. Entity normalization adds a non-trivial LLM call to the critical path. Guardrail: cache frequent entity mappings in a lookup table and only invoke the prompt for cache misses or low-confidence matches.

05

Required Inputs

Risk: incomplete inputs cause the model to guess entity mappings, producing wrong canonical IDs that poison retrieval. Guardrail: require [SOURCE_QUERY], [SOURCE_LANGUAGE], [TARGET_LANGUAGES], and [ENTITY_CATALOG] as mandatory fields. Validate that the catalog contains at minimum an id, canonical_name, and aliases array per entity.

06

Operational Risk: Entity Drift

Risk: the entity catalog becomes stale as organizations rename, products rebrand, or people change roles. The prompt will map to outdated identifiers. Guardrail: implement a catalog freshness check that runs before the prompt is invoked; if the catalog's last update exceeds a threshold (e.g., 24 hours for fast-moving domains), trigger a refresh or flag the output with a catalog_timestamp for downstream consumers.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template that maps named entities from a source-language query to canonical, language-independent identifiers for precise cross-lingual retrieval.

This prompt template normalizes named entities—people, organizations, products, locations, and domain-specific terms—found in a user's query into their canonical identifiers. The goal is to bridge the gap between how users refer to entities in their own language and how those entities are indexed in a multilingual knowledge base. The prompt expects a source query, a target retrieval language, and access to a canonical entity catalog (provided inline or via a tool). It outputs a structured mapping that can be fed directly into a retrieval system's filter or query rewriter.

text
You are an entity normalization engine for a multilingual retrieval system. Your task is to identify named entities in a user query and map them to their canonical, language-independent identifiers.

## INPUT
User Query: [USER_QUERY]
Source Language: [SOURCE_LANGUAGE]
Target Retrieval Language: [TARGET_LANGUAGE]

## CANONICAL ENTITY CATALOG
[ENTITY_CATALOG]

## INSTRUCTIONS
1. Extract every named entity from the User Query. Entities include people, organizations, products, brands, locations, technical terms, and domain-specific concepts.
2. For each extracted entity, find its canonical identifier in the Entity Catalog. Match on:
   - Exact name in any language variant listed.
   - Known aliases, acronyms, or abbreviations.
   - Common translations or transliterations between the source and target languages.
3. If an entity is not found in the catalog, mark it as `unmatched` and provide the best-guess normalized form in the target language.
4. Do not invent canonical IDs. If the catalog does not contain a match, the `canonical_id` field must be `null`.

## OUTPUT SCHEMA
Return a JSON object with this exact structure:
{
  "entities": [
    {
      "mention": "string (exact text from query)",
      "entity_type": "PER | ORG | PROD | LOC | TERM | OTHER",
      "canonical_id": "string | null",
      "canonical_name": "string (preferred name in target language)",
      "match_method": "exact | alias | translation | transliteration | guess | none",
      "confidence": 0.0-1.0
    }
  ],
  "unmatched_count": 0,
  "normalized_query_hint": "string (query with mentions replaced by canonical names in target language, for retrieval fallback)"
}

## CONSTRAINTS
- Preserve the original mention text exactly as it appears in the query.
- If multiple catalog entries are possible candidates, return the highest-confidence match and list alternatives in a `candidates` array per entity.
- Set confidence below 0.5 for transliteration-only or guess-based matches.
- The `normalized_query_hint` is a fallback string for keyword retrieval, not a replacement for structured entity filters.

Adaptation notes: Replace [ENTITY_CATALOG] with your actual canonical entity list, formatted as a JSON array of objects with id, canonical_name, language_variants, and aliases fields. For large catalogs, replace the inline catalog with a tool call—define a search_entity_catalog function that accepts a mention string and language, and returns candidate matches. If your retrieval system uses structured filters, add a filter_clause field to the output schema that generates the exact filter syntax your backend expects (e.g., entity_id: "canonical-123" OR entity_id: "canonical-456"). For high-stakes domains like legal or medical, route unmatched entities with confidence below 0.7 to a human review queue before retrieval proceeds.

What to do next: Test this prompt against a golden dataset of 50–100 queries with known entity mappings across your supported language pairs. Measure precision and recall of canonical ID assignment, and pay special attention to false positives where an ambiguous mention is incorrectly matched. Wire the output into your retrieval pipeline as a pre-retrieval filter, and log every unmatched entity for catalog expansion.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Cross-Lingual Entity Normalization prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to programmatically verify the input before execution.

PlaceholderPurposeExampleValidation Notes

[SOURCE_QUERY]

The original user query containing named entities to normalize

Who is the CEO of Münchener Rück?

Non-empty string; max 2000 chars; must contain at least one detectable named entity or the prompt should be skipped

[SOURCE_LANGUAGE]

ISO 639-1 code for the language of [SOURCE_QUERY]

en

Must match a supported language code from your language detection service; reject if confidence below 0.85

[TARGET_LANGUAGES]

JSON array of ISO 639-1 codes for the languages of the knowledge base indexes

["de", "fr", "ja"]

Must be a valid JSON array with at least one element; each code must be in your supported index language list; empty array triggers a fallback to [DEFAULT_INDEX_LANGUAGE]

[ENTITY_TYPES]

JSON array of entity types to extract and normalize

["PERSON", "ORGANIZATION", "PRODUCT"]

Must be a valid JSON array; allowed values constrained to your canonical entity taxonomy; empty array means extract all supported types

[CANONICAL_ENTITY_STORE]

A JSON object or reference ID for the canonical entity lookup table available to the model

{"store_id": "ent-store-v3", "entities": [...]}

If using in-prompt injection, validate JSON schema and size under token budget; if using tool access, confirm store availability and auth before prompt assembly

[OUTPUT_SCHEMA]

The expected JSON schema for the normalized output

{"type": "object", "properties": {"entities": [...]}}

Must be a valid JSON Schema draft-07 object; validate with a schema validator before injection; reject schemas with unsupported keywords for your model

[CONFIDENCE_THRESHOLD]

Minimum confidence score (0.0-1.0) for including a normalization in the output

0.7

Must be a float between 0.0 and 1.0; values below 0.5 produce noisy outputs; values above 0.95 may suppress correct low-confidence matches; default to 0.7 if unset

[MAX_ENTITIES]

Maximum number of normalized entities to return

10

Must be a positive integer; cap at 50 to prevent runaway token usage; if input contains more entities than this limit, prioritize by salience or first occurrence

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Cross-Lingual Entity Normalization prompt into a production retrieval pipeline with validation, caching, and fallback controls.

This prompt is designed to be called as a pre-retrieval microservice. When a user query enters your RAG system, intercept it before the retrieval step and send the raw query text, the detected source language, and your canonical entity catalog to the model. The model returns a structured JSON payload containing normalized entity identifiers and the original query with entity placeholders replaced. This normalized query string becomes the input to your downstream vector, keyword, or hybrid retrieval indexes. Do not pass the raw user query directly to retrieval if entity normalization is required for cross-lingual recall.

Implement a strict validation layer around the model's JSON output. The response must be parsed and checked before the normalized query is used for retrieval. Validate that every entity_id returned exists in your canonical entity catalog; reject or flag any hallucinated identifiers. Confirm that the normalized_query string contains the expected placeholder tokens (e.g., [ENT:canonical_id]) and that the original entity surface forms have been removed. If validation fails, log the raw response and the failure reason, then fall back to a literal translation of the original query without entity normalization. This prevents a bad normalization from silently degrading retrieval quality. For high-stakes domains like legal or medical knowledge bases, route validation failures to a human review queue instead of auto-falling back.

Cache normalized entity mappings aggressively. Entity normalization is idempotent for a given surface form and language pair. Store the mapping of (source_language, surface_form) -> canonical_entity_id in a fast key-value store (e.g., Redis) with a TTL that matches your entity catalog update cadence. Before calling the LLM, check the cache. This reduces latency and cost for frequently mentioned entities like company names, product lines, or well-known people. Invalidate the cache when your entity catalog is updated. For entity disambiguation cases where the model must consider surrounding context, include a context hash in the cache key to avoid incorrect cache hits.

Choose a model with strong multilingual instruction-following and JSON mode support. GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro are all suitable. Set temperature=0 to maximize deterministic entity mapping. Enable structured output mode (JSON schema constraint) if the model provider supports it; otherwise, include a retry loop that detects JSON parse errors and re-prompts with the error message appended. Limit retries to 2 attempts before falling back to the un-normalized query path. Log every retry event for observability into model reliability.

Wire this prompt into an evaluation harness before production deployment. Build a golden dataset of 100-200 queries spanning your supported languages, each with hand-labeled canonical entity IDs and expected normalized query strings. Run the prompt against this dataset and measure exact-match accuracy on entity IDs, recall of all entities present, and precision (no false entity insertions). Track semantic drift by comparing retrieval results from the normalized query against results from a human-translated ideal query. Gate deployment on passing a minimum threshold (e.g., 95% entity ID accuracy) and set up periodic re-evaluation when the entity catalog changes or the model is updated.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when normalizing entities across languages and how to guard against it.

01

Entity Collision Across Languages

What to watch: The same surface string maps to different canonical entities in different languages (e.g., 'Apple' as a company vs. the fruit in a food corpus). The model picks the wrong canonical ID because it defaults to the most common sense in the target language. Guardrail: Require the prompt to output a disambiguation context field that explains which entity was chosen and why. If the confidence is low, route to a human review queue with both candidate entities presented.

02

Untranslatable Proper Nouns

What to watch: Named entities like person names, brand names, or legal entity names are incorrectly translated instead of being matched to their canonical form. 'Giovanni Rossi' becomes 'John Red' in English retrieval, producing zero matches against the knowledge base. Guardrail: Add an explicit instruction in the prompt template that proper nouns must be transliterated, not translated. Include a validation step that checks if the output entity string exists in the canonical entity index before retrieval proceeds.

03

Acronym Expansion Mismatch

What to watch: An acronym in the source language expands to a different full form in the target language, or the same acronym means different things across languages (e.g., 'CEO' in English vs. a different expansion in French). The model normalizes to the wrong entity. Guardrail: Include a language-specific acronym dictionary as context in the prompt. Require the model to output the detected source language of the acronym and the target language expansion, flagging any ambiguity for human review.

04

Partial Entity Match Drift

What to watch: The model matches part of a multi-word entity name correctly but normalizes the full entity to a related but incorrect canonical ID (e.g., 'Banco Santander Brasil' normalized to the parent 'Banco Santander' entity). Retrieval returns documents about the wrong subsidiary. Guardrail: Structure the output schema to require both a canonical_id and a matched_span field. Add a post-retrieval check that verifies the matched span from the source query aligns with the canonical entity's known aliases in the entity resolution system.

05

Cultural Context Loss in Entity Resolution

What to watch: An entity reference that relies on cultural or regional context (e.g., a local regulatory body, a regional product name) is normalized to a generic or incorrect global entity because the model lacks the cultural grounding. Guardrail: Provide a locale code and a region-specific entity glossary as part of the prompt's input context. If the model cannot find a high-confidence match in the provided glossary, instruct it to return a null canonical ID with a requires_context flag rather than guessing.

06

Confidence Score Calibration Failure

What to watch: The model returns a high confidence score for an entity normalization that is wrong, or a low score for a correct one, because the scoring is based on surface linguistic similarity rather than factual knowledge graph proximity. Downstream systems trust the score and skip verification. Guardrail: Do not rely solely on the model's self-reported confidence. Implement an independent verification step that checks the resolved canonical ID against a knowledge graph or entity linking API. Use the model's score only as a tie-breaker, not a gate.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Cross-Lingual Entity Normalization prompt before shipping. Each criterion targets a specific failure mode observed in multilingual entity resolution, such as language bias, over-normalization, or missing canonical IDs.

CriterionPass StandardFailure SignalTest Method

Canonical ID Accuracy

Every extracted entity maps to the correct, language-independent canonical ID from the provided knowledge base.

Entity mapped to a similar but incorrect ID; entity mapped to a string literal instead of an ID; entity left unmapped despite a valid KB entry.

Golden dataset: 50 source queries with known entities across 5+ languages. Assert exact ID match. Measure Precision@1.

Cross-Script Entity Recall

Entities mentioned in non-Latin scripts (e.g., 北京, Москва) are identified and normalized with the same accuracy as Latin-script mentions.

Entity in non-Latin script is missed entirely; entity is transliterated instead of resolved to its canonical ID.

Stratified test set: equal distribution of Latin, Cyrillic, CJK, and Arabic script queries. Compare recall per script group.

Alias and Abbreviation Handling

Common aliases, acronyms, and short-form names resolve to the correct canonical entity without hallucination.

Acronym expanded to a wrong entity; local-market product name mapped to a global parent incorrectly; abbreviation ignored.

Adversarial alias list: 20 entities each with 3 known aliases or abbreviations in different languages. Assert consistent ID output.

Disambiguation in Context

Ambiguous entity mentions are resolved using surrounding query context, not defaulting to the most frequent sense.

Model always picks the highest-prevalence entity regardless of context; model outputs multiple IDs without a primary selection when one is clearly implied.

Contrastive pairs: 15 query pairs where the same surface form refers to different entities based on context. Assert correct disambiguation.

Null Handling and Abstention

Returns an empty list or explicit null marker when no entity is present, rather than hallucinating a plausible entity.

Model extracts a generic noun as an entity; model forces a match to a vaguely similar KB entry; model invents an ID.

Negative test set: 20 queries containing zero known entities. Assert empty output list. Measure hallucination rate.

Output Schema Compliance

Output is valid JSON matching the [OUTPUT_SCHEMA] exactly, with all required fields present and correctly typed.

Missing canonical_id field; entity_mention is a substring copy error; confidence is a string instead of a float; extra unexplained fields.

Schema validator run against 100 outputs. Assert 100% structural validity. No manual fixes allowed before validation.

Confidence Score Calibration

Confidence scores correlate with actual correctness; high-confidence predictions are rarely wrong, low-confidence predictions signal ambiguity.

Model assigns 0.99 confidence to an incorrect mapping; model assigns 0.5 confidence to an unambiguous, direct match.

Reliability diagram: bin outputs by confidence decile and measure accuracy per bin. Expected monotonic increase.

Language-Agnostic Behavior

Normalization quality does not degrade for queries written in low-resource languages compared to high-resource languages.

Significant accuracy drop for languages not explicitly named in the prompt; model defaults to English-centric entity interpretations.

Cross-language parity test: same set of entities queried in 10 languages. Measure variance in F1 score across languages. Flag if >5% drop.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt\nStart with the base prompt and a small multilingual entity list. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with no additional validation. Remove the `[OUTPUT_SCHEMA]` constraint and ask for a simple JSON object with `canonical_id` and `confidence`. Test with 10-15 queries across 2-3 languages.\n\n### Watch for\n- The model returning entity names instead of canonical IDs\n- Confidence scores that are always 0.9+ without real disambiguation\n- Missing entities silently dropped instead of flagged as `unmatched`\n- Language-specific script variations (Cyrillic, Hanzi) causing false negatives

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.