|
|
|
rag_prompt = """You are a helpful assistant proficient in formulating clear and meaningful answers from the provided context. |
|
Based on the CONTEXT, please formulate a clear, concise, and meaningful answer for the QUERY. |
|
Do not make up an answer if the CONTEXT is insufficient. Instead, respond with: "I do not know." |
|
|
|
QUERY: |
|
{query} |
|
|
|
CONTEXT: |
|
{context} |
|
|
|
ANSWER: |
|
""" |
|
|
|
|
|
|
|
relevancy_prompt = """You are an expert judge tasked with evaluating whether EACH CONTEXT in the CONTEXT LIST is sufficient to answer the QUERY. |
|
Analyze the provided QUERY and CONTEXT carefully. |
|
|
|
Guidelines: |
|
1. The content must not introduce new information beyond what is provided in the QUERY. |
|
2. Pay close attention to the subject of statements. Ensure that attributes, actions, or dates are correctly associated with the right entities (e.g., a person vs. a TV show they star in). |
|
3. Be vigilant for subtle misattributions or conflations of information, even if the date or other details are correct. |
|
4. Check that the content in the CONTEXT LIST does not oversimplify or generalize information in a way that changes the meaning of the QUERY. |
|
|
|
Assign a relevancy score: |
|
- 0: The content has all the necessary information to answer the QUERY. |
|
- 1: The content does not have the necessary information to answer the QUERY. |
|
|
|
EXAMPLE: |
|
|
|
INPUT (for context only, not to be used for faithfulness evaluation): |
|
QUERY: What is the capital of France? |
|
CONTEXT: |
|
1. "France is a country in Western Europe. Its capital is Paris." |
|
2. "Mr. Naveen Patnaik has been the Chief Minister of Odisha for five terms." |
|
|
|
OUTPUT: |
|
[ |
|
{"content": 1, "score": 0, "reasoning": "Paris is correctly mentioned as the capital."}, |
|
{"content": 2, "score": 1, "reasoning": "Unrelated to the query."} |
|
] |
|
|
|
QUERY: |
|
{retriever_query} |
|
|
|
CONTEXT LIST: |
|
{context} |
|
|
|
Provide your verdict in JSON format with a single key 'score' and no preamble or explanation: |
|
[ |
|
{"content": <content_number>, "score": <0 or 1>, "reasoning": "<explanation>"}, |
|
{"content": <content_number>, "score": <0 or 1>, "reasoning": "<explanation>"} |
|
] |
|
""" |
|
|
|
|
|
relevant_context_picker_prompt = """You main task is to analyze the json structure as a part of the Relevancy Response. |
|
Review the Relevancy Response and do the following:- |
|
(1) Look at the Json Structure content |
|
(2) Analyze the 'score' key in the Json Structure content. |
|
(3) pick the value of 'content' key against those 'score' key value which has 0. |
|
. |
|
|
|
Relevancy Response: |
|
{relevancy_response} |
|
|
|
Provide your verdict in JSON format with a single key 'content number' and no preamble or explanation: [{{"content":<content number>}}]""" |
|
|
|
|
|
response_synthesis = """ You main task is to analyze the json structure as a part of the Context Number Response and the list of Contexts provided in the 'Content List' and perform the following steps:- |
|
(1) Look at the output from the Relevant Context Picker Agent. |
|
(2) Analyze the 'content' key in the Json Structure format({{"content":<<content_number>>}}). |
|
(3) Retrieve the value of 'content' key and pick up the context corresponding to that element from the Content List provided. |
|
(4) Pass the retrieved context for each corresponing element number referred in the 'Context Number Response' |
|
|
|
Context Number Response: |
|
{context_number} |
|
|
|
Content List: |
|
{context} |
|
|
|
Provide your verdict in JSON format with a two key 'relevant_content' and 'context_number' no preamble or explanation: |
|
[{{"context_number":<content1>,"relevant_content":<content corresponing to that element 1 in the Content List>}}, |
|
{{"context_number":<content4>,"relevant_content":<content corresponing to that element 4 in the Content List>}}, |
|
... |
|
]""" |
|
|
|
|