You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bump transformer version and fix Llava example (#12324)
A lot has changed on Llava model definition between 4.47 to 4.52, this
PR:
* Change the state dict key mapping to match the new Llava model
definition in HF.
* Use the `processor.apply_chat_template()` API to get `input_id`s so
that we can be a bit more resilient to input_id format changes.
revision="a272c74b2481d8aff3aa6fc2c4bf891fe57334fb", # Need this for transformers >= 4.44.2
314
+
patch_size=self.model.vision_tower.config.patch_size, # Required after transformers >= 4.52.0
327
315
)
328
-
self.prompt="""A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. USER: <image>
329
-
What are the things I should be cautious about when I visit here? ASSISTANT:"""
self.system_prompt="""A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. """
321
+
current_template=self.processor.chat_template
322
+
# Prepend the system prompt to the template
323
+
new_template=self.system_prompt+current_template
324
+
325
+
# Set the modified template back to the tokenizer
326
+
self.processor.chat_template=new_template
327
+
330
328
self.model_name="llava-1.5-7b-hf"
329
+
330
+
self.conversation= [
331
+
{
332
+
"role": "user",
333
+
"content": [
334
+
{"type": "image", "url": self.image_url},
335
+
{
336
+
"type": "text",
337
+
"text": "What are the things I should be cautious about when I visit here?",
0 commit comments