Text Generation
Transformers
Safetensors
GGUF
English
gemma2
conversational
function-calling
trl
text-generation-inference
Instructions to use DiTy/gemma-2-9b-it-function-calling-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DiTy/gemma-2-9b-it-function-calling-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("DiTy/gemma-2-9b-it-function-calling-GGUF") model = AutoModelForCausalLM.from_pretrained("DiTy/gemma-2-9b-it-function-calling-GGUF", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16 # Run inference directly in the terminal: llama cli -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16 # Run inference directly in the terminal: llama cli -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16
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 DiTy/gemma-2-9b-it-function-calling-GGUF:F16 # Run inference directly in the terminal: ./llama-cli -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16
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 DiTy/gemma-2-9b-it-function-calling-GGUF:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16
Use Docker
docker model run hf.co/DiTy/gemma-2-9b-it-function-calling-GGUF:F16
- LM Studio
- Jan
- vLLM
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "DiTy/gemma-2-9b-it-function-calling-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": "DiTy/gemma-2-9b-it-function-calling-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/DiTy/gemma-2-9b-it-function-calling-GGUF:F16
- SGLang
How to use DiTy/gemma-2-9b-it-function-calling-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 "DiTy/gemma-2-9b-it-function-calling-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": "DiTy/gemma-2-9b-it-function-calling-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 "DiTy/gemma-2-9b-it-function-calling-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": "DiTy/gemma-2-9b-it-function-calling-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with Ollama:
ollama run hf.co/DiTy/gemma-2-9b-it-function-calling-GGUF:F16
- Unsloth Desktop
- Pi
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "DiTy/gemma-2-9b-it-function-calling-GGUF:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with Docker Model Runner:
docker model run hf.co/DiTy/gemma-2-9b-it-function-calling-GGUF:F16
- Lemonade
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull DiTy/gemma-2-9b-it-function-calling-GGUF:F16
Run and chat with the model
lemonade run user.gemma-2-9b-it-function-calling-GGUF-F16
List all available models
lemonade list
- Hermes Agent
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default DiTy/gemma-2-9b-it-function-calling-GGUF:F16
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use DiTy/gemma-2-9b-it-function-calling-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf DiTy/gemma-2-9b-it-function-calling-GGUF:F16
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "DiTy/gemma-2-9b-it-function-calling-GGUF:F16" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Fix chat template with system message
Browse files- README.md +7 -7
- tokenizer_config.json +1 -1
README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
| 1 |
---
|
| 2 |
-
library_name: transformers
|
| 3 |
-
tags:
|
| 4 |
-
- conversational
|
| 5 |
-
- gemma2
|
| 6 |
-
- function-calling
|
| 7 |
-
- trl
|
| 8 |
-
license: apache-2.0
|
| 9 |
base_model: google/gemma-2-9b-it
|
| 10 |
datasets:
|
| 11 |
- DiTy/function-calling
|
| 12 |
language:
|
| 13 |
- en
|
|
|
|
|
|
|
| 14 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
# DiTy/gemma-2-9b-it-function-calling-GGUF
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
base_model: google/gemma-2-9b-it
|
| 3 |
datasets:
|
| 4 |
- DiTy/function-calling
|
| 5 |
language:
|
| 6 |
- en
|
| 7 |
+
library_name: transformers
|
| 8 |
+
license: apache-2.0
|
| 9 |
pipeline_tag: text-generation
|
| 10 |
+
tags:
|
| 11 |
+
- conversational
|
| 12 |
+
- gemma2
|
| 13 |
+
- function-calling
|
| 14 |
+
- trl
|
| 15 |
---
|
| 16 |
|
| 17 |
# DiTy/gemma-2-9b-it-function-calling-GGUF
|
tokenizer_config.json
CHANGED
|
@@ -2000,7 +2000,7 @@
|
|
| 2000 |
"<end_of_turn>"
|
| 2001 |
],
|
| 2002 |
"bos_token": "<bos>",
|
| 2003 |
-
"chat_template": "\n{%- macro render_json(d, indent=4) -%}\n{%- if d is string %}\n{{ '\"' + d + '\"' }}\n{%- elif d is mapping %}\n{%- for key, value in d.items() %}\n{%- if value is string %}\n{{ \" \" * indent + '\"' + key + '\": \"' + value + '\"' }}\n{%- elif value is mapping %}\n{{ \" \" * indent + '\"' + key + '\": {' }}\n{{ render_json(value, indent + 4) }}\n{{ \" \" * indent + \"}\" }}\n{%- elif value is sequence %}\n{{ \" \" * indent + '\"' + key + '\": [\n' }}\n{%- for item in value %}\n{{- \" \" * (indent + 4) + render_json(item, indent + 4) }}\n{%- if not loop.last %},\n{% endif %}\n{%- endfor %}\n{{ '\n' + \" \" * indent + \"]\" }}\n{%- else %}\n{{ \" \" * indent + '\"' + key + '\": ' + value|string }}\n{%- endif %}\n{%- if not loop.last %},\n{% endif %}\n{%- endfor %}\n{%- elif d is sequence %}\n{%- for item in d %}\n{{ \" \" * indent + render_json(item, indent + 4) }}\n{%- if not loop.last %},\n{% endif %}\n{%- endfor %}\n{%- else %}\n{{ \" \" * indent + d|string }}\n{%- endif %}\n{%- endmacro %}\n\n\n{#- This block checks system prompt and list of tools #}\n{%- if not add_generation_prompt is defined %}\n {%- set add_generation_prompt = false %}\n{%- endif %}\n{%- if messages[0][\"role\"] == \"system\" %}\n {%- set system_message = messages[0][\"content\"] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n {%- set system_message = \"\" %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n{%- set user_messages = loop_messages | selectattr(\"role\", \"equalto\", \"user\") | list %}\n\n\n{#- This block checks for alternating user/model messages, skipping tool calling messages #}\n{%- set ns = namespace() %}\n{%- set ns.index = 0 %}\n{%- for message in loop_messages %}\n {%- if
|
| 2004 |
"clean_up_tokenization_spaces": false,
|
| 2005 |
"eos_token": "<eos>",
|
| 2006 |
"model_max_length": 1000000000000000019884624838656,
|
|
|
|
| 2000 |
"<end_of_turn>"
|
| 2001 |
],
|
| 2002 |
"bos_token": "<bos>",
|
| 2003 |
+
"chat_template": "\n{%- macro render_json(d, indent=4) -%}\n{%- if d is string %}\n{{ '\"' + d + '\"' }}\n{%- elif d is mapping %}\n{%- for key, value in d.items() %}\n{%- if value is string %}\n{{ \" \" * indent + '\"' + key + '\": \"' + value + '\"' }}\n{%- elif value is mapping %}\n{{ \" \" * indent + '\"' + key + '\": {' }}\n{{ render_json(value, indent + 4) }}\n{{ \" \" * indent + \"}\" }}\n{%- elif value is sequence %}\n{{ \" \" * indent + '\"' + key + '\": [\n' }}\n{%- for item in value %}\n{{- \" \" * (indent + 4) + render_json(item, indent + 4) }}\n{%- if not loop.last %},\n{% endif %}\n{%- endfor %}\n{{ '\n' + \" \" * indent + \"]\" }}\n{%- else %}\n{{ \" \" * indent + '\"' + key + '\": ' + value|string }}\n{%- endif %}\n{%- if not loop.last %},\n{% endif %}\n{%- endfor %}\n{%- elif d is sequence %}\n{%- for item in d %}\n{{ \" \" * indent + render_json(item, indent + 4) }}\n{%- if not loop.last %},\n{% endif %}\n{%- endfor %}\n{%- else %}\n{{ \" \" * indent + d|string }}\n{%- endif %}\n{%- endmacro %}\n\n\n{#- This block checks system prompt and list of tools #}\n{%- if not add_generation_prompt is defined %}\n {%- set add_generation_prompt = false %}\n{%- endif %}\n{%- if messages[0][\"role\"] == \"system\" %}\n {%- set system_message = messages[0][\"content\"] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n {%- set system_message = \"\" %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n{%- set user_messages = loop_messages | selectattr(\"role\", \"equalto\", \"user\") | list %}\n\n\n{#- This block checks for alternating user/model messages, skipping tool calling messages #}\n{%- set ns = namespace() %}\n{%- set ns.index = 0 %}\n{%- for message in loop_messages %}\n {%- if (message[\"role\"] == \"user\" or message[\"role\"] == \"function-response\") != (ns.index % 2 == 0) %}\n {{- raise_exception(\"After the optional system message, conversation roles must alternate user/model/user/model/... NB: 'function-call' is same as the 'model' and 'function-response' is same as the 'user'!\") }}\n {%- endif %}\n {%- set ns.index = ns.index + 1 %}\n{%- endfor %}\n\n\n{#- This block format full dialogue messages #}\n{{- bos_token }}\n{{- \"<start_of_turn>user\" + '\n' }}\n{%- if system_message != \"\" %}\n {{- system_message }}\n{%- endif %}\n{%- if tools is not none %}\n {%- for tool in tools %}\n {%- set tool = tool.function %}\n {{- '{\n' }}\n {{- render_json(tool, 4) }}\n {%- if not loop.last %}\n {{- \"\n},\n\" }}\n {%- else %}\n {{- \"\n}\n\" }}\n {% endif %}\n {%- endfor %}\n {%- elif system_message != \"\" %}\n {{- '\n\n' }}\n{%- endif %}\n{{ loop_messages[0]['content'] + '<end_of_turn>\n' }}\n{%- for message in loop_messages[1:] %}\n {%- if message[\"role\"] == \"user\" %}\n {{- \"<start_of_turn>user\" + '\n' + message['content'] + '<end_of_turn>\n' }}\n {%- elif message[\"role\"] == \"model\" %}\n {{- \"<start_of_turn>model\" + '\n' + message['content'] + '<end_of_turn>\n' }}\n {%- elif message[\"role\"] == \"function-call\" %}\n {{- \"<start_of_turn>model\" + '\n' + \"Function call: \" + message['content'] + '<end_of_turn>\n' }}\n {%- elif message[\"role\"] == \"function-response\" %}\n {{- \"<start_of_turn>user\" + '\n' + \"Function response: \" + message['content'] + '<end_of_turn>\n' }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {%- if loop_messages[-1]['role'] == \"user\" or loop_messages[-1]['role'] == \"function-response\" %}\n{{ '<start_of_turn>model\n' }}\n {%- else %}\n {{- raise_exception(\"For add_generation_prompt=True, the last message role must be 'user' or 'function-response'.\") }}\n {%- endif %}\n{%- endif %}\n\n",
|
| 2004 |
"clean_up_tokenization_spaces": false,
|
| 2005 |
"eos_token": "<eos>",
|
| 2006 |
"model_max_length": 1000000000000000019884624838656,
|