-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix Idefics3 processor - handle gracefully cases with text and no images #35363
base: main
Are you sure you want to change the base?
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait for @yonigozlan to be sure! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that looks much better! Just suggested a check to avoid hallucinations like this:
messages = [
{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "What do we see in this image?"},
]
}
]
prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(text=prompt, return_tensors="pt")
inputs = {k: v.to(DEVICE) for k, v in inputs.items()}
# Generate
generated_ids = model.generate(**inputs, max_new_tokens=50)
generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True)
print(generated_texts)
['User:What do we see in this image?\nAssistant: The image depicts a scene from a historical or fictional setting, likely from the medieval period, given the attire and architecture. The central focus is on a large, ornate gate, which appears to be the entrance to a castle or a fortified structure.']
also in Idefics3ProcessorTest
could we add a test for text only inference and one to check that an error is raised if we have an image in the conversation, but no images are passed to the processor?
Co-authored-by: Yoni Gozlan <[email protected]>
thanks @andimarafioti
|
Looks great thanks @mfarre for fixing this! LGTM for me, but let's maybe wait for @ArthurZucker 's review before merging :) |
What does this PR do?
Fixing Idefics3 processor to work with batches that do not include images
Who can review?
@andimarafioti