Inferensys

Prompt

Cross-Lingual Query Decomposition Prompt Template

A practical prompt playbook for decomposing complex, multi-part user questions across languages into independently retrievable sub-questions with a dependency graph for multi-hop RAG assembly.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Identify the retrieval scenarios where cross-lingual query decomposition is required and where it adds unnecessary complexity.

This prompt is designed for RAG architects and search engineers who must handle complex, multi-part user questions in multilingual retrieval systems. The core job-to-be-done is transforming a single compound question—posed in one language—into a set of atomic, independently retrievable sub-questions, each translated into the target index languages. This is necessary when a user asks a question that contains comparisons, conditional logic, temporal sequences, or requires evidence from multiple documents that must be assembled stepwise. A single translated query will fail in these scenarios because the evidence is scattered across documents in different languages, and the retrieval system needs to execute multiple hops in a specific order to gather all the pieces.

Use this prompt when the source question exhibits clear multi-hop structure: 'Compare the warranty terms for Product X in the EU and the US, then tell me which is longer' requires retrieving two separate documents, likely in different languages, before a comparison can be made. Similarly, 'What were the side effects reported in the German trial, and did the Japanese study find the same?' demands sequential retrieval where the second query depends on the findings of the first. The prompt outputs a dependency graph that your retrieval orchestrator can parse to schedule parallel and sequential retrieval calls correctly. Do not use this prompt for simple factual lookups that a single translated query can satisfy, such as 'What is the capital of France?' or 'When was Company Y founded?'—these only add latency and token cost without improving recall. Also avoid it when the question's complexity is purely linguistic rather than evidentiary; if a question is verbose but ultimately asks for a single fact, a direct translation prompt is more efficient.

Before integrating this prompt into your pipeline, verify that your retrieval backend supports multi-hop orchestration. The output dependency graph assumes you have a system capable of executing retrieval steps in order, passing intermediate results as context to subsequent steps. If your current RAG setup is a single-round retriever-reader loop, you will need to build or adopt an agentic retrieval layer first. Start by testing the prompt against a golden set of 20-30 known multi-hop, cross-lingual questions from your domain, and manually verify that the decomposed sub-questions are both necessary and sufficient to answer the original query. A common failure mode is over-decomposition, where the model breaks a question into too many granular steps, increasing latency without improving answer quality. Set a maximum sub-question limit (e.g., 5) in your orchestration logic and log cases where the limit is hit for later review.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Understand the operational boundaries before integrating this template into a production RAG pipeline.

01

Good Fit: Complex Multi-Hop Questions

Use when: A user asks a single question that requires synthesizing information from multiple documents, potentially in different languages. Guardrail: The prompt's dependency graph output ensures downstream retrieval and assembly steps are ordered correctly, preventing premature answer generation.

02

Bad Fit: Simple Factoid Lookups

Avoid when: The user's question can be answered by a single translated keyword search. Guardrail: Using decomposition for simple queries adds latency and computational cost. Route simple queries to a direct cross-lingual translation prompt instead.

03

Required Inputs

Risk: The prompt fails silently if the source language or target index languages are unspecified. Guardrail: The [SOURCE_LANGUAGE] and [TARGET_INDEX_LANGUAGES] placeholders are mandatory. Implement a pre-flight check in your application layer to reject requests missing these parameters.

04

Operational Risk: Dependency Chain Breakage

Risk: If a single sub-query in the dependency graph fails to retrieve results, the entire multi-hop chain can collapse. Guardrail: Implement a retry with query relaxation for failed sub-queries. If a dependency remains unresolved, the final assembly step must explicitly flag the missing evidence rather than hallucinating a connection.

05

Operational Risk: Semantic Drift in Translation

Risk: Decomposing a query and then translating each sub-question can compound minor translation errors, leading to retrieval of irrelevant documents. Guardrail: Add a back-translation verification step for each generated sub-query. If the semantic consistency score falls below a threshold, route the sub-query for human review or use a pivot language.

06

Bad Fit: Real-Time Conversational Agents

Avoid when: The user expects a sub-second response. Guardrail: Decomposition and parallel multi-language retrieval introduce non-trivial latency. For real-time chat, use a faster intent-routing prompt to select a single retrieval strategy, reserving this decomposition template for asynchronous or background research tasks.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that decomposes a complex, multi-part user query into independently retrievable sub-questions, each translated into the target index languages, and outputs a dependency graph for multi-hop assembly.

This template is designed for RAG architects who need to handle complex questions in multilingual settings. It takes a user's query in a source language, breaks it down into atomic sub-questions, translates each into the target retrieval languages, and defines the order in which they must be answered. The output is a structured JSON object that can be directly consumed by an orchestration layer to execute parallel and sequential retrieval steps.

code
You are a query decomposition engine for a multilingual RAG system. Your job is to analyze a complex user query and break it into a set of independent sub-questions that can be answered separately. Each sub-question must be translated into the target index languages. You must also define a dependency graph showing which sub-questions depend on the answers of others.

## INPUT
User Query: [USER_QUERY]
Source Language: [SOURCE_LANGUAGE]
Target Index Languages: [TARGET_LANGUAGES]

## CONSTRAINTS
- Decompose the query into the smallest number of atomic sub-questions that fully cover the user's intent.
- Each sub-question must be self-contained and answerable without referring to other sub-questions.
- Translate every sub-question into each of the target index languages.
- Identify dependencies: if answering sub-question B requires the answer to sub-question A, mark A as a prerequisite of B.
- If the query is already simple and cannot be decomposed, return a single sub-question with no dependencies.
- Do not answer the questions. Only generate the decomposed and translated queries.

## OUTPUT SCHEMA
Return a single JSON object with the following structure:
{
  "original_query": "string",
  "source_language": "string",
  "target_languages": ["string"],
  "sub_questions": [
    {
      "id": "string (e.g., 'q1')",
      "description": "string (the sub-question in the source language)",
      "translations": {
        "[language_code]": "string (translated sub-question)"
      },
      "depends_on": ["string (list of sub-question IDs that must be answered first)"]
    }
  ]
}

## EXAMPLE
User Query: "What were the revenue impacts of the new privacy regulations in Germany and how did our competitor respond?"
Source Language: "en"
Target Index Languages: ["en", "de"]

Output:
{
  "original_query": "What were the revenue impacts of the new privacy regulations in Germany and how did our competitor respond?",
  "source_language": "en",
  "target_languages": ["en", "de"],
  "sub_questions": [
    {
      "id": "q1",
      "description": "What are the new privacy regulations in Germany?",
      "translations": {
        "en": "What are the new privacy regulations in Germany?",
        "de": "Was sind die neuen Datenschutzbestimmungen in Deutschland?"
      },
      "depends_on": []
    },
    {
      "id": "q2",
      "description": "What were the revenue impacts of these regulations on our company?",
      "translations": {
        "en": "What were the revenue impacts of these regulations on our company?",
        "de": "Welche Umsatzauswirkungen hatten diese Vorschriften auf unser Unternehmen?"
      },
      "depends_on": ["q1"]
    },
    {
      "id": "q3",
      "description": "How did our competitor respond to these regulations?",
      "translations": {
        "en": "How did our competitor respond to these regulations?",
        "de": "Wie hat unser Wettbewerber auf diese Vorschriften reagiert?"
      },
      "depends_on": ["q1"]
    }
  ]
}

To adapt this template, replace the placeholders with your application's runtime values. The [USER_QUERY] should be the raw, unmodified input from the user. [SOURCE_LANGUAGE] should be an ISO 639-1 code detected upstream. [TARGET_LANGUAGES] is a list of language codes for the indexes you intend to query. The output schema is designed to feed directly into an orchestration engine: execute all sub-questions with empty depends_on arrays in parallel, then use their results as context when executing dependent sub-questions. For high-risk domains such as legal or financial analysis, add a [RISK_LEVEL] placeholder and include an instruction to flag sub-questions that require human review before retrieval.

Before deploying, validate the output against the schema. Common failure modes include the model answering the questions instead of decomposing them, generating sub-questions that are not truly atomic, or producing translations that drift semantically from the source. Implement a post-processing validator that checks for the presence of all required fields, verifies that dependency IDs reference existing sub-questions, and confirms that translations exist for every target language. For production systems, log the decomposition graph alongside retrieval results to trace multi-hop answer assembly and diagnose failures.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Cross-Lingual Query Decomposition 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 and safe.

PlaceholderPurposeExampleValidation Notes

[SOURCE_QUERY]

The user's original multi-part question in the source language

Compare the Q3 revenue growth of our Berlin and Tokyo offices and explain the primary drivers for any divergence.

Check that the string is non-empty, under 2000 characters, and contains at least one interrogative or comparative clause. Reject if it is a single, simple factoid question.

[SOURCE_LANGUAGE]

ISO 639-1 code or IETF BCP 47 language tag for the source query

en

Must match a supported language code from the system's allowed list. Validate against a closed enum. Reject if null or 'auto' when decomposition requires explicit language knowledge.

[TARGET_INDEX_LANGUAGES]

Array of language codes for the retrieval indexes that must be queried

["de", "ja"]

Must be a non-empty array of valid ISO 639-1 codes. Each code must correspond to a deployed retrieval index. Reject if the array contains the source language only without a cross-lingual requirement.

[MAX_SUB_QUESTIONS]

Integer cap on the number of sub-questions the model may generate

5

Must be an integer between 2 and 10. Lower values prevent over-decomposition of simple comparisons; higher values allow complex multi-hop breakdowns. Default to 5 if not specified.

[DOMAIN_GLOSSARY]

Optional dictionary of domain-specific terms with canonical translations per target language

{"revenue growth": {"de": "Umsatzwachstum", "ja": "収益成長"}}

If provided, validate as a JSON object where each key maps to an object with target language entries. Null is allowed. If present, terms should be injected into the translation step to override literal translation.

[INCLUDE_DEPENDENCY_GRAPH]

Boolean flag controlling whether the output includes a directed acyclic graph of sub-question dependencies

Must be true or false. When true, the model must output a 'dependency_graph' field. When false, sub-questions are treated as independent and parallel. Default to true for multi-hop assembly.

[OUTPUT_SCHEMA]

The exact JSON schema the model must conform to for the decomposed output

See output-contract table for full schema definition.

Validate that the schema is a valid JSON Schema object with required fields: sub_questions, source_language, target_languages. Reject if the schema permits ambiguous types or missing required fields.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Cross-Lingual Query Decomposition prompt into a production RAG pipeline with validation, retries, and dependency-aware execution.

This prompt is not a standalone translator; it is a planning step in a multi-hop retrieval pipeline. The application must receive the decomposed sub-questions and their dependency graph, then execute retrieval for each sub-question in the specified target language against the appropriate index. The harness should treat the model output as a structured execution plan, not a final answer. Because the prompt generates a JSON schema with a dependency_graph, the application layer must parse this graph, resolve dependencies, and sequence retrieval calls so that sub-questions depending on prior results wait for those results before execution. A common mistake is to fire all sub-questions in parallel without respecting the dependency order, which breaks multi-hop reasoning chains.

Validation and Schema Enforcement: Before any retrieval call, validate the model's JSON output against the expected schema. Check that every sub-question has a non-empty text field, a valid ISO 639-1 target_language code, and that all depends_on indices reference existing sub-question IDs. Reject outputs where a dependency references a non-existent sub-question or creates a cycle. Use a JSON Schema validator in your application code—do not rely on the model to self-correct without a validation gate. If validation fails, retry the prompt once with the validation error message appended to the [CONSTRAINTS] field. After two consecutive failures, log the raw output and escalate to a human reviewer or a fallback single-query translation prompt.

Retrieval Execution and Context Assembly: For each validated sub-question, execute retrieval against the index corresponding to its target_language. Store the retrieved chunks keyed by sub-question ID. When a sub-question depends on a prior result, inject the retrieved context from the dependency into the retrieval query for the dependent sub-question—either by appending it as a [CONTEXT] block or by using it to refine the query vector. After all sub-questions are resolved, assemble the full evidence map (sub-question ID → retrieved chunks) and pass it to a downstream answer-generation prompt. Log the decomposition plan, retrieval latency per sub-question, and any dependency-resolution failures for observability.

Model Choice and Latency Budget: This prompt benefits from models with strong instruction-following and JSON output discipline, such as GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro. Expect higher latency than a single translation prompt because the model must reason over the query structure and generate a plan. Set a timeout of 10–15 seconds for the decomposition call. If the source query is short and clearly single-hop, skip decomposition entirely and route directly to a simpler cross-lingual translation prompt. Use a lightweight classifier or keyword heuristic (e.g., presence of 'and', 'then', 'after', or multiple question marks) to decide whether decomposition is warranted before invoking this more expensive prompt.

Failure Modes and Guardrails: The most common failure is the model generating sub-questions that are not truly independent, causing redundant retrieval or circular dependencies. Monitor for sub-questions that rephrase the same intent in slightly different words—deduplicate them by cosine similarity before retrieval. Another failure is language drift, where a sub-question is generated in the wrong target language. Validate each target_language code against your configured index languages and reject sub-questions targeting unsupported languages. Finally, if the dependency graph is too deep (more than 3 hops), consider truncating or flagging for human review, as retrieval errors compound across hops and degrade the final answer quality.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact structure, types, and validation rules for the Cross-Lingual Query Decomposition output. Use this contract to build a parser that rejects malformed responses before they enter the retrieval pipeline.

Field or ElementType or FormatRequiredValidation Rule

sub_questions

Array of objects

Must be a non-empty array. Reject if array is missing, null, or contains zero elements.

sub_questions[].id

String (kebab-case)

Must match pattern ^sq-[a-z0-9-]+$. Must be unique within the array. Reject on collision or invalid format.

sub_questions[].text

String

Must be a non-empty string in the target index language. Reject if identical to the source query without translation.

sub_questions[].target_language

ISO 639-1 code

Must be a valid 2-letter language code. Reject if code is not in the allowed target index languages list.

sub_questions[].source_span

Array of two integers [start, end]

Must reference valid character offsets in the original [SOURCE_QUERY]. start must be less than end. Reject on out-of-bounds indices.

dependency_graph

Array of objects

Must be a valid array. Can be empty if no dependencies exist. Reject if null or not an array.

dependency_graph[].from_id

String

Must match an existing sub_questions[].id. Reject on dangling reference.

dependency_graph[].to_id

String

Must match an existing sub_questions[].id. Must not equal from_id. Reject on self-loop or dangling reference.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when decomposing cross-lingual queries and how to guard against it.

01

Semantic Drift During Translation

What to watch: Sub-questions translated independently lose the original query's intent, especially with idiomatic expressions or domain jargon. A financial 'bear market' becomes a literal animal reference. Guardrail: Back-translate each sub-question to the source language and compute a semantic similarity score against the original. Flag sub-questions below a 0.85 cosine threshold for human review.

02

Dependency Graph Breakage

What to watch: The model generates sub-questions with circular dependencies or missing prerequisites, making multi-hop assembly impossible. Sub-question 2 requires the answer from sub-question 1, but sub-question 1 also references sub-question 2. Guardrail: Validate the dependency graph is a Directed Acyclic Graph (DAG) before execution. Reject any decomposition with cycles and re-prompt with explicit ordering constraints.

03

Entity Name Transliteration Errors

What to watch: Named entities (people, products, organizations) are translated instead of transliterated or mapped to canonical IDs. 'Beijing University' becomes 'Peking University' in one sub-query and 'University of Beijing' in another, retrieving disjoint document sets. Guardrail: Extract all named entities before decomposition, resolve them to canonical language-independent identifiers via a knowledge base, and inject those IDs into every sub-question.

04

Over-Decomposition into Unanswerable Fragments

What to watch: The model splits a question into sub-questions so granular that no single document can answer any of them, producing empty retrieval sets. 'What caused the decline?' becomes 'What is decline?' and 'What is causation?' Guardrail: Set a minimum semantic density threshold for each sub-question. If a sub-question is a definition or tautology, merge it back into its parent. Test each sub-question against a sample retrieval index before full execution.

05

Language Mismatch with Index

What to watch: Sub-questions are generated in a language not supported by the target retrieval index, or the model hallucinates a language code. A query targeting a Japanese-only index produces sub-questions in Korean. Guardrail: Validate each sub-question's detected language against the target index's configured languages before retrieval. Use a fast language detection library (e.g., fastText) and reject mismatches.

06

Implicit Context Loss Across Sub-Questions

What to watch: Contextual constraints from the original query (time range, user role, source filter) are dropped from individual sub-questions. The original query specifies 'last quarter,' but sub-questions omit the date range entirely. Guardrail: Extract all explicit and implicit constraints from the original query before decomposition. Append them as mandatory filter clauses to every sub-question in the prompt template, and validate their presence in the output.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the quality of decomposed sub-questions and their dependency graph before integrating this prompt into a production retrieval pipeline.

CriterionPass StandardFailure SignalTest Method

Sub-Question Completeness

All distinct information needs from [COMPLEX_QUERY] are represented by at least one sub-question

A fact requested in the source query has no corresponding sub-question

Manual review of a golden set of 20 complex queries; compare extracted needs to generated sub-questions

Translation Fidelity

Each sub-question in [TARGET_LANGUAGE] preserves the semantic intent of its source sub-question without introducing hallucinated constraints

Back-translation of a sub-question introduces a term or constraint not present in the original

Automated back-translation check using a separate translation model; flag if cosine similarity between original and back-translated embedding is below 0.85

Dependency Graph Correctness

The dependency graph accurately identifies which sub-questions require results from others; no false dependencies or missing edges

A sub-question marked as independent fails when executed without prior context, or a dependent question is executed first and returns irrelevant results

Execute sub-questions in the declared dependency order against a known test corpus; verify that dependent questions produce correct answers only when their prerequisites are supplied

Independence of Leaf Questions

Sub-questions with no dependencies are self-contained and answerable without any prior retrieval context

A leaf question contains an unresolved pronoun or reference (e.g., 'her policy', 'the date') that requires external context

Parse each leaf question for anaphora or unresolved references using a separate NER/coref model; fail if any are detected

Idiomatic and Cultural Adaptation

Idioms, metaphors, and culture-specific references in [COMPLEX_QUERY] are correctly interpreted and translated into equivalent concepts in [TARGET_LANGUAGE], not translated literally

A literal translation of an idiom produces a nonsensical or misleading sub-query in the target language

Include 5 queries with known idioms in the test set; have a native speaker or a secondary LLM judge flag literal translations

Output Schema Validity

The generated JSON strictly conforms to the declared [OUTPUT_SCHEMA] with all required fields present and correctly typed

JSON parsing fails due to a missing 'sub_questions' array or a malformed 'dependencies' field

Automated schema validation in the application layer; retry prompt once on validation failure, then escalate

Target Language Coverage

Sub-questions are generated for every language specified in [TARGET_LANGUAGES]; no target language is skipped

A required target language is absent from the output, or sub-questions are generated in the wrong language

Assert that the set of languages in the output matches the [TARGET_LANGUAGES] list exactly; fail on mismatch

Multi-Hop Assembly Feasibility

The final assembly plan describes a feasible order for combining sub-question answers into a coherent response to [COMPLEX_QUERY]

The assembly plan references a sub-question result that is not produced by any generated sub-question

Simulate the assembly plan by providing mock answers for each sub-question; verify that the plan produces a coherent final answer

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet). Remove the dependency graph output to start simple: ask only for decomposed sub-questions and their target-language translations. Skip strict schema validation and log outputs manually.

code
Simplify the output to:
{
  "sub_questions": [
    {"id": "q1", "text_en": "...", "text_[TARGET_LANG]": "..."}
  ]
}

Watch for

  • Translations that are literal but lose idiomatic meaning
  • Sub-questions that are not independently retrievable (still contain pronouns or dependencies)
  • Model skipping the target language and answering in the source language
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.