The prompt
Question: {original_prompt}
{model_response}
Is this a valid answer to the question?
Make sure to examine the question
thoroughly and generate a complete
reasoning for why the answer is correct
or not before responding. What it is
Gives the model a question and an answer and asks whether the answer is valid, with complete reasoning before it responds. The docs cite the paper Language Models (Mostly) Know What They Know. 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
- Developers checking LLM output
- Anyone writing prompts
يعطي النموذج سؤالًا وإجابة ويسأله هل الإجابة صحيحة، مع استدلال كامل قبل الرد.
Examples
Example from the docs
pythonif __name__ == "__main__":
original_prompt = """
Question: Who was the third president of the
United States?
"""
model_response = """
Here are some brainstormed ideas: James Monroe
Thomas Jefferson
Jefferson
Thomas Jefferson
George Washington
"""
response = evaluate_model_output(original_prompt, model_response)
print(response.model_dump_json(indent=2))
"""
{
"chain_of_thought": "Let's examine the question
carefully: 'Who was the third president of the
United States?'\n\nThe brainstormed ideas are:
\n1. James Monroe\n2. Thomas Jefferson\n3.
Jefferson\n4. Thomas Jefferson\n5. George
Washington.\n\nTo determine the validity of these
answers, I'll cross-check with historical
records.\n\n1. James Monroe was not the third
president; he was the fifth president.\n2. Thomas
Jefferson was indeed the third president of the
United States.\n3. 'Jefferson' is a correct but
incomplete answer; it lacks the first name, though
it is commonly understood.\n4. 'Thomas Jefferson'
is the full name and correct answer.\n5. George
Washington was the first president, not the
third.\n\nTherefore, the correct, valid answer to
the question 'Who was the third president of the
United States?' is 'Thomas Jefferson,' and this
answer is correct.",
"is_valid_answer": true
}
"""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 the original paper used a fine-tuned regression head over the model output, and they use a function call as a substitute.
- The docs pass a Pydantic response model with this prompt, so the printed output follows that schema.