Instructions to use HuggingFaceM4/idefics2-8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceM4/idefics2-8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="HuggingFaceM4/idefics2-8b")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics2-8b") model = AutoModelForMultimodalLM.from_pretrained("HuggingFaceM4/idefics2-8b") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HuggingFaceM4/idefics2-8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceM4/idefics2-8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceM4/idefics2-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/HuggingFaceM4/idefics2-8b
- SGLang
How to use HuggingFaceM4/idefics2-8b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "HuggingFaceM4/idefics2-8b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceM4/idefics2-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "HuggingFaceM4/idefics2-8b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceM4/idefics2-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use HuggingFaceM4/idefics2-8b with Docker Model Runner:
docker model run hf.co/HuggingFaceM4/idefics2-8b
GPT-4 Output in Training Data
The model’s license is listed as Apache 2.0, but the training data (such as teknium/OpenHermes-2.5) includes outputs from GPT-4. How should this be interpreted, especially in terms of commercial use?
Or is the output from GPT-4 being removed from the training data?
Hi @alfredplpl ,
Most current models are necessarily trained in a way on GPT4 outputs.
Simply because it's all over the internet, and thus present in the recent Common Crawl dumps.
If you really care about that, you can start from the base Idefics2-base which has not been trained on GPT4 outputs and redo the fine-tuning on the data you want.
Thank you for your response. I see, that's an interesting perspective. No problem at all. Thank you also for informing me about how to handle it.
@HugoLaurencon , I'm also confused about the model license.
If you really care about that, you can start from the base Idefics2-base which has not been trained on GPT4 outputs and redo the fine-tuning on the data you want.
While it is true that Idefics2-base doesn't contain GPT-4 generated data, it was trained on PMD, which restricts commercial use:
PMD should only be used for non-commercial research. PMD should not be used for any tasks that involve identifying features related to people (facial recognition, gender, age, ethnicity identification, etc.) or make decisions that impact people (mortgages, job applications, criminal sentences; or moderation decisions about user-uploaded data that could result in bans from a website). Any commercial and for-profit uses of PMD are restricted – it should not be used to train models that will be deployed in production systems as part of a product offered by businesses or government agencies.
How does this affect to the commercial use of Idefics2?
Thanks for raising the point.
It's true that it's not detailed, but we did not use all subsets of PMD.
We used essentially:
- Conceptual Captions (license:
The dataset may be freely used for any purpose) - Localized Narratives: (license:
All the annotations available through this website are released under a CC BY 4.0 license) - Visual Genome: (license:
Visual Genome by Ranjay Krishna is licensed under a Creative Commons Attribution 4.0 International License.) - WIT (license:
This data is available under the Creative Commons Attribution-ShareAlike 3.0 Unported license.)
So I think it's good
This is great news, thank you for the clarification!
No worries, I close this but feel free to reopen if you have any doubts