Qwen ile çok modlu duygu sınıflandırma
Şimdi istemini Qwen2 Görsel-Dil Modeli ile entegre etme zamanı! Daha önce oluşturduğun ve chat_template olarak mevcut olan istem şablonunu kullanacaksın.
Hadi model bu makale hakkında ne düşünüyor görelim! Model (vl_model) ve işlemci (vl_model_processor) senin için yüklendi.
Bu egzersiz, kursun bir parçasıdır
Hugging Face ile Multi-Modal Modeller
Egzersiz talimatları
- İşlemciyi kullanarak
chat_templateiçin ön işleme yap. - Modeli kullanarak çıktı kimliklerini üret; yeni belirteçleri
500ile sınırla. - Özel belirteçleri atlayarak kırpılmış üretilen kimlikleri çözümle.
Uygulamalı etkileşimli egzersiz
Bu egzersizi bu örnek kodu tamamlayarak deneyin.
text = vl_model_processor.apply_chat_template(chat_template, tokenize=False, add_generation_prompt=True)
image_inputs, _ = process_vision_info(chat_template)
# Use the processor to preprocess the text and image
inputs = ____(
text=[____],
images=____,
padding=True,
return_tensors="pt",
)
# Use the model to generate the output IDs
generated_ids = vl_model.____(**inputs, ____)
generated_ids_trimmed = [out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]
# Decode the generated IDs
output_text = vl_model_processor.____(
generated_ids_trimmed, skip_special_tokens=True
)
print(output_text[0])