Vision Language Models (VLMs) へのプロンプト設計
次の2つの演習では、Hugging Face の BBC News データセット にあるニュース記事と、その記事の見出し画像を組み合わせて、マルチモーダルモデルで感情分析を行います。

まず、画像とニュース記事の両方を含むチャットテンプレートを準備します。データセット(dataset)と見出し画像(image)は読み込まれています。
この演習はコースの一部です
Hugging Face で学ぶマルチモーダルモデル
演習の手順
datasetのインデックス6のデータポイントから、ニュース記事の本文(content)を読み込みます。- f-string を使って
contentをtext_queryに挿入し、テキストクエリを完成させます。 imageとtext_queryをチャットテンプレートに追加し、text_queryのコンテンツタイプを"text"として指定します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Load the news article content from datapoint 6
content = ____
# Complete the text query
text_query = f"Does the news article have a positive, negative, or neutral impact on championship winning chances: {____}. Provide reasoning."
# Add the text query dictionary to the chat template
chat_template = [
{
"role": "user",
"content": [
{
"type": "image",
"image": ____,
},
____
],
}
]