Prompt Research Limited info

Refine an Answer with New Context

Gives the model a query, an existing answer and new context, and asks it to refine the answer only if needed, returning the original when the context is not useful.

  • 🤖 Any chat LLM
  • 🗂️ Research

Prompt by LlamaIndex (run-llama/llama_index) · Original source (opens in a new tab)

Refine an Answer with New Context — prompt preview

The prompt

prompt
The original query is as follows: {query_str}
We have provided an existing answer: {existing_answer}
We have the opportunity to refine the existing answer (only if needed) with some more context below.
------------
{context_msg}
------------
Given the new context, refine the original answer to better answer the query. If the context isn't useful, return the original answer.
Refined Answer:

What it is

Gives the model a query, an existing answer and new context, and asks it to refine the answer only if needed, returning the original when the context is not useful. The source file publishes this template without a worked usage example. The prompt text comes from the LlamaIndex repository (MIT licence, Copyright (c) Jerry Liu). Python quotes were removed and the backslash-n escapes are shown as line breaks. Placeholders keep the source syntax. Original author: LlamaIndex (run-llama/llama_index).

Who it's for

  • Developers of RAG systems

يعطي النموذج سؤالًا وإجابة حالية وسياقًا جديدًا، ويطلب منه تحسين الإجابة عند الحاجة فقط وإعادة الإجابة الأصلية إذا لم يفد السياق.

Tips

  • In the source this is the default refine template, and the framework fills {query_str}, {existing_answer} and {context_msg}.