Prompt Research

Self-Ask: Let the Model Decide on Follow-Up Questions

Asks the model whether a query needs follow-up questions and, if it does, to generate them, answer them and then answer the query.

  • 🤖 Any chat LLM
  • 🗂️ Research

Last verified: write-up checked

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

Self-Ask: Let the Model Decide on Follow-Up Questions — prompt preview

The prompt

prompt
Query: {query}
Are follow-up questions needed?
If so, generate follow-up questions, their answers, and then the final answer to the query.

What it is

Asks the model whether a query needs follow-up questions and, if it does, to generate them, answer them and then answer the query. The docs cite the paper Measuring and Narrowing the Compositionality Gap, which describes models that answer sub-problems correctly but miss the overall query. 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

  • Researchers
  • Anyone writing prompts
  • Developers

يسأل النموذج هل يحتاج السؤال إلى أسئلة متابعة، وإن احتاج يولّدها ويجيب عنها ثم يجيب عن السؤال الأصلي.

Examples

Example from the docs

python
python
if __name__ == "__main__":
    query = "Who was president of the U.S. when superconductivity was discovered?"

    response = self_ask(query)

    print(response.follow_ups_required)
    #> True
    for follow_up in response.follow_ups:
        print(follow_up)
        """
        question='When was superconductivity discovered?' answer='Superconductivity was discovered in April 1911.'
        """
        """
        question='Who was president of the U.S. in April 1911?' answer='William Howard Taft was the President of the United States in April 1911.'
        """
    print(response.final_answer)
    """
    William Howard Taft was president of the U.S. when superconductivity was discovered.
    """

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 say that without Instructor this prompt would generally be implemented as a one-shot or few-shot prompt.
  • The docs pass a Pydantic response model with this prompt, so the printed output follows that schema.