以一次學習進行遷移學習
遷移學習有多種方法,其中之一是一次學習(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"])