Instructions to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF", dtype="auto") - llama-cpp-python
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF", filename="Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q2_K.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
- SGLang
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with Ollama:
ollama run hf.co/QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
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 QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF to start chatting
Install Unsloth Studio (Windows)
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 QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF-Q4_K_M
List all available models
lemonade list
QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF
This is quantized version of hiieu/Meta-Llama-3-8B-Instruct-function-calling-json-mode created using llama.cpp
Model Description
This model was fine-tuned on meta-llama/Meta-Llama-3-8B-Instruct for function calling and json mode.
Usage
JSON Mode
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "hiieu/Meta-Llama-3-8B-Instruct-function-calling-json-mode"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "system", "content": "You are a helpful assistant, answer in JSON with key \"message\""},
{"role": "user", "content": "Who are you?"},
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.generate(
input_ids,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
# >> {"message": "I am a helpful assistant, with access to a vast amount of information. I can help you with tasks such as answering questions, providing definitions, translating text, and more. Feel free to ask me anything!"}
Function Calling
Function calling requires two step inferences, below is the example:
Step 1:
functions_metadata = [
{
"type": "function",
"function": {
"name": "get_temperature",
"description": "get temperature of a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "name"
}
},
"required": [
"city"
]
}
}
}
]
messages = [
{ "role": "system", "content": f"""You are a helpful assistant with access to the following functions: \n {str(functions_metadata)}\n\nTo use these functions respond with:\n<functioncall> {{ "name": "function_name", "arguments": {{ "arg_1": "value_1", "arg_1": "value_1", ... }} }} </functioncall>\n\nEdge cases you must handle:\n - If there are no functions that match the user request, you will respond politely that you cannot help."""},
{ "role": "user", "content": "What is the temperature in Tokyo right now?"}
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.generate(
input_ids,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
# >> <functioncall> {"name": "get_temperature", "arguments": '{"city": "Tokyo"}'} </functioncall>"""}
Step 2:
messages = [
{ "role": "system", "content": f"""You are a helpful assistant with access to the following functions: \n {str(functions_metadata)}\n\nTo use these functions respond with:\n<functioncall> {{ "name": "function_name", "arguments": {{ "arg_1": "value_1", "arg_1": "value_1", ... }} }} </functioncall>\n\nEdge cases you must handle:\n - If there are no functions that match the user request, you will respond politely that you cannot help."""},
{ "role": "user", "content": "What is the temperature in Tokyo right now?"},
# You will get the previous prediction, extract it will the tag <functioncall>
# execute the function and append it to the messages like below:
{ "role": "assistant", "content": """<functioncall> {"name": "get_temperature", "arguments": '{"city": "Tokyo"}'} </functioncall>"""},
{ "role": "user", "content": """<function_response> {"temperature":30 C} </function_response>"""}
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.generate(
input_ids,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
# >> The current temperature in Tokyo is 30 degrees Celsius.
Uploaded model
- Developed by: hiieu
This model was trained 2x faster with Unsloth and Huggingface's TRL library.
- Downloads last month
- 218
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
Model tree for QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF
Base model
meta-llama/Meta-Llama-3-8B-Instruct