How AI Language Models Work ยท Building with Models
A prompt is just text, but its shape matters: an instruction, a few worked examples, and an ending that invites exactly the answer you want.
# A prompt is just text, but its shape changes the answer a lot.
system = "You label reviews as positive or negative. Answer with one word."
examples = [("I loved it", "positive"), ("Waste of money", "negative")]
question = "Works great, would buy again"
prompt = system + "\n"
for review, label in examples:
prompt += "Review: " + review + "\nLabel: " + label + "\n"
prompt += "Review: " + question + "\nLabel:"
print(prompt)review is created with the value 'I loved it'. label is created with the value 'positive'.review changes from 'I loved it' to 'Waste of money'. label changes from 'positive' to 'negative'.for review, label in examples.