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 +20 -3
- generation_config.json +1 -1
- model.safetensors +2 -2
config.json
CHANGED
|
@@ -2,29 +2,46 @@
|
|
| 2 |
"architectures": [
|
| 3 |
"LlavaForConditionalGeneration"
|
| 4 |
],
|
| 5 |
-
"ignore_index": -100,
|
| 6 |
"image_seq_length": 576,
|
| 7 |
"image_token_index": 32000,
|
| 8 |
"model_type": "llava",
|
|
|
|
| 9 |
"projector_hidden_act": "gelu",
|
| 10 |
"text_config": {
|
|
|
|
|
|
|
| 11 |
"head_dim": 2,
|
|
|
|
| 12 |
"hidden_size": 8,
|
|
|
|
| 13 |
"intermediate_size": 32,
|
|
|
|
|
|
|
| 14 |
"model_type": "llama",
|
| 15 |
"num_attention_heads": 4,
|
| 16 |
"num_hidden_layers": 2,
|
| 17 |
"num_key_value_heads": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
"vocab_size": 32005
|
| 19 |
},
|
| 20 |
"torch_dtype": "float32",
|
| 21 |
-
"transformers_version": "4.
|
| 22 |
"vision_config": {
|
| 23 |
-
"
|
|
|
|
|
|
|
| 24 |
"image_size": 336,
|
|
|
|
|
|
|
| 25 |
"intermediate_size": 32,
|
|
|
|
| 26 |
"model_type": "clip_vision_model",
|
| 27 |
"num_attention_heads": 4,
|
|
|
|
| 28 |
"num_hidden_layers": 2,
|
| 29 |
"patch_size": 14,
|
| 30 |
"projection_dim": 8
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
"LlavaForConditionalGeneration"
|
| 4 |
],
|
|
|
|
| 5 |
"image_seq_length": 576,
|
| 6 |
"image_token_index": 32000,
|
| 7 |
"model_type": "llava",
|
| 8 |
+
"multimodal_projector_bias": true,
|
| 9 |
"projector_hidden_act": "gelu",
|
| 10 |
"text_config": {
|
| 11 |
+
"attention_bias": false,
|
| 12 |
+
"attention_dropout": 0.0,
|
| 13 |
"head_dim": 2,
|
| 14 |
+
"hidden_act": "silu",
|
| 15 |
"hidden_size": 8,
|
| 16 |
+
"initializer_range": 0.02,
|
| 17 |
"intermediate_size": 32,
|
| 18 |
+
"max_position_embeddings": 2048,
|
| 19 |
+
"mlp_bias": false,
|
| 20 |
"model_type": "llama",
|
| 21 |
"num_attention_heads": 4,
|
| 22 |
"num_hidden_layers": 2,
|
| 23 |
"num_key_value_heads": 2,
|
| 24 |
+
"pretraining_tp": 1,
|
| 25 |
+
"rms_norm_eps": 1e-06,
|
| 26 |
+
"rope_scaling": null,
|
| 27 |
+
"rope_theta": 10000.0,
|
| 28 |
+
"use_cache": true,
|
| 29 |
"vocab_size": 32005
|
| 30 |
},
|
| 31 |
"torch_dtype": "float32",
|
| 32 |
+
"transformers_version": "4.54.0.dev0",
|
| 33 |
"vision_config": {
|
| 34 |
+
"attention_dropout": 0.0,
|
| 35 |
+
"hidden_act": "quick_gelu",
|
| 36 |
+
"hidden_size": 16,
|
| 37 |
"image_size": 336,
|
| 38 |
+
"initializer_factor": 1.0,
|
| 39 |
+
"initializer_range": 0.02,
|
| 40 |
"intermediate_size": 32,
|
| 41 |
+
"layer_norm_eps": 1e-05,
|
| 42 |
"model_type": "clip_vision_model",
|
| 43 |
"num_attention_heads": 4,
|
| 44 |
+
"num_channels": 3,
|
| 45 |
"num_hidden_layers": 2,
|
| 46 |
"patch_size": 14,
|
| 47 |
"projection_dim": 8
|
generation_config.json
CHANGED
|
@@ -2,5 +2,5 @@
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 2,
|
| 5 |
-
"transformers_version": "4.
|
| 6 |
}
|
|
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 2,
|
| 5 |
+
"transformers_version": "4.54.0.dev0"
|
| 6 |
}
|
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:5f54b0ec090dd9d4ec1955951dc2d1449bcf1cffebcee2f651554858609f23c6
|
| 3 |
+
size 2157456
|