Prompt Template
rankify.generator.prompt_template
DEFAULT_PROMPTS = {PromptTemplate.BASIC_RAG: 'You are a helpful assistant. Give a single, concise answer to the question using the provided contexts.\nIf the provided contexts are not sufficient, you may also use your own knowledgeQuestion: {question}\nContexts:\n{contexts}\nAnswer:', PromptTemplate.CHAIN_OF_THOUGHT_RAG: "You are a helpful assistant. Think step by step and then answer concisely with only the answer as a fact.\nUse the provided contexts if possible; if they are insuffiecient, you may use your own knowledge.Question: {question}\nContexts:\n{contexts}\nLet's think step by step.\nAnswer:", PromptTemplate.SELF_CONSISTENCY_RAG: "You are a helpful assistant. Think step by step and then answer concisely with only the answer as a fact.\nUse the provided contexts if possible; if they are insuffiecient, you may use your own knowledge.Question: {question}\nContexts:\n{contexts}\nLet's think step by step.\nAnswer:", PromptTemplate.ZERO_SHOT: 'Answer the following question concisely.\nQuestion: {question}\nAnswer:', PromptTemplate.REACT_RAG: 'You are an intelligent assistant that solves tasks by interleaving reasoning with actions.\n\nYou must follow this format strictly:\nThought: [your reasoning about the problem]\nAction: [the action you want to take, in the form Search[argument]]\nObservation: [the result returned by the environment]\n\nRepeat Thought → Action → Observation as many times as needed.\nIf you are confident you know the answer from your own knowledge, you may proceed directly to the Final Answer without searching.\nWhen you have enough information, provide:\nFinal Answer: [your final solution to the user’s query]\n\nGuidelines:\n- Be concise in each Thought, just explain what is necessary for your next step.\n- Only use the defined Actions available to you (Search[query]).\n- If no action is required or you are sure of the answer, proceed to the Final Answer.\n- Do not hallucinate Observations; they are always provided externally.\n- End with "Final Answer:" when the task is solved.\n\n- The final Answer should be as precise and concise as possible.\nQuestion: {question}\nContexts:\n{contexts}\nThought:', PromptTemplate.IN_CONTEXT_RALM: 'You are a helpful assistant. Give a single, concise answer to the question using the provided contexts.\nIf the provided contexts are not sufficient, you may also use your own knowledgeQuestion: {question}\nContexts:\n{contexts}\nAnswer:'}
module-attribute
PromptTemplate
Bases: Enum
PromptTemplate Enum for RAG Prompt Strategies.
Enumerates the supported prompt templates for different RAG methods in Rankify. Each value corresponds to a specific prompt formatting strategy, used by the PromptGenerator to construct prompts for the model.
Members
BASIC_RAG: Standard prompt for naive RAG (context + question + answer). CHAIN_OF_THOUGHT_RAG: Prompt for chain-of-thought reasoning (step-by-step thinking). ZERO_SHOT: Prompt for zero-shot generation (question only, no context). SELF_CONSISTENCY_RAG: Prompt for self-consistency reasoning (multiple step-by-step answers). REACT_RAG: Prompt for ReAct reasoning and action (interleaved reasoning and retrieval actions).
Notes
- Used by PromptGenerator to select and format prompts for each RAG method.
- Ensures consistent prompt structure across different techniques and models.
- The corresponding template strings are defined in DEFAULT_PROMPTS.