Instructions to use trl-internal-testing/tiny-LlavaForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-LlavaForConditionalGeneration 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-LlavaForConditionalGeneration") 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-LlavaForConditionalGeneration") model = AutoModelForImageTextToText.from_pretrained("trl-internal-testing/tiny-LlavaForConditionalGeneration") 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-LlavaForConditionalGeneration 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-LlavaForConditionalGeneration" # 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-LlavaForConditionalGeneration", "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-LlavaForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-LlavaForConditionalGeneration 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-LlavaForConditionalGeneration" \ --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-LlavaForConditionalGeneration", "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-LlavaForConditionalGeneration" \ --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-LlavaForConditionalGeneration", "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-LlavaForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-LlavaForConditionalGeneration
Upload LlavaForConditionalGeneration
Browse files- config.json +5 -3
- generation_config.json +1 -1
- model.safetensors +1 -1
config.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
"architectures": [
|
| 3 |
"LlavaForConditionalGeneration"
|
| 4 |
],
|
|
|
|
| 5 |
"ignore_index": -100,
|
| 6 |
"image_seq_length": 576,
|
| 7 |
"image_token_index": 32000,
|
|
@@ -16,11 +17,13 @@
|
|
| 16 |
],
|
| 17 |
"attention_bias": false,
|
| 18 |
"attention_dropout": 0.0,
|
|
|
|
| 19 |
"head_dim": 128,
|
| 20 |
"hidden_act": "silu",
|
| 21 |
"hidden_size": 16,
|
| 22 |
"initializer_range": 0.02,
|
| 23 |
"intermediate_size": 11008,
|
|
|
|
| 24 |
"max_position_embeddings": 4096,
|
| 25 |
"mlp_bias": false,
|
| 26 |
"model_type": "llama",
|
|
@@ -31,15 +34,14 @@
|
|
| 31 |
"rms_norm_eps": 1e-05,
|
| 32 |
"rope_scaling": null,
|
| 33 |
"rope_theta": 10000.0,
|
| 34 |
-
"torch_dtype": "float16",
|
| 35 |
"use_cache": true,
|
| 36 |
"vocab_size": 32064
|
| 37 |
},
|
| 38 |
"tie_word_embeddings": false,
|
| 39 |
-
"
|
| 40 |
-
"transformers_version": "4.56.0.dev0",
|
| 41 |
"vision_config": {
|
| 42 |
"attention_dropout": 0.0,
|
|
|
|
| 43 |
"hidden_act": "quick_gelu",
|
| 44 |
"hidden_size": 16,
|
| 45 |
"image_size": 336,
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
"LlavaForConditionalGeneration"
|
| 4 |
],
|
| 5 |
+
"dtype": "bfloat16",
|
| 6 |
"ignore_index": -100,
|
| 7 |
"image_seq_length": 576,
|
| 8 |
"image_token_index": 32000,
|
|
|
|
| 17 |
],
|
| 18 |
"attention_bias": false,
|
| 19 |
"attention_dropout": 0.0,
|
| 20 |
+
"dtype": "float16",
|
| 21 |
"head_dim": 128,
|
| 22 |
"hidden_act": "silu",
|
| 23 |
"hidden_size": 16,
|
| 24 |
"initializer_range": 0.02,
|
| 25 |
"intermediate_size": 11008,
|
| 26 |
+
"layer_types": null,
|
| 27 |
"max_position_embeddings": 4096,
|
| 28 |
"mlp_bias": false,
|
| 29 |
"model_type": "llama",
|
|
|
|
| 34 |
"rms_norm_eps": 1e-05,
|
| 35 |
"rope_scaling": null,
|
| 36 |
"rope_theta": 10000.0,
|
|
|
|
| 37 |
"use_cache": true,
|
| 38 |
"vocab_size": 32064
|
| 39 |
},
|
| 40 |
"tie_word_embeddings": false,
|
| 41 |
+
"transformers_version": "4.57.0.dev0",
|
|
|
|
| 42 |
"vision_config": {
|
| 43 |
"attention_dropout": 0.0,
|
| 44 |
+
"embed_dim": 32,
|
| 45 |
"hidden_act": "quick_gelu",
|
| 46 |
"hidden_size": 16,
|
| 47 |
"image_size": 336,
|
generation_config.json
CHANGED
|
@@ -3,5 +3,5 @@
|
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 2,
|
| 5 |
"pad_token_id": 32001,
|
| 6 |
-
"transformers_version": "4.
|
| 7 |
}
|
|
|
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 2,
|
| 5 |
"pad_token_id": 32001,
|
| 6 |
+
"transformers_version": "4.57.0.dev0"
|
| 7 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4855896
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7d138f4c3620f03b4650611fe4a001a4661bb9a6773c5bc82d2b0015cc625978
|
| 3 |
size 4855896
|