Yagna1 commited on
Commit
9ccf60b
·
verified ·
1 Parent(s): 4cecc0f

Mirror of JackJ1/functiongemma-270m-it-mobile-actions-litertlm

Browse files
.gitattributes CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ mobile-actions_q8_ekv1024.litertlm filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,64 +1,36 @@
1
- ---
2
- language: en
3
- license: apache-2.0
4
- tags:
5
- - text-generation
6
- - function-calling
7
- - gemma
8
- - instruction-tuning
9
- - mobile
10
- pipeline_tag: text-generation
11
- library_name: transformers
12
- datasets:
13
- - google/mobile-actions
14
- model-index:
15
- - name: functiongemma-270m-mobile-actions
16
- results:
17
- - task:
18
- type: text-generation
19
- dataset:
20
- name: Google Mobile Actions
21
- type: google/mobile-actions
22
- metrics:
23
- - name: training-loss
24
- type: loss
25
- value: 0.0
26
- ---
27
-
28
- # FunctionGemma 270M – Mobile Actions Fine-Tuned
29
-
30
- ## 🔍 Overview
31
 
32
- FunctionGemma 270M is a fine-tuned version of Gemma-3 optimized for **mobile function-calling tasks** such as reminders, alarms, and scheduling.
33
- This repository includes the merged model weights and mobile artifacts for on-device deployment.
34
 
35
- ## 📁 Contents
 
36
 
37
- - `functiongemma-merged/` — merged weights + model config
38
- - `mobile/` — converted mobile assets (TFLite, `.task`, tokenizer)
39
-
40
- ## 🚀 Intended Use
41
 
42
- - On-device text generation and function-calling workflows
43
- - Mobile applications requiring low-latency inference
44
- - Integration with **MediaPipe/Edge Gallery AI**
45
 
46
- ## Limitations
 
 
 
 
 
 
47
 
48
- - Performance may vary outside the mobile actions domain
49
- - Not intended for high-risk automated decision-making
50
- - Biases from the training data may persist
51
 
52
- ## 📦 How to Use (Python)
 
 
 
 
 
 
 
 
53
 
54
- ```python
55
- from transformers import AutoModelForCausalLM, AutoTokenizer
56
 
57
- model_id = "Yagna1/functiongemma-270m-mobile-actions"
58
- model = AutoModelForCausalLM.from_pretrained(model_id)
59
- tokenizer = AutoTokenizer.from_pretrained(model_id)
60
 
61
- input_text = "Set a reminder for 7 AM"
62
- inputs = tokenizer(input_text, return_tensors="pt")
63
- outputs = model.generate(**inputs, max_new_tokens=128)
64
- print(tokenizer.decode(outputs[0]))
 
1
+ # functiongemma-270m-mobile-actions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ FunctionGemma 270M fine-tuned for Mobile Actions with LiteRT-LM.
 
4
 
5
+ **Original Model**: [JackJ1/functiongemma-270m-it-mobile-actions-litertlm](https://huggingface.co/JackJ1/functiongemma-270m-it-mobile-actions-litertlm)
6
+ **Credit**: JackJ1 for the original fine-tuning work.
7
 
8
+ ---
 
 
 
9
 
10
+ ## Quick Start
 
 
11
 
12
+ 1. Download `mobile-actions_q8_ekv1024.litertlm`
13
+ 2. Import into [Google AI Edge Gallery](https://github.com/google-ai-edge/gallery) app
14
+ 3. Enable "Mobile Actions" feature
15
+ 4. Test with prompts like:
16
+ - "Turn on flashlight"
17
+ - "Create contact John Doe"
18
+ - "Show Times Square on map"
19
 
20
+ ## Original README
 
 
21
 
22
+ ---
23
+ base_model: google/functiongemma-270m-it
24
+ tags:
25
+ - function-calling
26
+ - mobile-actions
27
+ - gemma
28
+ - .litertlm
29
+ ---
30
+ A fine-tuned model based on `google/functiongemma-270m-it`.
31
 
32
+ With "mobile-actions_q8_ekv1024.litertlm" included.
 
33
 
34
+ You can download and use it in "Mobile Actions" from Google AI Edge Gallery directly.
 
 
35
 
36
+ Enjoy :)
 
 
 
chat_template.jinja CHANGED
@@ -139,9 +139,6 @@ declaration:{{- tool_data['function']['name'] -}}
139
  {%- endfor -%}
140
  {%- endif -%}
141
  {%- set loop_messages = messages[1:] -%}
142
- {%- else -%}
143
- {{- 'You are a model that can do function calling with the following functions' -}}
144
- {%- set loop_messages = messages -%}
145
  {%- endif -%}
146
  {%- if tools -%}
147
  {%- for tool in tools %}
 
139
  {%- endfor -%}
140
  {%- endif -%}
141
  {%- set loop_messages = messages[1:] -%}
 
 
 
142
  {%- endif -%}
143
  {%- if tools -%}
144
  {%- for tool in tools %}
config.json CHANGED
@@ -7,8 +7,8 @@
7
  "attention_dropout": 0.0,
8
  "attn_logit_softcapping": null,
9
  "bos_token_id": 2,
10
- "torch_dtype": "bfloat16",
11
- "eos_token_id": 106,
12
  "final_logit_softcapping": null,
13
  "head_dim": 256,
14
  "hidden_activation": "gelu_pytorch_tanh",
@@ -44,13 +44,10 @@
44
  "query_pre_attn_scalar": 256,
45
  "rms_norm_eps": 1e-06,
46
  "rope_local_base_freq": 10000.0,
47
- "rope_parameters": null,
48
  "rope_scaling": null,
49
  "rope_theta": 1000000.0,
50
  "sliding_window": 512,
51
- "transformers_version": "4.57.3",
52
- "unsloth_fixed": true,
53
- "unsloth_version": "2025.12.7",
54
  "use_bidirectional_attention": false,
55
  "use_cache": true,
56
  "vocab_size": 262144
 
7
  "attention_dropout": 0.0,
8
  "attn_logit_softcapping": null,
9
  "bos_token_id": 2,
10
+ "dtype": "float32",
11
+ "eos_token_id": 1,
12
  "final_logit_softcapping": null,
13
  "head_dim": 256,
14
  "hidden_activation": "gelu_pytorch_tanh",
 
44
  "query_pre_attn_scalar": 256,
45
  "rms_norm_eps": 1e-06,
46
  "rope_local_base_freq": 10000.0,
 
47
  "rope_scaling": null,
48
  "rope_theta": 1000000.0,
49
  "sliding_window": 512,
50
+ "transformers_version": "4.57.1",
 
 
51
  "use_bidirectional_attention": false,
52
  "use_cache": true,
53
  "vocab_size": 262144
generation_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "cache_implementation": "hybrid",
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 1,
7
+ 1,
8
+ 50,
9
+ 106
10
+ ],
11
+ "pad_token_id": 0,
12
+ "top_k": 64,
13
+ "top_p": 0.95,
14
+ "transformers_version": "4.57.1"
15
+ }
mobile-actions_q8_ekv1024.litertlm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:510c8257d1f9d12b5be630b5d6a593732e10896e9ee0b3f3d20b2eebff8e1b13
3
+ size 284426240
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:dde266a469471fd2e4c814e82fd87ca5827f07d8fc0c5b1a8243a93448e64b37
3
- size 536223056
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b964ff53e84a6485037e6054502dfe96503dad8773aa132c6e193a605b9547b8
3
+ size 1072419256
special_tokens_map.json CHANGED
@@ -9,7 +9,7 @@
9
  },
10
  "eoi_token": "<end_of_image>",
11
  "eos_token": {
12
- "content": "<end_of_turn>",
13
  "lstrip": false,
14
  "normalized": false,
15
  "rstrip": false,
 
9
  },
10
  "eoi_token": "<end_of_image>",
11
  "eos_token": {
12
+ "content": "<eos>",
13
  "lstrip": false,
14
  "normalized": false,
15
  "rstrip": false,
tokenizer_config.json CHANGED
@@ -51335,7 +51335,7 @@
51335
  "bos_token": "<bos>",
51336
  "clean_up_tokenization_spaces": false,
51337
  "eoi_token": "<end_of_image>",
51338
- "eos_token": "<end_of_turn>",
51339
  "extra_special_tokens": {
51340
  "boi_token": "<start_of_image>",
51341
  "eoi_token": "<end_of_image>",
@@ -51343,7 +51343,7 @@
51343
  "sfr_token": "<start_function_response>"
51344
  },
51345
  "image_token": "<image_soft_token>",
51346
- "model_max_length": 32768,
51347
  "pad_token": "<pad>",
51348
  "padding_side": "left",
51349
  "sfr_token": "<start_function_response>",
@@ -51351,6 +51351,5 @@
51351
  "spaces_between_special_tokens": false,
51352
  "tokenizer_class": "GemmaTokenizer",
51353
  "unk_token": "<unk>",
51354
- "use_default_system_prompt": false,
51355
- "chat_template": "{%- macro format_parameters(properties, required) -%}\n {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in properties | dictsort -%}\n {%- if key not in standard_keys -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {{- key }}:{description:<escape>{{ value['description'] }}<escape>\n {%- if value['type'] | upper == 'STRING' -%}\n {%- if value['enum'] -%}\n ,enum:{{ format_argument(value['enum']) }}\n {%- endif -%}\n {%- elif value['type'] | upper == 'OBJECT' -%}\n ,properties:{\n {%- if value['properties'] is defined and value['properties'] is mapping -%}\n {{- format_parameters(value['properties'], value['required'] | default([])) -}}\n {%- elif value is mapping -%}\n {{- format_parameters(value, value['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- if value['required'] -%}\n ,required:[\n {%- for item in value['required'] | default([]) -%}\n <escape>{{- item -}}<escape>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- endif -%}\n {%- elif value['type'] | upper == 'ARRAY' -%}\n {%- if value['items'] is mapping and value['items'] -%}\n ,items:{\n {%- set ns_items = namespace(found_first=false) -%}\n {%- for item_key, item_value in value['items'] | dictsort -%}\n {%- if item_value is not none -%}\n {%- if ns_items.found_first %},{% endif -%}\n {%- set ns_items.found_first = true -%}\n {%- if item_key == 'properties' -%}\n properties:{\n {%- if item_value is mapping -%}\n {{- format_parameters(item_value, value['items']['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- elif item_key == 'required' -%}\n required:[\n {%- for req_item in item_value -%}\n <escape>{{- req_item -}}<escape>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- elif item_key == 'type' -%}\n {%- if item_value is string -%}\n type:{{ format_argument(item_value | upper) }}\n {%- else -%}\n type:{{ format_argument(item_value | map('upper') | list) }}\n {%- endif -%}\n {%- else -%}\n {{ item_key }}:{{ format_argument(item_value) }}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n }\n {%- endif -%}\n {%- endif -%}\n ,type:<escape>{{ value['type'] | upper }}<escape>}\n {%- endif -%}\n {%- endfor -%}\n{%- endmacro -%}\n{% macro format_function_declaration(tool_data) -%}\ndeclaration:{{- tool_data['function']['name'] -}}\n{description:<escape>{{- tool_data['function']['description'] -}}<escape>\n{%- set params = tool_data['function']['parameters'] -%}\n{%- if params -%}\n ,parameters:{\n {%- if params['properties'] -%}\n properties:{ {{- format_parameters(params['properties'], params['required']) -}} },\n {%- endif -%}\n {%- if params['required'] -%}\n required:[\n {%- for item in params['required'] -%}\n <escape>{{- item -}}<escape>\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n ],\n {%- endif -%}\n {%- if params['type'] -%}\n type:<escape>{{- params['type'] | upper -}}<escape>}\n {%- endif -%}\n{%- endif -%}\n}\n{%- endmacro -%}\n{% macro format_argument(argument, escape_keys=True) -%}\n{%- if argument is string -%}\n {{- '<escape>' + argument + '<escape>' -}}\n{%- elif argument is boolean -%}\n {%- if argument -%}\n {{- 'true' -}}\n {%- else -%}\n {{- 'false' -}}\n {%- endif -%}\n{%- elif argument is mapping -%}\n {{- '{' -}}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in argument | dictsort -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {%- if escape_keys -%}\n {{- '<escape>' + key + '<escape>' -}}\n {%- else -%}\n {{- key -}}\n {%- endif -%}\n :{{- format_argument(value, escape_keys=escape_keys) -}}\n {%- endfor -%}\n {{- '}' -}}\n{%- elif argument is sequence -%}\n {{- '[' -}}\n {%- for item in argument -%}\n {{- format_argument(item, escape_keys=escape_keys) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- ']' -}}\n{%- else -%}\n {{- argument -}}\n{%- endif -%}\n{%- endmacro -%}\n{{ bos_token }}\n{%- set ns = namespace(prev_message_type=None) -%}\n{#- Tool Declarations -#}\n{%- set loop_messages = messages -%}\n{%- if tools or messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}\n {{- '<start_of_turn>developer\\n' -}}\n {%- if messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}\n {%- if messages[0]['content'] is string -%}\n {{- messages[0]['content'] | trim -}}\n {%- elif messages[0]['content'] is sequence -%}\n {%- for item in messages[0]['content'] -%}\n {%- if item['type'] == 'text' -%}\n {{- item['text'] | trim -}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {%- set loop_messages = messages[1:] -%}\n {%- else -%}\n {{- 'You are a model that can do function calling with the following functions' -}}\n {%- set loop_messages = messages -%}\n {%- endif -%}\n {%- if tools -%}\n {%- for tool in tools %}\n {{- '<start_function_declaration>' -}}\n {{- format_function_declaration(tool) | trim }}\n {{- '<end_function_declaration>' -}}\n {%- endfor %}\n {%- endif -%}\n {{- '<end_of_turn>\\n' }}\n{%- endif %}\n{#- Loop through messages. -#}\n{%- for message in loop_messages -%}\n {%- if (message['role'] == 'assistant') -%}\n {#- Rename \"assistant\" to \"model\". -#}\n {%- set role = \"model\" -%}\n {%- else -%}\n {%- set role = message['role'] -%}\n {%- endif -%}\n {%- if role != 'tool' -%}\n {%- if ns.prev_message_type != 'tool_response' -%}\n {{- '<start_of_turn>' + role + '\\n' }}\n {%- endif -%}\n {%- set ns.prev_message_type = None -%}\n {%- if 'content' in message and message['content'] is not none -%}\n {%- if message['content'] is string -%}\n {{ message['content'] | trim }}\n {%- elif message['content'] is sequence -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'image' -%}\n {{ '<start_of_image>' }}\n {%- elif item['type'] == 'text' -%}\n {{ item['text'] | trim }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ raise_exception(\"Invalid content type in user/assistant message\") }}\n {%- endif -%}\n {%- set ns.prev_message_type = 'content' -%}\n {%- endif -%}\n {%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls'] is iterable -%}\n {#- Tool Calls -#}\n {%- for tool_call in message['tool_calls'] -%}\n {% set function = tool_call['function'] %}\n {{- '<start_function_call>call:' + function['name'] + '{' -}}\n {%- if 'arguments' in function -%}\n {%- if function['arguments'] is mapping -%}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in function['arguments'] | dictsort -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {%- elif function['arguments'] is string -%}\n {# This handles string-JSON, just in case #}\n {{ function['arguments'] }}\n {%- endif %}\n {%- endif -%}\n {{- '}<end_function_call>' -}}\n {%- endfor -%}\n {%- if loop.last -%}\n {{ '<start_function_response>' }}\n {%- endif -%}\n {%- set ns.prev_message_type = 'tool_call' -%}\n {%- endif -%}\n {%- else -%}\n {#- Tool Responses -#}\n {%- if 'content' in message and message['content'] -%}\n {%- if message['content'] is mapping -%}\n {%- if 'name' in message['content'] and 'response' in message['content'] -%}\n {{ '<start_function_response>response:' + message['content']['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in message['content']['response'] | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- elif 'name' in message -%}\n {{ '<start_function_response>response:' + message['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in message['content'] | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.\") }}\n {%- endif -%}\n {%- elif message['content'] is string -%}\n {%- if 'name' in message -%}\n {{ '<start_function_response>response:' + message['name'] | trim + '{value:' + format_argument(message['content'], escape_keys=False) + '}<end_function_response>' }}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response: 'name' must be provided.\") }}\n {%- endif -%}\n {%- elif message['content'] is sequence -%}\n {%- for item in message['content'] -%}\n {%- if item is mapping -%}\n {%- if 'name' in item and 'response' in item -%}\n {{ '<start_function_response>response:' + item['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in item['response'] | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- elif 'name' in message -%}\n {{ '<start_function_response>response:' + message['name'] | trim + '{' }}\n {%- set response_ns = namespace(found_first=false) -%}\n {%- for key, value in item | dictsort -%}\n {%- if response_ns.found_first %},{% endif -%}\n {%- set response_ns.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {{- '}<end_function_response>' -}}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.\") }}\n {%- endif -%}\n {%- else -%}\n {{ raise_exception(\"Invalid tool response message: multiple responses must all be mappings\") }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ raise_exception(\"Invalid content type in tool message: must be mapping, sequence of mappings, or string.\") }}\n {%- endif -%}\n {%- endif -%}\n {%- set ns.prev_message_type = 'tool_response' -%}\n {%- endif -%}\n {%- if ns.prev_message_type not in ['tool_call', 'tool_response'] -%}\n {{ '<end_of_turn>\\n' }}\n {%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {%- if ns.prev_message_type != 'tool_response' -%}\n {{- '<start_of_turn>model\\n' -}}\n {%- endif -%}\n{%- endif -%}\n"
51356
- }
 
51335
  "bos_token": "<bos>",
51336
  "clean_up_tokenization_spaces": false,
51337
  "eoi_token": "<end_of_image>",
51338
+ "eos_token": "<eos>",
51339
  "extra_special_tokens": {
51340
  "boi_token": "<start_of_image>",
51341
  "eoi_token": "<end_of_image>",
 
51343
  "sfr_token": "<start_function_response>"
51344
  },
51345
  "image_token": "<image_soft_token>",
51346
+ "model_max_length": 1000000000000000019884624838656,
51347
  "pad_token": "<pad>",
51348
  "padding_side": "left",
51349
  "sfr_token": "<start_function_response>",
 
51351
  "spaces_between_special_tokens": false,
51352
  "tokenizer_class": "GemmaTokenizer",
51353
  "unk_token": "<unk>",
51354
+ "use_default_system_prompt": false
51355
+ }