始める無料で始める

ワンショット学習による転移学習

転移学習にはさまざまなアプローチがあります。その一つがワンショット学習で、モデルに1つの例を見せて学習させる手法です。

モデルに対してワンショット学習の例を設定しましょう。

この演習はコースの一部です

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"])
コードを編集して実行