Text Generation
Transformers
TensorBoard
Safetensors
gemma3_text
Generated from Trainer
sft
trl
conversational
text-generation-inference
Run this model with HF Jobs
Run hsmehta012/functiongemma-270m-it-simple-tool-calling 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/hsmehta012/functiongemma-270m-it-simple-tool-calling. 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/hsmehta012/functiongemma-270m-it-simple-tool-calling 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/hsmehta012/functiongemma-270m-it-simple-tool-calling. 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/hsmehta012/functiongemma-270m-it-simple-tool-calling. 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 hsmehta012/functiongemma-270m-it-simple-tool-calling with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hsmehta012/functiongemma-270m-it-simple-tool-calling with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hsmehta012/functiongemma-270m-it-simple-tool-calling") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hsmehta012/functiongemma-270m-it-simple-tool-calling") model = AutoModelForCausalLM.from_pretrained("hsmehta012/functiongemma-270m-it-simple-tool-calling", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hsmehta012/functiongemma-270m-it-simple-tool-calling with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hsmehta012/functiongemma-270m-it-simple-tool-calling" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hsmehta012/functiongemma-270m-it-simple-tool-calling", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hsmehta012/functiongemma-270m-it-simple-tool-calling
- SGLang
How to use hsmehta012/functiongemma-270m-it-simple-tool-calling 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 "hsmehta012/functiongemma-270m-it-simple-tool-calling" \ --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": "hsmehta012/functiongemma-270m-it-simple-tool-calling", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "hsmehta012/functiongemma-270m-it-simple-tool-calling" \ --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": "hsmehta012/functiongemma-270m-it-simple-tool-calling", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use hsmehta012/functiongemma-270m-it-simple-tool-calling with Docker Model Runner:
docker model run hf.co/hsmehta012/functiongemma-270m-it-simple-tool-calling
Training in progress, step 40
Browse filesFiles changed (10)
- .gitattributes+1
- README.mdAdded+58
- chat_template.jinjaAdded+279
- config.jsonAdded+62
- generation_config.jsonAdded+15
- model.safetensorsAdded+3
- runs/Aug17_09-34-20_d500e00f3041/events.out.tfevents.1786959260.d500e00f3041.492.0Added+3
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+27
- training_args.binAdded+3
32 unmodified lines33343532 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 -text32 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 -text
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758---base_model: google/functiongemma-270m-itlibrary_name: transformersmodel_name: functiongemma-270m-it-simple-tool-callingtags:- generated_from_trainer- sft- trllicence: license---
# Model Card for functiongemma-270m-it-simple-tool-calling
This model is a fine-tuned version of [google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it).It has been trained using [TRL](https://github.com/huggingface/trl).
## Quick start
```pythonfrom transformers import pipeline
question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"generator = pipeline("text-generation", model="hsmehta012/functiongemma-270m-it-simple-tool-calling", device="cuda")output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]print(output["generated_text"])```
## Training procedure
This model was trained with SFT.
### Framework versions
- TRL: 1.10.0- Transformers: 5.13.1- Pytorch: 2.11.0+cu128- Datasets: 5.0.1- Tokenizers: 0.22.2
## Citations
Cite TRL as: ```bibtex@software{vonwerra2020trl, title = {{TRL: Transformers Reinforcement Learning}}, author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin}, license = {Apache-2.0}, url = {https://github.com/huggingface/trl}, year = {2020}}```123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279{%- 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 -%} {%- if key not in standard_keys -%} {%- if ns.found_first %},{% endif -%} {%- set ns.found_first = true -%} {{- key }}:{description:<escape>{{ value['description'] }}<escape> {%- if value['type'] | upper == 'STRING' -%} {%- if value['enum'] -%} ,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([]) -%} <escape>{{- item -}}<escape> {%- 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 -%} <escape>{{- req_item -}}<escape> {%- 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 -%} ,type:<escape>{{ value['type'] | upper }}<escape>} {%- endif -%} {%- endfor -%}{%- endmacro -%}{% macro format_function_declaration(tool_data) -%}declaration:{{- tool_data['function']['name'] -}}{description:<escape>{{- tool_data['function']['description'] -}}<escape>{%- 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'] -%} <escape>{{- item -}}<escape> {{- ',' if not loop.last -}} {%- endfor -%} ], {%- endif -%} {%- if params['type'] -%} type:<escape>{{- params['type'] | upper -}}<escape>} {%- endif -%}{%- endif -%}}{%- endmacro -%}{% macro format_argument(argument, escape_keys=True) -%}{%- if argument is string -%} {{- '<escape>' + argument + '<escape>' -}}{%- elif argument is boolean -%} {%- if argument -%} {{- 'true' -}} {%- else -%} {{- 'false' -}} {%- endif -%}{%- 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 -%} {{- '<escape>' + key + '<escape>' -}} {%- 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 -%}{{ bos_token }}{%- set ns = namespace(prev_message_type=None) -%}{#- Tool Declarations -#}{%- set loop_messages = messages -%}{%- if tools or messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%} {{- '<start_of_turn>developer\n' -}} {%- if messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%} {%- if messages[0]['content'] is string -%} {{- messages[0]['content'] | trim -}} {%- elif messages[0]['content'] is sequence -%} {%- for item in messages[0]['content'] -%} {%- if item['type'] == 'text' -%} {{- item['text'] | trim -}} {%- endif -%} {%- endfor -%} {%- endif -%} {%- set loop_messages = messages[1:] -%} {%- endif -%} {%- if tools -%} {%- for tool in tools %} {{- '<start_function_declaration>' -}} {{- format_function_declaration(tool) | trim }} {{- '<end_function_declaration>' -}} {%- endfor %} {%- endif -%} {{- '<end_of_turn>\n' }}{%- endif %}{#- Loop through messages. -#}{%- for message in loop_messages -%} {%- if (message['role'] == 'assistant') -%} {#- Rename "assistant" to "model". -#} {%- set role = "model" -%} {%- else -%} {%- set role = message['role'] -%} {%- endif -%} {%- if role != 'tool' -%} {%- if ns.prev_message_type != 'tool_response' -%} {{- '<start_of_turn>' + role + '\n' }} {%- endif -%} {%- set ns.prev_message_type = None -%} {%- if 'content' in message and message['content'] is not none -%} {%- if message['content'] is string -%} {{ message['content'] | trim }} {%- elif message['content'] is sequence -%} {%- for item in message['content'] -%} {%- if item['type'] == 'image' -%} {{ '<start_of_image>' }} {%- elif item['type'] == 'text' -%} {{ item['text'] | trim }} {%- endif -%} {%- endfor -%} {%- else -%} {{ raise_exception("Invalid content type in user/assistant message") }} {%- endif -%} {%- set ns.prev_message_type = 'content' -%} {%- endif -%} {%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls'] is iterable -%} {#- Tool Calls -#} {%- for tool_call in message['tool_calls'] -%} {% set function = tool_call['function'] %} {{- '<start_function_call>call:' + function['name'] + '{' -}} {%- if 'arguments' in function -%} {%- if function['arguments'] is mapping -%} {%- set ns = namespace(found_first=false) -%} {%- for key, value in function['arguments'] | dictsort -%} {%- if ns.found_first %},{% endif -%} {%- set ns.found_first = true -%} {{- key -}}:{{- format_argument(value, escape_keys=False) -}} {%- endfor -%} {%- elif function['arguments'] is string -%} {# This handles string-JSON, just in case #} {{ function['arguments'] }} {%- endif %} {%- endif -%} {{- '}<end_function_call>' -}} {%- endfor -%} {%- if loop.last -%} {{ '<start_function_response>' }} {%- endif -%} {%- set ns.prev_message_type = 'tool_call' -%} {%- endif -%} {%- else -%} {#- Tool Responses -#} {%- if 'content' in message and message['content'] -%} {%- if message['content'] is mapping -%} {%- if 'name' in message['content'] and 'response' in message['content'] -%} {{ '<start_function_response>response:' + message['content']['name'] | trim + '{' }} {%- set response_ns = namespace(found_first=false) -%} {%- for key, value in message['content']['response'] | dictsort -%} {%- if response_ns.found_first %},{% endif -%} {%- set response_ns.found_first = true -%} {{- key -}}:{{- format_argument(value, escape_keys=False) -}} {%- endfor -%} {{- '}<end_function_response>' -}} {%- elif 'name' in message -%} {{ '<start_function_response>response:' + message['name'] | trim + '{' }} {%- set response_ns = namespace(found_first=false) -%} {%- for key, value in message['content'] | dictsort -%} {%- if response_ns.found_first %},{% endif -%} {%- set response_ns.found_first = true -%} {{- key -}}:{{- format_argument(value, escape_keys=False) -}} {%- endfor -%} {{- '}<end_function_response>' -}} {%- else -%} {{ raise_exception("Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.") }} {%- endif -%} {%- elif message['content'] is string -%} {%- if 'name' in message -%} {{ '<start_function_response>response:' + message['name'] | trim + '{value:' + format_argument(message['content'], escape_keys=False) + '}<end_function_response>' }} {%- else -%} {{ raise_exception("Invalid tool response: 'name' must be provided.") }} {%- endif -%} {%- elif message['content'] is sequence -%} {%- for item in message['content'] -%} {%- if item is mapping -%} {%- if 'name' in item and 'response' in item -%} {{ '<start_function_response>response:' + item['name'] | trim + '{' }} {%- set response_ns = namespace(found_first=false) -%} {%- for key, value in item['response'] | dictsort -%} {%- if response_ns.found_first %},{% endif -%} {%- set response_ns.found_first = true -%} {{- key -}}:{{- format_argument(value, escape_keys=False) -}} {%- endfor -%} {{- '}<end_function_response>' -}} {%- elif 'name' in message -%} {{ '<start_function_response>response:' + message['name'] | trim + '{' }} {%- set response_ns = namespace(found_first=false) -%} {%- for key, value in item | dictsort -%} {%- if response_ns.found_first %},{% endif -%} {%- set response_ns.found_first = true -%} {{- key -}}:{{- format_argument(value, escape_keys=False) -}} {%- endfor -%} {{- '}<end_function_response>' -}} {%- else -%} {{ raise_exception("Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.") }} {%- endif -%} {%- else -%} {{ raise_exception("Invalid tool response message: multiple responses must all be mappings") }} {%- endif -%} {%- endfor -%} {%- else -%} {{ raise_exception("Invalid content type in tool message: must be mapping, sequence of mappings, or string.") }} {%- endif -%} {%- endif -%} {%- set ns.prev_message_type = 'tool_response' -%} {%- endif -%} {%- if ns.prev_message_type not in ['tool_call', 'tool_response'] -%} {{ '<end_of_turn>\n' }} {%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%} {%- if ns.prev_message_type != 'tool_response' -%} {{- '<start_of_turn>model\n' -}} {%- endif -%}{%- endif -%}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162{ "_sliding_window_pattern": 6, "architectures": [ "Gemma3ForCausalLM" ], "attention_bias": false, "attention_dropout": 0.0, "attn_logit_softcapping": null, "bos_token_id": 2, "dtype": "bfloat16", "eos_token_id": 1, "final_logit_softcapping": null, "head_dim": 256, "hidden_activation": "gelu_pytorch_tanh", "hidden_size": 640, "initializer_range": 0.02, "intermediate_size": 2048, "layer_types": [ "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention" ], "max_position_embeddings": 32768, "model_type": "gemma3_text", "num_attention_heads": 4, "num_hidden_layers": 18, "num_key_value_heads": 1, "pad_token_id": 0, "query_pre_attn_scalar": 256, "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, "transformers_version": "5.13.1", "use_bidirectional_attention": false, "use_cache": false, "vocab_size": 262144}123456789101112131415{ "bos_token_id": 2, "cache_implementation": "hybrid", "do_sample": true, "eos_token_id": [ 1, 1, 50, 106 ], "pad_token_id": 0, "top_k": 64, "top_p": 0.95, "transformers_version": "5.13.1"}123version https://git-lfs.github.com/spec/v1oid sha256:01378233009d32cde09a5f6d133384c2a3eb8199ce4c54d085dd02fc58ce9e4fsize 536223056123version https://git-lfs.github.com/spec/v1oid sha256:3e6c92026423a5f9d3e4e819adb976ee39ec445464c2a3a0456adeafab6109e0size 23779123version https://git-lfs.github.com/spec/v1oid sha256:80d7f800b949accd7eb940bac75e642f9468e4df157403032a55bf54ed23b650size 33384898123456789101112131415161718192021222324252627{ "backend": "tokenizers", "boi_token": "<start_of_image>", "bos_token": "<bos>", "clean_up_tokenization_spaces": false, "eoi_token": "<end_of_image>", "eos_token": "<eos>", "image_token": "<image_soft_token>", "is_local": false, "local_files_only": false, "mask_token": "<mask>", "model_max_length": 1000000000000000019884624838656, "model_specific_special_tokens": { "boi_token": "<start_of_image>", "eoi_token": "<end_of_image>", "image_token": "<image_soft_token>", "sfr_token": "<start_function_response>" }, "pad_token": "<pad>", "padding_side": "left", "sfr_token": "<start_function_response>", "sp_model_kwargs": null, "spaces_between_special_tokens": false, "tokenizer_class": "GemmaTokenizer", "unk_token": "<unk>", "use_default_system_prompt": false}123version https://git-lfs.github.com/spec/v1oid sha256:0e9053791a24ddf0a513de13c47d639996f9a24c75d67a470ed60af467f3ddd4size 5713.gitattributes+1
README.mdAdded+58
chat_template.jinjaAdded+279
config.jsonAdded+62
generation_config.jsonAdded+15
model.safetensorsAdded+3
runs/Aug17_09-34-20_d500e00f3041/events.out.tfevents.1786959260.d500e00f3041.492.0Added+3
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+27
training_args.binAdded+3