Lesson 1 of 5 · 2 min
Prompts that work
The largest gains usually come from plain things: say who the answer is for, show an example of a good one, put long documents before the question, and ask for a fixed format your code can read. Change one thing at a time and rerun the same test questions.
def build_prompt(document, question):
return (
"You answer using only the document.\n"
"<document>\n" + document + "\n</document>\n"
'Reply as JSON: {"answer": str, "quote": str}\n'
"If the document does not say, set answer to \"not stated\".\n"
"Question: " + question
)
print(build_prompt("The library opens at 9.", "When does it open?"))