Each EDSL question type includes default instructions to the model about how to answer the question. We can view these instructions by inspecting the user prompt for a question that has been created (the other type of promptβsysten promptβis for agent instructions).For example, here we see that the default instruction for multiple choice questions is:βOnly 1 option may be selected. Respond only with a string corresponding to one of the options. After the answer, you can put a comment explaining why you chose that option on the next line.βThis text is automatically appended to the question text:
from edsl import QuestionMultipleChoice, Survey, Modelq = QuestionMultipleChoice( question_name = "primary_color", question_text = "What is the most common primary color?", question_options = ["Red", "Yellow", "Blue"])survey = Survey([q])survey.show_prompts()
user_prompt
system_prompt
interview_index
question_name
scenario_index
agent_index
model
estimated_cost
cache_keys
0
What is the most common primary color? Red Yellow Blue Only 1 option may be selected. Respond only with a string corresponding to one of the options. After the answer, you can put a comment explaining why you chose that option on the next line.
What is the most common primary color? Red Yellow Blue Only 1 option may be selected. Respond only with a string corresponding to one of the options. After the answer, you can put a comment explaining why you chose that option on the next line.
We can compare this with default instructions for other question types:
Which colors are βprimaryβ? Red Orange Yellow Green Blue Purple Please respond only with a comma-separated list of the options that apply, with square brackets. E.g., [βGoodβ, βBadβ, βUglyβ] After the answer, you can put a comment explaining your choice on the next line.
from edsl import QuestionRank, Survey, Modelq = QuestionRank( question_name = "primary_colors_rank", question_text = "Rank the primary colors in terms of popularity.", question_options = ["Red", "Yellow", "Blue"])survey = Survey([q])survey.by(Model()).prompts().select("user_prompt")
user_prompt
0
Rank the primary colors in terms of popularity. The options are 0: Red 1: Yellow 2: Blue You have to include 3 options in your answer. Please respond only with a comma-separated list of the code of the raked options, with square brackets. E.g., [0, 1, 3] After the answer, you can put a comment explaining your choice on the next line.
from edsl import QuestionLinearScale, Survey, Modelq = QuestionLinearScale( question_name = "primary_color_scale", question_text = "Most people know what the primary colors are.", question_options = [1,2,3,4,5], option_labels = { 1:"This statement is completely inaccurate", 5:"This statement is completely accurate." })survey = Survey([q])survey.by(Model()).prompts().select("user_prompt")
user_prompt
0
Most people know what the primary colors are. 1 : This statement is completely inaccurate 2 : 3 : 4 : 5 : This statement is completely accurate. Only 1 option may be selected. Respond only with the code corresponding to one of the options. E.g., β1β or β5β by itself. After the answer, you can put a comment explaining why you chose that option on the next line.
We can see that each default instruction includes directions on (1) formatting the answer and (2) providing a comment about the answer. When a question is administered, the contents of the comment that is returned are automatically stored in a separate field of the results. We can see this when we run a question and inspect the columns of the results that have been created. Here we run the multiple choice question created above:
from edsl import QuestionMultipleChoice, Survey, Modelq = QuestionMultipleChoice( question_name = "primary_color", question_text = "What is the most common primary color?", question_options = ["Red", "Yellow", "Blue"])r = q.run() # default model will be used
We can see that the results include a comment field:
If desired, we can omit the instruction to provide a comment by passing a parameter include_comment=False to the question constructor. This may be desired if comments are not necessary or to save tokens. Here we inspect how the question prompt has been modified and verify that the comment field in the results is blank:
from edsl import QuestionMultipleChoice, Survey, Modelq = QuestionMultipleChoice( question_name = "primary_color", question_text = "What is the most common primary color?", question_options = ["Red", "Yellow", "Blue"], include_comment = False # optional)q.by(Model()).prompts().select("user_prompt")
user_prompt
0
What is the most common primary color? Red Yellow Blue Only 1 option may be selected. Respond only with a string corresponding to one of the options.
r = q.run() # default model will be usedr.select("model", "primary_color", "primary_color_comment")
We can also modify the default instruction if we want to use the comment field in a different way. This can be done by passing an optional parameter answering_instruction to the question constructor. For example, here we pass an instruction that preserves the directions about the format of the answer to a multiple choice question (βRespond only with a string corresponding to one of the options.β) but replace the comments part of the instruction with a new instruction for the model to instead note itβs second choice answer. We include the original question in the survey as well for ease of comparison:
from edsl import QuestionMultipleChoice, Survey, Modelq1 = QuestionMultipleChoice( question_name = "primary_color_v1", question_text = "What is the most common primary color?", question_options = ["Red", "Yellow", "Blue"])q2 = QuestionMultipleChoice( question_name = "primary_color_v2", question_text = "What is the most common primary color?", question_options = ["Red", "Yellow", "Blue"], answering_instructions = """ Respond only with a string corresponding to one of the options. After the answer, please provide your second choice on the next line. """)survey = Survey([q1, q2])survey.by(Model()).prompts().select("user_prompt")
user_prompt
0
What is the most common primary color? Red Yellow Blue Only 1 option may be selected. Respond only with a string corresponding to one of the options. After the answer, you can put a comment explaining why you chose that option on the next line.
1
What is the most common primary color? Red Yellow Blue Only 1 option may be selected. Respond only with a string corresponding to one of the options. After the answer, please provide your second choice on the next line.
Please see the questions page of the documentation for more examples and details on all of the required and optional parameters for question types!Here we post this notebook to Expected Parrot for reference:
from edsl import Notebook
nb = Notebook(path = "answering_instructions_example.ipynb")nb.push( description = "Example answering instructions", alias = "answering-instructions-notebook", visibility = "public")