On the planet of Agentic AI, the flexibility to name instruments is what interprets pure language into executable software program actions. Final month, we launched FunctionGemma, a specialised model of our Gemma 3 270M mannequin explicitly fine-tuned for perform calling. It’s designed for builders constructing quick and cost-effective brokers that translate pure language into executable API actions.
Particular purposes typically require specialist fashions. On this publish, we reveal the best way to fine-tune FunctionGemma to deal with software choice ambiguity: when a mannequin should select between a number of seemingly related features to name. We additionally introduce the “FunctionGemma Tuning Lab“, a demo software that makes this course of accessible with out writing a single line of coaching code.
Why Fantastic-Tune for Software Calling?
If FunctionGemma already helps software calling, why is fine-tuning obligatory?
The reply lies in context and coverage. A generic mannequin does not know what you are promoting guidelines. Widespread use instances for fine-tuning embody:
- Resolving Choice Ambiguity: If a person asks, “What’s the journey coverage?”, a base mannequin may default to a Google search. An enterprise mannequin, nevertheless, ought to search the inner information base.
- Extremely-Specialization: You’ll be able to practice a mannequin to grasp area of interest duties or proprietary codecs not present in public information, akin to dealing with domain-specific cell actions (e.g., controlling gadget options) or parsing inner APIs to assemble extremely complicated regulatory reviews.
- Mannequin Distillation: You should use a big mannequin to generate artificial coaching information, then fine-tune a smaller, sooner mannequin to run that particular workflow effectively.
The Case Examine: Inner Docs vs. Google Search
Let’s take a look at a sensible instance from the technical information on fine-tuning FunctionGemma utilizing the Hugging Face TRL library.
The Problem
The purpose was to coach a mannequin to tell apart between two particular instruments:
search_knowledge_base(Inner paperwork)search_google(Public data)
When requested “What are the perfect practices for writing a easy recursive perform in Python?”, a generic mannequin defaults to Google. Nonetheless, for a question like “What’s the reimbursement restrict for journey meals?”, the mannequin must know that that is an inner coverage query.
The Answer
To judge efficiency, we used the bebechien/SimpleToolCalling dataset, which comprises pattern conversations requiring a selection between two instruments: search_knowledge_base and search_google.
This dataset is break up into coaching and testing units. We maintain the take a look at set separate so we will consider the mannequin on “unseen” information, guaranteeing it learns the underlying routing logic relatively than simply memorizing particular examples.
After we evaluated the bottom FunctionGemma mannequin utilizing a 50/50 break up between coaching and testing, the outcomes have been suboptimal. The bottom mannequin selected the fallacious software or provided to “focus on” the coverage relatively than executing the perform name.
⚠️ A Vital Observe on Knowledge Distribution
When making ready your dataset, the way you break up your information is simply as necessary as the info itself.
from datasets import load_dataset
dataset = load_dataset("bebechien/SimpleToolCalling", break up="practice")
# Convert dataset to conversational format
dataset = dataset.map(create_conversation, remove_columns=dataset.options, batched=False)
# Cut up dataset into 50% coaching samples and 50% take a look at samples
dataset = dataset.train_test_split(test_size=0.5, shuffle=False)
Python
On this case examine, the information carried out a 50/50 train-test break up with shuffling disabled (shuffle=False). Whereas an 80/20 break up is commonplace for manufacturing, this equal division was chosen particularly to spotlight the mannequin’s efficiency enchancment on a big quantity of unseen information.
Nonetheless, there’s a entice right here:
Disabling shuffling was intentional right here because the dataset is shuffled already. But when your supply information is sorted by class (e.g., all search_google examples seem first, adopted by all search_knowledge_base examples), utilizing shuffle=False will end result within the mannequin coaching fully on one software and being examined on the opposite. This lack of selection throughout the coaching section results in catastrophic efficiency because the mannequin by no means learns to tell apart between totally different classes.
Greatest Follow:
When making use of this to customized datasets, at all times guarantee your supply information is pre-mixed. If the distribution order is unknown, you need to change the parameter to shuffle=True to make sure the mannequin learns a balanced illustration of all instruments throughout coaching.
The Outcome
The mannequin was fine-tuned utilizing SFTTrainer (Supervised Fantastic-Tuning) for 8 epochs.The coaching information explicitly taught the mannequin which queries belonged to which area.
The graph above illustrates the “loss” (the error price) reducing over time. The sharp drop at first signifies the mannequin quickly adapting to the brand new routing logic.
After fine-tuning, the mannequin’s habits modified dramatically. It realized to strictly adhere to the enterprise coverage. When requested the identical questions, akin to “What’s the course of for creating a brand new Jira venture?”, the fine-tuned mannequin accurately executed:
name:search_knowledge_base{question:Jira venture creation course of}
Python
Introducing the FunctionGemma Tuning Lab
Not everybody needs to handle Python dependencies, configure SFTConfig, or write coaching loops from scratch. Introducing the FunctionGemma Tuning Lab.
The FunctionGemma Tuning Lab is a user-friendly demo hosted on Hugging Face Areas. It streamlines all the technique of instructing the mannequin your particular perform schemas.
Key Options
- No-Code Interface: You need not write Python scripts. You’ll be able to outline perform schemas (JSON) immediately within the UI.
- Customized Knowledge Import: Merely add a CSV file containing your Consumer Immediate, Software Identify, and Software Arguments.
- One-Click on Fantastic-Tuning: Configure your studying price and epochs by way of sliders and begin coaching instantly. We offer a set of defaults designed to work nicely for most traditional use instances.
- Actual-Time Visualization: Watch your coaching logs and loss curves replace in real-time to make sure convergence.
- Auto-Analysis: The Tuning Lab robotically evaluates efficiency earlier than and after coaching, supplying you with quick suggestions on the development.
Getting Began with Tuning Lab
To make use of the Tuning Lab regionally, you may clone the repository with hf CLI and run the app with a number of easy instructions:
hf obtain google/functiongemma-tuning-lab --repo-type=house --local-dir=functiongemma-tuning-lab
cd functiongemma-tuning-lab
pip set up -r necessities.txt
python app.py
Shell
Conclusion
Whether or not you select to put in writing your personal coaching script utilizing TRL or make the most of the demo visible interface of the FunctionGemma Tuning Lab, fine-tuning is the important thing to unlocking the total potential of FunctionGemma. It transforms a generic assistant right into a specialised agent able to adhering to strict enterprise logic and dealing with complicated, proprietary information constructions.
Thanks for studying!
References
Weblog Submit
Code Examples
HuggingFace House







