glaiveai/glaive-function-calling-v2
Viewer β’ Updated β’ 113k β’ 38.6k β’ 515
How to use alok21in/llama-3.1-8b-function-calling with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for alok21in/llama-3.1-8b-function-calling to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for alok21in/llama-3.1-8b-function-calling to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for alok21in/llama-3.1-8b-function-calling to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="alok21in/llama-3.1-8b-function-calling",
max_seq_length=2048,
)Fine-tuned by Alok Kumar Dubey | GitHub | LinkedIn | HuggingFace
A LoRA adapter fine-tuned on top of Meta-Llama-3.1-8B-Instruct for function calling and tool use. The model learns to identify when to call a function, generate correct JSON arguments, and formulate a natural language response from the function output.
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "alok21in/llama-3.1-8b-function-calling",
max_seq_length = 1024,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
prompt = """Below is a system context describing available tools, followed by a user request.
### Available Tools:
You have access to a weather API that takes a city name and returns current weather.
### Conversation & Response:
USER: What is the weather in London?
ASSISTANT:"""
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=200, pad_token_id=tokenizer.eos_token_id)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Input:
USER: What is the weather in London?
Output:
<functioncall> {"name": "get_weather", "arguments": '{"city": "London"}'}
FUNCTION RESPONSE: {"city": "London", "weather": "Sunny", "temperature": 22, "humidity": 60}
The weather in London is sunny, with a temperature of 22Β°C and humidity of 60%.
| Parameter | Value |
|---|---|
| Base Model | meta-llama/Meta-Llama-3.1-8B-Instruct |
| Dataset | glaiveai/glaive-function-calling-v2 |
| Training Samples | 5,000 |
| LoRA Rank (r) | 8 |
| LoRA Alpha | 16 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Quantization | 4-bit (QLoRA) |
| Max Seq Length | 1024 |
| Batch Size | 1 (effective 8 with grad accumulation) |
| Learning Rate | 2e-4 |
| Steps | 60 |
| Optimizer | adamw_8bit |
| Hardware | Kaggle T4 GPU (15GB) |
| Framework | Unsloth 2026.4.2 + TRL |
| Step | Loss |
|---|---|
| 1 | 1.1046 |
| 10 | 0.6266 |
| 30 | 0.4327 |
| 60 | 0.6127 |
Loss decreased from 1.10 β ~0.4 showing successful learning.
This model is built on Meta's Llama 3.1 and follows the Llama 3 Community License.
Base model
meta-llama/Llama-3.1-8B