Standard retrieval ranking optimizes for surface-level relevance to a query string. This prompt is for teams building conversational AI, search personalization, and task-oriented assistants where the user's underlying goal matters more than keyword overlap. It instructs the model to infer user intent, task context, and information need depth from the query and conversation history, then re-rank evidence passages by how well they serve what the user is actually trying to accomplish. Use this when your RAG pipeline retrieves relevant passages but the top-K results are not the most useful ones for the user's real task.
Prompt
Evidence Ranking with User Intent Alignment Prompt

When to Use This Prompt
Learn when intent-aligned evidence ranking solves real RAG problems and when simpler retrieval is enough.
The ideal user is an engineering lead or RAG pipeline builder who can already retrieve relevant documents but sees a gap between retrieval relevance and answer usefulness. For example, a user asking 'How do I handle timeout errors in the payment API?' might retrieve passages about API timeouts in general, but the user's actual intent is troubleshooting a specific integration failure during payment processing. This prompt re-ranks evidence to prioritize passages about payment-specific timeout handling, error recovery patterns, and idempotency—even if those passages scored lower on pure keyword overlap. Required context includes the original query, conversation history (if multi-turn), and the retrieved evidence set with passage IDs. The prompt works best when retrieval recall is high but precision for the user's task is low.
Do not use this prompt for simple factoid lookup where intent is unambiguous—a query like 'What is the capital of France?' does not benefit from intent inference. Avoid it for latency-critical paths where the extra inference step is too expensive; intent-aligned re-ranking adds one model call per ranking operation. It is also not a substitute for poor retrieval: if your retriever is not surfacing relevant passages at all, fix retrieval recall before adding intent-aware ranking. For high-stakes domains such as medical or legal, pair this prompt with a grounding verification step to ensure re-ranked evidence still meets domain-specific authority and accuracy standards before it reaches answer generation.
Use Case Fit
Where the Evidence Ranking with User Intent Alignment Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your pipeline before integrating it.
Strong Fit: Conversational Search with Ambiguous Queries
Use when: User queries are short, ambiguous, or could serve multiple intents (e.g., 'Python performance' could mean profiling code, choosing a web framework, or snake movement). Guardrail: Pair this prompt with an explicit intent classification step before ranking. If intent confidence is low, route to a clarification flow instead of forcing a ranking based on a guess.
Strong Fit: Personalized RAG with User Context
Use when: You have reliable user task context, role, or session history that can be injected as [USER_INTENT] to re-rank generic retrieval results. Guardrail: Validate that user context is fresh and relevant. Stale persona data produces worse rankings than no personalization. Implement a context staleness check before injecting intent signals.
Poor Fit: Single-Intent Factoid Lookup
Avoid when: The query has exactly one correct answer and surface relevance ranking already retrieves the right passage (e.g., 'What is the capital of France?'). Guardrail: Measure whether intent-aligned re-ranking changes the top-1 result for unambiguous queries. If it does, your intent model is overfitting and should be bypassed for high-confidence single-intent queries.
Required Input: Inferred Intent with Confidence Score
Risk: Feeding the prompt a raw intent label without confidence leads to overconfident re-ranking when intent detection is wrong. Guardrail: Always include an [INTENT_CONFIDENCE] field alongside [USER_INTENT]. When confidence is below a defined threshold, fall back to surface relevance ranking and log the case for intent model improvement.
Operational Risk: Intent Drift Over Sessions
Risk: In multi-turn conversations, user intent can shift mid-session, but the prompt may continue ranking against a stale earlier intent. Guardrail: Re-infer intent at each turn that triggers retrieval. Implement a session-level intent history with decay weighting so recent intent signals dominate ranking decisions.
Operational Risk: Ranking Instability from Intent Noise
Risk: Small variations in inferred intent can produce large ranking changes, causing inconsistent answers across similar queries. Guardrail: Run ranking stability checks by perturbing the [USER_INTENT] input slightly and measuring top-K overlap. If rankings are brittle, add a stability constraint to the prompt or increase the retrieval set size before re-ranking.
Copy-Ready Prompt Template
A reusable prompt that ranks evidence passages by alignment with inferred user intent, task context, and information need depth.
This template is designed to be dropped into a RAG pipeline or search ranking system where surface-level relevance scoring is insufficient. It forces the model to first infer what the user is actually trying to accomplish—their task, depth of need, and decision context—before scoring each evidence passage. The output is a ranked list where position reflects intent alignment, not just keyword overlap. Use this when your retrieval set contains passages that are topically relevant but misaligned with the user's real goal, such as returning introductory material when the user needs a technical specification, or returning recent news when the user needs historical context.
textYou are an evidence ranking specialist. Your job is to re-rank a set of retrieved evidence passages so the most useful passages appear first, based on the user's inferred intent, task context, and information need depth. ## INPUT **User Query:** [USER_QUERY] **User Context (if available):** [USER_CONTEXT] **Retrieved Evidence Passages:** [EVIDENCE_PASSAGES] ## INSTRUCTIONS ### Step 1: Infer User Intent Analyze the user query and any provided context. Determine: - **Task Type:** What is the user trying to do? (e.g., make a decision, learn a concept, troubleshoot an issue, compare options, find a specific fact, get a procedural guide) - **Depth of Need:** Does the user need a quick answer, a detailed explanation, or exhaustive coverage? - **Domain Familiarity:** Is the user likely a novice, practitioner, or expert in this domain? - **Temporal Sensitivity:** Does the query require current information, historical context, or is time irrelevant? - **Actionability:** Does the user need information they can act on immediately, or background understanding? ### Step 2: Score Each Passage For each evidence passage, assign a score from 0 to 10 based on how well it serves the inferred intent: - **Task Alignment (0-4 points):** Does this passage help the user accomplish their inferred task? - **Depth Match (0-3 points):** Does the passage's level of detail match the user's inferred depth of need? - **Audience Fit (0-2 points):** Is the passage written at an appropriate level for the user's inferred domain familiarity? - **Temporal Fit (0-1 point):** Does the passage's recency or timeframe match the query's temporal sensitivity? ### Step 3: Rank and Explain Produce a ranked list of all passages, ordered from highest to lowest intent-alignment score. For each passage, include: - The passage ID - The total score - A one-sentence explanation of why this passage does or does not align with the inferred user intent ## OUTPUT FORMAT First, state your inferred user intent in 2-3 sentences. Then, output the ranked list in this exact format: **Ranked Evidence:** 1. [Passage ID] | Score: [X.X/10] | [One-sentence rationale] 2. [Passage ID] | Score: [X.X/10] | [One-sentence rationale] ... ## CONSTRAINTS - Do not skip any passage. Every retrieved passage must appear in the ranked list. - If two passages serve the intent equally well, prefer the one with higher specificity. - If a passage is actively misleading or contradicts the inferred intent, score it below 3 and explain why. - Do not invent facts not present in the passages.
Adaptation notes: Replace [USER_CONTEXT] with session history, user profile signals, or an empty placeholder if unavailable. The [EVIDENCE_PASSAGES] block should include passage IDs and full text, formatted consistently (e.g., [P1] Title: ... Content: ...). If your system already has a user intent classifier upstream, you can replace Step 1 with the classifier's output and instruct the model to use that intent directly rather than re-inferring it. For production systems with strict latency budgets, consider splitting this into two calls: one for intent inference and one for scoring, caching the intent result across related queries.
Validation and risk controls: After the model returns a ranking, validate that every input passage ID appears exactly once in the output. If passage counts don't match, reject the output and retry with a stronger constraint instruction. For high-stakes domains like medical or legal search, route outputs scoring below 5/10 to a human reviewer before surfacing them to users. Log the inferred intent alongside the ranking for offline evaluation—this lets you measure whether intent misinference is the root cause of poor rankings over time. Run periodic eval checks comparing intent-aligned rankings against pure relevance baselines using user satisfaction metrics or click-through data.
Prompt Variables
Required and optional inputs for the Evidence Ranking with User Intent Alignment Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Validation notes describe how to check that the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[QUERY] | The user's original question or search string that triggered evidence retrieval | What are the tax implications of remote work across state lines? | Must be non-empty string. Check for minimum length of 10 characters. Reject queries that are only stop words or punctuation. |
[RETRIEVED_PASSAGES] | Array of evidence passages from the retrieval system, each with content and optional metadata | [{"id":"doc_12","content":"Under the convenience of the employer rule...","source":"tax_code_2024.pdf","date":"2024-03-15"}] | Must be a valid JSON array with at least 1 passage. Each passage object must contain an id and content field. Empty arrays should trigger a refusal path, not ranking. |
[USER_INTENT_PROFILE] | Inferred or declared user intent, task context, and information need depth | {"intent":"compliance_check","task":"filing_multi_state_return","depth":"detailed","urgency":"high"} | Must be a valid JSON object with at least an intent field. Unknown intent values should default to general_inquiry rather than failing. Validate against allowed intent taxonomy if one exists. |
[USER_CONTEXT] | Optional session history, user role, or prior clarifications that refine intent understanding | {"role":"tax_preparer","prior_clarifications":["User confirmed they live in NY but work remotely for a CA company"]} | Can be null or empty object. If provided, must be valid JSON. Do not inject PII or sensitive account data into this field without redaction review. |
[RANKING_CRITERIA_OVERRIDES] | Optional custom weights or dimensions that modify the default ranking behavior | {"prioritize_recency":true,"recency_window_days":180,"min_authority_tier":"official"} | Can be null. If provided, must be a valid JSON object with recognized key names. Unrecognized keys should be logged and ignored rather than causing a prompt assembly failure. |
[OUTPUT_FORMAT] | Specification for how the ranked evidence list should be structured in the response | json_array_with_scores | Must match one of the supported output format identifiers: json_array_with_scores, json_array_with_tiers, json_array_with_rationale. Invalid format values should fall back to json_array_with_scores with a warning. |
[MAX_RESULTS] | Maximum number of ranked passages to return in the output | 5 | Must be a positive integer between 1 and 50. Values outside this range should be clamped. Null or missing values should default to 10. Non-integer values should be rejected at validation time. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score a passage must meet to be included in the ranked output | 0.6 | Must be a float between 0.0 and 1.0. Values outside this range should be clamped. Null should default to 0.0, meaning no filtering. String values that parse to valid floats are acceptable but should log a type warning. |
Common Failure Modes
Evidence ranking with user intent alignment fails in predictable ways. These are the most common production failure modes and the guardrails that catch them before they affect users.
Intent Misclassification Cascades
What to watch: The prompt infers the wrong user intent (e.g., treating a comparison query as a fact lookup), which cascades into ranking evidence by the wrong criteria. Passages that are highly relevant to the actual intent get buried. Guardrail: Output the inferred intent as a structured field alongside the ranking. Validate intent classification against a known taxonomy before ranking proceeds. If intent confidence is below threshold, route to clarification or fall back to surface relevance ranking.
Surface Relevance Overriding Task Context
What to watch: The model ranks passages by keyword or semantic similarity to the query while ignoring the user's task context (e.g., ranking beginner tutorials above API references for a user who is clearly integrating a production system). Guardrail: Include explicit task-context weighting in the prompt instructions. Require the model to justify each ranking decision with a task-alignment reason, not just a relevance score. Test with query pairs that have identical surface text but different task contexts.
Depth Mismatch Between Evidence and Need
What to watch: The user needs deep, technical evidence but the ranking promotes shallow, introductory passages because they match query terms. Or the reverse: a quick-answer need gets buried in dense specification documents. Guardrail: Classify the user's information need depth (quick reference, detailed explanation, exhaustive research) before ranking. Use depth alignment as an explicit ranking dimension. Flag passages whose depth level mismatches the inferred need.
Position and Length Bias in Intent-Aware Ranking
What to watch: Even with intent alignment instructions, the model still favors passages that appear first in the retrieval set or are longer, regardless of actual task fit. This is especially dangerous when intent alignment is supposed to override these surface biases. Guardrail: Randomize passage order before ranking. Include passage length as a controlled variable in eval tests. Measure ranking stability across order permutations. If rankings flip significantly when order changes, the intent signal is too weak.
Overfitting to Explicit Intent Signals
What to watch: The model latches onto explicit intent keywords in the query (e.g., 'tutorial', 'compare', 'debug') and ignores implicit context from conversation history, user role, or session state. A user asking 'how do I fix this' after an error log gets tutorial-style evidence instead of diagnostic references. Guardrail: Provide conversation history and user context as separate, labeled inputs in the prompt. Require the model to reconcile explicit query signals with implicit session context. Test with queries where the explicit keyword contradicts the actual task.
Confidence Inflation on Ambiguous Intent
What to watch: When user intent is genuinely ambiguous, the model still produces a confident ranking with high scores, masking the uncertainty. Downstream answer generation then proceeds on a wrong assumption. Guardrail: Require the model to output an intent confidence score alongside the inferred intent. Set a threshold below which the system either asks clarifying questions or produces a diversified ranking covering multiple possible intents. Log all low-confidence intent cases for review.
Evaluation Rubric
Use this rubric to evaluate the quality of the Evidence Ranking with User Intent Alignment Prompt's output before shipping. Each criterion targets a specific failure mode in intent-aligned ranking.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Intent Alignment | The top-ranked passage directly addresses the inferred user task, not just the surface query terms. | Top passage is lexically similar to the query but irrelevant to the user's actual goal (e.g., returns a definition when the user needs a tutorial). | Human review of top-1 passage against a pre-defined [USER_INTENT_LABEL] for 50 test cases. |
Ranking Rationale Quality | The [RANKING_RATIONALE] for each passage references specific evidence content and explains its contribution to the user's task. | Rationale is generic (e.g., 'relevant to the query') or hallucinates content not present in the passage. | LLM-as-judge check: does the rationale contain a direct quote or specific paraphrase from the passage? Pass if >90% do. |
Task Context Sensitivity | Rankings shift appropriately when [USER_TASK_CONTEXT] changes from 'quick fact check' to 'deep research' for the same query. | Rankings remain static regardless of the [USER_TASK_CONTEXT] input, indicating the prompt ignores the context variable. | A/B test with 20 query pairs, varying only [USER_TASK_CONTEXT]. Measure Kendall's Tau correlation; a score <0.5 indicates a sensitivity failure. |
Information Need Depth Handling | For a [USER_KNOWLEDGE_LEVEL] of 'expert', the prompt prioritizes nuanced, primary-source passages over introductory overviews. | An introductory Wikipedia-style passage is ranked first for an expert-level query, while a technical specification is ranked lower. | Curate 10 expert-level queries with a known gold ranking. Check if the gold 'expert' passage is in the top 3. Pass if accuracy >80%. |
Source Authority Weighting | When [USER_TASK_CONTEXT] implies a need for high authority (e.g., 'medical decision support'), authoritative sources are upweighted. | A highly relevant but low-authority source (e.g., a personal blog) outranks a slightly less relevant but highly authoritative source (e.g., a peer-reviewed journal). | Use a test set of 15 queries where authority is critical. Check if the top-3 passages have a mean authority score above a defined threshold. |
Output Schema Compliance | The output is valid JSON matching the [OUTPUT_SCHEMA] and contains all required fields for each ranked passage. | JSON parsing fails, a required field like [PASSAGE_ID] is missing, or an extra text block is present outside the JSON structure. | Automated schema validation in a CI pipeline. Test with 100 diverse inputs; pass requires 100% parse success and schema conformance. |
Confidence Score Calibration | A passage with a [CONFIDENCE_SCORE] of 'high' is demonstrably central to fulfilling the user's intent, not just topically related. | A passage that is only tangentially related receives a 'high' confidence score, or a directly on-point passage receives a 'low' score. | Sample 30 ranked passages with their scores. Human evaluator agreement with the assigned tier (high/medium/low) must exceed 85% Cohen's Kappa. |
Handling of Insufficient Evidence | If no passage sufficiently aligns with the user's intent, the output is an empty ranking and a clear [GAP_FLAG] is set to true. | The prompt hallucinates a ranking by forcing irrelevant passages into the output or returns a ranking without setting the [GAP_FLAG]. | Test with 10 queries where the retrieval set is intentionally irrelevant. Pass if [GAP_FLAG] is true and the ranking list is empty in 100% of cases. |
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 single user intent field and a small evidence set (3–5 passages). Drop strict output schemas and accept a plain ranked list with brief rationale. Focus on testing whether intent alignment changes ranking order compared to pure relevance ranking.
code[USER_QUERY] [INFERRED_INTENT: "troubleshooting" | "purchase_decision" | "learning"] [EVIDENCE_PASSAGES: 3-5 items] Rank passages by alignment with the inferred intent. Return ordered list with one-sentence rationale per passage.
Watch for
- Intent misclassification cascading into wrong ranking
- Over-indexing on intent keywords while ignoring evidence quality
- No baseline comparison against relevance-only ranking

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