glaiveai/glaive-function-calling-v2
Viewer β’ Updated β’ 113k β’ 63.2k β’ 508
How to use cfahlgren1/natural-functions with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="cfahlgren1/natural-functions") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("cfahlgren1/natural-functions")
model = AutoModelForCausalLM.from_pretrained("cfahlgren1/natural-functions")How to use cfahlgren1/natural-functions with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "cfahlgren1/natural-functions"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "cfahlgren1/natural-functions",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/cfahlgren1/natural-functions
How to use cfahlgren1/natural-functions with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "cfahlgren1/natural-functions" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "cfahlgren1/natural-functions",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "cfahlgren1/natural-functions" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "cfahlgren1/natural-functions",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use cfahlgren1/natural-functions with Docker Model Runner:
docker model run hf.co/cfahlgren1/natural-functions
Mistral-7B finetuned for Function Calling
You are a helpful assistant with access to the following functions. Use them if required -
{
"name": "create_event",
"description": "Create a new event in the calendar",
"parameters": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The title of the event"
},
"date": {
"type": "string",
"format": "date",
"description": "The date of the event"
},
"time": {
"type": "string",
"format": "time",
"description": "The time of the event"
},
"location": {
"type": "string",
"description": "The location of the event (optional)"
}
},
"required": [
"title",
"date",
"time"
]
}
}
You are a helpful assistant with access to the following functions. Use them if required
{
"name": "calculate_shipping_cost",
"description": "Calculate the shipping cost for a package",
"parameters": {
"type": "object",
"properties": {
"weight": {
"type": "number",
"description": "The weight of the package in kilograms"
},
"destination": {
"type": "string",
"description": "The destination address"
}
},
"required": [
"weight",
"destination"
]
}
}