Run this model with HF Jobs
Run yujiepan/gemma-4-e-tiny-random on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/yujiepan/gemma-4-e-tiny-random. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/yujiepan/gemma-4-e-tiny-random on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/yujiepan/gemma-4-e-tiny-random. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/yujiepan/gemma-4-e-tiny-random. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use yujiepan/gemma-4-e-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yujiepan/gemma-4-e-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-4-e-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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("yujiepan/gemma-4-e-tiny-random") model = AutoModelForMultimodalLM.from_pretrained("yujiepan/gemma-4-e-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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yujiepan/gemma-4-e-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-4-e-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-4-e-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-4-e-tiny-random
- SGLang
How to use yujiepan/gemma-4-e-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-4-e-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-4-e-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-4-e-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-4-e-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-4-e-tiny-random with Docker Model Runner:
docker model run hf.co/yujiepan/gemma-4-e-tiny-random
Upload folder using huggingface_hub
Browse filesFiles changed (9)
- .gitattributes+1
- README.mdAdded+384
- chat_template.jinjaAdded+263
- config.jsonAdded+160
- generation_config.jsonAdded+15
- model.safetensorsAdded+3
- processor_config.jsonAdded+75
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+95
32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384---library_name: transformersbase_model:- google/gemma-4-E4B-it---
This tiny model is intended for debugging. It is randomly initialized using the configuration adapted from [google/gemma-4-E4B-it](https://huggingface.co/google/gemma-4-E4B-it).
| File path | Size ||------|------|| model.safetensors | 9.5MB |
### Example usage:
```pythonimport torch
from transformers import pipeline, AutoProcessor, AutoModelForCausalLM
model_id = "yujiepan/gemma-4-e-tiny-random"processor = AutoProcessor.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, dtype=torch.bfloat16, device_map="auto")messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Write a short joke about saving RAM."},]text = processor.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)inputs = processor(text=text, return_tensors="pt").to(model.device)input_len = inputs["input_ids"].shape[-1]outputs = model.generate(**inputs, max_new_tokens=16)response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)print(processor.parse_response(response))```
### Codes to create this repo:
<details><summary>Click to expand</summary>
```pythonimport jsonfrom pathlib import Path
import torch
from huggingface_hub import file_exists, hf_hub_download# from timm.models.mobilenetv5 import decode_arch_deffrom transformers import ( AutoConfig, AutoModelForCausalLM, AutoProcessor, AutoTokenizer, Gemma4ForConditionalGeneration, GenerationConfig, set_seed,)
source_model_id = "google/gemma-4-E4B-it"save_folder = "/tmp/yujiepan/gemma-4-e-tiny-random"
processor = AutoProcessor.from_pretrained(source_model_id)processor.save_pretrained(save_folder)
with open(hf_hub_download(source_model_id, filename='config.json', repo_type='model'), 'r', encoding='utf-8') as f: config_json = json.load(f)
config_json['audio_config'].update({ "num_attention_heads": 2, "num_hidden_layers": 2, "hidden_size": 64, 'output_proj_dims': 32,})config_json['text_config'].update({ "global_head_dim": 64, "head_dim": 32, "hidden_size": 8, "hidden_size_per_layer_input": 2, "intermediate_size": 64, "layer_types": ['sliding_attention', 'full_attention', 'sliding_attention', 'full_attention'], "num_attention_heads": 8, "num_hidden_layers": 4, "num_key_value_heads": 4, "num_kv_shared_layers": 2,})config_json['vision_config'].update({ 'num_hidden_layers': 2, 'hidden_size': 8, 'intermediate_size': 64, 'head_dim': 32, 'global_head_dim': 32, 'num_attention_heads': 4, "num_key_value_heads": 4,})
with open(f"{save_folder}/config.json", "w", encoding='utf-8') as f: json.dump(config_json, f, indent=2)
config = AutoConfig.from_pretrained( save_folder, trust_remote_code=True,)print(config)
torch.set_default_dtype(torch.bfloat16)model = Gemma4ForConditionalGeneration(config)torch.set_default_dtype(torch.float32)if file_exists(filename="generation_config.json", repo_id=source_model_id, repo_type='model'): model.generation_config = GenerationConfig.from_pretrained( source_model_id, trust_remote_code=True, )set_seed(42)model = model.cpu()all_numels = 0for name, p in sorted(model.named_parameters()): all_numels += p.numel()with torch.no_grad(): for name, p in sorted(model.named_parameters()): torch.nn.init.normal_(p, 0, 0.2) print(name, p.shape, f'{p.numel() / all_numels * 100: .4f}%')model.save_pretrained(save_folder)```
</details>
### Printing the model:
<details><summary>Click to expand</summary>
```textGemma4ForConditionalGeneration( (model): Gemma4Model( (language_model): Gemma4TextModel( (embed_tokens): Gemma4TextScaledWordEmbedding(262144, 8, padding_idx=0) (layers): ModuleList( (0): Gemma4TextDecoderLayer( (self_attn): Gemma4TextAttention( (q_norm): Gemma4RMSNorm() (k_norm): Gemma4RMSNorm() (v_norm): Gemma4RMSNorm() (k_proj): Linear(in_features=8, out_features=128, bias=False) (q_proj): Linear(in_features=8, out_features=256, bias=False) (v_proj): Linear(in_features=8, out_features=128, bias=False) (o_proj): Linear(in_features=256, out_features=8, bias=False) ) (mlp): Gemma4TextMLP( (gate_proj): Linear(in_features=8, out_features=64, bias=False) (up_proj): Linear(in_features=8, out_features=64, bias=False) (down_proj): Linear(in_features=64, out_features=8, bias=False) (act_fn): GELUTanh() ) (input_layernorm): Gemma4RMSNorm() (post_attention_layernorm): Gemma4RMSNorm() (pre_feedforward_layernorm): Gemma4RMSNorm() (post_feedforward_layernorm): Gemma4RMSNorm() (act_fn): GELUTanh() (per_layer_input_gate): Linear(in_features=8, out_features=2, bias=False) (per_layer_projection): Linear(in_features=2, out_features=8, bias=False) (post_per_layer_input_norm): Gemma4RMSNorm() ) (1): Gemma4TextDecoderLayer( (self_attn): Gemma4TextAttention( (q_norm): Gemma4RMSNorm() (k_norm): Gemma4RMSNorm() (v_norm): Gemma4RMSNorm() (k_proj): Linear(in_features=8, out_features=256, bias=False) (q_proj): Linear(in_features=8, out_features=512, bias=False) (v_proj): Linear(in_features=8, out_features=256, bias=False) (o_proj): Linear(in_features=512, out_features=8, bias=False) ) (mlp): Gemma4TextMLP( (gate_proj): Linear(in_features=8, out_features=64, bias=False) (up_proj): Linear(in_features=8, out_features=64, bias=False) (down_proj): Linear(in_features=64, out_features=8, bias=False) (act_fn): GELUTanh() ) (input_layernorm): Gemma4RMSNorm() (post_attention_layernorm): Gemma4RMSNorm() (pre_feedforward_layernorm): Gemma4RMSNorm() (post_feedforward_layernorm): Gemma4RMSNorm() (act_fn): GELUTanh() (per_layer_input_gate): Linear(in_features=8, out_features=2, bias=False) (per_layer_projection): Linear(in_features=2, out_features=8, bias=False) (post_per_layer_input_norm): Gemma4RMSNorm() ) (2): Gemma4TextDecoderLayer( (self_attn): Gemma4TextAttention( (q_norm): Gemma4RMSNorm() (k_norm): Gemma4RMSNorm() (v_norm): Gemma4RMSNorm() (k_proj): Linear(in_features=8, out_features=128, bias=False) (q_proj): Linear(in_features=8, out_features=256, bias=False) (v_proj): Linear(in_features=8, out_features=128, bias=False) (o_proj): Linear(in_features=256, out_features=8, bias=False) ) (mlp): Gemma4TextMLP( (gate_proj): Linear(in_features=8, out_features=64, bias=False) (up_proj): Linear(in_features=8, out_features=64, bias=False) (down_proj): Linear(in_features=64, out_features=8, bias=False) (act_fn): GELUTanh() ) (input_layernorm): Gemma4RMSNorm() (post_attention_layernorm): Gemma4RMSNorm() (pre_feedforward_layernorm): Gemma4RMSNorm() (post_feedforward_layernorm): Gemma4RMSNorm() (act_fn): GELUTanh() (per_layer_input_gate): Linear(in_features=8, out_features=2, bias=False) (per_layer_projection): Linear(in_features=2, out_features=8, bias=False) (post_per_layer_input_norm): Gemma4RMSNorm() ) (3): Gemma4TextDecoderLayer( (self_attn): Gemma4TextAttention( (q_norm): Gemma4RMSNorm() (k_norm): Gemma4RMSNorm() (v_norm): Gemma4RMSNorm() (k_proj): Linear(in_features=8, out_features=256, bias=False) (q_proj): Linear(in_features=8, out_features=512, bias=False) (v_proj): Linear(in_features=8, out_features=256, bias=False) (o_proj): Linear(in_features=512, out_features=8, bias=False) ) (mlp): Gemma4TextMLP( (gate_proj): Linear(in_features=8, out_features=64, bias=False) (up_proj): Linear(in_features=8, out_features=64, bias=False) (down_proj): Linear(in_features=64, out_features=8, bias=False) (act_fn): GELUTanh() ) (input_layernorm): Gemma4RMSNorm() (post_attention_layernorm): Gemma4RMSNorm() (pre_feedforward_layernorm): Gemma4RMSNorm() (post_feedforward_layernorm): Gemma4RMSNorm() (act_fn): GELUTanh() (per_layer_input_gate): Linear(in_features=8, out_features=2, bias=False) (per_layer_projection): Linear(in_features=2, out_features=8, bias=False) (post_per_layer_input_norm): Gemma4RMSNorm() ) ) (norm): Gemma4RMSNorm() (rotary_emb): Gemma4TextRotaryEmbedding() (embed_tokens_per_layer): Gemma4TextScaledWordEmbedding(262144, 8, padding_idx=0) (per_layer_model_projection): Linear(in_features=8, out_features=8, bias=False) (per_layer_projection_norm): Gemma4RMSNorm() ) (vision_tower): Gemma4VisionModel( (patch_embedder): Gemma4VisionPatchEmbedder( (input_proj): Linear(in_features=768, out_features=8, bias=False) ) (encoder): Gemma4VisionEncoder( (rotary_emb): Gemma4VisionRotaryEmbedding() (layers): ModuleList( (0-1): 2 x Gemma4VisionEncoderLayer( (self_attn): Gemma4VisionAttention( (q_proj): Gemma4ClippableLinear( (linear): Linear(in_features=8, out_features=128, bias=False) ) (k_proj): Gemma4ClippableLinear( (linear): Linear(in_features=8, out_features=128, bias=False) ) (v_proj): Gemma4ClippableLinear( (linear): Linear(in_features=8, out_features=128, bias=False) ) (o_proj): Gemma4ClippableLinear( (linear): Linear(in_features=128, out_features=8, bias=False) ) (q_norm): Gemma4RMSNorm() (k_norm): Gemma4RMSNorm() (v_norm): Gemma4RMSNorm() ) (mlp): Gemma4VisionMLP( (gate_proj): Gemma4ClippableLinear( (linear): Linear(in_features=8, out_features=64, bias=False) ) (up_proj): Gemma4ClippableLinear( (linear): Linear(in_features=8, out_features=64, bias=False) ) (down_proj): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=8, bias=False) ) (act_fn): GELUTanh() ) (input_layernorm): Gemma4RMSNorm() (post_attention_layernorm): Gemma4RMSNorm() (pre_feedforward_layernorm): Gemma4RMSNorm() (post_feedforward_layernorm): Gemma4RMSNorm() ) ) ) (pooler): Gemma4VisionPooler() ) (embed_vision): Gemma4MultimodalEmbedder( (embedding_projection): Linear(in_features=8, out_features=8, bias=False) (embedding_pre_projection_norm): Gemma4RMSNorm() ) (audio_tower): Gemma4AudioModel( (subsample_conv_projection): Gemma4AudioSubSampleConvProjection( (layer0): Gemma4AudioSubSampleConvProjectionLayer( (conv): Conv2d(1, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False) (norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True) (act): ReLU() ) (layer1): Gemma4AudioSubSampleConvProjectionLayer( (conv): Conv2d(128, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False) (norm): LayerNorm((32,), eps=1e-06, elementwise_affine=True) (act): ReLU() ) (input_proj_linear): Linear(in_features=1024, out_features=64, bias=False) ) (rel_pos_enc): Gemma4AudioRelPositionalEncoding() (layers): ModuleList( (0-1): 2 x Gemma4AudioLayer( (feed_forward1): Gemma4AudioFeedForward( (ffw_layer_1): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=256, bias=False) ) (ffw_layer_2): Gemma4ClippableLinear( (linear): Linear(in_features=256, out_features=64, bias=False) ) (pre_layer_norm): Gemma4RMSNorm() (post_layer_norm): Gemma4RMSNorm() (act_fn): SiLUActivation() ) (feed_forward2): Gemma4AudioFeedForward( (ffw_layer_1): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=256, bias=False) ) (ffw_layer_2): Gemma4ClippableLinear( (linear): Linear(in_features=256, out_features=64, bias=False) ) (pre_layer_norm): Gemma4RMSNorm() (post_layer_norm): Gemma4RMSNorm() (act_fn): SiLUActivation() ) (self_attn): Gemma4AudioAttention( (q_proj): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=64, bias=False) ) (k_proj): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=64, bias=False) ) (v_proj): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=64, bias=False) ) (post): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=64, bias=False) ) (relative_k_proj): Linear(in_features=64, out_features=64, bias=False) ) (lconv1d): Gemma4AudioLightConv1d( (linear_start): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=128, bias=False) ) (linear_end): Gemma4ClippableLinear( (linear): Linear(in_features=64, out_features=64, bias=False) ) (depthwise_conv1d): Gemma4AudioCausalConv1d(64, 64, kernel_size=(5,), stride=(1,), groups=64, bias=False) (pre_layer_norm): Gemma4RMSNorm() (conv_norm): Gemma4RMSNorm() (act_fn): SiLUActivation() ) (norm_pre_attn): Gemma4RMSNorm() (norm_post_attn): Gemma4RMSNorm() (norm_out): Gemma4RMSNorm() ) ) (output_proj): Linear(in_features=64, out_features=32, bias=True) ) (embed_audio): Gemma4MultimodalEmbedder( (embedding_projection): Linear(in_features=32, out_features=8, bias=False) (embedding_pre_projection_norm): Gemma4RMSNorm() ) ) (lm_head): Linear(in_features=8, out_features=262144, bias=False))```
</details>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263{%- macro format_parameters(properties, required) -%} {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%} {%- set ns = namespace(found_first=false) -%} {%- for key, value in properties | dictsort -%} {%- set add_comma = false -%} {%- if key not in standard_keys -%} {%- if ns.found_first %},{% endif -%} {%- set ns.found_first = true -%} {{ key }}:{ {%- if value['description'] -%} description:<|"|>{{ value['description'] }}<|"|> {%- set add_comma = true -%} {%- endif -%} {%- if value['nullable'] %} {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%} nullable:true {%- endif -%} {%- if value['type'] | upper == 'STRING' -%} {%- if value['enum'] -%} {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%} enum:{{ format_argument(value['enum']) }} {%- endif -%} {%- elif value['type'] | upper == 'OBJECT' -%} ,properties:{ {%- if value['properties'] is defined and value['properties'] is mapping -%} {{- format_parameters(value['properties'], value['required'] | default([])) -}} {%- elif value is mapping -%} {{- format_parameters(value, value['required'] | default([])) -}} {%- endif -%} } {%- if value['required'] -%} ,required:[ {%- for item in value['required'] | default([]) -%} <|"|>{{- item -}}<|"|> {%- if not loop.last %},{% endif -%} {%- endfor -%} ] {%- endif -%} {%- elif value['type'] | upper == 'ARRAY' -%} {%- if value['items'] is mapping and value['items'] -%} ,items:{ {%- set ns_items = namespace(found_first=false) -%} {%- for item_key, item_value in value['items'] | dictsort -%} {%- if item_value is not none -%} {%- if ns_items.found_first %},{% endif -%} {%- set ns_items.found_first = true -%} {%- if item_key == 'properties' -%} properties:{ {%- if item_value is mapping -%} {{- format_parameters(item_value, value['items']['required'] | default([])) -}} {%- endif -%} } {%- elif item_key == 'required' -%} required:[ {%- for req_item in item_value -%} <|"|>{{- req_item -}}<|"|> {%- if not loop.last %},{% endif -%} {%- endfor -%} ] {%- elif item_key == 'type' -%} {%- if item_value is string -%} type:{{ format_argument(item_value | upper) }} {%- else -%} type:{{ format_argument(item_value | map('upper') | list) }} {%- endif -%} {%- else -%} {{ item_key }}:{{ format_argument(item_value) }} {%- endif -%} {%- endif -%} {%- endfor -%} } {%- endif -%} {%- endif -%} {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%} type:<|"|>{{ value['type'] | upper }}<|"|>} {%- endif -%} {%- endfor -%}{%- endmacro -%}{%- macro format_function_declaration(tool_data) -%} declaration:{{- tool_data['function']['name'] -}}{description:<|"|>{{- tool_data['function']['description'] -}}<|"|> {%- set params = tool_data['function']['parameters'] -%} {%- if params -%} ,parameters:{ {%- if params['properties'] -%} properties:{ {{- format_parameters(params['properties'], params['required']) -}} }, {%- endif -%} {%- if params['required'] -%} required:[ {%- for item in params['required'] -%} <|"|>{{- item -}}<|"|> {{- ',' if not loop.last -}} {%- endfor -%} ], {%- endif -%} {%- if params['type'] -%} type:<|"|>{{- params['type'] | upper -}}<|"|>} {%- endif -%} {%- endif -%} {%- if 'response' in tool_data['function'] -%} {%- set response_declaration = tool_data['function']['response'] -%} ,response:{ {%- if response_declaration['description'] -%} description:<|"|>{{- response_declaration['description'] -}}<|"|>, {%- endif -%} {%- if response_declaration['type'] | upper == 'OBJECT' -%} type:<|"|>{{- response_declaration['type'] | upper -}}<|"|>} {%- endif -%} {%- endif -%} }{%- endmacro -%}{%- macro format_argument(argument, escape_keys=True) -%} {%- if argument is string -%} {{- '<|"|>' + argument + '<|"|>' -}} {%- elif argument is boolean -%} {{- 'true' if argument else 'false' -}} {%- elif argument is mapping -%} {{- '{' -}} {%- set ns = namespace(found_first=false) -%} {%- for key, value in argument | dictsort -%} {%- if ns.found_first %},{% endif -%} {%- set ns.found_first = true -%} {%- if escape_keys -%} {{- '<|"|>' + key + '<|"|>' -}} {%- else -%} {{- key -}} {%- endif -%} :{{- format_argument(value, escape_keys=escape_keys) -}} {%- endfor -%} {{- '}' -}} {%- elif argument is sequence -%} {{- '[' -}} {%- for item in argument -%} {{- format_argument(item, escape_keys=escape_keys) -}} {%- if not loop.last %},{% endif -%} {%- endfor -%} {{- ']' -}} {%- else -%} {{- argument -}} {%- endif -%}{%- endmacro -%}{%- macro strip_thinking(text) -%} {%- set ns = namespace(result='') -%} {%- for part in text.split('<channel|>') -%} {%- if '<|channel>' in part -%} {%- set ns.result = ns.result + part.split('<|channel>')[0] -%} {%- else -%} {%- set ns.result = ns.result + part -%} {%- endif -%} {%- endfor -%} {{- ns.result | trim -}}{%- endmacro -%}
{%- set ns = namespace(prev_message_type=None) -%}{%- set loop_messages = messages -%}{{ bos_token }}{#- Handle System/Tool Definitions Block -#}{%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%} {{- '<|turn>system\n' -}}
{#- Inject Thinking token at the very top of the FIRST system turn -#} {%- if enable_thinking is defined and enable_thinking -%} {{- '<|think|>' -}} {%- set ns.prev_message_type = 'think' -%} {%- endif -%}
{%- if messages[0]['role'] in ['system', 'developer'] -%} {{- messages[0]['content'] | trim -}} {%- set loop_messages = messages[1:] -%} {%- endif -%}
{%- if tools -%} {%- for tool in tools %} {{- '<|tool>' -}} {{- format_function_declaration(tool) | trim -}} {{- '<tool|>' -}} {%- endfor %} {%- set ns.prev_message_type = 'tool' -%} {%- endif -%}
{{- '<turn|>\n' -}}{%- endif %}
{#- Loop through messages -#}{%- for message in loop_messages -%} {%- set ns.prev_message_type = None -%} {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%} {{- '<|turn>' + role + '\n' }}
{%- if message['tool_calls'] -%} {%- for tool_call in message['tool_calls'] -%} {%- set function = tool_call['function'] -%} {{- '<|tool_call>call:' + function['name'] + '{' -}} {%- if function['arguments'] is mapping -%} {%- set ns_args = namespace(found_first=false) -%} {%- for key, value in function['arguments'] | dictsort -%} {%- if ns_args.found_first %},{% endif -%} {%- set ns_args.found_first = true -%} {{- key -}}:{{- format_argument(value, escape_keys=False) -}} {%- endfor -%} {%- elif function['arguments'] is string -%} {{- function['arguments'] -}} {%- endif -%} {{- '}<tool_call|>' -}} {%- endfor -%} {%- set ns.prev_message_type = 'tool_call' -%} {%- endif -%}
{%- if message['tool_responses'] -%} {#- Tool Response handling -#} {%- for tool_response in message['tool_responses'] -%} {{- '<|tool_response>' -}} {%- if tool_response['response'] is mapping -%} {{- 'response:' + tool_response['name'] | default('unknown') + '{' -}} {%- for key, value in tool_response['response'] | dictsort -%} {{- key -}}:{{- format_argument(value, escape_keys=False) -}} {%- if not loop.last %},{% endif -%} {%- endfor -%} {{- '}' -}} {%- else -%} {{- 'response:' + tool_response['name'] | default('unknown') + '{value:' + format_argument(tool_response['response'], escape_keys=False) + '}' -}} {%- endif -%} {{- '<tool_response|>' -}} {%- endfor -%} {%- set ns.prev_message_type = 'tool_response' -%} {%- endif -%}
{%- if message['content'] is string -%} {%- if role == 'model' -%} {{- strip_thinking(message['content']) -}} {%- else -%} {{- message['content'] | trim -}} {%- endif -%} {%- elif message['content'] is sequence -%} {%- for item in message['content'] -%} {%- if item['type'] == 'text' -%} {%- if role == 'model' -%} {{- strip_thinking(item['text']) -}} {%- else -%} {{- item['text'] | trim -}} {%- endif -%} {%- elif item['type'] == 'image' -%} {{- '\n\n<|image|>\n\n' -}} {%- set ns.prev_message_type = 'image' -%} {%- elif item['type'] == 'audio' -%} {{- '<|audio|>' -}} {%- set ns.prev_message_type = 'audio' -%} {%- elif item['type'] == 'video' -%} {{- '\n\n<|video|>\n\n' -}} {%- set ns.prev_message_type = 'video' -%} {%- endif -%} {%- endfor -%} {%- endif -%}
{%- if not (message['tool_responses'] and not message['content']) -%} {{- '<turn|>\n' -}} {%- endif -%}{%- endfor -%}
{%- if add_generation_prompt -%} {%- if ns.prev_message_type != 'tool_response' -%} {{- '<|turn>model\n' -}} {%- endif -%}{%- endif -%}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160{ "architectures": [ "Gemma4ForConditionalGeneration" ], "audio_config": { "_name_or_path": "", "architectures": null, "attention_chunk_size": 12, "attention_context_left": 13, "attention_context_right": 0, "attention_invalid_logits_value": -1000000000.0, "attention_logit_cap": 50.0, "chunk_size_feed_forward": 0, "conv_kernel_size": 5, "dtype": "bfloat16", "gradient_clipping": 10000000000.0, "hidden_act": "silu", "hidden_size": 64, "id2label": { "0": "LABEL_0", "1": "LABEL_1" }, "initializer_range": 0.02, "is_encoder_decoder": false, "label2id": { "LABEL_0": 0, "LABEL_1": 1 }, "model_type": "gemma4_audio", "num_attention_heads": 2, "num_hidden_layers": 2, "output_attentions": false, "output_hidden_states": false, "output_proj_dims": 32, "problem_type": null, "residual_weight": 0.5, "return_dict": true, "rms_norm_eps": 1e-06, "subsampling_conv_channels": [ 128, 32 ], "use_clipped_linears": true }, "audio_token_id": 258881, "boa_token_id": 256000, "boi_token_id": 255999, "dtype": "bfloat16", "eoa_token_id": 258883, "eoa_token_index": 258883, "eoi_token_id": 258882, "eos_token_id": [ 1, 106 ], "image_token_id": 258880, "initializer_range": 0.02, "model_type": "gemma4", "text_config": { "attention_bias": false, "attention_dropout": 0.0, "attention_k_eq_v": false, "bos_token_id": 2, "dtype": "bfloat16", "enable_moe_block": false, "eos_token_id": 1, "expert_intermediate_size": null, "final_logit_softcapping": 30.0, "global_head_dim": 64, "head_dim": 32, "hidden_activation": "gelu_pytorch_tanh", "hidden_size": 8, "hidden_size_per_layer_input": 2, "initializer_range": 0.02, "intermediate_size": 64, "layer_types": [ "sliding_attention", "full_attention", "sliding_attention", "full_attention" ], "max_position_embeddings": 131072, "model_type": "gemma4_text", "moe_intermediate_size": null, "num_attention_heads": 8, "num_experts": null, "num_global_key_value_heads": null, "num_hidden_layers": 4, "num_key_value_heads": 4, "num_kv_shared_layers": 2, "pad_token_id": 0, "rms_norm_eps": 1e-06, "rope_parameters": { "full_attention": { "partial_rotary_factor": 0.25, "rope_theta": 1000000.0, "rope_type": "proportional" }, "sliding_attention": { "rope_theta": 10000.0, "rope_type": "default" } }, "sliding_window": 512, "tie_word_embeddings": true, "top_k_experts": null, "use_bidirectional_attention": null, "use_cache": true, "use_double_wide_mlp": false, "vocab_size": 262144, "vocab_size_per_layer_input": 262144 }, "tie_word_embeddings": true, "transformers_version": "5.5.0", "video_token_id": 258884, "vision_config": { "_name_or_path": "", "architectures": null, "attention_bias": false, "attention_dropout": 0.0, "chunk_size_feed_forward": 0, "default_output_length": 280, "dtype": "bfloat16", "global_head_dim": 32, "head_dim": 32, "hidden_activation": "gelu_pytorch_tanh", "hidden_size": 8, "id2label": { "0": "LABEL_0", "1": "LABEL_1" }, "initializer_range": 0.02, "intermediate_size": 64, "is_encoder_decoder": false, "label2id": { "LABEL_0": 0, "LABEL_1": 1 }, "max_position_embeddings": 131072, "model_type": "gemma4_vision", "num_attention_heads": 4, "num_hidden_layers": 2, "num_key_value_heads": 4, "output_attentions": false, "output_hidden_states": false, "patch_size": 16, "pooling_kernel_size": 3, "position_embedding_size": 10240, "problem_type": null, "return_dict": true, "rms_norm_eps": 1e-06, "rope_parameters": { "rope_theta": 100.0, "rope_type": "default" }, "standardize": false, "use_clipped_linears": true }, "vision_soft_tokens_per_image": 280}123456789101112131415{ "bos_token_id": 2, "do_sample": true, "eos_token_id": [ 1, 106, 50 ], "pad_token_id": 0, "temperature": 1.0, "top_k": 64, "top_p": 0.95, "transformers_version": "5.5.0", "trust_remote_code": true}123version https://git-lfs.github.com/spec/v1oid sha256:6c2045c91d5ee53e379d6f3c4947b914c36ab4308f708e25858c2eb5bd694bc3size 9483948123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475{ "audio_ms_per_token": 40, "audio_seq_length": 750, "feature_extractor": { "dither": 0.0, "feature_extractor_type": "Gemma4AudioFeatureExtractor", "feature_size": 128, "fft_length": 512, "fft_overdrive": false, "frame_length": 320, "hop_length": 160, "input_scale_factor": 1.0, "max_frequency": 8000.0, "mel_floor": 0.001, "min_frequency": 0.0, "padding_side": "right", "padding_value": 0.0, "per_bin_mean": null, "per_bin_stddev": null, "preemphasis": 0.0, "preemphasis_htk_flavor": true, "return_attention_mask": true, "sampling_rate": 16000 }, "image_processor": { "do_convert_rgb": true, "do_normalize": false, "do_rescale": true, "do_resize": true, "image_mean": [ 0.0, 0.0, 0.0 ], "image_processor_type": "Gemma4ImageProcessor", "image_seq_length": 280, "image_std": [ 1.0, 1.0, 1.0 ], "max_soft_tokens": 280, "patch_size": 16, "pooling_kernel_size": 3, "resample": 3, "rescale_factor": 0.00392156862745098 }, "image_seq_length": 280, "processor_class": "Gemma4Processor", "video_processor": { "do_convert_rgb": true, "do_normalize": true, "do_rescale": true, "do_resize": true, "do_sample_frames": true, "image_mean": [ 0.0, 0.0, 0.0 ], "image_std": [ 1.0, 1.0, 1.0 ], "max_soft_tokens": 70, "num_frames": 32, "patch_size": 16, "pooling_kernel_size": 3, "resample": 3, "rescale_factor": 0.00392156862745098, "return_metadata": false, "video_processor_type": "Gemma4VideoProcessor" }}123version https://git-lfs.github.com/spec/v1oid sha256:cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0fsize 321696261234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495{ "audio_token": "<|audio|>", "backend": "tokenizers", "boa_token": "<|audio>", "boi_token": "<|image>", "bos_token": "<bos>", "eoa_token": "<audio|>", "eoc_token": "<channel|>", "eoi_token": "<image|>", "eos_token": "<eos>", "eot_token": "<turn|>", "escape_token": "<|\"|>", "etc_token": "<tool_call|>", "etd_token": "<tool|>", "etr_token": "<tool_response|>", "extra_special_tokens": [ "<|video|>" ], "image_token": "<|image|>", "is_local": false, "mask_token": "<mask>", "model_max_length": 1000000000000000019884624838656, "model_specific_special_tokens": { "audio_token": "<|audio|>", "boa_token": "<|audio>", "boi_token": "<|image>", "eoa_token": "<audio|>", "eoc_token": "<channel|>", "eoi_token": "<image|>", "eot_token": "<turn|>", "escape_token": "<|\"|>", "etc_token": "<tool_call|>", "etd_token": "<tool|>", "etr_token": "<tool_response|>", "image_token": "<|image|>", "soc_token": "<|channel>", "sot_token": "<|turn>", "stc_token": "<|tool_call>", "std_token": "<|tool>", "str_token": "<|tool_response>", "think_token": "<|think|>" }, "pad_token": "<pad>", "padding_side": "left", "processor_class": "Gemma4Processor", "response_schema": { "properties": { "content": { "type": "string" }, "role": { "const": "assistant" }, "thinking": { "type": "string" }, "tool_calls": { "items": { "properties": { "function": { "properties": { "arguments": { "additionalProperties": {}, "type": "object", "x-parser": "gemma4-tool-call" }, "name": { "type": "string" } }, "type": "object", "x-regex": "call\\:(?P<name>\\w+)(?P<arguments>\\{.*\\})" }, "type": { "const": "function" } }, "type": "object" }, "type": "array", "x-regex-iterator": "<\\|tool_call>(.*?)<tool_call\\|>" } }, "type": "object", "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<content>(?:(?!\\<\\|tool_call\\>)(?!\\<turn\\|\\>).)+)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?:\\<turn\\|\\>)?" }, "soc_token": "<|channel>", "sot_token": "<|turn>", "stc_token": "<|tool_call>", "std_token": "<|tool>", "str_token": "<|tool_response>", "think_token": "<|think|>", "tokenizer_class": "GemmaTokenizer", "unk_token": "<unk>"}.gitattributes+1
README.mdAdded+384
chat_template.jinjaAdded+263
config.jsonAdded+160
generation_config.jsonAdded+15
model.safetensorsAdded+3
processor_config.jsonAdded+75
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+95