Vision Language Models (VLMs) को प्रॉम्प्ट करना
अगले दो अभ्यासों में, आप Hugging Face पर BBC News डेटासेट से किसी समाचार लेख और उसकी संबंधित हेडलाइन इमेज का सेंटिमेंट एक मल्टी-मोडल मॉडल से विश्लेषण करेंगे:

शुरू करने के लिए, आप मॉडल के लिए एक चैट टेम्पलेट तैयार करेंगे जिसमें इमेज और समाचार लेख दोनों शामिल हों. dataset (डेटासेट) और image (हेडलाइन इमेज) लोड कर दिए गए हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Hugging Face के साथ मल्टी-मोडल मॉडल्स
अभ्यास निर्देश
datasetमें इंडेक्स6वाले datapoint से समाचार लेख की सामग्री (content) लोड करें.- f-strings का उपयोग करके
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": ____,
},
____
],
}
]