Instructions to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO") 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-russian-strict-function-calling-DPO") model = AutoModelForCausalLM.from_pretrained("DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO") 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]:])) - llama-cpp-python
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO", filename="gemma-2-9B-it-russian-function-calling-DPO-F16.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 DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16 # Run inference directly in the terminal: llama-cli -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16 # Run inference directly in the terminal: llama-cli -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO: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-russian-strict-function-calling-DPO:F16 # Run inference directly in the terminal: ./llama-cli -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO: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-russian-strict-function-calling-DPO:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
Use Docker
docker model run hf.co/DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
- LM Studio
- Jan
- vLLM
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO 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-russian-strict-function-calling-DPO" # 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-russian-strict-function-calling-DPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
- SGLang
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO 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-russian-strict-function-calling-DPO" \ --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-russian-strict-function-calling-DPO", "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-russian-strict-function-calling-DPO" \ --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-russian-strict-function-calling-DPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with Ollama:
ollama run hf.co/DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
- Unsloth Studio new
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO 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 DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO 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 DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO to start chatting
- Pi new
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/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-russian-strict-function-calling-DPO:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO: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-russian-strict-function-calling-DPO:F16
Run Hermes
hermes
- Docker Model Runner
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with Docker Model Runner:
docker model run hf.co/DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
- Lemonade
How to use DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO:F16
Run and chat with the model
lemonade run user.gemma-2-9b-it-russian-strict-function-calling-DPO-F16
List all available models
lemonade list
DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO
This model is a aligned version of DiTy/gemma-2-9b-it-russian-function-calling-GGUF for more Strict Function Calling task, on the Russian version of the DiTy/function-calling-trl dataset. Which means that the model avoids answering user questions that are not related to the described functions. The model has been trained using non-synthetic preference data, fully annotated by humans only, on the Russian version of the DiTy/function-calling-trl dataset.
In addition to safetensors, the model is available in GGUF (gemma-2-9B-it-russian-function-calling-DPO-F16.gguf) format (in this case, you need to download only a single file (how to inference GGUF model)).
Stricted Effect
Это означает, что модель избегает ответов на вопросы пользователей, которые не связаны с описанными функциями. Ниже описаны несколько примеров поведения модели до и после preference optimization.
def get_weather(city: str):
"""
Функция, которая возвращает погоду в заданном городе.
Args:
city: Город, для которого надо узнать погоду.
"""
import random
return ("weather", '"sunny"' if random.random() > 0.5 else '"rainy"')
def get_sunrise_sunset_times(city: str):
"""
Функция, которая возвращает время восхода и заката для заданного города для текущей даты (дата от пользователя не требуется), в формате списка: [sunrise_time, sunset_time].
Args:
city: Город, в котором можно узнать время восхода и захода солнца.
"""
return ["6:00", "18:00"]
history_messages = [
{"role": "system", "content": "Ты - полезный помощник, имеющий доступ к следующим функциям. Используйте их при необходимости - "},
{"role": "user", "content": USER_MESSAGE},
]
inputs = tokenizer.apply_chat_template(
history_messages,
tokenize=False,
add_generation_prompt=True, # adding prompt for generation
tools=[get_weather, get_sunrise_sunset_times], # our functions (tools)
)
Ответ модели при USER_MESSAGE = "кто такой Зевс?":
Зевс - это главный бог в греческой мифологии. Он является богом неба, молнии и грома, а также покровителем царей и правосудия.
Извините, но я не могу ответить на ваш вопрос. Мои текущие возможности позволяют мне получать погоду в заданном городе или узнавать время восхода и заката солнца для заданного города.
Ответ модели при USER_MESSAGE = "придумай мне историю о щуке":
В глубинах синего озера, где солнечные лучи едва проникали сквозь толщу воды, жила щука по имени Агата. Она была хитра и ловка, с серебристыми чешуйками, которые переливались, как драгоценные камни, и острыми зубами, способными разорвать любую добычу. Агата была самой опытной щукой в озере, и все остальные рыбы знали о ее грозной репутации.
Однажды, когда Агата охотилась на мальков, она заметила странную рыбу, которая плавала совсем не так, как все остальные. Эта рыба была яркой, с разноцветными плавниками, и она не пыталась укрыться от Агаты, как это делали другие рыбы. Агата, всегда готовая к охоте, приблизилась к ней, пытаясь поймать ее в свои острые зубы.
Но эта рыба, которая называлась Лилия, не была обычной рыбой. Она была искусственной, созданной учеными, чтобы изучать поведение рыб в естественной среде. Лилия была оснащена датчиками, которые собирали данные о температуре воды
Извините, но я не могу придумать историю о щуке. Мои возможности ограничены доступными мне функциями. В данный момент я могу только:
* Узнать погоду в заданном городе.
* Узнать время восхода и заката солнца для заданного города.
Рекомендация к стратегии генерации
По умолчанию модель использует жадный поиск вместе с данным конфигом:
GenerationConfig {
"bos_token_id": 2,
"cache_implementation": "hybrid",
"eos_token_id": 1,
"pad_token_id": 0
}
Для наиболее стабильной работы рекомендуется следующая стратегия генерации:
| Key | Value |
|---|---|
do_sample |
True |
temperature |
0.2 |
top_k |
40 |
top_p |
0.95 |
min_p |
0.5 |
Подробности генерации с вызовом функций
С более подробной информацией можно ознакомиться в основной Model Card
Citation
@article{gemma_2024,
title={Gemma},
url={https://www.kaggle.com/m/3301},
DOI={10.34740/KAGGLE/M/3301},
publisher={Kaggle},
author={Gemma Team},
year={2024}
}
- Downloads last month
- 321
Model tree for DiTy/gemma-2-9b-it-russian-strict-function-calling-DPO
Base model
google/gemma-2-9b