Image-Text-to-Text
Transformers
Safetensors
Habana
English
llava
LLM
Intel
conversational
Eval Results (legacy)
Instructions to use Intel/llava-gemma-2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Intel/llava-gemma-2b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Intel/llava-gemma-2b") 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("Intel/llava-gemma-2b") model = AutoModelForImageTextToText.from_pretrained("Intel/llava-gemma-2b") 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 Intel/llava-gemma-2b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Intel/llava-gemma-2b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Intel/llava-gemma-2b", "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/Intel/llava-gemma-2b
- SGLang
How to use Intel/llava-gemma-2b 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 "Intel/llava-gemma-2b" \ --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": "Intel/llava-gemma-2b", "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 "Intel/llava-gemma-2b" \ --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": "Intel/llava-gemma-2b", "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 Intel/llava-gemma-2b with Docker Model Runner:
docker model run hf.co/Intel/llava-gemma-2b
Converting weights
Browse files- README.md +2 -2
- config.json +43 -38
- generation_config.json +1 -13
- model-00001-of-00003.safetensors +3 -0
- model-00002-of-00003.safetensors +3 -0
- model-00003-of-00003.safetensors +3 -0
- model.safetensors.index.json +0 -0
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
license_name: gemma-terms
|
| 3 |
-
license_link: https://ai.google.dev/gemma/terms
|
| 4 |
language:
|
| 5 |
- en
|
|
|
|
|
|
|
| 6 |
---
|
| 7 |
|
| 8 |
# LLaVA-Gemma Model Card
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
+
license_name: gemma-terms
|
| 5 |
+
license_link: https://ai.google.dev/gemma/terms
|
| 6 |
---
|
| 7 |
|
| 8 |
# LLaVA-Gemma Model Card
|
config.json
CHANGED
|
@@ -1,43 +1,48 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "
|
| 3 |
"architectures": [
|
| 4 |
-
"
|
| 5 |
],
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
"
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
"
|
| 33 |
-
"rope_scaling": null,
|
| 34 |
-
"rope_theta": 10000.0,
|
| 35 |
-
"tokenizer_model_max_length": 2048,
|
| 36 |
-
"tokenizer_padding_side": "right",
|
| 37 |
-
"torch_dtype": "bfloat16",
|
| 38 |
"transformers_version": "4.39.0.dev0",
|
| 39 |
-
"
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "./llava-gemma-2b-it",
|
| 3 |
"architectures": [
|
| 4 |
+
"LlavaForConditionalGeneration"
|
| 5 |
],
|
| 6 |
+
"ignore_index": -100,
|
| 7 |
+
"image_token_index": 256000,
|
| 8 |
+
"model_type": "llava",
|
| 9 |
+
"projector_hidden_act": "gelu",
|
| 10 |
+
"text_config": {
|
| 11 |
+
"_name_or_path": "google/gemma-2b-it",
|
| 12 |
+
"architectures": [
|
| 13 |
+
"GemmaForCausalLM"
|
| 14 |
+
],
|
| 15 |
+
"bos_token_id": 2,
|
| 16 |
+
"eos_token_id": 1,
|
| 17 |
+
"head_dim": 256,
|
| 18 |
+
"hidden_act": "gelu",
|
| 19 |
+
"hidden_size": 2048,
|
| 20 |
+
"intermediate_size": 16384,
|
| 21 |
+
"max_position_embeddings": 8192,
|
| 22 |
+
"model_type": "gemma",
|
| 23 |
+
"num_attention_heads": 8,
|
| 24 |
+
"num_hidden_layers": 18,
|
| 25 |
+
"num_key_value_heads": 1,
|
| 26 |
+
"pad_token_id": 0,
|
| 27 |
+
"rope_scaling": null,
|
| 28 |
+
"tie_word_embeddings": true,
|
| 29 |
+
"torch_dtype": "bfloat16",
|
| 30 |
+
"vocab_size": 256064
|
| 31 |
+
},
|
| 32 |
+
"torch_dtype": "float32",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
"transformers_version": "4.39.0.dev0",
|
| 34 |
+
"vision_config": {
|
| 35 |
+
"hidden_size": 1024,
|
| 36 |
+
"image_size": 336,
|
| 37 |
+
"intermediate_size": 4096,
|
| 38 |
+
"model_type": "clip_vision_model",
|
| 39 |
+
"num_attention_heads": 16,
|
| 40 |
+
"num_hidden_layers": 24,
|
| 41 |
+
"patch_size": 14,
|
| 42 |
+
"projection_dim": 768,
|
| 43 |
+
"vocab_size": 32000
|
| 44 |
+
},
|
| 45 |
+
"vision_feature_layer": -2,
|
| 46 |
+
"vision_feature_select_strategy": "default",
|
| 47 |
+
"vocab_size": 256064
|
| 48 |
}
|
generation_config.json
CHANGED
|
@@ -1,19 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
-
"attn_softmax_bf16": null,
|
| 4 |
"bos_token_id": 2,
|
| 5 |
-
"bucket_internal": null,
|
| 6 |
-
"bucket_size": -1,
|
| 7 |
"eos_token_id": 1,
|
| 8 |
-
"flash_attention_recompute": null,
|
| 9 |
-
"ignore_eos": null,
|
| 10 |
-
"kv_cache_fp8": null,
|
| 11 |
-
"limit_hpu_graphs": null,
|
| 12 |
"pad_token_id": 0,
|
| 13 |
-
"
|
| 14 |
-
"reuse_cache": null,
|
| 15 |
-
"static_shapes": null,
|
| 16 |
-
"transformers_version": "4.39.0.dev0",
|
| 17 |
-
"trim_logits": null,
|
| 18 |
-
"use_flash_attention": null
|
| 19 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
|
|
|
| 3 |
"bos_token_id": 2,
|
|
|
|
|
|
|
| 4 |
"eos_token_id": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"pad_token_id": 0,
|
| 6 |
+
"transformers_version": "4.39.0.dev0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
}
|
model-00001-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a34f002270e12d50917ff5d307951ed107140530372c2d549aea081e327b4f6f
|
| 3 |
+
size 4964385864
|
model-00002-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:21d7fe224a3dced4a95cd2316b9d131a5c80705115849dd980eafbfe108d5e5c
|
| 3 |
+
size 4999820616
|
model-00003-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40c198b0d6b4170bd3d8eb708a66a672b76ae70eece7ab843b8ed3605d97c85c
|
| 3 |
+
size 1300294808
|
model.safetensors.index.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|