FunctionGemma Fitness Coach

A LoRA adapter for google/functiongemma-270m-it fine-tuned on the tengomucho/fitness-coach-function-calling dataset to enable accurate function calling for fitness and health-related queries.

Model Description

This is a parameter-efficient fine-tuned version of Google's FunctionGemma-270M-it model, specialized for mapping natural language fitness queries to function calls. The model uses LoRA (Low-Rank Adaptation) to add only ~8M trainable parameters on top of the 270M base model.

  • Developed by: tengomucho
  • Base Model: google/functiongemma-270m-it
  • Model type: Causal Language Model with LoRA adapter
  • Language: English
  • License: Gemma Terms of Use
  • Finetuned from: google/functiongemma-270m-it

Supported Functions

The model is trained to handle the following fitness-related function calls:

  • get_steps() - Retrieve today's step count
  • get_daily_step_goal() - Get the user's daily step goal
  • get_goal_progress() - Calculate progress toward step goal
  • get_sleeping_minutes() - Get sleep duration
  • get_active_minutes() - Get active minutes count
  • get_heart_rate() - Get current heart rate
  • get_body_battery_level() - Get body battery level (energy/fatigue indicator)

Intended Uses

Primary Use Cases

  • Fitness coaching chatbots and virtual assistants
  • Health tracking application integrations
  • Natural language interfaces for fitness data APIs
  • Educational projects for function calling and prompt engineering

Out-of-Scope Use

  • General-purpose function calling (the model is specialized for fitness functions)
  • Non-fitness related queries
  • Medical diagnosis or treatment recommendations
  • Production medical applications without proper validation

Training Data

The model was fine-tuned on tengomucho/fitness-coach-function-calling, a synthetic dataset containing:

  • Natural language fitness queries paired with corresponding function calls
  • System prompts defining the fitness coach assistant role
  • Tool definitions following the FunctionGemma format
  • JSON-formatted function call responses

Dataset split:

  • Training set: 70% (shuffled)
  • Test set: 30% (shuffled)
  • Seed: 42

Training Procedure

Training Hyperparameters

  • Training epochs: 8
  • Batch size: 4 per device
  • Learning rate: 5e-5
  • Optimizer: Adafactor
  • LR scheduler: Constant
  • Max sequence length: 512 tokens
  • Hardware: TPU v5litepod-8
  • Training time: ~10-15 minutes
  • Framework: Hugging Face Transformers + TRL + PEFT

LoRA Configuration

LoraConfig(
    r=32,
    lora_alpha=64,
    lora_dropout=0.05,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
    task_type="CAUSAL_LM"
)

Infrastructure

  • Distributed Training: FSDPv2 (Fully Sharded Data Parallel v2)
  • XLA/SPMD: Enabled for TPU optimization
  • Gradient Checkpointing: Enabled via xla_fsdp_grad_ckpt
  • Mixed Precision: BFloat16

Performance

  • Baseline accuracy: ~58% (base FunctionGemma model)
  • Fine-tuned accuracy: ~85% on fitness function calling tasks
  • Improvement: +27 percentage points

How to Use

Installation

pip install transformers peft torch

Loading the Model

import peft # This import will enable automatic loading from adapters
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load model
model = AutoModelForCausalLM.from_pretrained("tengomucho/functiongemma-fitness-coach")

# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("google/functiongemma-270m-it")

Inference Example

import json

# Define your fitness functions
tools = [
    {
        "type": "function",
        "function": {
            "name": "get_steps",
            "description": "Get the number of steps taken today",
            "parameters": {"type": "object", "properties": {}}
        }
    },
    {
        "type": "function",
        "function": {
            "name": "get_heart_rate",
            "description": "Get the current heart rate",
            "parameters": {"type": "object", "properties": {}}
        }
    }
    # ... add other functions
]

# Create conversation
messages = [
    {
        "role": "developer",
        "content": "You are a fitness coach assistant that helps users track their health and fitness data."
    },
    {
        "role": "user",
        "content": "How many steps have I taken today?"
    }
]

# Format input
input_text = tokenizer.apply_chat_template(
    messages,
    tools=tools,
    tokenize=False,
    add_generation_prompt=True
)

# Generate
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)

print(response)
# Expected output: {"name": "get_steps", "arguments": {}}

Limitations and Bias

  • Domain-specific: The model is optimized only for the seven fitness functions it was trained on
  • Synthetic data: Training data is synthetically generated and may not cover all real-world query variations
  • English only: The model is trained exclusively on English text
  • No medical advice: This model should not be used for medical diagnosis or treatment recommendations
  • API assumptions: Function calls assume the existence of corresponding APIs to execute them

Model Card Authors

  • tengomucho
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support