Model Card for gemma-2-2B-it-thinking-function_calling-V0

This model is a fine-tuned version of google/gemma-2-2b-it, specifically trained for function calling with an added "Thinking Layer". The model was trained using TRL and incorporates an explicit thinking process before making function calls.

🎯 Key Features

  • Function Calling: Generation of structured function calls
  • Thinking Layer: Explicit reasoning process before execution
  • Supported Functions:
    • convert_currency: Currency conversion
    • calculate_distance: Distance calculation between locations

πŸš€ Quick Start

Function Calling Example

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

# Load model and tokenizer
model_name = "Sellid/gemma-2-2B-it-thinking-function_calling-V0"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Example for currency conversion
prompt = """<bos><start_of_turn>human
You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags.
Here are the available tools:<tools>[{
    "type": "function",
    "function": {
        "name": "convert_currency",
        "description": "Convert from one currency to another",
        "parameters": {
            "type": "object",
            "properties": {
                "amount": {"type": "number", "description": "The amount to convert"},
                "from_currency": {"type": "string", "description": "The currency to convert from"},
                "to_currency": {"type": "string", "description": "The currency to convert to"}
            },
            "required": ["amount", "from_currency", "to_currency"]
        }
    }
}]</tools>

Hi, I need to convert 500 USD to Euros. Can you help me with that?<end_of_turn><eos>
<start_of_turn>model"""

# Generate response
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0]))

πŸ€– Model Architecture

The model uses a special prompt structure with three main components:

  1. Tools Definition:
<tools>
[Function signatures in JSON format]
</tools>
  1. Thinking Layer:
<think>
[Explicit thinking process of the model]
</think>
  1. Function Call:
<tool_call>
{
    "name": "function_name",
    "arguments": {
        "param1": "value1",
        ...
    }
}
</tool_call>

Thinking Layer Process

The Thinking Layer executes the following steps:

  1. Analysis of user request
  2. Selection of appropriate function
  3. Validation of parameters
  4. Generation of function call

πŸ“Š Performance & Limitations

  • Memory Requirements: ~4GB RAM
  • Inference Time: ~1-2 seconds/request
  • Supported Platforms:
    • CPU
    • NVIDIA GPUs (CUDA)
    • Apple Silicon (MPS)

Limitations

  • Limited to pre-trained functions
  • No function call chaining
  • No dynamic function extension

πŸ”§ Training Details

The model was trained using SFT (Supervised Fine-Tuning):

Framework Versions

  • TRL: 0.15.1
  • Transformers: 4.49.0
  • Pytorch: 2.7.0.dev20250222
  • Datasets: 3.3.2
  • Tokenizers: 0.21.0

πŸ“š Citations

If you use this model, please cite TRL:

@misc{vonwerra2022trl,
    title        = {{TRL: Transformer Reinforcement Learning}},
    author       = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin GallouΓ©dec},
    year         = 2020,
    journal      = {GitHub repository},
    publisher    = {GitHub},
    howpublished = {\url{https://github.com/huggingface/trl}}
}

And this model:

@misc{gemma-function-calling-thinking,
    title        = {Gemma Function-Calling with Thinking Layer},
    author       = {Sellid},
    year         = 2024,
    publisher    = {Hugging Face Model Hub},
    howpublished = {\url{https://huggingface.co/Sellid/gemma-2-2B-it-thinking-function_calling-V0}}
}
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

Model tree for Sellid/gemma-2-2B-it-thinking-function_calling-V0

Base model

google/gemma-2-2b
Finetuned
(548)
this model