Function Gemma
Function Gemma is a Google-trained light-wight model with 270M parameters to enables users to make connection between their prompt and executive actions. You can find another variant of the model fine-tuned by Google over (google/mobile-actions)[https://huggingface.co/datasets/google/mobile-actions] here: litert-community/FunctionGemma_270M_Mobile_Actions. You can also use this FunctionGemma-270m-it-Extended-Mobile-Actions model variation fine-tuned over extended Mobile Actions tools set dataset in AliRGHZ/Mobile-Actions.
For deploying the model into your application, kindly follow the instructions available here. For further fine-tuning you can follow the instructions suggested by Google here.
Training Configuration:
- Epochs: 2
- Batch size: 4 per device
- Gradient accumulation steps: 8
- Learning rate: 1e-5
- Scheduler: Cosine
- Optimizer: AdamW (fused)
- Precision: bfloat16
- Gradient checkpointing: Enabled
- Completion only loss: True (trains only on model outputs, not prompts)
Training Infrastructure:
- Hardware: Google Colab A100 GPU
- Training time: ~24 minutes for 2 epochs
- Library versions: transformers==5.2.0 torch==2.10.0 huggingface_hub==1.5.0, trl==0.29.0, accelerate==1.13.0
Sample Functions and Tools:
# =======================================EMAIL===========================================
send_email_schema = {
"function": {
"name": "send_email",
"description": "Sends an email.",
"parameters": {
"type": "OBJECT",
"properties": {
"to": {"type": "STRING", "description": "The recipient email address."},
"subject": {"type": "STRING", "description": "The email subject."},
"body": {"type": "STRING", "description": "The email body."},
"create_chooser": {"type": "BOOLEAN", "description": "Whether to display a program chooser to handle the message."}
},
"required": ["to", "subject"],
},
}
}
def send_email(to: str, subject:str, body: str = "", create_chooser: bool = True):
"""Sends an email.
Parameters:
to: The recipient email address (e.g. 'abc@gmail.com').
subject: The email subject/title/.
body: The email body.
create_chooser: Whether to display a program chooser to handle the message.
"""
try:
email.send(recipient= to,
subject= subject,
text=body,
create_chooser= create_chooser)
except Exception as e:
raise Exception(f"Error in sending Email to {to}, with subject of {subject}: {e}")
return {"response": f"Sent the email to {to} with subject of {subject} and body of {body[0:10]} ...!"}
# ==================================================================================
# =======================================CALL===========================================
phone_call_schema = {
"function": {
"name": "phone_call",
"description": "Make a call with number or open phone dial.",
"parameters": {
"type": "OBJECT",
"properties": {
"number": {"type": "STRING", "description": "The number to which we want to call."},
"dial_call": {"type": "BOOLEAN", "description": "True if you want to dial call via phone, and False if you want to call the number directly."}
},
"required": ["number", "dial_call"],
},
}
}
def phone_call(number:str = "", dial_call: bool = False):
"""Make a call with number or open phone dial.
Parameters:
number: The number to which we want to call.
dial_call: True if you want to dial call via phone, and False if you want to call the number directly.
"""
try:
if(dial_call):
call.dialcall()
else:
call.makecall(tel=number)
except Exception as e:
raise Exception(f"Error in calling to {number} or dialling: {e}")
return {"response": f"Call made to the number {number} or opened dialling, successfully!"}
# ==================================================================================
# =======================================SMS===========================================
phone_sms_schema = {
"function": {
"name": "phone_sms",
"description": "Send a sms message.",
"parameters": {
"type": "OBJECT",
"properties": {
"sms_recipient": {"type": "STRING", "description": "The recipient number."},
"sms_message": {"type": "STRING", "description": "The message body."}
},
"required": ["sms_recipient"],
},
}
}
def phone_sms(sms_recipient:str = "", sms_message:str = ""):
"""Send a sms message.
Parameters:
sms_recipient: The recipient number.
sms_message: The message body.
"""
try:
sms.send(recipient= sms_recipient, message= sms_message)
except Exception as e:
raise Exception(f"Error in sending sms message to {sms_recipient}: {e}")
return {"response": f"SMS message sent to {sms_recipient}, successfully!"}
# ==================================================================================
# =======================================LIGHT===========================================
LIGHT = ObjectProperty()
ILLUMINATION = NumericProperty()
def get_illumination(illumination, light):
ILLUMINATION = light.illumination or illumination
turnOn_light_schema = {
"function": {
"name": "turnOn_light",
"description": "Turn on the light.",
"parameters": {
"type": "OBJECT",
"properties": {},
"required": [],
},
}
}
def turnOn_light():
"""
Turn on the light.
"""
try:
from plyer import light
from kivy.clock import Clock
light.enable()
Clock.schedule_interval(get_illumination(ILLUMINATION, light), 1 / 20.)
except Exception as e:
raise Exception(f"Error in turning the light on: {e}")
return {"response": f"Light's turned on successfully!"}
turnOff_light_schema = {
"function": {
"name": "turnOff_light",
"description": "Turn off the light.",
"parameters": {
"type": "OBJECT",
"properties": {},
"required": [],
},
}
}
def turnOff_light():
"""
Turn off the light.
"""
try:
from plyer import light
from kivy.clock import Clock
light.disable()
Clock.unschedule(get_illumination(ILLUMINATION, light))
except Exception as e:
raise Exception(f"Error in turning the light off: {e}")
return {"response": f"Light's turned off successfully!"}
tools = [
send_email_schema,
phone_call_schema,
phone_sms_schema,
turnOff_light_schema,
turnOn_light_schema,
]
- Downloads last month
- 10
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support