Instructions to use trl-internal-testing/tiny-Idefics2ForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-Idefics2ForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="trl-internal-testing/tiny-Idefics2ForConditionalGeneration") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("trl-internal-testing/tiny-Idefics2ForConditionalGeneration") model = AutoModelForMultimodalLM.from_pretrained("trl-internal-testing/tiny-Idefics2ForConditionalGeneration", device_map="auto") 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use trl-internal-testing/tiny-Idefics2ForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-Idefics2ForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-Idefics2ForConditionalGeneration", "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/trl-internal-testing/tiny-Idefics2ForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-Idefics2ForConditionalGeneration 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 "trl-internal-testing/tiny-Idefics2ForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Idefics2ForConditionalGeneration", "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 "trl-internal-testing/tiny-Idefics2ForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Idefics2ForConditionalGeneration", "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 trl-internal-testing/tiny-Idefics2ForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-Idefics2ForConditionalGeneration
Upload Idefics2ForConditionalGeneration
Browse files- config.json +3 -3
- generation_config.json +1 -1
- model.safetensors +2 -2
- tokenizer.json +8 -1
config.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
},
|
| 21 |
"text_config": {
|
| 22 |
"attention_dropout": 0.0,
|
| 23 |
-
"head_dim":
|
| 24 |
"hidden_act": "silu",
|
| 25 |
"hidden_size": 16,
|
| 26 |
"initializer_range": 0.02,
|
|
@@ -39,7 +39,7 @@
|
|
| 39 |
"vocab_size": 32003
|
| 40 |
},
|
| 41 |
"tie_word_embeddings": false,
|
| 42 |
-
"transformers_version": "4.
|
| 43 |
"use_cache": true,
|
| 44 |
"vision_config": {
|
| 45 |
"attention_dropout": 0.0,
|
|
@@ -51,7 +51,7 @@
|
|
| 51 |
"intermediate_size": 4304,
|
| 52 |
"layer_norm_eps": 1e-06,
|
| 53 |
"model_type": "idefics2_vision",
|
| 54 |
-
"num_attention_heads":
|
| 55 |
"num_channels": 3,
|
| 56 |
"num_hidden_layers": 2,
|
| 57 |
"num_key_value_heads": 2,
|
|
|
|
| 20 |
},
|
| 21 |
"text_config": {
|
| 22 |
"attention_dropout": 0.0,
|
| 23 |
+
"head_dim": 8,
|
| 24 |
"hidden_act": "silu",
|
| 25 |
"hidden_size": 16,
|
| 26 |
"initializer_range": 0.02,
|
|
|
|
| 39 |
"vocab_size": 32003
|
| 40 |
},
|
| 41 |
"tie_word_embeddings": false,
|
| 42 |
+
"transformers_version": "4.56.2",
|
| 43 |
"use_cache": true,
|
| 44 |
"vision_config": {
|
| 45 |
"attention_dropout": 0.0,
|
|
|
|
| 51 |
"intermediate_size": 4304,
|
| 52 |
"layer_norm_eps": 1e-06,
|
| 53 |
"model_type": "idefics2_vision",
|
| 54 |
+
"num_attention_heads": 2,
|
| 55 |
"num_channels": 3,
|
| 56 |
"num_hidden_layers": 2,
|
| 57 |
"num_key_value_heads": 2,
|
generation_config.json
CHANGED
|
@@ -14,5 +14,5 @@
|
|
| 14 |
32002
|
| 15 |
],
|
| 16 |
"pad_token_id": 0,
|
| 17 |
-
"transformers_version": "4.
|
| 18 |
}
|
|
|
|
| 14 |
32002
|
| 15 |
],
|
| 16 |
"pad_token_id": 0,
|
| 17 |
+
"transformers_version": "4.56.2"
|
| 18 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:92bd5bebb5114b038f7254d46dd7627f43b3fa0d2476e70ae6f18f9ce24336fa
|
| 3 |
+
size 14654080
|
tokenizer.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
| 1 |
{
|
| 2 |
"version": "1.0",
|
| 3 |
"truncation": null,
|
| 4 |
-
"padding":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"added_tokens": [
|
| 6 |
{
|
| 7 |
"id": 0,
|
|
|
|
| 1 |
{
|
| 2 |
"version": "1.0",
|
| 3 |
"truncation": null,
|
| 4 |
+
"padding": {
|
| 5 |
+
"strategy": "BatchLongest",
|
| 6 |
+
"direction": "Left",
|
| 7 |
+
"pad_to_multiple_of": null,
|
| 8 |
+
"pad_id": 0,
|
| 9 |
+
"pad_type_id": 0,
|
| 10 |
+
"pad_token": "<unk>"
|
| 11 |
+
},
|
| 12 |
"added_tokens": [
|
| 13 |
{
|
| 14 |
"id": 0,
|