始める無料で始める

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

転移学習にはさまざまなアプローチがあり、その一つがワンショット学習です。これは、モデルが見たことのある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"])
コードを編集して実行