Roman0 commited on
Commit
93ba3ac
·
verified ·
1 Parent(s): 3fea153

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +592 -589
README.md CHANGED
@@ -1,589 +1,592 @@
1
- ---
2
- license: gemma
3
- tags:
4
- - gemma3
5
- - gemma
6
- - google
7
- - functiongemma
8
- - heretic
9
- - uncensored
10
- - decensored
11
- - abliterated
12
- pipeline_tag: text-generation
13
- library_name: transformers
14
- extra_gated_heading: Access Gemma on Hugging Face
15
- extra_gated_prompt: To access FunctionGemma on Hugging Face, you’re required to review
16
- and agree to Google’s usage license. To do this, please ensure you’re logged in
17
- to Hugging Face and click below. Requests are processed immediately.
18
- extra_gated_button_content: Acknowledge license
19
- ---
20
- # This is a decensored version of [google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it), made using [Heretic](https://github.com/p-e-w/heretic) v1.1.0
21
-
22
- ## Abliteration parameters
23
-
24
- | Parameter | Value |
25
- | :-------- | :---: |
26
- | **direction_index** | per layer |
27
- | **attn.o_proj.max_weight** | 1.33 |
28
- | **attn.o_proj.max_weight_position** | 12.65 |
29
- | **attn.o_proj.min_weight** | 0.85 |
30
- | **attn.o_proj.min_weight_distance** | 4.36 |
31
- | **mlp.down_proj.max_weight** | 1.46 |
32
- | **mlp.down_proj.max_weight_position** | 12.22 |
33
- | **mlp.down_proj.min_weight** | 1.40 |
34
- | **mlp.down_proj.min_weight_distance** | 4.97 |
35
-
36
- ## Performance
37
-
38
- | Metric | This model | Original model ([google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it)) |
39
- | :----- | :--------: | :---------------------------: |
40
- | **KL divergence** | 0.2617 | 0 *(by definition)* |
41
- | **Refusals** | 2/100 | 100/100 |
42
-
43
- -----
44
-
45
-
46
- # FunctionGemma model card
47
-
48
- **Model Page**: [FunctionGemma](https://ai.google.dev/gemma/docs/functiongemma)
49
-
50
- **Resources and Technical Documentation**:
51
-
52
- - [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)
53
- - [FunctionGemma on Kaggle](https://www.kaggle.com/models/google/functiongemma/)
54
- - [FunctionGemma on Vertex Model Garden](https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/functiongemma)
55
-
56
- **Terms of Use**: [Terms](https://ai.google.dev/gemma/terms)\
57
- **Authors**: Google DeepMind
58
-
59
- ## Model Information
60
-
61
- Summary description and brief definition of inputs and outputs.
62
-
63
- ### Description
64
-
65
- > [!Note]
66
- > FunctionGemma is intended to be fine-tuned for your specific function-calling task, including multi-turn use cases.
67
-
68
-
69
- FunctionGemma is a lightweight, open model from Google, built as a foundation
70
- for creating your own specialized function calling models. FunctionGemma is not
71
- intended for use as a direct dialogue model, and is designed to be highly
72
- performant after further fine-tuning, as is typical of models this size. Built
73
- on the Gemma 3 270M model and with the same research and technology used to
74
- create the Gemini models, FunctionGemma has been trained specifically for
75
- function calling. The model has the same architecture as Gemma 3, but uses a
76
- different chat format. The model is well suited for text-only function calling.
77
- The uniquely small size makes it possible to deploy in environments with limited
78
- resources such as laptops, desktops or your own cloud infrastructure,
79
- democratizing access to state of the art AI models and helping foster innovation
80
- for everyone. Furthermore, akin to the base Gemma 270M, the model has been
81
- optimized to be extremely versatile, performant on a variety of hardware in
82
- single turn scenarios, but should be finetuned on single turn or multiturn task
83
- specific data to achieve best accuracy in specific domains.
84
- To demonstrate how specializing the 270M parameter model can achieve high
85
- performance on specific agentic workflows, we have highlighted two use cases in
86
- the
87
- [Google AI Edge Gallery app](https://play.google.com/store/apps/details?id=com.google.ai.edge.gallery&pcampaignid=web_share).
88
-
89
- - **Tiny Garden:** A model fine-tuned to power a voice-controlled
90
- interactive game. It handles game logic to manage a virtual plot of land,
91
- decomposing commands like "Plant sunflowers in the top row" and "Water the
92
- flowers in plots 1 and 2" into app-specific functions (e.g., plant_seed,
93
- water_plots) and coordinate targets. This demonstrates the model's capacity
94
- to drive custom app mechanics without server connectivity.
95
-
96
- - **Mobile Actions:** To empower developers to build their own expert
97
- agents, we have published [a
98
- dataset](https://huggingface.co/datasets/google/mobile-actions) and
99
- [fine-tuning recipe](https://github.com/google-gemini/gemma-cookbook/blob/main/FunctionGemma/%5BFunctionGemma%5DFinetune_FunctionGemma_270M_for_Mobile_Actions_with_Hugging_Face.ipynb)
100
- to demonstrate fine-tuning FunctionGemma. It translates user inputs (e.g.,
101
- "Create a calendar event for lunch," "Turn on the flashlight") into
102
- function calls that trigger Android OS system tools. This interactive
103
- notebook demonstrates how to take the base FunctionGemma model and build a
104
- "Mobile Actions" fine tune from scratch for use in the
105
- [Google AI Edge gallery app](https://play.google.com/store/apps/details?id=com.google.ai.edge.gallery&pcampaignid=web_share).
106
- This use case demonstrates the model's ability to act as an offline,
107
- private agent for personal device tasks.
108
-
109
- ### Inputs and outputs
110
-
111
- - **Input:**
112
- - Text string, such as a question, a prompt, or a document to be
113
- summarized
114
- - Total input context of 32K tokens
115
- - **Output:**
116
- - Generated text in response to the input, such as an answer to a
117
- question, or a summary of a document
118
- - Total output context up to 32K tokens per request, subtracting
119
- the request input tokens
120
-
121
- ### Basic Usage
122
-
123
- The following is a code example of how to use FunctionGemma to generate a function call from a JSON definition using the Hugging Face Transformers library.
124
-
125
- First install the dependencies:
126
-
127
- ```sh
128
- $ pip install torch
129
- $ pip install transformers
130
- ```
131
-
132
- Then load the model and the processor using Transformers:
133
-
134
- ```python
135
- from transformers import AutoProcessor, AutoModelForCausalLM
136
-
137
- processor = AutoProcessor.from_pretrained("google/functiongemma-270m-it", device_map="auto")
138
- model = AutoModelForCausalLM.from_pretrained("google/functiongemma-270m-it", dtype="auto", device_map="auto")
139
- ```
140
-
141
- Define the function definition using JSON schema, then set a system instruction using the developer role. This is required to let the model know it should use the function(s) provided. Add a user query as input to the model and then generate the output. The model will then generate one or more function calls that it wants the developer to make on its behalf.
142
-
143
- ```python
144
- weather_function_schema = {
145
- "type": "function",
146
- "function": {
147
- "name": "get_current_temperature",
148
- "description": "Gets the current temperature for a given location.",
149
- "parameters": {
150
- "type": "object",
151
- "properties": {
152
- "location": {
153
- "type": "string",
154
- "description": "The city name, e.g. San Francisco",
155
- },
156
- },
157
- "required": ["location"],
158
- },
159
- }
160
- }
161
-
162
- message = [
163
- # ESSENTIAL SYSTEM PROMPT:
164
- # This line activates the model's function calling logic.
165
- {
166
- "role": "developer",
167
- "content": "You are a model that can do function calling with the following functions"
168
- },
169
- {
170
- "role": "user",
171
- "content": "What's the temperature in London?"
172
- }
173
- ]
174
-
175
- inputs = processor.apply_chat_template(message, tools=[weather_function_schema], add_generation_prompt=True, return_dict=True, return_tensors="pt")
176
-
177
- out = model.generate(**inputs.to(model.device), pad_token_id=processor.eos_token_id, max_new_tokens=128)
178
- output = processor.decode(out[0][len(inputs["input_ids"][0]):], skip_special_tokens=True)
179
-
180
- print(output)
181
- # <start_function_call>call:get_current_temperature{location:<escape>London<escape>}<end_function_call>
182
- ```
183
-
184
- For more detailed examples see the [Gemma documentation](https://ai.google.dev/gemma/docs/functiongemma).
185
-
186
- ## Model Data
187
-
188
- Data used for model training and how the data was processed.
189
-
190
- ### Training Dataset
191
-
192
- These models were trained on a dataset of text data that includes a wide
193
- variety of sources. The model was trained with 6T tokens. The knowledge cutoff
194
- date for the training data was August 2024. There are the key components:
195
-
196
- - Public Tool Definitions - Common APIs found on the web
197
- - Tool Use Interactions - These are a mix of prompts, function calls,
198
- function responses, and natural language responses from the model to
199
- summarise the function call response, or request clarifications when the
200
- prompt is ambiguous or incomplete.
201
-
202
- ### Data Preprocessing
203
-
204
- Here are the key data cleaning and filtering methods applied to the training
205
- data:
206
-
207
- - CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering
208
- was applied at multiple stages in the data preparation process to ensure
209
- the exclusion of harmful and illegal content.
210
- - Sensitive Data Filtering: As part of making Gemma pre-trained models
211
- safe and reliable, automated techniques were used to filter out certain
212
- personal information and other sensitive data from training sets.
213
- - Additional methods: Filtering based on content quality and safety in
214
- line with
215
- [our policies](https://ai.google/static/documents/ai-responsibility-update-published-february-2025.pdf).
216
-
217
- ## Implementation Information
218
-
219
- Details about the model internals.
220
-
221
- ### Hardware
222
-
223
- Gemma was trained using [Tensor Processing Unit
224
- (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu) hardware (TPUv4p, TPUv5p
225
- and TPUv5e). Training vision-language models (VLMs) requires significant
226
- computational power. TPUs, designed specifically for matrix operations common in
227
- machine learning, offer several advantages in this domain:
228
-
229
- - Performance: TPUs are specifically designed to handle the massive
230
- computations involved in training VLMs. They can speed up training
231
- considerably compared to CPUs.
232
- - Memory: TPUs often come with large amounts of high-bandwidth memory,
233
- allowing for the handling of large models and batch sizes during training.
234
- This can lead to better model quality.
235
- - Scalability: TPU Pods (large clusters of TPUs) provide a scalable
236
- solution for handling the growing complexity of large foundation models.
237
- You can distribute training across multiple TPU devices for faster and more
238
- efficient processing.
239
- - Cost-effectiveness: In many scenarios, TPUs can provide a more
240
- cost-effective solution for training large models compared to CPU-based
241
- infrastructure, especially when considering the time and resources saved
242
- due to faster training.
243
- - These advantages are aligned with
244
- [Google's commitments to operate sustainably](https://sustainability.google/operating-sustainably/).
245
-
246
- ### Software
247
-
248
- Training was done using [JAX](https://github.com/jax-ml/jax) and
249
- [ML Pathways](https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/).
250
- JAX allows researchers to take advantage of the latest generation of hardware,
251
- including TPUs, for faster and more efficient training of large models. ML
252
- Pathways is Google's latest effort to build artificially intelligent systems
253
- capable of generalizing across multiple tasks. This is specially suitable for
254
- foundation models, including large language models like these ones.\
255
- Together, JAX and ML Pathways are used as described in the [paper about the
256
- Gemini family of models](https://goo.gle/gemma2report); *"the 'single
257
- controller' programming model of Jax and Pathways allows a single Python process
258
- to orchestrate the entire training run, dramatically simplifying the development
259
- workflow."*
260
-
261
- ## Evaluation
262
-
263
- Model evaluation metrics and results.
264
-
265
- ### Benchmark Results
266
-
267
- <table>
268
- <thead>
269
- <tr>
270
- <th><strong>Benchmark</strong></th>
271
- <th><strong>n-shot</strong></th>
272
- <th><strong>Function Gemma 270m</strong></th>
273
- </tr>
274
- </thead>
275
- <tbody>
276
- <tr>
277
- <td>BFCL Simple</td>
278
- <td>0-shot</td>
279
- <td>61.6</td>
280
- </tr>
281
- <tr>
282
- <td>BFCL Parallel</td>
283
- <td>0-shot</td>
284
- <td>63.5</td>
285
- </tr>
286
- <tr>
287
- <td>BFCL Multiple</td>
288
- <td>0-shot</td>
289
- <td>39</td>
290
- </tr>
291
- <tr>
292
- <td>BFCL Parallel Multiple</td>
293
- <td>0-shot</td>
294
- <td>29.5</td>
295
- </tr>
296
- <tr>
297
- <td>BFCL Live Simple </td>
298
- <td>0-shot</td>
299
- <td>36.2</td>
300
- </tr>
301
- <tr>
302
- <td>BFCL Live Parallel</td>
303
- <td>0-shot</td>
304
- <td>25.7</td>
305
- </tr>
306
- <tr>
307
- <td>BFCL Live Multiple</td>
308
- <td>0-shot</td>
309
- <td>22.9</td>
310
- </tr>
311
- <tr>
312
- <td>BFCL Live Parallel Multiple</td>
313
- <td>0-shot</td>
314
- <td>20.8</td>
315
- </tr>
316
- <tr>
317
- <td>BFCL Relevance</td>
318
- <td>0-shot</td>
319
- <td>61.1</td>
320
- </tr>
321
- <tr>
322
- <td>BFCL Irrelevance</td>
323
- <td>0-shot</td>
324
- <td>70.6</td>
325
- </tr>
326
- </tbody>
327
- </table>
328
-
329
- **Impact on Performance after Fine-tuning on Mobile Actions Dataset**\
330
- To demonstrate the value of specialization for small language models, we
331
- compared the base FunctionGemma model against the fine-tuned model using the
332
- "Mobile Actions"
333
- [recipe](https://github.com/google-gemini/gemma-cookbook/blob/main/FunctionGemma/%5BFunctionGemma%5DFinetune_FunctionGemma_270M_for_Mobile_Actions_with_Hugging_Face.ipynb).
334
- Fine-tuning significantly improved the base FunctionGemma model's ability to
335
- correctly identify and format mobile system calls.
336
-
337
- <table>
338
- <thead>
339
- <tr>
340
- <th><br>
341
- Model</th>
342
- <th><br>
343
- Eval results for Mobile Actions</th>
344
- </tr>
345
- </thead>
346
- <tbody>
347
- <tr>
348
- <td><br>
349
- Base FunctionGemma model</td>
350
- <td><br>
351
- 58%</td>
352
- </tr>
353
- <tr>
354
- <td><br>
355
- Mobile Actions Fine-Tune</td>
356
- <td><br>
357
- 85%</td>
358
- </tr>
359
- </tbody>
360
- </table>
361
-
362
- **On-Device Performance of the Gemma 270m Fine-tuned Use Cases**\
363
- We evaluated the fine-tuned use cases on a Samsung S25 Ultra to assess on-device
364
- latency and memory footprint.
365
-
366
- - **Context:** 512 prefill tokens and 32 decode tokens.
367
- - **Hardware:** S25 Ultra CPU using LiteRT XNNPACK delegate with 4 threads.
368
-
369
- Mobile Actions On Device Performance
370
-
371
- <table>
372
- <thead>
373
- <tr>
374
- <th><br>
375
- Backend</th>
376
- <th><br>
377
- Quantization scheme</th>
378
- <th><br>
379
- Context length</th>
380
- <th><br>
381
- Prefill (tokens per second)</th>
382
- <th><br>
383
- Decode (tokens per second)</th>
384
- <th><br>
385
- Time-to-first-token (seconds)</th>
386
- <th><br>
387
- Model Size (MB)</th>
388
- <th><br>
389
- Peak RSS Memory (MB)</th>
390
- </tr>
391
- </thead>
392
- <tbody>
393
- <tr>
394
- <td><br>
395
- CPU</td>
396
- <td><br>
397
- dynamic_int8</td>
398
- <td><br>
399
- 1024</td>
400
- <td><br>
401
- 1718</td>
402
- <td><br>
403
- 125.9</td>
404
- <td><br>
405
- 0.3</td>
406
- <td><br>
407
- 288</td>
408
- <td><br>
409
- 551</td>
410
- </tr>
411
- </tbody>
412
- </table>
413
-
414
- Tiny Garden On Device Performance
415
-
416
- <table>
417
- <thead>
418
- <tr>
419
- <th><br>
420
- Backend</th>
421
- <th><br>
422
- Quantization scheme</th>
423
- <th><br>
424
- Context length</th>
425
- <th><br>
426
- Prefill (tokens per second)</th>
427
- <th><br>
428
- Decode (tokens per second)</th>
429
- <th><br>
430
- Time-to-first-token (seconds)</th>
431
- <th><br>
432
- Model Size (MB)</th>
433
- <th><br>
434
- Peak RSS Memory (MB)</th>
435
- </tr>
436
- </thead>
437
- <tbody>
438
- <tr>
439
- <td><br>
440
- CPU</td>
441
- <td><br>
442
- dynamic_int8</td>
443
- <td><br>
444
- 1024</td>
445
- <td><br>
446
- 1743</td>
447
- <td><br>
448
- 125.7</td>
449
- <td><br>
450
- 0.3</td>
451
- <td><br>
452
- 288</td>
453
- <td><br>
454
- 549</td>
455
- </tr>
456
- </tbody>
457
- </table>
458
-
459
- ## Ethics and Safety
460
-
461
- Ethics and safety evaluation approach and results.
462
-
463
- ### Evaluation Approach
464
-
465
- Our evaluation methods include structured evaluations and internal red-teaming
466
- testing of relevant content policies. Red-teaming was conducted by a number of
467
- different teams, each with different goals and human evaluation metrics. These
468
- models were evaluated against a number of different categories relevant to
469
- ethics and safety, including:
470
-
471
- - **Child Safety**: Evaluation of text-to-text and image to text prompts
472
- covering child safety policies, including child sexual abuse and exploitation.
473
- - **Content Safety:** Evaluation of text-to-text and image to text prompts
474
- covering safety policies including, harassment, violence and gore, and hate
475
- speech.
476
- - **Representational Harms**: Evaluation of text-to-text and image to text
477
- prompts covering safety policies including bias, stereotyping, and harmful
478
- associations or inaccuracies.
479
-
480
- ### Evaluation Results
481
-
482
- For all areas of safety testing, we saw major improvements in the categories of
483
- child safety, content safety, and representational harms relative to previous
484
- Gemma models. All testing was conducted without safety filters to evaluate the
485
- model capabilities and behaviors. The model produced minimal policy violations,
486
- and showed significant improvements over previous Gemma models' performance
487
- with respect to ungrounded inferences. A limitation of our evaluations was they
488
- included only English language prompts.
489
-
490
- ## Usage and Limitations
491
-
492
- These models have certain limitations that users should be aware of.
493
-
494
- ### Intended Usage
495
-
496
- This model is not intended for use as a direct dialogue model.\
497
- Open Large Language Models (LLMs) have a wide range of applications across
498
- various industries and domains. The following list of potential uses is not
499
- comprehensive. The purpose of this list is to provide contextual information
500
- about the possible use-cases that the model creators considered as part of model
501
- training and development.
502
-
503
- - Content Creation and Communication
504
- - Text Generation: These models can be used to generate creative
505
- text formats such as poems, scripts, code, marketing copy, and email drafts.
506
- - Chatbots and Conversational AI: Power conversational interfaces
507
- for customer service, virtual assistants, or interactive applications.
508
- - Text Summarization: Generate concise summaries of a text corpus,
509
- research papers, or reports.
510
- - Research and Education
511
- - Natural Language Processing (NLP) Research: These models can
512
- serve as a foundation for researchers to experiment with NLP
513
- techniques, develop algorithms, and contribute to the advancement of the field.
514
- - Language Learning Tools: Support interactive language learning
515
- experiences, aiding in grammar correction or providing writing practice.
516
- - Knowledge Exploration: Assist researchers in exploring large
517
- bodies of text by generating summaries or answering questions about
518
- specific topics.
519
-
520
- ### Limitations
521
-
522
- - Training Data
523
- - The quality and diversity of the training data significantly
524
- influence the model's capabilities. Biases or gaps in the training data
525
- can lead to limitations in the model's responses.
526
- - The scope of the training dataset determines the subject areas
527
- the model can handle effectively.
528
- - Context and Task Complexity
529
- - Models are better at tasks that can be framed with clear
530
- prompts and instructions. Open-ended or highly complex tasks might be
531
- challenging.
532
- - A model's performance can be influenced by the amount of context
533
- provided (longer context generally leads to better outputs, up to a
534
- certain point).
535
- - Language Ambiguity and Nuance
536
- - Natural language is inherently complex. Models might struggle
537
- to grasp subtle nuances, sarcasm, or figurative language.
538
- - Factual Accuracy
539
- - Models generate responses based on information they learned
540
- from their training datasets, but they are not knowledge bases. They
541
- may generate incorrect or outdated factual statements.
542
- - Common Sense
543
- - Models rely on statistical patterns in language. They might
544
- lack the ability to apply common sense reasoning in certain situations.
545
-
546
- ### Ethical Considerations and Risks
547
-
548
- The development of large language models (LLMs) raises several ethical
549
- concerns. In creating an open model, we have carefully considered the
550
- following:
551
-
552
- - Bias and Fairness
553
- - LLMs trained on large-scale, real-world text data can reflect
554
- socio-cultural biases embedded in the training material. These models
555
- underwent careful scrutiny, input data pre-processing described and
556
- posterior evaluations reported in this card.
557
- - Misinformation and Misuse
558
- - LLMs can be misused to generate text that is false, misleading,
559
- or harmful.
560
- - Guidelines are provided for responsible use with the model, see
561
- the [Responsible Generative AI Toolkit](https://ai.google.dev/responsible).
562
- - Transparency and Accountability:
563
- - This model card summarizes details on the models' architecture,
564
- capabilities, limitations, and evaluation processes.
565
- - A responsibly developed open model offers the opportunity to
566
- share innovation by making LLM technology accessible to developers and
567
- researchers across the AI ecosystem.
568
-
569
- Risks identified and mitigations:
570
-
571
- - Perpetuation of biases: It's encouraged to perform continuous
572
- monitoring (using evaluation metrics, human review) and the exploration of
573
- de-biasing techniques during model training, fine-tuning, and other use cases.
574
- - Generation of harmful content: Mechanisms and guidelines for content
575
- safety are essential. Developers are encouraged to exercise caution and
576
- implement appropriate content safety safeguards based on their specific
577
- product policies and application use cases.
578
- - Misuse for malicious purposes: Technical limitations and developer and
579
- end-user education can help mitigate against malicious applications of
580
- LLMs. Educational resources and reporting mechanisms for users to flag
581
- misuse are provided. Prohibited uses of Gemma models are outlined in the
582
- [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy)..
583
- - Privacy violations: Models were trained on data filtered for removal of
584
- PII (Personally Identifiable Information). Developers are encouraged to
585
- adhere to privacy regulations with privacy-preserving techniques.
586
-
587
- ### Benefits
588
-
589
- At the time of release, this family of models provides high-performance open large language model implementations designed from the ground up for Responsible AI development compared to similarly sized models.
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ tags:
4
+ - gemma3
5
+ - gemma
6
+ - google
7
+ - functiongemma
8
+ - heretic
9
+ - uncensored
10
+ - decensored
11
+ - abliterated
12
+ pipeline_tag: text-generation
13
+ library_name: transformers
14
+ extra_gated_heading: Access Gemma on Hugging Face
15
+ extra_gated_prompt: >-
16
+ To access FunctionGemma on Hugging Face, you’re required to review and agree
17
+ to Google’s usage license. To do this, please ensure you’re logged in to
18
+ Hugging Face and click below. Requests are processed immediately.
19
+ extra_gated_button_content: Acknowledge license
20
+ base_model:
21
+ - google/functiongemma-270m-it
22
+ ---
23
+ # This is a decensored version of [google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it), made using [Heretic](https://github.com/p-e-w/heretic) v1.1.0
24
+
25
+ ## Abliteration parameters
26
+
27
+ | Parameter | Value |
28
+ | :-------- | :---: |
29
+ | **direction_index** | per layer |
30
+ | **attn.o_proj.max_weight** | 1.33 |
31
+ | **attn.o_proj.max_weight_position** | 12.65 |
32
+ | **attn.o_proj.min_weight** | 0.85 |
33
+ | **attn.o_proj.min_weight_distance** | 4.36 |
34
+ | **mlp.down_proj.max_weight** | 1.46 |
35
+ | **mlp.down_proj.max_weight_position** | 12.22 |
36
+ | **mlp.down_proj.min_weight** | 1.40 |
37
+ | **mlp.down_proj.min_weight_distance** | 4.97 |
38
+
39
+ ## Performance
40
+
41
+ | Metric | This model | Original model ([google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it)) |
42
+ | :----- | :--------: | :---------------------------: |
43
+ | **KL divergence** | 0.2617 | 0 *(by definition)* |
44
+ | **Refusals** | 2/100 | 100/100 |
45
+
46
+ -----
47
+
48
+
49
+ # FunctionGemma model card
50
+
51
+ **Model Page**: [FunctionGemma](https://ai.google.dev/gemma/docs/functiongemma)
52
+
53
+ **Resources and Technical Documentation**:
54
+
55
+ - [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)
56
+ - [FunctionGemma on Kaggle](https://www.kaggle.com/models/google/functiongemma/)
57
+ - [FunctionGemma on Vertex Model Garden](https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/functiongemma)
58
+
59
+ **Terms of Use**: [Terms](https://ai.google.dev/gemma/terms)\
60
+ **Authors**: Google DeepMind
61
+
62
+ ## Model Information
63
+
64
+ Summary description and brief definition of inputs and outputs.
65
+
66
+ ### Description
67
+
68
+ > [!Note]
69
+ > FunctionGemma is intended to be fine-tuned for your specific function-calling task, including multi-turn use cases.
70
+
71
+
72
+ FunctionGemma is a lightweight, open model from Google, built as a foundation
73
+ for creating your own specialized function calling models. FunctionGemma is not
74
+ intended for use as a direct dialogue model, and is designed to be highly
75
+ performant after further fine-tuning, as is typical of models this size. Built
76
+ on the Gemma 3 270M model and with the same research and technology used to
77
+ create the Gemini models, FunctionGemma has been trained specifically for
78
+ function calling. The model has the same architecture as Gemma 3, but uses a
79
+ different chat format. The model is well suited for text-only function calling.
80
+ The uniquely small size makes it possible to deploy in environments with limited
81
+ resources such as laptops, desktops or your own cloud infrastructure,
82
+ democratizing access to state of the art AI models and helping foster innovation
83
+ for everyone. Furthermore, akin to the base Gemma 270M, the model has been
84
+ optimized to be extremely versatile, performant on a variety of hardware in
85
+ single turn scenarios, but should be finetuned on single turn or multiturn task
86
+ specific data to achieve best accuracy in specific domains.
87
+ To demonstrate how specializing the 270M parameter model can achieve high
88
+ performance on specific agentic workflows, we have highlighted two use cases in
89
+ the
90
+ [Google AI Edge Gallery app](https://play.google.com/store/apps/details?id=com.google.ai.edge.gallery&pcampaignid=web_share).
91
+
92
+ - **Tiny Garden:** A model fine-tuned to power a voice-controlled
93
+ interactive game. It handles game logic to manage a virtual plot of land,
94
+ decomposing commands like "Plant sunflowers in the top row" and "Water the
95
+ flowers in plots 1 and 2" into app-specific functions (e.g., plant_seed,
96
+ water_plots) and coordinate targets. This demonstrates the model's capacity
97
+ to drive custom app mechanics without server connectivity.
98
+
99
+ - **Mobile Actions:** To empower developers to build their own expert
100
+ agents, we have published [a
101
+ dataset](https://huggingface.co/datasets/google/mobile-actions) and
102
+ [fine-tuning recipe](https://github.com/google-gemini/gemma-cookbook/blob/main/FunctionGemma/%5BFunctionGemma%5DFinetune_FunctionGemma_270M_for_Mobile_Actions_with_Hugging_Face.ipynb)
103
+ to demonstrate fine-tuning FunctionGemma. It translates user inputs (e.g.,
104
+ "Create a calendar event for lunch," "Turn on the flashlight") into
105
+ function calls that trigger Android OS system tools. This interactive
106
+ notebook demonstrates how to take the base FunctionGemma model and build a
107
+ "Mobile Actions" fine tune from scratch for use in the
108
+ [Google AI Edge gallery app](https://play.google.com/store/apps/details?id=com.google.ai.edge.gallery&pcampaignid=web_share).
109
+ This use case demonstrates the model's ability to act as an offline,
110
+ private agent for personal device tasks.
111
+
112
+ ### Inputs and outputs
113
+
114
+ - **Input:**
115
+ - Text string, such as a question, a prompt, or a document to be
116
+ summarized
117
+ - Total input context of 32K tokens
118
+ - **Output:**
119
+ - Generated text in response to the input, such as an answer to a
120
+ question, or a summary of a document
121
+ - Total output context up to 32K tokens per request, subtracting
122
+ the request input tokens
123
+
124
+ ### Basic Usage
125
+
126
+ The following is a code example of how to use FunctionGemma to generate a function call from a JSON definition using the Hugging Face Transformers library.
127
+
128
+ First install the dependencies:
129
+
130
+ ```sh
131
+ $ pip install torch
132
+ $ pip install transformers
133
+ ```
134
+
135
+ Then load the model and the processor using Transformers:
136
+
137
+ ```python
138
+ from transformers import AutoProcessor, AutoModelForCausalLM
139
+
140
+ processor = AutoProcessor.from_pretrained("google/functiongemma-270m-it", device_map="auto")
141
+ model = AutoModelForCausalLM.from_pretrained("google/functiongemma-270m-it", dtype="auto", device_map="auto")
142
+ ```
143
+
144
+ Define the function definition using JSON schema, then set a system instruction using the developer role. This is required to let the model know it should use the function(s) provided. Add a user query as input to the model and then generate the output. The model will then generate one or more function calls that it wants the developer to make on its behalf.
145
+
146
+ ```python
147
+ weather_function_schema = {
148
+ "type": "function",
149
+ "function": {
150
+ "name": "get_current_temperature",
151
+ "description": "Gets the current temperature for a given location.",
152
+ "parameters": {
153
+ "type": "object",
154
+ "properties": {
155
+ "location": {
156
+ "type": "string",
157
+ "description": "The city name, e.g. San Francisco",
158
+ },
159
+ },
160
+ "required": ["location"],
161
+ },
162
+ }
163
+ }
164
+
165
+ message = [
166
+ # ESSENTIAL SYSTEM PROMPT:
167
+ # This line activates the model's function calling logic.
168
+ {
169
+ "role": "developer",
170
+ "content": "You are a model that can do function calling with the following functions"
171
+ },
172
+ {
173
+ "role": "user",
174
+ "content": "What's the temperature in London?"
175
+ }
176
+ ]
177
+
178
+ inputs = processor.apply_chat_template(message, tools=[weather_function_schema], add_generation_prompt=True, return_dict=True, return_tensors="pt")
179
+
180
+ out = model.generate(**inputs.to(model.device), pad_token_id=processor.eos_token_id, max_new_tokens=128)
181
+ output = processor.decode(out[0][len(inputs["input_ids"][0]):], skip_special_tokens=True)
182
+
183
+ print(output)
184
+ # <start_function_call>call:get_current_temperature{location:<escape>London<escape>}<end_function_call>
185
+ ```
186
+
187
+ For more detailed examples see the [Gemma documentation](https://ai.google.dev/gemma/docs/functiongemma).
188
+
189
+ ## Model Data
190
+
191
+ Data used for model training and how the data was processed.
192
+
193
+ ### Training Dataset
194
+
195
+ These models were trained on a dataset of text data that includes a wide
196
+ variety of sources. The model was trained with 6T tokens. The knowledge cutoff
197
+ date for the training data was August 2024. There are the key components:
198
+
199
+ - Public Tool Definitions - Common APIs found on the web
200
+ - Tool Use Interactions - These are a mix of prompts, function calls,
201
+ function responses, and natural language responses from the model to
202
+ summarise the function call response, or request clarifications when the
203
+ prompt is ambiguous or incomplete.
204
+
205
+ ### Data Preprocessing
206
+
207
+ Here are the key data cleaning and filtering methods applied to the training
208
+ data:
209
+
210
+ - CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering
211
+ was applied at multiple stages in the data preparation process to ensure
212
+ the exclusion of harmful and illegal content.
213
+ - Sensitive Data Filtering: As part of making Gemma pre-trained models
214
+ safe and reliable, automated techniques were used to filter out certain
215
+ personal information and other sensitive data from training sets.
216
+ - Additional methods: Filtering based on content quality and safety in
217
+ line with
218
+ [our policies](https://ai.google/static/documents/ai-responsibility-update-published-february-2025.pdf).
219
+
220
+ ## Implementation Information
221
+
222
+ Details about the model internals.
223
+
224
+ ### Hardware
225
+
226
+ Gemma was trained using [Tensor Processing Unit
227
+ (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu) hardware (TPUv4p, TPUv5p
228
+ and TPUv5e). Training vision-language models (VLMs) requires significant
229
+ computational power. TPUs, designed specifically for matrix operations common in
230
+ machine learning, offer several advantages in this domain:
231
+
232
+ - Performance: TPUs are specifically designed to handle the massive
233
+ computations involved in training VLMs. They can speed up training
234
+ considerably compared to CPUs.
235
+ - Memory: TPUs often come with large amounts of high-bandwidth memory,
236
+ allowing for the handling of large models and batch sizes during training.
237
+ This can lead to better model quality.
238
+ - Scalability: TPU Pods (large clusters of TPUs) provide a scalable
239
+ solution for handling the growing complexity of large foundation models.
240
+ You can distribute training across multiple TPU devices for faster and more
241
+ efficient processing.
242
+ - Cost-effectiveness: In many scenarios, TPUs can provide a more
243
+ cost-effective solution for training large models compared to CPU-based
244
+ infrastructure, especially when considering the time and resources saved
245
+ due to faster training.
246
+ - These advantages are aligned with
247
+ [Google's commitments to operate sustainably](https://sustainability.google/operating-sustainably/).
248
+
249
+ ### Software
250
+
251
+ Training was done using [JAX](https://github.com/jax-ml/jax) and
252
+ [ML Pathways](https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/).
253
+ JAX allows researchers to take advantage of the latest generation of hardware,
254
+ including TPUs, for faster and more efficient training of large models. ML
255
+ Pathways is Google's latest effort to build artificially intelligent systems
256
+ capable of generalizing across multiple tasks. This is specially suitable for
257
+ foundation models, including large language models like these ones.\
258
+ Together, JAX and ML Pathways are used as described in the [paper about the
259
+ Gemini family of models](https://goo.gle/gemma2report); *"the 'single
260
+ controller' programming model of Jax and Pathways allows a single Python process
261
+ to orchestrate the entire training run, dramatically simplifying the development
262
+ workflow."*
263
+
264
+ ## Evaluation
265
+
266
+ Model evaluation metrics and results.
267
+
268
+ ### Benchmark Results
269
+
270
+ <table>
271
+ <thead>
272
+ <tr>
273
+ <th><strong>Benchmark</strong></th>
274
+ <th><strong>n-shot</strong></th>
275
+ <th><strong>Function Gemma 270m</strong></th>
276
+ </tr>
277
+ </thead>
278
+ <tbody>
279
+ <tr>
280
+ <td>BFCL Simple</td>
281
+ <td>0-shot</td>
282
+ <td>61.6</td>
283
+ </tr>
284
+ <tr>
285
+ <td>BFCL Parallel</td>
286
+ <td>0-shot</td>
287
+ <td>63.5</td>
288
+ </tr>
289
+ <tr>
290
+ <td>BFCL Multiple</td>
291
+ <td>0-shot</td>
292
+ <td>39</td>
293
+ </tr>
294
+ <tr>
295
+ <td>BFCL Parallel Multiple</td>
296
+ <td>0-shot</td>
297
+ <td>29.5</td>
298
+ </tr>
299
+ <tr>
300
+ <td>BFCL Live Simple </td>
301
+ <td>0-shot</td>
302
+ <td>36.2</td>
303
+ </tr>
304
+ <tr>
305
+ <td>BFCL Live Parallel</td>
306
+ <td>0-shot</td>
307
+ <td>25.7</td>
308
+ </tr>
309
+ <tr>
310
+ <td>BFCL Live Multiple</td>
311
+ <td>0-shot</td>
312
+ <td>22.9</td>
313
+ </tr>
314
+ <tr>
315
+ <td>BFCL Live Parallel Multiple</td>
316
+ <td>0-shot</td>
317
+ <td>20.8</td>
318
+ </tr>
319
+ <tr>
320
+ <td>BFCL Relevance</td>
321
+ <td>0-shot</td>
322
+ <td>61.1</td>
323
+ </tr>
324
+ <tr>
325
+ <td>BFCL Irrelevance</td>
326
+ <td>0-shot</td>
327
+ <td>70.6</td>
328
+ </tr>
329
+ </tbody>
330
+ </table>
331
+
332
+ **Impact on Performance after Fine-tuning on Mobile Actions Dataset**\
333
+ To demonstrate the value of specialization for small language models, we
334
+ compared the base FunctionGemma model against the fine-tuned model using the
335
+ "Mobile Actions"
336
+ [recipe](https://github.com/google-gemini/gemma-cookbook/blob/main/FunctionGemma/%5BFunctionGemma%5DFinetune_FunctionGemma_270M_for_Mobile_Actions_with_Hugging_Face.ipynb).
337
+ Fine-tuning significantly improved the base FunctionGemma model's ability to
338
+ correctly identify and format mobile system calls.
339
+
340
+ <table>
341
+ <thead>
342
+ <tr>
343
+ <th><br>
344
+ Model</th>
345
+ <th><br>
346
+ Eval results for Mobile Actions</th>
347
+ </tr>
348
+ </thead>
349
+ <tbody>
350
+ <tr>
351
+ <td><br>
352
+ Base FunctionGemma model</td>
353
+ <td><br>
354
+ 58%</td>
355
+ </tr>
356
+ <tr>
357
+ <td><br>
358
+ Mobile Actions Fine-Tune</td>
359
+ <td><br>
360
+ 85%</td>
361
+ </tr>
362
+ </tbody>
363
+ </table>
364
+
365
+ **On-Device Performance of the Gemma 270m Fine-tuned Use Cases**\
366
+ We evaluated the fine-tuned use cases on a Samsung S25 Ultra to assess on-device
367
+ latency and memory footprint.
368
+
369
+ - **Context:** 512 prefill tokens and 32 decode tokens.
370
+ - **Hardware:** S25 Ultra CPU using LiteRT XNNPACK delegate with 4 threads.
371
+
372
+ Mobile Actions On Device Performance
373
+
374
+ <table>
375
+ <thead>
376
+ <tr>
377
+ <th><br>
378
+ Backend</th>
379
+ <th><br>
380
+ Quantization scheme</th>
381
+ <th><br>
382
+ Context length</th>
383
+ <th><br>
384
+ Prefill (tokens per second)</th>
385
+ <th><br>
386
+ Decode (tokens per second)</th>
387
+ <th><br>
388
+ Time-to-first-token (seconds)</th>
389
+ <th><br>
390
+ Model Size (MB)</th>
391
+ <th><br>
392
+ Peak RSS Memory (MB)</th>
393
+ </tr>
394
+ </thead>
395
+ <tbody>
396
+ <tr>
397
+ <td><br>
398
+ CPU</td>
399
+ <td><br>
400
+ dynamic_int8</td>
401
+ <td><br>
402
+ 1024</td>
403
+ <td><br>
404
+ 1718</td>
405
+ <td><br>
406
+ 125.9</td>
407
+ <td><br>
408
+ 0.3</td>
409
+ <td><br>
410
+ 288</td>
411
+ <td><br>
412
+ 551</td>
413
+ </tr>
414
+ </tbody>
415
+ </table>
416
+
417
+ Tiny Garden On Device Performance
418
+
419
+ <table>
420
+ <thead>
421
+ <tr>
422
+ <th><br>
423
+ Backend</th>
424
+ <th><br>
425
+ Quantization scheme</th>
426
+ <th><br>
427
+ Context length</th>
428
+ <th><br>
429
+ Prefill (tokens per second)</th>
430
+ <th><br>
431
+ Decode (tokens per second)</th>
432
+ <th><br>
433
+ Time-to-first-token (seconds)</th>
434
+ <th><br>
435
+ Model Size (MB)</th>
436
+ <th><br>
437
+ Peak RSS Memory (MB)</th>
438
+ </tr>
439
+ </thead>
440
+ <tbody>
441
+ <tr>
442
+ <td><br>
443
+ CPU</td>
444
+ <td><br>
445
+ dynamic_int8</td>
446
+ <td><br>
447
+ 1024</td>
448
+ <td><br>
449
+ 1743</td>
450
+ <td><br>
451
+ 125.7</td>
452
+ <td><br>
453
+ 0.3</td>
454
+ <td><br>
455
+ 288</td>
456
+ <td><br>
457
+ 549</td>
458
+ </tr>
459
+ </tbody>
460
+ </table>
461
+
462
+ ## Ethics and Safety
463
+
464
+ Ethics and safety evaluation approach and results.
465
+
466
+ ### Evaluation Approach
467
+
468
+ Our evaluation methods include structured evaluations and internal red-teaming
469
+ testing of relevant content policies. Red-teaming was conducted by a number of
470
+ different teams, each with different goals and human evaluation metrics. These
471
+ models were evaluated against a number of different categories relevant to
472
+ ethics and safety, including:
473
+
474
+ - **Child Safety**: Evaluation of text-to-text and image to text prompts
475
+ covering child safety policies, including child sexual abuse and exploitation.
476
+ - **Content Safety:** Evaluation of text-to-text and image to text prompts
477
+ covering safety policies including, harassment, violence and gore, and hate
478
+ speech.
479
+ - **Representational Harms**: Evaluation of text-to-text and image to text
480
+ prompts covering safety policies including bias, stereotyping, and harmful
481
+ associations or inaccuracies.
482
+
483
+ ### Evaluation Results
484
+
485
+ For all areas of safety testing, we saw major improvements in the categories of
486
+ child safety, content safety, and representational harms relative to previous
487
+ Gemma models. All testing was conducted without safety filters to evaluate the
488
+ model capabilities and behaviors. The model produced minimal policy violations,
489
+ and showed significant improvements over previous Gemma models' performance
490
+ with respect to ungrounded inferences. A limitation of our evaluations was they
491
+ included only English language prompts.
492
+
493
+ ## Usage and Limitations
494
+
495
+ These models have certain limitations that users should be aware of.
496
+
497
+ ### Intended Usage
498
+
499
+ This model is not intended for use as a direct dialogue model.\
500
+ Open Large Language Models (LLMs) have a wide range of applications across
501
+ various industries and domains. The following list of potential uses is not
502
+ comprehensive. The purpose of this list is to provide contextual information
503
+ about the possible use-cases that the model creators considered as part of model
504
+ training and development.
505
+
506
+ - Content Creation and Communication
507
+ - Text Generation: These models can be used to generate creative
508
+ text formats such as poems, scripts, code, marketing copy, and email drafts.
509
+ - Chatbots and Conversational AI: Power conversational interfaces
510
+ for customer service, virtual assistants, or interactive applications.
511
+ - Text Summarization: Generate concise summaries of a text corpus,
512
+ research papers, or reports.
513
+ - Research and Education
514
+ - Natural Language Processing (NLP) Research: These models can
515
+ serve as a foundation for researchers to experiment with NLP
516
+ techniques, develop algorithms, and contribute to the advancement of the field.
517
+ - Language Learning Tools: Support interactive language learning
518
+ experiences, aiding in grammar correction or providing writing practice.
519
+ - Knowledge Exploration: Assist researchers in exploring large
520
+ bodies of text by generating summaries or answering questions about
521
+ specific topics.
522
+
523
+ ### Limitations
524
+
525
+ - Training Data
526
+ - The quality and diversity of the training data significantly
527
+ influence the model's capabilities. Biases or gaps in the training data
528
+ can lead to limitations in the model's responses.
529
+ - The scope of the training dataset determines the subject areas
530
+ the model can handle effectively.
531
+ - Context and Task Complexity
532
+ - Models are better at tasks that can be framed with clear
533
+ prompts and instructions. Open-ended or highly complex tasks might be
534
+ challenging.
535
+ - A model's performance can be influenced by the amount of context
536
+ provided (longer context generally leads to better outputs, up to a
537
+ certain point).
538
+ - Language Ambiguity and Nuance
539
+ - Natural language is inherently complex. Models might struggle
540
+ to grasp subtle nuances, sarcasm, or figurative language.
541
+ - Factual Accuracy
542
+ - Models generate responses based on information they learned
543
+ from their training datasets, but they are not knowledge bases. They
544
+ may generate incorrect or outdated factual statements.
545
+ - Common Sense
546
+ - Models rely on statistical patterns in language. They might
547
+ lack the ability to apply common sense reasoning in certain situations.
548
+
549
+ ### Ethical Considerations and Risks
550
+
551
+ The development of large language models (LLMs) raises several ethical
552
+ concerns. In creating an open model, we have carefully considered the
553
+ following:
554
+
555
+ - Bias and Fairness
556
+ - LLMs trained on large-scale, real-world text data can reflect
557
+ socio-cultural biases embedded in the training material. These models
558
+ underwent careful scrutiny, input data pre-processing described and
559
+ posterior evaluations reported in this card.
560
+ - Misinformation and Misuse
561
+ - LLMs can be misused to generate text that is false, misleading,
562
+ or harmful.
563
+ - Guidelines are provided for responsible use with the model, see
564
+ the [Responsible Generative AI Toolkit](https://ai.google.dev/responsible).
565
+ - Transparency and Accountability:
566
+ - This model card summarizes details on the models' architecture,
567
+ capabilities, limitations, and evaluation processes.
568
+ - A responsibly developed open model offers the opportunity to
569
+ share innovation by making LLM technology accessible to developers and
570
+ researchers across the AI ecosystem.
571
+
572
+ Risks identified and mitigations:
573
+
574
+ - Perpetuation of biases: It's encouraged to perform continuous
575
+ monitoring (using evaluation metrics, human review) and the exploration of
576
+ de-biasing techniques during model training, fine-tuning, and other use cases.
577
+ - Generation of harmful content: Mechanisms and guidelines for content
578
+ safety are essential. Developers are encouraged to exercise caution and
579
+ implement appropriate content safety safeguards based on their specific
580
+ product policies and application use cases.
581
+ - Misuse for malicious purposes: Technical limitations and developer and
582
+ end-user education can help mitigate against malicious applications of
583
+ LLMs. Educational resources and reporting mechanisms for users to flag
584
+ misuse are provided. Prohibited uses of Gemma models are outlined in the
585
+ [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy)..
586
+ - Privacy violations: Models were trained on data filtered for removal of
587
+ PII (Personally Identifiable Information). Developers are encouraged to
588
+ adhere to privacy regulations with privacy-preserving techniques.
589
+
590
+ ### Benefits
591
+
592
+ At the time of release, this family of models provides high-performance open large language model implementations designed from the ground up for Responsible AI development compared to similarly sized models.