Instructions to use trl-internal-testing/tiny-InternVLForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-InternVLForConditionalGeneration 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-InternVLForConditionalGeneration") 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("trl-internal-testing/tiny-InternVLForConditionalGeneration") model = AutoModelForImageTextToText.from_pretrained("trl-internal-testing/tiny-InternVLForConditionalGeneration") 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 trl-internal-testing/tiny-InternVLForConditionalGeneration 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-InternVLForConditionalGeneration" # 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-InternVLForConditionalGeneration", "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-InternVLForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-InternVLForConditionalGeneration 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-InternVLForConditionalGeneration" \ --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-InternVLForConditionalGeneration", "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-InternVLForConditionalGeneration" \ --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-InternVLForConditionalGeneration", "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-InternVLForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-InternVLForConditionalGeneration
Upload InternVLForConditionalGeneration
Browse files- config.json +5 -30
- generation_config.json +1 -1
- model.safetensors +1 -1
config.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
"InternVLForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"downsample_ratio": 0.5,
|
|
|
|
| 6 |
"image_seq_length": 256,
|
| 7 |
"image_token_id": 151667,
|
| 8 |
"model_type": "internvl",
|
|
@@ -13,38 +14,13 @@
|
|
| 13 |
],
|
| 14 |
"attention_dropout": 0.0,
|
| 15 |
"bos_token_id": 151643,
|
|
|
|
| 16 |
"eos_token_id": 151645,
|
| 17 |
"hidden_act": "silu",
|
| 18 |
"hidden_size": 16,
|
| 19 |
"initializer_range": 0.02,
|
| 20 |
"intermediate_size": 18944,
|
| 21 |
"layer_types": [
|
| 22 |
-
"full_attention",
|
| 23 |
-
"full_attention",
|
| 24 |
-
"full_attention",
|
| 25 |
-
"full_attention",
|
| 26 |
-
"full_attention",
|
| 27 |
-
"full_attention",
|
| 28 |
-
"full_attention",
|
| 29 |
-
"full_attention",
|
| 30 |
-
"full_attention",
|
| 31 |
-
"full_attention",
|
| 32 |
-
"full_attention",
|
| 33 |
-
"full_attention",
|
| 34 |
-
"full_attention",
|
| 35 |
-
"full_attention",
|
| 36 |
-
"full_attention",
|
| 37 |
-
"full_attention",
|
| 38 |
-
"full_attention",
|
| 39 |
-
"full_attention",
|
| 40 |
-
"full_attention",
|
| 41 |
-
"full_attention",
|
| 42 |
-
"full_attention",
|
| 43 |
-
"full_attention",
|
| 44 |
-
"full_attention",
|
| 45 |
-
"full_attention",
|
| 46 |
-
"full_attention",
|
| 47 |
-
"full_attention",
|
| 48 |
"full_attention",
|
| 49 |
"full_attention"
|
| 50 |
],
|
|
@@ -62,13 +38,11 @@
|
|
| 62 |
},
|
| 63 |
"rope_theta": 1000000.0,
|
| 64 |
"sliding_window": null,
|
| 65 |
-
"torch_dtype": "bfloat16",
|
| 66 |
"use_cache": true,
|
| 67 |
"use_sliding_window": false,
|
| 68 |
"vocab_size": 151674
|
| 69 |
},
|
| 70 |
-
"
|
| 71 |
-
"transformers_version": "4.56.0.dev0",
|
| 72 |
"vision_config": {
|
| 73 |
"architectures": [
|
| 74 |
"InternVisionModel"
|
|
@@ -76,6 +50,8 @@
|
|
| 76 |
"attention_bias": true,
|
| 77 |
"attention_dropout": 0.0,
|
| 78 |
"dropout": 0.0,
|
|
|
|
|
|
|
| 79 |
"hidden_act": "gelu",
|
| 80 |
"hidden_dropout_prob": 0.0,
|
| 81 |
"hidden_size": 16,
|
|
@@ -99,7 +75,6 @@
|
|
| 99 |
14
|
| 100 |
],
|
| 101 |
"projection_dropout": 0.0,
|
| 102 |
-
"torch_dtype": "bfloat16",
|
| 103 |
"use_absolute_position_embeddings": true,
|
| 104 |
"use_mask_token": false,
|
| 105 |
"use_mean_pooling": true,
|
|
|
|
| 3 |
"InternVLForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"downsample_ratio": 0.5,
|
| 6 |
+
"dtype": "bfloat16",
|
| 7 |
"image_seq_length": 256,
|
| 8 |
"image_token_id": 151667,
|
| 9 |
"model_type": "internvl",
|
|
|
|
| 14 |
],
|
| 15 |
"attention_dropout": 0.0,
|
| 16 |
"bos_token_id": 151643,
|
| 17 |
+
"dtype": "bfloat16",
|
| 18 |
"eos_token_id": 151645,
|
| 19 |
"hidden_act": "silu",
|
| 20 |
"hidden_size": 16,
|
| 21 |
"initializer_range": 0.02,
|
| 22 |
"intermediate_size": 18944,
|
| 23 |
"layer_types": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
"full_attention",
|
| 25 |
"full_attention"
|
| 26 |
],
|
|
|
|
| 38 |
},
|
| 39 |
"rope_theta": 1000000.0,
|
| 40 |
"sliding_window": null,
|
|
|
|
| 41 |
"use_cache": true,
|
| 42 |
"use_sliding_window": false,
|
| 43 |
"vocab_size": 151674
|
| 44 |
},
|
| 45 |
+
"transformers_version": "4.57.0.dev0",
|
|
|
|
| 46 |
"vision_config": {
|
| 47 |
"architectures": [
|
| 48 |
"InternVisionModel"
|
|
|
|
| 50 |
"attention_bias": true,
|
| 51 |
"attention_dropout": 0.0,
|
| 52 |
"dropout": 0.0,
|
| 53 |
+
"dtype": "bfloat16",
|
| 54 |
+
"embed_dim": 32,
|
| 55 |
"hidden_act": "gelu",
|
| 56 |
"hidden_dropout_prob": 0.0,
|
| 57 |
"hidden_size": 16,
|
|
|
|
| 75 |
14
|
| 76 |
],
|
| 77 |
"projection_dropout": 0.0,
|
|
|
|
| 78 |
"use_absolute_position_embeddings": true,
|
| 79 |
"use_mask_token": false,
|
| 80 |
"use_mean_pooling": true,
|
generation_config.json
CHANGED
|
@@ -2,5 +2,5 @@
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 151643,
|
| 4 |
"eos_token_id": 151645,
|
| 5 |
-
"transformers_version": "4.
|
| 6 |
}
|
|
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 151643,
|
| 4 |
"eos_token_id": 151645,
|
| 5 |
+
"transformers_version": "4.57.0.dev0"
|
| 6 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 13956416
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ac4ed3cf0838f9202013909fc3c8a6c701744bfce8b283c64ab908a202327caf
|
| 3 |
size 13956416
|