Skip to content
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

[Inference API] Add image-text-to-text task and fix generate script #1440

Merged
merged 6 commits into from
Oct 16, 2024

Conversation

hanouticelina
Copy link
Contributor

@hanouticelina hanouticelina commented Oct 3, 2024

This PR does two things:

  • adds image-text-to-text task in the documentation.
  • adds conversational VLMs in Chat Completion documentation.
  • upgrades huggingface/tasks and generate the documentations.

@HuggingFaceDocBuilderDev

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.

@hanouticelina
Copy link
Contributor Author

The PR documentation is not deployed correctly and returns 404 🤔 did I miss something?

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @hanouticelina! Seems like you uncovered some annoying discrepancies 🙈

The PR documentation is not deployed correctly and returns 404 🤔 did I miss something?

Maybe it needed some time to update. Link is working for me now: https://moon-ci-docs.huggingface.co/docs/api-inference/pr_1440/en/index

Comment on lines 49 to 54
import requests

API_URL = "https://api-inference.huggingface.co/models/HuggingFaceM4/idefics2-8b-chatty"
headers = {"Authorization": "Bearer hf_***"}

from huggingface_hub import InferenceClient
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not expected (i.e. having import requests ... before from huggingface_hub import InferenceClient). I realized that https://huggingface.co/meta-llama/Llama-3.2-11B-Vision-Instruct?inference_api=true has a problem. Model doesn't have a chat template and therefore is not tagged as "conversational" which creates this weird side effect.

So I see 3 independent things to correct here:

  1. it would be nice to recommend meta-llama/Llama-3.2-11B-Vision-Instruct first on the image-text-to-image task page (to update here)
  2. we should fix in moon-landing the "conversational" detection. At the moment, it's based only on the presence of a chat template. However for idefics chatty 8b it seems it's using "use_default_system_prompt": true instead. @Rocketknight1 is it safe to assume that a model with no chat template but this parameter set to True is in fact a conversational model? And if not, which parameter could we check?
  3. For non-conversational image-text-to-text (does that even exist?), we should fix the snippet generator so that only the requests-based snippet is displayed instead of this weird combination.

cc @osanseviero as well for viz'

Copy link
Contributor Author

@hanouticelina hanouticelina Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to add, HuggingFaceM4/idefics2-8b-chatty has thechat_template defined in the processor_config.json. The tokenizer.chat_template attribute is supposed to be saved in tokenizer_config.json file. I guess the template was set using transformers.ProcessorMixin instead.

Copy link
Contributor Author

@hanouticelina hanouticelina Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the 3rd point, pinging @mishig25 since it's related to huggingface.js/pull/938. do you think it's okay to map image-text-to-text to snippetBasic instead and define the task input here ?

docs/api-inference/tasks/image-text-to-text.md Outdated Show resolved Hide resolved
docs/api-inference/tasks/image-text-to-text.md Outdated Show resolved Hide resolved
scripts/api-inference/scripts/generate.ts Outdated Show resolved Hide resolved
docs/api-inference/tasks/text-generation.md Outdated Show resolved Hide resolved
Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hanouticelina ! Now that huggingface/huggingface.js#956 has been merged, can you regenerate the docs which should finally highlight Llama 11B Vision model 😄

docs/api-inference/tasks/chat-completion.md Outdated Show resolved Hide resolved
docs/api-inference/tasks/chat-completion.md Outdated Show resolved Hide resolved
scripts/api-inference/scripts/generate.ts Outdated Show resolved Hide resolved
@hanouticelina
Copy link
Contributor Author

@Wauplin I regenerated the docs and Llama 11B Vision is finally highlighted!
I also changed the sentence used in the "Recommended Models" section to ensure it works whether or not there are recommended models listed in the section:

- This is only a subset of the supported models. Find the model that suits you best [here](...)
+ Explore all available models and find the one that suits you best [here](...)

I think we're pretty much good to finally merge this PR :)

@hanouticelina hanouticelina requested a review from Wauplin October 16, 2024 14:39
Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a nice addition! Thanks @hanouticelina for packing this up 🤗

@hanouticelina hanouticelina merged commit 0bcbf66 into main Oct 16, 2024
2 checks passed
@hanouticelina hanouticelina deleted the add-image-text-to-text-task branch October 16, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants