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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("tiny-random/gemma-3n") model = AutoModelForMultimodalLM.from_pretrained("tiny-random/gemma-3n", device_map="auto") 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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 filesFiles changed (2)
9 unmodified lines101112131415165 unmodified lines2223242526272842 unmodified lines7172737475767722 unmodified lines1001011021031041051068 unmodified lines1151161171181191201219 unmodified lines"conf_conv_kernel_size": 5,"conf_num_attention_heads": 2,"conf_num_hidden_layers": 2,"conf_positional_bias_size": 256,"conf_reduction_factor": 4,"conf_residual_weight": 0.5,"gradient_clipping": 10000000000.0,5 unmodified lines128,32],"sscp_conv_eps": 0.001,"sscp_conv_group_norm_eps": 0.001,"sscp_conv_kernel_size": [[42 unmodified lines"altup_active_idx": 0,"altup_coef_clip": 120.0,"altup_correct_scale": true,"altup_lr_multiplier": 1.0,"altup_num_inputs": 4,"attention_bias": false,"attention_dropout": 0.0,22 unmodified lines"num_hidden_layers": 4,"num_key_value_heads": 1,"num_kv_shared_layers": 2,"query_pre_attn_scalar": 256,"rms_norm_eps": 1e-06,"rope_local_base_freq": 10000.0,"rope_scaling": null,8 unmodified lines"transformers_version": "4.54.0.dev0","vision_config": {"architecture": "mobilenetv5_300m_enc","do_pooling": true,"hidden_size": 2048,"initializer_range": 0.02,"label_names": [9 unmodified lines1011121314155 unmodified lines21222324252642 unmodified lines69707172737422 unmodified lines9798991001011028 unmodified lines1111121131141151161179 unmodified lines"conf_conv_kernel_size": 5,"conf_num_attention_heads": 2,"conf_num_hidden_layers": 2,"conf_reduction_factor": 4,"conf_residual_weight": 0.5,"gradient_clipping": 10000000000.0,5 unmodified lines128,32],"sscp_conv_group_norm_eps": 0.001,"sscp_conv_kernel_size": [[42 unmodified lines"altup_active_idx": 0,"altup_coef_clip": 120.0,"altup_correct_scale": true,"altup_num_inputs": 4,"attention_bias": false,"attention_dropout": 0.0,22 unmodified lines"num_hidden_layers": 4,"num_key_value_heads": 1,"num_kv_shared_layers": 2,"rms_norm_eps": 1e-06,"rope_local_base_freq": 10000.0,"rope_scaling": null,8 unmodified lines"transformers_version": "4.54.0.dev0","vision_config": {"architecture": "mobilenetv5_300m_enc","do_pooling": false,"hidden_size": 2048,"initializer_range": 0.02,"label_names": [
40 unmodified lines4142434445464740 unmodified lines"processor_class": "Gemma3nProcessor","resample": 2,"rescale_factor": 0.00392156862745098,"return_attention_mask": false,"return_tensors": null,"sampling_rate": 16000,"size": {40 unmodified lines4142434445464740 unmodified lines"processor_class": "Gemma3nProcessor","resample": 2,"rescale_factor": 0.00392156862745098,"return_attention_mask": true,"return_tensors": null,"sampling_rate": 16000,"size": {
config.json+1-5
preprocessor_config.json+1-1