Few-Shot Builder چالش 3 از جلسهی 62، متوسط
تابع few_shot(examples, question) را کامل کن: برای هر جفت (review, label) دو خط Review: ... و Label: ... بسازد، آخر کار سؤال جدید را با Label: خالی اضافه کند و همه را با خط جدید ("\n") به هم بچسباند. خروجی باید این ۸ خط باشد:Review: The new level is amazing!Label: positiveReview: It keeps crashing on my phone.Label: negativeReview: Graphics are okay, music is great.Label: positiveReview: Too many ads, I deleted it.Label:
def few_shot(examples, question):
lines = []
for review, label in examples:
# add two lines: "Review: ..." and "Label: ..."
pass
# add the new question and an empty "Label:"
return "\n".join(lines)
examples = [
("The new level is amazing!", "positive"),
("It keeps crashing on my phone.", "negative"),
("Graphics are okay, music is great.", "positive"),
]
print(few_shot(examples, "Too many ads, I deleted it."))
راهنما و جواب این چالش · برگشت به درس جلسهی 62: پرامپتنویسی پیشرفته ۱ · چالش بعدی: Prompt Checker
بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال