Image-Text-to-Text
Transformers
Safetensors
English
gemma3n
function-calling
tool-use
on-device
mobile
gemma
litertlm
conversational
Instructions to use kontextdev/agent-gemma with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kontextdev/agent-gemma with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="kontextdev/agent-gemma") 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("kontextdev/agent-gemma") model = AutoModelForImageTextToText.from_pretrained("kontextdev/agent-gemma") 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 kontextdev/agent-gemma with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kontextdev/agent-gemma" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kontextdev/agent-gemma", "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/kontextdev/agent-gemma
- SGLang
How to use kontextdev/agent-gemma 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 "kontextdev/agent-gemma" \ --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": "kontextdev/agent-gemma", "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 "kontextdev/agent-gemma" \ --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": "kontextdev/agent-gemma", "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 kontextdev/agent-gemma with Docker Model Runner:
docker model run hf.co/kontextdev/agent-gemma
| { | |
| "architectures": [ | |
| "Gemma3nForConditionalGeneration" | |
| ], | |
| "audio_config": { | |
| "conf_attention_chunk_size": 12, | |
| "conf_attention_context_left": 13, | |
| "conf_attention_context_right": 0, | |
| "conf_attention_logit_cap": 50.0, | |
| "conf_conv_kernel_size": 5, | |
| "conf_num_attention_heads": 8, | |
| "conf_num_hidden_layers": 12, | |
| "conf_reduction_factor": 4, | |
| "conf_residual_weight": 0.5, | |
| "dtype": "bfloat16", | |
| "gradient_clipping": 10000000000.0, | |
| "hidden_size": 1536, | |
| "input_feat_size": 128, | |
| "model_type": "gemma3n_audio", | |
| "rms_norm_eps": 1e-06, | |
| "sscp_conv_channel_size": [ | |
| 128, | |
| 32 | |
| ], | |
| "sscp_conv_group_norm_eps": 0.001, | |
| "sscp_conv_kernel_size": [ | |
| [ | |
| 3, | |
| 3 | |
| ], | |
| [ | |
| 3, | |
| 3 | |
| ] | |
| ], | |
| "sscp_conv_stride_size": [ | |
| [ | |
| 2, | |
| 2 | |
| ], | |
| [ | |
| 2, | |
| 2 | |
| ] | |
| ], | |
| "vocab_offset": 262272, | |
| "vocab_size": 128 | |
| }, | |
| "audio_soft_tokens_per_image": 188, | |
| "audio_token_id": 262273, | |
| "boa_token_id": 256000, | |
| "boi_token_id": 255999, | |
| "dtype": "bfloat16", | |
| "eoa_token_id": 262272, | |
| "eoi_token_id": 262144, | |
| "eos_token_id": [ | |
| 1, | |
| 106 | |
| ], | |
| "image_token_id": 262145, | |
| "initializer_range": 0.02, | |
| "model_type": "gemma3n", | |
| "text_config": { | |
| "activation_sparsity_pattern": [ | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.95, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0, | |
| 0.0 | |
| ], | |
| "altup_active_idx": 0, | |
| "altup_coef_clip": 120.0, | |
| "altup_correct_scale": true, | |
| "altup_num_inputs": 4, | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "bos_token_id": 2, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 1, | |
| "final_logit_softcapping": 30.0, | |
| "head_dim": 256, | |
| "hidden_activation": "gelu_pytorch_tanh", | |
| "hidden_size": 2048, | |
| "hidden_size_per_layer_input": 256, | |
| "initializer_range": 0.02, | |
| "intermediate_size": [ | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192, | |
| 8192 | |
| ], | |
| "laurel_rank": 64, | |
| "layer_types": [ | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention" | |
| ], | |
| "max_position_embeddings": 32768, | |
| "model_type": "gemma3n_text", | |
| "num_attention_heads": 8, | |
| "num_hidden_layers": 30, | |
| "num_key_value_heads": 2, | |
| "num_kv_shared_layers": 10, | |
| "pad_token_id": 0, | |
| "rms_norm_eps": 1e-06, | |
| "rope_parameters": { | |
| "full_attention": { | |
| "rope_theta": 1000000.0, | |
| "rope_type": "default" | |
| }, | |
| "sliding_attention": { | |
| "rope_theta": 10000.0, | |
| "rope_type": "default" | |
| } | |
| }, | |
| "sliding_window": 512, | |
| "tie_word_embeddings": true, | |
| "use_cache": true, | |
| "vocab_size": 262400, | |
| "vocab_size_per_layer_input": 262144 | |
| }, | |
| "tie_word_embeddings": true, | |
| "transformers_version": "5.3.0", | |
| "vision_config": { | |
| "architecture": "mobilenetv5_300m_enc", | |
| "do_pooling": false, | |
| "dtype": "bfloat16", | |
| "hidden_size": 2048, | |
| "initializer_range": 0.02, | |
| "label_names": [ | |
| "LABEL_0", | |
| "LABEL_1" | |
| ], | |
| "model_args": null, | |
| "model_type": "gemma3n_vision", | |
| "num_classes": 2, | |
| "rms_norm_eps": 1e-06, | |
| "vocab_offset": 262144, | |
| "vocab_size": 128 | |
| }, | |
| "vision_soft_tokens_per_image": 256 | |
| } | |