Downloads · 30 days
8
6% of all-time downloads
asanchez75/Llama-3.2-3B-tool-search
Llama-3.2-3B-tool-search is a machine learning model from asanchez75. 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 llama3.
This model (LoRA adapter) is a fine-tuned version of LLaMA-3.2-3B that specializes in tool calling capabilities. It has been trained to decide when to use one of two available tools: searchdocuments or checkandconnect…
Downloads · 30 days
8
6% of all-time downloads
All-time downloads
139
Public
Repo size
115 MB
Likes
0
Public
Click a slice to open those files.
.safetensors97.3 MB · 85%
From the Hugging Face model README
This model (LoRA adapter) is a fine-tuned version of LLaMA-3.2-3B that specializes in tool calling capabilities.
It has been trained to decide when to use one of two available tools: search_documents or check_and_connect based on user queries, responding with properly formatted JSON function calls.
This model is a Parameter-Efficient Fine-Tuning (PEFT) adaptation of LLaMA-3.2-3B focused on tool use. It employs Low-Rank Adaptation (LoRA) to efficiently fine-tune the base model for function calling capabilities.
This model is designed to be used as an AI assistant that can intelligently determine when to call external tools. It specializes in two specific functions:
search_documents: Triggered when users ask for medical information (prefixed with "Search information about")check_and_connect: Triggered when users ask about system status or connectivityThe model outputs properly formatted JSON function calls that can be parsed by downstream applications to execute the appropriate tools.
This model can be integrated into:
This model should not be used for:
Users (both direct and downstream) should:
Use the code below to get started with the model:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the model and tokenizer
model_path = "your-username/llama-3-2-3b-tool-caller-lora" # Replace with actual path
model = AutoModelForCausalLM.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
# Define the prompting format (must match training)
SYSTEM_PROMPT = """Environment: ipython
Cutting Knowledge Date: December 2023
Today Date: 18 May 2025"""
USER_INSTRUCTION_HEADER = """Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.
Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. Do not use variables.
{ "type": "function", "function": { "name": "check_and_connect", "description": "check_and_connect", "parameters": { "properties": {}, "type": "object" } } }
{ "type": "function", "function": { "name": "search_documents", "description": "\n Searches for documents based on a user's query string. Use this to find information on a specific topic.\n\n ", "parameters": { "properties": { "query": { "description": "The actual search phrase or question. For example, 'What are the causes of climate change?' or 'population of Madre de Dios'.", "type": "string" } }, "required": [ "query" ], "type": "object" } } }
"""
# Example 1: Information query (add the prefix)
user_query = "What is the capital of France?"
formatted_query = f"Search information about {user_query}" # Add prefix for search_documents in French
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f"{USER_INSTRUCTION_HEADER}{formatted_query}"},
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
outputs = model.generate(input_ids=inputs, max_new_tokens=128)
response = tokenizer.decode(outputs[0, inputs.shape[-1]:], skip_special_tokens=True)
print(response)
# Example 2: System status query (no prefix needed)
status_query = "Are we connected?"
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f"{USER_INSTRUCTION_HEADER}{status_query}"},
]
# Generate response...
The model was trained on a custom dataset with 1,050 examples from asanchez75/tool_finetuning_dataset:
The dataset was created in JSONL format with each entry having a complete conversation structure including system, user, and assistant messages.
The model was fine-tuned using Unsloth's optimized implementation of LoRA over a 4-bit quantized version of LLaMA-3.2-3B-Instruct.
The model was evaluated on sample inference examples from both categories:
Qualitative evaluation showed the model successfully distinguishes between:
search_documents tool (when prefixed appropriately)check_and_connect toolCarbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[Your contact information]