Downloads · 30 days
26
4% of all-time downloads
ermiaazarkhalili/Gemma4-E4B-Function-Calling-xLAM-Unsloth
Gemma4-E4B-Function-Calling-xLAM-Unsloth is a text generation model from ermiaazarkhalili. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as gemma.
This model is a fine-tuned version of Gemma4-E4B-it optimized for function calling using Unsloth for 2x faster training and 60% less VRAM.
Downloads · 30 days
26
4% of all-time downloads
All-time downloads
631
Public
Parameters
8B
32 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors16 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of Gemma4-E4B-it optimized for function calling using Unsloth for 2x faster training and 60% less VRAM.
Trained on the Salesforce/xlam-function-calling-60k dataset, which contains 60,000 function calling examples with queries, tool definitions, and structured answers.
| Property | Value |
|---|---|
| Developed by | ermiaazarkhalili |
| License | GEMMA |
| Language | English |
| Base Model | Gemma4-E4B-it |
| Model Size | 4B parameters |
| Training Framework | Unsloth + TRL |
| Training Method | SFT with QLoRA (4-bit) |
| Context Length | 2,048 tokens |
| GGUF Available | Gemma4-E4B-Function-Calling-xLAM-Unsloth-GGUF |
| Parameter | Value |
|---|---|
| Unsloth Class | FastModel |
| Chat Template | gemma-4 |
| Learning Rate | 2e-4 |
| Batch Size | 2 per device |
| Gradient Accumulation | 4 steps |
| Effective Batch Size | 8 |
| Max Steps | 1,000 |
| Optimizer | AdamW 8-bit |
| LR Scheduler | Linear |
| Warmup Steps | 5 |
| Precision | Auto (BF16/FP16) |
| Gradient Checkpointing | Enabled (Unsloth optimized) |
| Seed | 3407 |
| Parameter | Value |
|---|---|
| LoRA Rank (r) | 16 |
| LoRA Alpha | 16 |
| LoRA Dropout | 0 |
| Quantization | 4-bit QLoRA |
| Target Modules | attention + MLP (via FastModel) |
| Property | Value |
|---|---|
| Dataset | xLAM Function Calling 60K |
| Training Samples | 60,000 |
| Format | XML-tagged: <query>, <tools>, <answers> |
| Property | Value |
|---|---|
| GPU | NVIDIA H100 80GB HBM3 (MIG 3g.40gb slice) |
| Cluster | DRAC Fir (Compute Canada) |
| Execution | Papermill on SLURM |
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "ermiaazarkhalili/Gemma4-E4B-Function-Calling-xLAM-Unsloth"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "user", "content": "Check if the numbers 8 and 1233 are powers of two."}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(response)
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
"ermiaazarkhalili/Gemma4-E4B-Function-Calling-xLAM-Unsloth",
max_seq_length=2048,
load_in_4bit=True,
)
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
import torch
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
)
model = AutoModelForCausalLM.from_pretrained(
"ermiaazarkhalili/Gemma4-E4B-Function-Calling-xLAM-Unsloth",
quantization_config=quantization_config,
device_map="auto",
)
Quantized GGUF versions for CPU and edge inference are available at: Gemma4-E4B-Function-Calling-xLAM-Unsloth-GGUF
| Format | Description |
|---|---|
Q4_K_M | Recommended — good balance of quality and size |
Q5_K_M | Higher quality, slightly larger |
Q8_0 | Near-lossless, largest GGUF size |
ollama pull hf.co/ermiaazarkhalili/Gemma4-E4B-Function-Calling-xLAM-Unsloth-GGUF:Q4_K_M
ollama run hf.co/ermiaazarkhalili/Gemma4-E4B-Function-Calling-xLAM-Unsloth-GGUF:Q4_K_M "Check if the numbers 8 and 1233 are powers of two."
./llama-cli -m Gemma4-E4B-Function-Calling-xLAM-Unsloth-Q4_K_M.gguf -p "Check if the numbers 8 and 1233 are powers of two." -n 512
| Package | Version |
|---|---|
| Unsloth | 2026.4.4 |
| TRL | 0.24.0 |
| Transformers | 5.5.0 |
| PyTorch | 2.9.0 |
| Datasets | 4.3.0 |
| PEFT | 0.18.1 |
| BitsAndBytes | 0.49.2 |
@misc{ermiaazarkhalili_gemma4_e4b_function_calling_xlam_unsloth,
author = {ermiaazarkhalili},
title = {Gemma4-E4B-Function-Calling-xLAM-Unsloth: Fine-tuned Gemma4-E4B-it with Unsloth},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/ermiaazarkhalili/Gemma4-E4B-Function-Calling-xLAM-Unsloth}}
}