Gemma-3-4B-FC

Gemma-3-4B-FC is a LoRA fine-tuned version of Gemma 3 4B Instruct for function (tool) calling. The model is trained to recognize when external tools are required and generate structured tool calls with JSON arguments while maintaining conversational capabilities.

This repository contains only the LoRA adapter and tokenizer. The base model must be loaded separately.


Model Details

Model Description

Gemma-3-4B-FC extends Gemma 3 4B Instruct with function-calling capabilities using parameter-efficient fine-tuning (LoRA). The tokenizer included in this repository contains the custom chat template used during training and should always be loaded instead of the base tokenizer.

Developed by

Bandaru Venkata Satya Uday

Model Type

PEFT LoRA Adapter

Language(s)

Primarily English

Finetuned From

unsloth/gemma-3-4b-it


Model Sources


Uses

Direct Use

This model is intended for applications requiring structured function/tool calling, including:

  • AI Agents
  • Tool Calling
  • Function Calling
  • Workflow Automation
  • Assistant Applications

Since this repository only contains the LoRA adapter, users must first load the base Gemma 3 model and then apply the adapter.

Out-of-Scope Use

This model is not intended to execute tools. It only predicts which tool should be called and the corresponding JSON arguments.


How to Get Started

Install the required libraries.

pip install unsloth transformers peft

Load the base model.

from unsloth import FastModel

model, _ = FastModel.from_pretrained(
    model_name="unsloth/gemma-3-4b-it",
    max_seq_length=4096,
    load_in_4bit=False,
    load_in_8bit=False,
    full_finetuning=False,
)

Load the tokenizer from this repository.

from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(
    "SatyaUdayB/gemma-3-4b-FC"
)

Load the LoRA adapter.

from peft import PeftModel

model = PeftModel.from_pretrained(
    model,
    "SatyaUdayB/gemma-3-4b-FC"
)

Important

Use the tokenizer provided in this repository. It contains the custom chat template required for correct function-calling behavior.


Example

inputs = tokenizer.apply_chat_template(
    messages,
    tools=tools,
    add_generation_prompt=True,
    tokenize=True,
    return_tensors="pt",
    return_dict=True,
)

outputs = model.generate(
    **inputs.to("cuda"),
    max_new_tokens=128,
)

print(
    tokenizer.batch_decode(
        outputs,
        skip_special_tokens=False,
    )
)

Example output:

<tool_call>
[
  {
    "name": "get_current_time",
    "arguments": {
      "timezone": "Asia/Kolkata"
    }
  }
]
</tool_call>

Training Details

Training Data

This model was fine-tuned on a function-calling dataset derived from the APIGen-MT dataset. The data was preprocessed into a unified chat template and adapted for function-calling instruction tuning.

For more details about the dataset, please refer to the citation below.

Training Procedure

  • Base Model: Gemma 3 4B Instruct
  • Fine-tuning Method: LoRA
  • Frameworks: Unsloth, Transformers, PEFT and TRL
  • Context Length: 4096 tokens

Evaluation

Testing Data

A custom benchmark consisting of:

  • Single-tool prompts
  • Normal conversation
  • Edge cases

Metrics

Metric Score
Tool Accuracy 60.00%
Tool Call Format Accuracy 60.00%
JSON Validity 90.00%
False Positive Rate 40.00%

Summary

The model consistently produces syntactically valid JSON tool calls while demonstrating function-calling capability on a custom benchmark. Future work includes improving tool selection accuracy, reducing false-positive tool calls, and evaluating on public function-calling benchmarks such as BFCL.


Bias, Risks and Limitations

  • The model only predicts tool calls and does not execute tools.
  • Performance depends on using the tokenizer included in this repository.
  • Tool selection performance may vary depending on the prompt and available tool definitions.
  • Evaluation results are reported on a custom benchmark and may differ on public benchmarks.

Technical Specifications

Architecture

  • Base Model: Gemma 3 4B Instruct
  • Fine-tuning Method: LoRA
  • Adapter Framework: PEFT

Software

  • Transformers
  • PEFT
  • TRL
  • Unsloth

More Information

Future releases aim to improve tool selection performance, reduce false positives, evaluate on public function-calling benchmarks (e.g. BFCL), and provide merged model and GGUF releases.


Acknowledgements

This work builds upon the following open-source projects and resources:

  • Gemma 3 by Google
  • Unsloth
  • Hugging Face Transformers
  • PEFT
  • TRL
  • APIGen-MT

Citation

This model was trained using data derived from the APIGen-MT dataset. If you use this model, please consider citing the original APIGen-MT paper.

APIGen-MT

@article{prabhakar2025apigen,
  title={APIGen-MT: Agentic PIpeline for Multi-Turn Data Generation via Simulated Agent-Human Interplay},
  author={Prabhakar, Akshara and Liu, Zuxin and Zhu, Ming and Zhang, Jianguo and Awalgaonkar, Tulika and Wang, Shiyu and Liu, Zhiwei and Chen, Haolin and Hoang, Thai and others},
  journal={arXiv preprint arXiv:2504.03601},
  year={2025}
}

Framework Versions

  • PEFT 0.19.1
Downloads last month
55
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for SatyaUdayB/gemma-3-4b-FC

Adapter
(115)
this model

Paper for SatyaUdayB/gemma-3-4b-FC