π¦ Llama 3.1 8B β Function Calling (LoRA)
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.
π Quick Start
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))
π Example Output
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%.
ποΈ Training Details
| 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 |
π Training Loss
| Step | Loss |
|---|---|
| 1 | 1.1046 |
| 10 | 0.6266 |
| 30 | 0.4327 |
| 60 | 0.6127 |
Loss decreased from 1.10 β ~0.4 showing successful learning.
β οΈ Limitations
- Trained on only 5,000 samples β a larger run would improve reliability
- Only 60 training steps β more steps would reduce loss further
- Best used as a research/portfolio demonstration
π License
This model is built on Meta's Llama 3.1 and follows the Llama 3 Community License.
π Acknowledgements
Model tree for alok21in/llama-3.1-8b-function-calling
Base model
meta-llama/Llama-3.1-8B Finetuned
meta-llama/Llama-3.1-8B-Instruct