Instructions to use hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration") model = AutoModelForImageTextToText.from_pretrained("hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration
- SGLang
How to use hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration 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 "hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration with Docker Model Runner:
docker model run hf.co/hf-internal-testing/tiny-random-Idefics3ForConditionalGeneration
Add ONNX weights (#1)
Browse files- [WIP] Add ONNX weights (a4bc21e11403ad2ce02e854447bd62b8f9e043c3)
- Upload folder using huggingface_hub (7baa6f795070b572d49252c9755fcf7db2a20d5f)
- Update tokenizer_config.json (d421ac507aae8f8dbc5275bec59754c7a59e78ec)
- Update tokenizer_config.json (a323c4d52e9eb3041478e728c7f71ee0061d9ab8)
- Upload vision_encoder.onnx (87c7e3749633a71c7abfaff9fa54d7ec3da902f6)
- Upload vision_encoder.onnx (0cae8b150d6bfdf3369d091d29c2be6ba034d12d)
- Update chat_template.json (dc017fc5552737872adf0be8251b5747a7f57c15)
- chat_template.json +1 -1
- onnx/decoder_model_merged.onnx +3 -0
- onnx/embed_tokens.onnx +3 -0
- onnx/vision_encoder.onnx +3 -0
- tokenizer_config.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
| 1 |
{
|
| 2 |
-
"chat_template": "<|begin_of_text|>{% for message in messages %}{{message['role']
|
| 3 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"chat_template": "<|begin_of_text|>{% for message in messages %}{{message['role'] | capitalize}}{% if message['content'][0]['type'] == 'image' %}{{':'}}{% else %}{{': '}}{% endif %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}<end_of_utterance>\n{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}"
|
| 3 |
}
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:92c2bec0806487d3f5e40ddb7102ea9697fe259c8b9f237787b082c7759f6fa9
|
| 3 |
+
size 43161647
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15a53f2fbab3be311daa25af0ce915ba5c2f47f0b1f9fcdd0cf34a83ff91ef70
|
| 3 |
+
size 32834600
|
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0e9b72e85c8d13549bee6454d21fbd97ae00b611208f3e6ecd15dd8ec3602c5d
|
| 3 |
+
size 1281955
|
|
@@ -2080,7 +2080,7 @@
|
|
| 2080 |
"<end_of_utterance>"
|
| 2081 |
],
|
| 2082 |
"bos_token": "<|begin_of_text|>",
|
| 2083 |
-
"chat_template": "{%
|
| 2084 |
"clean_up_tokenization_spaces": true,
|
| 2085 |
"eos_token": "<|end_of_text|>",
|
| 2086 |
"legacy": false,
|
|
|
|
| 2080 |
"<end_of_utterance>"
|
| 2081 |
],
|
| 2082 |
"bos_token": "<|begin_of_text|>",
|
| 2083 |
+
"chat_template": "<|begin_of_text|>{% for message in messages %}{{message['role'] | capitalize }}{% if message['content'][0]['type'] == 'image' %}{{':'}}{% else %}{{': '}}{% endif %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}<end_of_utterance>\n{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}",
|
| 2084 |
"clean_up_tokenization_spaces": true,
|
| 2085 |
"eos_token": "<|end_of_text|>",
|
| 2086 |
"legacy": false,
|