File size: 3,040 Bytes
b98b172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b0f011
dbb2c53
b98b172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
license: apache-2.0
base_model: unsloth/functiongemma-270m-it
tags:
- function-calling
- tool-use
- mobile-actions
- gemma
- unsloth
datasets:
- google/mobile-actions
language:
- en
pipeline_tag: text-generation
---

## Model Card

This model is fine-tuned version of [google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it) model for mobile action function calling tasks. 

## Intended Use

Handles function-calling style mobile actions such as creating calendar events, sending emails, adding contacts, showing maps, managing Wi‑Fi, and toggling the flashlight, based on the `google/mobile-actions` dataset.

## Model Details

- **Base Model**: [google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it)
- **Fine-tuning**: SFT with LoRA
- **Dataset**: [google/mobile-actions](https://huggingface.co/datasets/google/mobile-actions)
- **Params**: ~270M (base) + LoRA merged into final weights

## Quick Start

```bash
pip install torch transformers datasets accelerate huggingface_hub
```

```python
import torch
from datasets import load_dataset
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer

model_id = "dousery/functiongemma-mobile-actions"  
device = "cuda" if torch.cuda.is_available() else "cpu"

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16 if device == "cuda" else torch.float32,
    device_map="auto" if device == "cuda" else None,
    trust_remote_code=True,
).eval()

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
if device == "cpu":
    model = model.to(device)

dataset = load_dataset("google/mobile-actions", split="train")
text = tokenizer.apply_chat_template(
    dataset[0]["messages"][:2],
    tools=dataset[0]["tools"],
    tokenize=False,
    add_generation_prompt=True,
).removeprefix("<bos>")

inputs = tokenizer(text, return_tensors="pt").to(device)
with torch.no_grad():
    _ = model.generate(
        **inputs,
        max_new_tokens=256,
        streamer=TextStreamer(tokenizer, skip_prompt=True),
        top_p=0.95,
        top_k=64,
        temperature=1.0,
    )
```

## Training Summary

- **Frameworks**: Unsloth + TRL, PyTorch 2.9.1, Transformers 4.57.3
- **Steps**: 100 (SFT with LoRA, then merged)
- **Effective Batch Size**: 8 (bs=4, grad accum=2)
- **LR / Scheduler**: 2e-4, linear
- **LoRA**: r=16, alpha=16, dropout=0, ~3.8M trainable params
- **Seq Len**: 4096
- **Hardware**: NVIDIA H100 80GB on Modal
- **Final Train Loss**: 0.2408 | **Eval Loss**: ~0.0129

## Limitations

- Trained for only 100 steps; niche mobile-action domain.
- Datetime formats can drift slightly.
- Best on GPU for speed; CPU works but slower.

## Citation

```bibtex
@misc{functiongemma-mobile-actions,
  title={FunctionGemma Mobile Actions - Merged for Mobile Function Calling},
  author={dousery},
  year={2025},
  howpublished={\url{https://huggingface.co/dousery/functiongemma-mobile-actions}}
}
```

## License

Apache-2.0 (inherits base model license).