Instructions to use yujiepan/gemma-3-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yujiepan/gemma-3-tiny-random with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="yujiepan/gemma-3-tiny-random") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("yujiepan/gemma-3-tiny-random") model = AutoModelForMultimodalLM.from_pretrained("yujiepan/gemma-3-tiny-random", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yujiepan/gemma-3-tiny-random with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yujiepan/gemma-3-tiny-random" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yujiepan/gemma-3-tiny-random", "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/yujiepan/gemma-3-tiny-random
- SGLang
How to use yujiepan/gemma-3-tiny-random 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 "yujiepan/gemma-3-tiny-random" \ --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": "yujiepan/gemma-3-tiny-random", "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 "yujiepan/gemma-3-tiny-random" \ --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": "yujiepan/gemma-3-tiny-random", "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 yujiepan/gemma-3-tiny-random with Docker Model Runner:
docker model run hf.co/yujiepan/gemma-3-tiny-random
Upload folder using huggingface_hub
Browse files- README.md +3 -0
- config.json +1 -1
README.md
CHANGED
|
@@ -69,6 +69,7 @@ config.text_config.head_dim = 32
|
|
| 69 |
config.text_config.num_attention_heads = 1
|
| 70 |
config.text_config.num_key_value_heads = 1
|
| 71 |
config.text_config.num_hidden_layers = 2
|
|
|
|
| 72 |
config.vision_config.hidden_size = 32
|
| 73 |
config.vision_config.num_hidden_layers = 2
|
| 74 |
config.vision_config.num_attention_heads = 1
|
|
@@ -76,6 +77,8 @@ config.vision_config.intermediate_size = 128
|
|
| 76 |
model = Gemma3ForConditionalGeneration(
|
| 77 |
config,
|
| 78 |
).to(torch.bfloat16)
|
|
|
|
|
|
|
| 79 |
model.generation_config = GenerationConfig.from_pretrained(
|
| 80 |
source_model_id, trust_remote_code=True,
|
| 81 |
)
|
|
|
|
| 69 |
config.text_config.num_attention_heads = 1
|
| 70 |
config.text_config.num_key_value_heads = 1
|
| 71 |
config.text_config.num_hidden_layers = 2
|
| 72 |
+
config.text_config.sliding_window_pattern = 2
|
| 73 |
config.vision_config.hidden_size = 32
|
| 74 |
config.vision_config.num_hidden_layers = 2
|
| 75 |
config.vision_config.num_attention_heads = 1
|
|
|
|
| 77 |
model = Gemma3ForConditionalGeneration(
|
| 78 |
config,
|
| 79 |
).to(torch.bfloat16)
|
| 80 |
+
for layer in model.language_model.model.layers:
|
| 81 |
+
print(layer.is_sliding)
|
| 82 |
model.generation_config = GenerationConfig.from_pretrained(
|
| 83 |
source_model_id, trust_remote_code=True,
|
| 84 |
)
|
config.json
CHANGED
|
@@ -37,7 +37,7 @@
|
|
| 37 |
},
|
| 38 |
"rope_theta": 1000000.0,
|
| 39 |
"sliding_window": 1024,
|
| 40 |
-
"sliding_window_pattern":
|
| 41 |
"use_cache": true,
|
| 42 |
"vocab_size": 262208
|
| 43 |
},
|
|
|
|
| 37 |
},
|
| 38 |
"rope_theta": 1000000.0,
|
| 39 |
"sliding_window": 1024,
|
| 40 |
+
"sliding_window_pattern": 2,
|
| 41 |
"use_cache": true,
|
| 42 |
"vocab_size": 262208
|
| 43 |
},
|