This prompt is designed for evaluation pipeline engineers who need to route LLM-generated outputs to language-appropriate judge rubrics. When you run an LLM-as-judge evaluation across a multilingual dataset, applying an English rubric to a Japanese output produces garbage scores. This prompt sits between the candidate output and your judge library: it detects the dominant language of the output, identifies mixed-language segments, and selects the correct judge prompt, evaluation criteria, and reference examples. Use this when you have a library of per-language rubrics and need deterministic, auditable routing before scoring.
Prompt
Language Detection for LLM Judge Rubric Selection Prompt

When to Use This Prompt
Determines when to deploy language detection for routing LLM outputs to the correct evaluation rubric in a multilingual judge pipeline.
The ideal user is an MLOps engineer or evaluation pipeline owner managing a regression test suite that spans multiple languages. You have a set of judge prompts tuned for specific languages—each with its own scoring criteria, few-shot examples, and calibration thresholds—and you need a reliable dispatcher that maps candidate outputs to the right rubric without manual sorting. The prompt expects a raw LLM output string as input and returns a structured routing decision: a primary language code, a confidence score, a list of any secondary languages detected, and the identifier of the matching judge rubric. This output feeds directly into your evaluation harness, which then loads the correct rubric and runs the scoring pass. The routing decision should be logged alongside the score for auditability, so you can trace any misrouting back to the detection step.
Do not use this prompt for real-time user-facing language detection, translation routing, or locale identification. Those are separate playbooks with different latency requirements, confidence thresholds, and failure modes. This prompt is specifically for offline or async evaluation pipelines where correctness and auditability matter more than speed. It is also not a replacement for a dedicated language detection library like fastText or CLD3 when you need millisecond inference on high-throughput streams. Use this prompt when the routing decision benefits from the model's ability to reason about mixed-language content, quoted material, and domain-specific terminology that confuses statistical detectors. If your outputs are consistently monolingual and the language is known from upstream metadata, skip this prompt entirely and route directly to the appropriate rubric.
Use Case Fit
Where this prompt works, where it fails, and what you must provide before wiring it into an evaluation pipeline.
Good Fit: Multilingual Eval Pipelines
Use when: your evaluation harness processes outputs in multiple languages and needs to select the correct grading rubric, reference examples, and judge prompt per language. Guardrail: always pair language detection with a confidence threshold; route low-confidence outputs to a human review queue or a generic rubric.
Bad Fit: Single-Language Systems
Avoid when: your system only handles one language and all rubrics are monolingual. Adding detection adds latency and a misclassification risk surface with no benefit. Guardrail: remove the detection step entirely and hardcode the rubric selection in your application config.
Required Input: Output Text with Sufficient Signal
What to watch: language detection fails on very short outputs, code snippets, numeric tables, or outputs dominated by proper nouns. Guardrail: enforce a minimum character count (e.g., 50+ non-whitespace characters) before invoking detection; below threshold, fall back to the input language or a default rubric.
Required Input: Language-to-Rubric Mapping
What to watch: detection produces an ISO 639-1 code, but your eval system needs a specific rubric ID. A missing mapping causes silent failures. Guardrail: maintain an explicit mapping table (language code → rubric ID, judge prompt, reference set) and validate that every supported language has a complete entry before deployment.
Operational Risk: Mixed-Language Outputs
Risk: LLM outputs often mix languages—quoted source material in one language, analysis in another. Single-label detection picks the dominant language and applies the wrong rubric to the minority-language segments. Guardrail: add a mixed-language detection step before rubric selection; if multiple languages are present, either split the output by language span or flag for human review.
Operational Risk: Untranslated Quoted Material
Risk: an output in Language A contains a long verbatim quote in Language B. Detection may classify the whole output as Language B, applying a rubric that doesn't match the surrounding analysis. Guardrail: preprocess outputs to identify quoted spans and run detection on the non-quoted portion only, or use span-level language identification before rubric assignment.
Copy-Ready Prompt Template
A production-ready prompt that detects output language and selects the correct evaluation rubric for LLM judge pipelines.
This prompt template is designed to be the first stage in a two-pass LLM judge evaluation pipeline. Before grading an AI-generated response, you must know what language it is written in so you can apply the correct rubric, reference examples, and evaluation criteria. This prompt takes the raw model output and a mapping of available language-specific rubrics, then returns a structured language detection result that your application can use to select the right judge configuration. The template is built for deterministic routing: it returns a standardized language code, a confidence score, and explicit handling for mixed-language outputs, untranslated quoted material, and edge cases where no matching rubric exists.
textYou are a language detection classifier for an LLM evaluation pipeline. Your output determines which grading rubric, evaluation criteria, and reference examples will be used to judge an AI-generated response. ## INPUT **Model Output to Classify:** [OUTPUT_TEXT] **Available Language Rubrics:** [AVAILABLE_RUBRICS] ## TASK Detect the primary language of the model output above. Use the following rules: 1. **Primary Language:** Identify the dominant language by word count. Ignore proper nouns, brand names, and URLs when counting. 2. **Mixed Language Handling:** If the output contains substantial content in multiple languages (more than 20% in a secondary language), flag it as mixed and list all detected languages with approximate proportions. 3. **Untranslated Quotes:** If the output contains quoted material in a different language from the surrounding text, classify by the surrounding text language but note the quoted language in the `quoted_languages` field. 4. **Code and Technical Content:** Ignore code blocks, variable names, and API identifiers when determining language. Classify based on natural language portions only. 5. **Short or Ambiguous Outputs:** If the output is fewer than 10 words or contains only proper nouns, set confidence to `low` and include an `ambiguity_reason`. 6. **Rubric Matching:** After detecting the language, select the best-matching rubric from the available rubrics list. If no rubric matches the detected language, set `rubric_match` to `null` and include a `fallback_recommendation`. ## OUTPUT SCHEMA Return a valid JSON object with exactly this structure: ```json { "detected_language": "ISO 639-1 code or 'mixed'", "language_name": "Human-readable language name", "confidence": "high | medium | low", "confidence_score": 0.0-1.0, "is_mixed_language": true/false, "language_breakdown": [ { "language_code": "ISO 639-1", "language_name": "string", "proportion": 0.0-1.0 } ], "quoted_languages": ["ISO 639-1 codes or empty array"], "rubric_match": "rubric identifier from available list or null", "fallback_recommendation": "string or null", "ambiguity_reason": "string or null", "output_word_count": integer, "natural_language_word_count": integer }
CONSTRAINTS
- Do not evaluate the quality of the model output. Only detect its language.
- Do not translate any content. Only classify.
- If the output is entirely code, return
und(undetermined) with confidencelow. - Always provide a
fallback_recommendationwhenrubric_matchis null. - Use BCP 47 language codes when regional specificity is available (e.g.,
pt-BR), otherwise use ISO 639-1.
EXAMPLES
Example 1: Clear single language Output: "The quarterly revenue exceeded projections by 12%, driven primarily by the enterprise segment." Available Rubrics: ["en-general", "en-technical", "es-general", "fr-general"]
json{ "detected_language": "en", "language_name": "English", "confidence": "high", "confidence_score": 0.98, "is_mixed_language": false, "language_breakdown": [{"language_code": "en", "language_name": "English", "proportion": 1.0}], "quoted_languages": [], "rubric_match": "en-general", "fallback_recommendation": null, "ambiguity_reason": null, "output_word_count": 12, "natural_language_word_count": 12 }
Example 2: Mixed language with untranslated quote Output: "As noted in the report, 'Die Marktbedingungen bleiben herausfordernd,' which suggests continued pressure on margins." Available Rubrics: ["en-general", "de-general", "en-finance"]
json{ "detected_language": "en", "language_name": "English", "confidence": "high", "confidence_score": 0.95, "is_mixed_language": false, "language_breakdown": [{"language_code": "en", "language_name": "English", "proportion": 0.82}, {"language_code": "de", "language_name": "German", "proportion": 0.18}], "quoted_languages": ["de"], "rubric_match": "en-general", "fallback_recommendation": null, "ambiguity_reason": null, "output_word_count": 22, "natural_language_word_count": 22 }
Example 3: No matching rubric available Output: "市場の反応は予想以上に早かった。" Available Rubrics: ["en-general", "es-general", "fr-general"]
json{ "detected_language": "ja", "language_name": "Japanese", "confidence": "high", "confidence_score": 0.97, "is_mixed_language": false, "language_breakdown": [{"language_code": "ja", "language_name": "Japanese", "proportion": 1.0}], "quoted_languages": [], "rubric_match": null, "fallback_recommendation": "No Japanese rubric available. Consider adding a ja-general rubric or routing to a general multilingual judge with Japanese reference examples.", "ambiguity_reason": null, "output_word_count": 8, "natural_language_word_count": 8 }
To adapt this template for your evaluation pipeline, replace the square-bracket placeholders with your actual values. [OUTPUT_TEXT] should contain the raw model-generated response you need to evaluate. [AVAILABLE_RUBRICS] should be a structured list of your language-specific rubric identifiers, ideally formatted as a JSON array or a clear mapping of language codes to rubric names. The output schema is designed to be machine-readable: your application should parse the rubric_match field to select the correct judge prompt, or trigger a fallback path when it is null. For production deployments, validate the JSON output against the schema before using it for routing. If the model returns malformed JSON, retry with a stricter schema instruction or fall back to a default rubric with a logged warning. This prompt works best with models that have strong JSON-following capabilities; if you are using a smaller or older model, consider adding an output repair step or using constrained decoding to enforce the schema.
Prompt Variables
Inputs required for the Language Detection for LLM Judge Rubric Selection Prompt. Each variable must be populated before the prompt is sent to the model. Validation notes describe how to verify the input is well-formed and safe to use.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TEXT_TO_EVALUATE] | The AI-generated output that needs to be graded. This is the text whose language must be detected. | The capital of France is Paris. It is known for its culture and cuisine. | Check that length is between 1 and 32000 characters. Reject empty strings. If null, fail fast before prompt assembly. |
[AVAILABLE_RUBRICS] | A JSON map of language codes to rubric identifiers or inline rubric definitions that the judge can select from. | {"en": "rubric-eng-v2", "fr": "rubric-fre-v1", "es": "rubric-spa-default", "ar": "rubric-ara-modern"} | Validate JSON parse. Confirm at least one entry exists. Each key must be a valid ISO 639-1 or BCP-47 code. Reject if map is empty. |
[DEFAULT_RUBRIC] | The fallback rubric identifier to use when the detected language is not found in [AVAILABLE_RUBRICS] or confidence is below threshold. | rubric-multilingual-fallback | Must be a non-empty string. Should correspond to a real rubric ID in your system. Null not allowed. This is your safety net for unknown languages. |
[CONFIDENCE_THRESHOLD] | A float between 0.0 and 1.0. If the model's language detection confidence is below this value, the [DEFAULT_RUBRIC] is used instead. | 0.85 | Must be a number. Clamp to range 0.0-1.0. Values below 0.7 risk frequent fallback; values above 0.95 risk false mismatches on short text. Log a warning if set outside 0.7-0.95. |
[OUTPUT_SCHEMA] | The expected JSON structure for the prompt response, including fields for detected language, confidence, selected rubric, and rationale. | {"detected_language": "fr", "confidence": 0.96, "selected_rubric": "rubric-fre-v1", "fallback_used": false, "rationale": "Strong French vocabulary and grammar markers detected."} | Validate JSON parse. Schema must include required fields: detected_language (string), confidence (number), selected_rubric (string), fallback_used (boolean). Reject if schema is missing required fields. |
[MIXED_LANGUAGE_POLICY] | Instruction for how to handle text that contains multiple languages. Options: 'primary_only', 'majority_threshold', 'strict_single', or a custom rule. | majority_threshold | Must be one of the enumerated string values. If custom, must be a non-empty string describing the rule. Reject null. This directly impacts rubric selection accuracy for code-switched outputs. |
[UNTRANSLATED_QUOTE_HANDLING] | Instruction for how to treat quoted material in a different language than the surrounding text. Options: 'ignore_quotes', 'weigh_quotes', 'treat_as_mixed'. | ignore_quotes | Must be one of the enumerated string values. If 'weigh_quotes', ensure the prompt logic accounts for quote length relative to total text. Reject null. Critical for academic and legal evaluation where quotes are common. |
Implementation Harness Notes
How to wire the language detection prompt into an evaluation pipeline with validation, retries, and routing logic.
This prompt is a routing component inside a larger LLM judge evaluation pipeline. Its job is to detect the language of a generated output so the system can select the correct grading rubric, reference examples, and judge prompt. The implementation harness must treat this as a deterministic classification step with strict validation, not as an open-ended generation task. The prompt should be called immediately after the candidate output is produced and before any evaluation logic runs. The detected language code becomes the primary key for rubric selection.
Wire the prompt into your application with a validation layer that enforces a closed set of supported language codes (e.g., ISO 639-1 two-letter codes). Reject any output that does not match the expected schema: {"language_code": "string", "confidence": float, "is_mixed_language": boolean}. If the confidence score falls below a configurable threshold (start with 0.85 and calibrate against your eval set), route to a fallback rubric or flag for human review. Implement a retry policy with a maximum of two attempts using a lower-temperature setting on retry (e.g., temperature 0.1 → 0.0). Log every detection result with the input text hash, detected language, confidence, and whether a retry was required. This log becomes your calibration dataset for tuning the confidence threshold over time.
For model selection, use a fast, low-cost model for this classification step. A lightweight model like GPT-4o-mini, Claude Haiku, or Gemini Flash is sufficient for language detection on short-to-medium texts. Reserve larger models for the actual evaluation step that follows. If your pipeline processes high volumes, consider batching language detection calls or caching results by input hash to avoid redundant API calls on retried evaluations. The most common production failure mode is overconfident misclassification on short outputs (under 20 words) or mixed-language texts where quoted material in a second language confuses the detector. Build eval cases specifically for these scenarios and monitor the is_mixed_language flag in production logs to catch routing errors before they corrupt evaluation scores.
Expected Output Contract
Fields, types, and validation rules for the JSON response produced by the Language Detection for LLM Judge Rubric Selection Prompt. Use this contract to parse, validate, and route the model's output before selecting a grading rubric.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
detected_language | ISO 639-1 string (e.g., 'en', 'ja', 'ar') | Must match a valid ISO 639-1 code; reject if not in allowed language set | |
confidence_score | float (0.0 to 1.0) | Must be a number between 0.0 and 1.0 inclusive; reject if non-numeric or out of range | |
is_mixed_language | boolean | Must be true or false; if true, additional_languages must be present and non-empty | |
additional_languages | array of strings (ISO 639-1) | Required when is_mixed_language is true; each element must be a valid ISO 639-1 code distinct from detected_language | |
primary_script | ISO 15924 string (e.g., 'Latn', 'Arab', 'Cyrl') | Must match a valid ISO 15924 four-letter script code; reject if unrecognized | |
needs_transliteration | boolean | Must be true or false; if true, transliteration_scheme should be populated if detectable | |
transliteration_scheme | string or null | If needs_transliteration is true, provide scheme name (e.g., 'Pinyin', 'Arabizi'); null if not applicable | |
rubric_locale | string (e.g., 'en-US', 'ja-JP', 'ar-001') | Must be a valid locale string; used to select the grading rubric; reject if format does not match language-region pattern |
Common Failure Modes
What breaks first when using an LLM to detect language for judge rubric selection, and how to prevent silent evaluation failures.
Short Text Ambiguity
What to watch: Inputs under 20 words, single-word queries, or proper nouns often lack sufficient signal for reliable language detection. The model may default to English or guess based on script alone, leading to wrong rubric selection. Guardrail: Implement a minimum character threshold. If the input is below the threshold, route to a script-based fallback or flag for human review. Add a confidence field to the output and reject classifications below 0.85 for short inputs.
Mixed-Language Output Contamination
What to watch: The LLM output being evaluated may contain untranslated quotes, code blocks, technical terms, or code-switched segments in a different language than the primary response. A single-language detection prompt will misclassify the output and apply the wrong rubric. Guardrail: Use a mixed-language detection prompt first. If multiple languages are detected, either segment the output and evaluate each segment separately, or flag the evaluation for human review with a note about language mixing.
CJK Script Confusion
What to watch: Chinese, Japanese, and Korean share character sets (Hanzi/Kanji/Hanja). A prompt that relies only on character presence will frequently misclassify short CJK strings, especially when no kana or hangul is present. Guardrail: Use a dedicated CJK disambiguation prompt that checks for script-specific characters (hiragana, katakana, hangul) and character frequency patterns. For inputs without disambiguating features, default to the most common language in your traffic or flag for review.
Overconfident Misclassification on Transliterated Text
What to watch: Romanized Arabic, Pinyin without tones, or romanized Hindi is often classified as English or the source language of the romanization scheme. This causes the wrong rubric to be selected, grading non-English content against English expectations. Guardrail: Add a transliteration detection layer before language classification. Check for patterns like repeated digits in Arabizi, tone-number suffixes, or common romanized phrases. If transliteration is suspected, route to a transliteration-aware detection prompt or flag for review.
Silent Failure on Unsupported Languages
What to watch: The detection prompt may map an unsupported language to the closest supported one (e.g., Catalan to Spanish, Ukrainian to Russian) without signaling the substitution. The wrong rubric is applied, and the evaluation score is silently invalid. Guardrail: Define an explicit supported-language allowlist. If the detected language is not in the allowlist, return an unsupported_language flag and route to a generic fallback rubric or escalate for human evaluation. Log all unsupported-language detections for monitoring.
Code Block and Technical Content Misattribution
What to watch: LLM outputs containing large code blocks, JSON, SQL, or log snippets are often classified by the code content rather than the surrounding natural language. A Python-heavy response with English comments may be classified as 'code' or misattributed entirely. Guardrail: Strip code blocks, JSON, and structured data before language detection. Run detection only on the natural language portions of the output. If the output is primarily code with minimal natural language, apply a code-specific evaluation rubric instead of a language-specific one.
Evaluation Rubric
Criteria for testing whether the language detection prompt reliably selects the correct LLM judge rubric before shipping to production.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Correct rubric selection for monolingual output | Output language matches the selected rubric's target language with confidence >= [CONFIDENCE_THRESHOLD] | Rubric language mismatches output language; wrong evaluation criteria applied | Run 100 monolingual outputs across supported languages; assert rubric_language == detected_language |
Mixed-language output handling | Primary language correctly identified when one language constitutes >= 70% of tokens; secondary languages flagged in [LANGUAGE_MIX_FLAG] | Rubric selected for minority language; no mix flag when multiple languages present | Test 50 mixed-language outputs with known ratios; assert primary_language matches majority language and mix_flag is true |
Untranslated quoted material resilience | Quoted foreign-language spans do not change rubric selection when surrounding text is monolingual | Rubric switches to quoted material language; evaluation criteria change mid-assessment | Test 30 outputs with embedded foreign-language quotes; assert selected_rubric matches surrounding text language |
Short output language detection | Correct language identified for outputs as short as 3 words with confidence >= [SHORT_TEXT_CONFIDENCE_FLOOR] | High-confidence misclassification on short outputs; null or unknown language returned | Test 50 short outputs (3-10 words) per language; assert language is correct and confidence meets floor |
Script-only disambiguation for CJK | Chinese, Japanese, and Korean correctly disambiguated using character set and script markers | CJK languages confused; Korean misclassified as Japanese or vice versa | Test 30 CJK outputs with ground-truth labels; assert language matches and disambiguation_method is not null |
Confidence score calibration | Confidence >= 0.9 correlates with >= 95% accuracy; confidence < [LOW_CONFIDENCE_THRESHOLD] triggers fallback rubric | Overconfident scores on misclassifications; low-confidence outputs routed without fallback | Run calibration set of 200 outputs; compute ECE; assert ECE < 0.1 and low-confidence path activates below threshold |
Unsupported language fallback | Outputs in unsupported languages route to [FALLBACK_RUBRIC] with unsupported_language flag set to true | Unsupported language assigned to nearest supported rubric; no flag raised | Test 20 outputs in unsupported languages; assert fallback_rubric is selected and unsupported_language is true |
Latency budget compliance | Language detection completes in < [LATENCY_BUDGET_MS] for 99th percentile of outputs under 2000 tokens | Detection exceeds latency budget; eval pipeline blocked waiting for classification | Load test with 500 outputs at expected production volume; measure p99 latency; assert p99 < latency budget |
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 simple function that calls the model, parses the language code, and logs the result. Skip strict schema enforcement initially—just check that the output contains a valid ISO 639-1 code and a confidence score. Use a small eval set of 20-30 examples covering common languages, short text, and one mixed-language case.
Watch for
- The model returning prose instead of structured JSON
- Overconfident predictions on 2-3 word inputs
- Missing handling for
[UNSUPPORTED_LANGUAGE]fallback

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