This prompt is designed for RAG system architects and search relevance engineers who need to route multilingual user queries to different rewriting and retrieval pipelines based on the user's underlying intent. The core job-to-be-done is to classify a query—regardless of its source language—into a stable set of intent categories such as factual lookup, comparison, procedure, summary, or clarification. This classification then acts as a dispatch signal, ensuring that a query like 'compare the battery life of X and Y' is rewritten for a comparison retrieval strategy, while 'how do I reset X' triggers a procedural retrieval strategy. Without this step, a single, monolithic retrieval approach often produces poor results because the same surface question structure can demand fundamentally different evidence structures depending on what the user actually wants to accomplish.
Prompt
Language-Agnostic Intent Detection Prompt for Query Rewriting

When to Use This Prompt
Defines the job-to-be-done, ideal user, required context, and clear boundaries for when this prompt should and should not be deployed in a production RAG system.
Use this prompt when you operate a multilingual corpus where users query in multiple languages, and you have already built or plan to build distinct retrieval pipelines optimized for different intent types. The prompt requires no external context beyond the raw user query; it is designed to be stateless and language-agnostic. It is particularly valuable in global product support, enterprise search, or e-commerce settings where a query in Japanese, German, or Arabic should be routed with the same intent-detection accuracy as an English query. The output is a structured JSON object containing the detected intent label and a confidence score, which your application can use to select the appropriate downstream rewriting prompt and retrieval backend. You should validate the output against an allowed intent taxonomy and implement a fallback routing rule for low-confidence classifications.
Do not use this prompt when your application context already provides the user's intent through UI affordances, such as a dedicated 'troubleshooting' search box versus a 'product comparison' tool. It is also unnecessary if you have a monolingual corpus with highly uniform query patterns where a single retrieval strategy works well. Avoid this prompt if your latency budget cannot tolerate an additional classification step before retrieval, or if you lack the engineering capacity to build and maintain the separate retrieval pipelines that the intent labels are meant to route to. In high-stakes domains like healthcare or legal research, always route low-confidence classifications to a human review queue rather than allowing an uncertain intent to silently degrade retrieval quality.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if language-agnostic intent detection is the right tool before you wire it into your query rewriting pipeline.
Good Fit: Multilingual Routing Pipelines
Use when: you have a single retrieval pipeline that must handle queries in many languages, and you need to select the correct rewriting strategy based on user intent. Guardrail: validate intent classification against a labeled set of queries in your top 3–5 languages before production rollout.
Bad Fit: Monolingual or Single-Intent Systems
Avoid when: your application serves only one language or handles a single intent type. Guardrail: if all queries are factual lookups, skip intent detection and use a simpler keyword expansion prompt to reduce latency and cost.
Required Inputs: Query Text Only
What to watch: the prompt needs only the raw user query string, but it must not rely on session history or user profile data. Guardrail: strip any PII or session tokens before passing the query to the intent classifier to prevent data leakage.
Operational Risk: Intent Drift Across Languages
What to watch: the same surface query can map to different intents in different languages due to cultural or idiomatic differences. Guardrail: maintain a per-language intent mapping table and log intent distributions by language to detect drift early.
Operational Risk: Over-Classification Granularity
What to watch: too many intent labels can cause brittle routing and increase misclassification. Guardrail: start with 3–5 coarse intent categories (factual, comparison, procedure, summary, clarification) and only add granularity when retrieval metrics justify it.
Bad Fit: Real-Time Latency Budgets Under 200ms
Avoid when: your retrieval pipeline has a strict sub-200ms latency budget and cannot absorb an extra model call. Guardrail: cache intent classifications for repeated query patterns or use a lightweight classifier model instead of a general-purpose LLM for this step.
Copy-Ready Prompt Template
A copy-ready system prompt for classifying user intent from a query in any language, enabling downstream routing to the correct rewriting strategy.
This template provides the core system instructions for a language-agnostic intent classifier. Its job is to look past the surface language of a user's query and identify the underlying need—such as a factual lookup, a comparison, or a procedure. The output is a structured intent label, not a rewritten query. This classification is the critical first step in a retrieval pipeline, as it determines which rewriting, expansion, or decomposition strategy will be applied next. Before pasting this prompt, you must define your own intent taxonomy and provide representative examples for each class. A generic taxonomy will produce generic results; the model's performance is directly tied to the specificity of your labels and the quality of your few-shot examples.
codeYou are an intent classifier for a multilingual retrieval system. Your task is to analyze a user's query and determine the single underlying intent, independent of the language in which the query is written. You will output a structured JSON object with the intent label and a confidence score. # INTENT TAXONOMY Classify every query into exactly one of the following intents: [INTENT_TAXONOMY] # CLASSIFICATION RULES - Base your classification on the semantic need expressed by the query, not on keyword matching. - If the query is ambiguous or could reasonably fit multiple intents, choose the most likely primary intent and set the confidence score accordingly. - Do not use the query's language as a classification signal. A factual lookup in French and a factual lookup in Japanese should both map to the same intent label. - If the query does not fit any defined intent, classify it as "[FALLBACK_INTENT]" with a low confidence score. # OUTPUT SCHEMA You must respond with a single JSON object conforming to this schema: { "intent": "string (one of the defined intent labels)", "confidence": number (0.0 to 1.0), "rationale": "string (brief explanation of the classification in English)" } # FEW-SHOT EXAMPLES [EXAMPLES] # INPUT [INPUT]
To adapt this template, start by replacing [INTENT_TAXONOMY] with your own list of intent labels and concise descriptions. A retrieval system might use labels like factual_lookup, comparison, procedural_how_to, summary_request, and troubleshooting. Next, replace [FALLBACK_INTENT] with a label like unknown or other to handle out-of-scope queries. The [EXAMPLES] placeholder is the most important to fill: provide at least 3-5 diverse few-shot examples per intent, covering multiple languages and edge cases. Each example should show the input query and the correct JSON output. Finally, [INPUT] is the runtime variable your application will inject before each model call. For high-stakes routing decisions, implement a post-processing check: if the confidence score falls below a threshold (e.g., 0.7), route the query to a human review queue or a default fallback strategy rather than proceeding automatically.
Prompt Variables
Required and optional inputs for the Language-Agnostic Intent Detection 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 before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_QUERY] | The raw user question in any language. This is the only required input for intent classification. | Was ist der Unterschied zwischen Vektor- und Keyword-Suche? | Non-empty string. Must be at least 3 characters. Reject empty or whitespace-only input before prompt assembly. |
[SUPPORTED_INTENTS] | A list of intent labels the model can choose from. Defines the classification taxonomy. | factual_lookup, comparison, procedure, summarization, definition, troubleshooting | Must be a non-empty array of strings. Each label should be lowercase with underscores. Validate against an allowlist of known intents in your routing config. |
[INTENT_DESCRIPTIONS] | Short definitions for each supported intent to guide the model's classification decision. | factual_lookup: User wants a specific fact or data point. comparison: User wants to contrast two or more items. | Optional but strongly recommended. If provided, must be a mapping where every key in [SUPPORTED_INTENTS] has a description string. Missing descriptions reduce classification accuracy. |
[OUTPUT_LANGUAGE] | The language for the output intent label and explanation. Defaults to English if not specified. | en | Must be a valid ISO 639-1 two-letter language code. If null or omitted, the model defaults to English. Validate against a list of languages your downstream routing logic supports. |
[FEW_SHOT_EXAMPLES] | Optional array of example query-to-intent mappings to improve classification on edge cases or domain-specific language. | [{"query": "How do I reset my password?", "intent": "procedure"}] | If provided, must be a valid JSON array of objects with query and intent fields. Each intent must exist in [SUPPORTED_INTENTS]. Max 5 examples recommended to avoid overfitting. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score the model must assign to return a single intent. Below this threshold, the output should return multiple candidate intents or an 'uncertain' flag. | 0.7 | Must be a float between 0.0 and 1.0. If null, default to 0.5. Values below 0.5 produce noisy routing. Values above 0.9 may cause excessive fallback to 'uncertain'. |
[UNKNOWN_INTENT_LABEL] | The label to return when the model cannot confidently classify the query into any supported intent. | other | Must be a string not present in [SUPPORTED_INTENTS]. If null, the model may hallucinate an unsupported intent. Validate that this label is handled by your routing fallback logic. |
[MAX_INTENTS_TO_RETURN] | Maximum number of candidate intents to return when confidence is below the threshold or the query is ambiguous. | 3 | Must be a positive integer. If null, default to 1. Values above 5 add latency without routing benefit. Validate that your downstream router can handle multi-intent responses. |
Implementation Harness Notes
How to wire the language-agnostic intent detection prompt into a production query rewriting pipeline with validation, routing, and fallback logic.
This prompt is designed to sit at the entry point of a multilingual retrieval pipeline, before any translation or expansion occurs. Its job is narrow: classify the user's underlying intent from the raw query text alone, independent of the query language. The output is a structured intent label and confidence score that downstream components use to select the appropriate rewriting strategy. Do not use this prompt to generate rewritten queries, translate text, or answer questions. It is a classification router, not a retrieval step.
Wire the prompt into your application as a synchronous pre-retrieval step. Accept the raw user query string as the [USER_QUERY] input. The model should return a JSON object with intent (one of the predefined labels such as factual_lookup, comparison, procedure, summary, opinion, or clarification) and confidence (a float between 0.0 and 1.0). Validate the output shape immediately: reject any response where intent is not in your allowed enum or confidence is outside range. If validation fails, retry once with a stricter system instruction that emphasizes the required schema. On a second failure, log the raw response and default to intent: factual_lookup with confidence: 0.0 so the pipeline degrades gracefully rather than blocking the user. For high-traffic systems, consider caching intent classifications for identical query strings to reduce latency and cost.
Model choice matters here. This is a classification task with a small output space, so a fast, cost-efficient model like GPT-4o-mini, Claude Haiku, or a fine-tuned open-weight classifier is appropriate. Avoid using large reasoning models for this step unless you have evidence that intent boundaries are genuinely ambiguous. If you observe frequent misclassifications between comparison and factual_lookup, add few-shot examples to the prompt that illustrate the distinction in multiple languages. Log every classification alongside the downstream rewriting strategy chosen and the eventual retrieval quality metrics. This traceability lets you measure whether intent misclassification is a root cause of poor retrieval and adjust the prompt or routing map accordingly. Never send the raw user query to a retrieval index without first passing it through this intent router and the corresponding rewriting prompt that the intent selects.
Expected Output Contract
Fields, types, and validation rules for the language-agnostic intent detection prompt output. Use this contract to parse, validate, and route the model response before selecting a rewriting strategy.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
intent_class | string enum: factual_lookup | comparison | procedure | summarization | clarification | other | Must match one of the allowed enum values exactly. Reject or retry on unknown values. | |
confidence_score | float between 0.0 and 1.0 | Must be a valid float within the inclusive range. Reject if non-numeric or outside bounds. Flag for human review if below [CONFIDENCE_THRESHOLD]. | |
detected_language | ISO 639-1 two-letter code | Must be a valid ISO 639-1 code. Reject if code is not in the allowed language list for the deployment. | |
alternative_intents | array of objects with class (string) and score (float) | If present, each object must contain a valid intent_class and a float score. Array may be empty. Null allowed. | |
reasoning | string | Free-text explanation of the classification decision. No structural validation required. Null allowed. | |
rewriting_strategy_hint | string enum: direct_translation | synonym_expand | decompose | metadata_extract | disambiguate | none | Must match one of the allowed strategy enum values. Used by the downstream routing layer to select the rewriting prompt. | |
ambiguous_terms | array of strings | If present, each element must be a non-empty string. Array may be empty. Null allowed. Used to trigger disambiguation prompts. | |
requires_clarification | boolean | Must be true or false. If true, the downstream system should prompt the user for clarification before rewriting. |
Common Failure Modes
Language-agnostic intent detection is powerful but brittle. These are the most common production failures and how to guard against them before they degrade your retrieval pipeline.
Intent Class Collapse for Ambiguous Queries
What to watch: The model confidently assigns a single intent to a query that genuinely has multiple valid interpretations (e.g., 'How does X compare to Y?' could be comparison or procedure). The downstream rewriting strategy then produces a query that misses the user's actual need. Guardrail: Require the prompt to output a ranked list of candidate intents with confidence scores, not a single label. Route to a disambiguation step or generate parallel rewrites for the top two intents when confidence is below a threshold.
Language-Specific Idiom Misclassification
What to watch: An idiomatic expression in the source language is translated literally by the model's internal reasoning, producing a nonsensical intent. For example, a German user asking 'Ich verstehe nur Bahnhof' (literally 'I only understand train station,' meaning 'I don't understand anything') might be classified as a factual lookup about transit. Guardrail: Include few-shot examples in the prompt that pair idiomatic queries in multiple languages with their true intent. Log low-confidence classifications by language for human review and idiom dictionary updates.
Overfitting to Surface Keywords
What to watch: The model latches onto a single keyword (e.g., 'error,' 'price,' 'API') and classifies intent based on that word alone, ignoring the surrounding syntactic structure that signals the real need. A query like 'Why did the price change after the API call?' might be classified as 'pricing inquiry' instead of 'troubleshooting.' Guardrail: Add a constraint in the prompt instructing the model to identify the main verb and object of the query before classifying intent. Use an eval set of keyword-confusable query pairs to measure resistance to this failure.
Code-Switched Query Fragmentation
What to watch: A user mixes two languages in a single query (e.g., 'I need the Dokumentation for the neue API'). The model may classify intent based on only one language segment, missing the full semantic payload. Guardrail: Pre-process the query with a code-switching detection step. If detected, route to a code-switching expansion prompt first to produce monolingual variants, then run intent detection on the resolved query. Do not send raw code-switched text directly to the intent classifier.
Silent Failure on Unseen Intent Categories
What to watch: The user's intent falls outside the predefined taxonomy (e.g., a new 'negotiation' intent in a sales copilot), but the model maps it to the closest existing label with high confidence instead of flagging it as unknown. This silently routes the query to the wrong rewriting strategy. Guardrail: Include an explicit 'other' or 'unknown' intent class in the taxonomy. Require the model to output a rationale string explaining its classification. Monitor the distribution of 'other' classifications and the semantic distance between queries and their assigned intent centroids.
Prompt Language Mismatch with Query Language
What to watch: The system prompt and intent taxonomy are written in English, but the user query is in Japanese. The model's internal reasoning defaults to English-centric intent definitions, misinterpreting culturally specific query patterns (e.g., indirect requests common in high-context languages). Guardrail: Provide the intent taxonomy and definitions in the detected query language, or at minimum in a language-agnostic structured format with multilingual examples. Test intent accuracy per language, not just in aggregate, and set per-language confidence thresholds.
Evaluation Rubric
Use this rubric to test the quality of the language-agnostic intent detection prompt before deploying it in a production query rewriting pipeline. Each criterion targets a specific failure mode common to multilingual intent classification.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Language Independence | Intent label is identical for semantically equivalent queries in English, Japanese, and Arabic. | Intent label changes when only the input language changes. | Run the prompt on a parallel set of 10 queries translated into 3 language families. Require 100% label agreement. |
Intent Granularity | Output selects exactly one label from the defined taxonomy (e.g., factual_lookup, comparison, procedure). | Output is a vague label like 'information' or a hallucinated category outside the schema. | Validate the output string against a strict enum list. Flag any output not matching the allowed set. |
Ambiguity Handling | For a query like 'apple', the output includes a secondary_confidence score below the threshold or a flag: ambiguous: true. | The model confidently assigns a single intent to a genuinely ambiguous query without signaling uncertainty. | Use a set of 5 known-ambiguous queries. Check that the ambiguous flag is true or confidence is below 0.7. |
Code-Switching Robustness | A query mixing Hindi and English ('Mujhe latest iPhone ke features batao') is classified correctly as factual_lookup. | The model defaults to a fallback intent or fails to parse the mixed-language input. | Run a test suite of 15 code-switched queries. Require >90% correct intent classification against a human-labeled key. |
Short Query Resilience | A one-word query like 'price' is classified as factual_lookup, not rejected or mislabeled. | The model returns an error, an empty string, or a refusal due to insufficient context. | Run a set of 10 single-word queries. Require a valid intent label and a confidence score for each. |
Schema Compliance | Output is valid JSON matching the [OUTPUT_SCHEMA] exactly, with fields intent, confidence, and ambiguous. | Output is a raw string, markdown-wrapped JSON, or missing required fields. | Parse the output with a JSON validator. Check for presence of all required keys and correct types (string, float, boolean). |
Domain Terminology Neutrality | A medical query ('indications for metformin') and a legal query ('elements of a contract') are classified by intent, not by domain. | The model invents a domain-specific intent label like 'medical_inquiry' that is not in the taxonomy. | Run queries from 5 distinct professional domains. Verify that all output labels belong to the predefined intent taxonomy. |
Confidence Calibration | Confidence score for a clear query is >0.9; for an ambiguous query, it is <0.7. | Confidence is always 0.99 or always 0.5, showing no differentiation between clear and ambiguous inputs. | Plot confidence scores for a balanced test set of 20 clear and 20 ambiguous queries. Check for a bimodal or well-spread distribution. |
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
Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet). Remove the strict JSON output requirement initially and ask for a simple intent label and confidence score. Test with 10-20 queries in 3-4 languages to validate the intent taxonomy before hardening.
codeClassify the user's underlying intent from the query alone, independent of language. Query: [USER_QUERY] Return: intent_label, confidence (0-1), brief reasoning
Watch for
- Intent taxonomy drift: the model invents new intent labels not in your routing map
- Language bias: high-resource languages get more accurate intent detection than low-resource ones
- Overconfidence on ambiguous queries: the model assigns high confidence to guesses

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