迁移学习与一次学习(one-shot learning)
迁移学习有多种方法,其中之一是一次学习(one-shot learning),即模型仅用一个已见过的示例进行训练。
为模型设置一个一次学习的示例。
本练习是课程的一部分
Python 中的 LLM 入门
练习说明
- 通过标明示例评论为
Positive来完成一次学习示例。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Include an example in the input ext
input_text = """
Text: "The dinner we had was great and the service too."
Classify the sentiment of this sentence as either positive or negative.
Example:
Text: "The food was delicious"
____
Text: "The dinner we had was great and the service too."
Sentiment:
"""
# Apply the example to the model
result = model(____, max_length=100)
print(result[0]["label"])