Downloads · 30 days
8
26% of all-time downloads
Thanush16/llama-3.2-1b-function-calling
llama-3.2-1b-function-calling is a machine learning model from Thanush16. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as mit.
A LoRA adapter that teaches Llama-3.2-1B-Instruct to emit well-formed function/tool calls. The base model understands tool-use intent but produces structurally incorrect JSON; this adapter fixes the output format.
Downloads · 30 days
8
26% of all-time downloads
All-time downloads
31
Public
Repo size
62.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors45.1 MB · 72%
From the Hugging Face model README
A LoRA adapter that teaches Llama-3.2-1B-Instruct to emit well-formed function/tool calls. The base model understands tool-use intent but produces structurally incorrect JSON; this adapter fixes the output format.
Before (base model):
{"type": "function", "function": "get_weather", "parameters": {"city": "Nagoya", "unit": "celsius"}}
After (with this adapter):
[{"name": "get_weather", "arguments": {"city": "Nagoya", "unit": "celsius"}}]
The base model used "parameters" (wrong key) and a flattened structure. The adapter corrects it to the standard name/arguments format, wrapped in a list.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
base_id = "meta-llama/Llama-3.2-1B-Instruct"
adapter_id = "Thanush16/llama-3.2-1b-function-calling"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
)
base = AutoModelForCausalLM.from_pretrained(base_id, quantization_config=bnb_config, device_map="auto")
model = PeftModel.from_pretrained(base, adapter_id)
model.eval()
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
Build prompts with tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True).
Trained on 500 examples to fix output format, not to be a broadly capable tool-use model. It reliably produces well-formed calls but wasn't evaluated for tool-selection accuracy on hard or ambiguous queries. Only the LoRA adapter is released — load it alongside the base model.