Writing clear prompts
Say exactly what you want and what shape the answer should take.
Models do their best with what you give them, so vague prompts get vague answers. A clear prompt says the task, gives needed context, marks off the input text, and says what form the answer should take. For programs this matters even more: if your code expects one word, ask for exactly one word, or your code will have to deal with a long sentence instead.
# Vague: the model might write a paragraph, or ask a question back.
vague = "What do you think of this? " + review
# Clear: the task, the input marked off, and the exact answer format.
clear = (
"Classify the sentiment of the customer review below.\n"
"Answer with one word: positive, negative or neutral.\n"
f"<text>\n{review}\n</text>"
)The clear prompt tells the model the job (sentiment), the allowed answers, and where the review starts and ends.
A useful checklist: task, context, input (in tags), output format, and an example if the format is unusual.
Even with a clear prompt, clean up the answer in code: .strip() removes spaces and .lower() makes 'Positive' and 'positive' the same.