Views
No views yet
google/mobile-actions dataset.pip install torch transformers datasets accelerate huggingface_hub1import torch
2from datasets import load_dataset
3from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
4
5model_id = "dousery/functiongemma-mobile-actions"
6device = "cuda" if torch.cuda.is_available() else "cpu"
7
8model = AutoModelForCausalLM.from_pretrained(
9 model_id,
10 torch_dtype=torch.float16 if device == "cuda" else torch.float32,
11 device_map="auto" if device == "cuda" else None,
12 trust_remote_code=True,
13).eval()
14
15tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
16if device == "cpu":
17 model = model.to(device)
18
19dataset = load_dataset("google/mobile-actions", split="train")
20text = tokenizer.apply_chat_template(
21 dataset[0]["messages"][:2],
22 tools=dataset[0]["tools"],
23 tokenize=False,
24 add_generation_prompt=True,
25).removeprefix("<bos>")
26
27inputs = tokenizer(text, return_tensors="pt").to(device)
28with torch.no_grad():
29 _ = model.generate(
30 **inputs,
31 max_new_tokens=256,
32 streamer=TextStreamer(tokenizer, skip_prompt=True),
33 top_p=0.95,
34 top_k=64,
35 temperature=1.0,
36 )1@misc{functiongemma-mobile-actions,
2 title={FunctionGemma Mobile Actions - Merged for Mobile Function Calling},
3 author={dousery},
4 year={2025},
5 howpublished={\url{https://huggingface.co/dousery/functiongemma-mobile-actions}}
6}