Instructions to use tiny-random/gemma-3n with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/gemma-3n with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tiny-random/gemma-3n") 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("tiny-random/gemma-3n") model = AutoModelForImageTextToText.from_pretrained("tiny-random/gemma-3n") 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 tiny-random/gemma-3n with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/gemma-3n" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/gemma-3n", "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/tiny-random/gemma-3n
- SGLang
How to use tiny-random/gemma-3n 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 "tiny-random/gemma-3n" \ --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": "tiny-random/gemma-3n", "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 "tiny-random/gemma-3n" \ --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": "tiny-random/gemma-3n", "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 tiny-random/gemma-3n with Docker Model Runner:
docker model run hf.co/tiny-random/gemma-3n
Upload folder using huggingface_hub
Browse files- config.json +1 -5
- preprocessor_config.json +1 -1
config.json
CHANGED
|
@@ -10,7 +10,6 @@
|
|
| 10 |
"conf_conv_kernel_size": 5,
|
| 11 |
"conf_num_attention_heads": 2,
|
| 12 |
"conf_num_hidden_layers": 2,
|
| 13 |
-
"conf_positional_bias_size": 256,
|
| 14 |
"conf_reduction_factor": 4,
|
| 15 |
"conf_residual_weight": 0.5,
|
| 16 |
"gradient_clipping": 10000000000.0,
|
|
@@ -22,7 +21,6 @@
|
|
| 22 |
128,
|
| 23 |
32
|
| 24 |
],
|
| 25 |
-
"sscp_conv_eps": 0.001,
|
| 26 |
"sscp_conv_group_norm_eps": 0.001,
|
| 27 |
"sscp_conv_kernel_size": [
|
| 28 |
[
|
|
@@ -71,7 +69,6 @@
|
|
| 71 |
"altup_active_idx": 0,
|
| 72 |
"altup_coef_clip": 120.0,
|
| 73 |
"altup_correct_scale": true,
|
| 74 |
-
"altup_lr_multiplier": 1.0,
|
| 75 |
"altup_num_inputs": 4,
|
| 76 |
"attention_bias": false,
|
| 77 |
"attention_dropout": 0.0,
|
|
@@ -100,7 +97,6 @@
|
|
| 100 |
"num_hidden_layers": 4,
|
| 101 |
"num_key_value_heads": 1,
|
| 102 |
"num_kv_shared_layers": 2,
|
| 103 |
-
"query_pre_attn_scalar": 256,
|
| 104 |
"rms_norm_eps": 1e-06,
|
| 105 |
"rope_local_base_freq": 10000.0,
|
| 106 |
"rope_scaling": null,
|
|
@@ -115,7 +111,7 @@
|
|
| 115 |
"transformers_version": "4.54.0.dev0",
|
| 116 |
"vision_config": {
|
| 117 |
"architecture": "mobilenetv5_300m_enc",
|
| 118 |
-
"do_pooling":
|
| 119 |
"hidden_size": 2048,
|
| 120 |
"initializer_range": 0.02,
|
| 121 |
"label_names": [
|
|
|
|
| 10 |
"conf_conv_kernel_size": 5,
|
| 11 |
"conf_num_attention_heads": 2,
|
| 12 |
"conf_num_hidden_layers": 2,
|
|
|
|
| 13 |
"conf_reduction_factor": 4,
|
| 14 |
"conf_residual_weight": 0.5,
|
| 15 |
"gradient_clipping": 10000000000.0,
|
|
|
|
| 21 |
128,
|
| 22 |
32
|
| 23 |
],
|
|
|
|
| 24 |
"sscp_conv_group_norm_eps": 0.001,
|
| 25 |
"sscp_conv_kernel_size": [
|
| 26 |
[
|
|
|
|
| 69 |
"altup_active_idx": 0,
|
| 70 |
"altup_coef_clip": 120.0,
|
| 71 |
"altup_correct_scale": true,
|
|
|
|
| 72 |
"altup_num_inputs": 4,
|
| 73 |
"attention_bias": false,
|
| 74 |
"attention_dropout": 0.0,
|
|
|
|
| 97 |
"num_hidden_layers": 4,
|
| 98 |
"num_key_value_heads": 1,
|
| 99 |
"num_kv_shared_layers": 2,
|
|
|
|
| 100 |
"rms_norm_eps": 1e-06,
|
| 101 |
"rope_local_base_freq": 10000.0,
|
| 102 |
"rope_scaling": null,
|
|
|
|
| 111 |
"transformers_version": "4.54.0.dev0",
|
| 112 |
"vision_config": {
|
| 113 |
"architecture": "mobilenetv5_300m_enc",
|
| 114 |
+
"do_pooling": false,
|
| 115 |
"hidden_size": 2048,
|
| 116 |
"initializer_range": 0.02,
|
| 117 |
"label_names": [
|
preprocessor_config.json
CHANGED
|
@@ -41,7 +41,7 @@
|
|
| 41 |
"processor_class": "Gemma3nProcessor",
|
| 42 |
"resample": 2,
|
| 43 |
"rescale_factor": 0.00392156862745098,
|
| 44 |
-
"return_attention_mask":
|
| 45 |
"return_tensors": null,
|
| 46 |
"sampling_rate": 16000,
|
| 47 |
"size": {
|
|
|
|
| 41 |
"processor_class": "Gemma3nProcessor",
|
| 42 |
"resample": 2,
|
| 43 |
"rescale_factor": 0.00392156862745098,
|
| 44 |
+
"return_attention_mask": true,
|
| 45 |
"return_tensors": null,
|
| 46 |
"sampling_rate": 16000,
|
| 47 |
"size": {
|