Prompt Productivity

System 2 Attention: Remove Irrelevant Details from a Question

Asks the model to extract only the part of a text that is relevant to the question, along with the question itself, so that a second call can answer from the cleaned-up version.

  • 🤖 Any chat LLM
  • 🗂️ Productivity

Last verified: write-up checked

Prompt by Jason Liu and contributors (567-labs/instructor) · Original source (opens in a new tab)

System 2 Attention: Remove Irrelevant Details from a Question — prompt preview

The prompt

prompt
Given the following text by a user, extract the part
that is actually relevant to their question. Please
include the actual question or query that the user
is asking.

Text by user:
{query}

What it is

Asks the model to extract only the part of a text that is relevant to the question, along with the question itself, so that a second call can answer from the cleaned-up version. The docs say this template comes from the paper System 2 Attention. This is step one; the second call in the docs only sends the relevant context and the question. The prompt text comes from the Instructor documentation (MIT licence, Copyright (c) 2023 Jason Liu). Python string quotes and code indentation were removed. Placeholders keep the source syntax. Original author: Jason Liu and contributors (567-labs/instructor).

Who it's for

  • Anyone writing prompts
  • Developers

يطلب من النموذج استخراج الجزء المتعلق بالسؤال فقط من النص مع السؤال نفسه، لتجيب خطوة ثانية من النسخة المنقحة.

Examples

Example from the docs

python
python
if __name__ == "__main__":
    query = """Mary has 3 times as much candy as Megan.
        Mary then adds 10 more pieces of candy to her collection.
        Max is 5 years older than Mary.
        If Megan has 5 pieces of candy, how many does Mary have in total?
        """

    # Step 1: Rewrite the prompt
    rewritten_prompt = rewrite_prompt(query)
    print(rewritten_prompt.relevant_context)
    """
    Mary has 3 times as much candy as Megan. Mary then adds 10 more pieces of candy to her collection. If Megan has 5 pieces of candy, how many does Mary have in total?
    """
    print(rewritten_prompt.user_query)
    #> how many does Mary have in total?

    # Step 2: Generate the final response
    final_response = generate_final_response(rewritten_prompt)
    print(final_response.answer)
    #> 25

What it does: The usage code and printed output from the Instructor docs. Output as printed in the docs, not re-run by us.

Tips

  • The docs run this in two steps: rewrite the prompt, then pass the rewritten prompt back to the model.
  • The docs pass a Pydantic response model with this prompt, so the printed output follows that schema.