Instructions to use ymcki/gemma-2-9b-it-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ymcki/gemma-2-9b-it-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ymcki/gemma-2-9b-it-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ymcki/gemma-2-9b-it-GGUF", dtype="auto") - llama-cpp-python
How to use ymcki/gemma-2-9b-it-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="ymcki/gemma-2-9b-it-GGUF", filename="gemma-2-9b-it-imatrix.Q4_0.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 ymcki/gemma-2-9b-it-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf ymcki/gemma-2-9b-it-GGUF:Q4_0 # Run inference directly in the terminal: llama-cli -hf ymcki/gemma-2-9b-it-GGUF:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf ymcki/gemma-2-9b-it-GGUF:Q4_0 # Run inference directly in the terminal: llama-cli -hf ymcki/gemma-2-9b-it-GGUF:Q4_0
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 ymcki/gemma-2-9b-it-GGUF:Q4_0 # Run inference directly in the terminal: ./llama-cli -hf ymcki/gemma-2-9b-it-GGUF:Q4_0
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 ymcki/gemma-2-9b-it-GGUF:Q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf ymcki/gemma-2-9b-it-GGUF:Q4_0
Use Docker
docker model run hf.co/ymcki/gemma-2-9b-it-GGUF:Q4_0
- LM Studio
- Jan
- vLLM
How to use ymcki/gemma-2-9b-it-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ymcki/gemma-2-9b-it-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": "ymcki/gemma-2-9b-it-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ymcki/gemma-2-9b-it-GGUF:Q4_0
- SGLang
How to use ymcki/gemma-2-9b-it-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 "ymcki/gemma-2-9b-it-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": "ymcki/gemma-2-9b-it-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 "ymcki/gemma-2-9b-it-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": "ymcki/gemma-2-9b-it-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use ymcki/gemma-2-9b-it-GGUF with Ollama:
ollama run hf.co/ymcki/gemma-2-9b-it-GGUF:Q4_0
- Unsloth Studio new
How to use ymcki/gemma-2-9b-it-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 ymcki/gemma-2-9b-it-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 ymcki/gemma-2-9b-it-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ymcki/gemma-2-9b-it-GGUF to start chatting
- Docker Model Runner
How to use ymcki/gemma-2-9b-it-GGUF with Docker Model Runner:
docker model run hf.co/ymcki/gemma-2-9b-it-GGUF:Q4_0
- Lemonade
How to use ymcki/gemma-2-9b-it-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ymcki/gemma-2-9b-it-GGUF:Q4_0
Run and chat with the model
lemonade run user.gemma-2-9b-it-GGUF-Q4_0
List all available models
lemonade list
- Description
- Prompt format
- Download a file (not the whole branch) from below:
- How to check i8mm and sve support for ARM devices
- Which Q4_0 model to use for ARM devices
- imatrix quantization
- Convert safetensors to f16 gguf
- Convert f16 gguf to Q8_0 gguf without imatrix
- Convert f16 gguf to other ggufs with imatrix
- Downloading using huggingface-cli
- Credits
Original model: https://huggingface.co/google/gemma-2-9b-it
Description
The purpose of this repository is to see whether Japanese specific imatrix can improve the performance of a non Japanese optimized model.
It also provides the Q4_0_8_8, Q4_0_4_8 and Q4_0_4_4 ggufs for edge devices that were otherwise not made by bartowski. These models should also be good for edge devices with 16GB RAM.
Prompt format
<start_of_turn>user
{prompt}<end_of_turn>
<start_of_turn>model
<end_of_turn>
<start_of_turn>model
Note that this model does not support a System prompt.
Download a file (not the whole branch) from below:
ELIZA-Tasks-100 is pretty standard benchmark for Japanese LLMs. The perfect score is 5.00. As a reference, bartowski's gemma-2-27b-it.Q6_K.gguf scores 4.04.
| Filename | Quant type | File Size | ELIZA-Tasks-100 | Nvidia 3090 | Description |
|---|---|---|---|---|---|
| gemma-2-9b-it.f16.gguf | f16 | 18.5GB | 3.75 | 31.9t/s | Full F16 weights. |
| gemma-2-9b-it.Q8_0.gguf | Q8_0 | 9.83GB | 3.66 | 56.1t/s | Extremely high quality, recommended for edge devices with 16GB RAM. |
| gemma-2-9b-it-imatrix.Q4_0.gguf | Q4_0 | 5.44GB | 3.76 | 80.6t/s | Good quality, recommended for edge devices wth 8GB RAM. |
| gemma-2-9b-it-imatrix.Q4_0_8_8.gguf | Q4_0_8_8 | 5.44GB | 3.74 | 0.7t/s | Good quality, recommended for edge devices with 8GB RAM. |
| gemma-2-9b-it-imatrix.Q4_0_4_8.gguf | Q4_0_4_8 | 5.44GB | 3.64 | 0.7t/s | Good quality, recommended for edge devices with 8GB RAM. |
| gemma-2-9b-it-imatrix.Q4_0_4_4.gguf | Q4_0_4_4 | 5.44GB | 3.72 | 0.72t/s | Good quality, recommended for edge devices with 8GB RAM. |
| gemma-2-9b-it.Q4_0.gguf | Q4_0 | 5.44GB | 3.64 | 65.1t/s | Good quality, recommended for edge device with 8GB RAM |
| gemma-2-9b-it.Q4_0_8_8.gguf | Q4_0_8_8 | 5.44GB | 3.64 | 0.57t/s | Good quality but imatrix version seems better. |
| gemma-2-9b-it.Q4_0_4_8.gguf | Q4_0_4_8 | 5.44GB | 3.68 | 0.61t/s | Good quality but imatrix version seems better. |
| gemma-2-9b-it.Q4_0_4_4.gguf | Q4_0_4_4 | 5.44GB | 3.63 | 0.76t/s | Good quality but imatrix version seems better. |
How to check i8mm and sve support for ARM devices
ARM i8mm support is necessary to take advantage of Q4_0_4_8 gguf. All ARM architecture >= ARMv8.6-A supports i8mm.
ARM sve support is necessary to take advantage of Q4_0_8_8 gguf. sve is an optional feature that starts from ARMv8.2-A but majority of ARM chips doesn't implement it.
For ARM devices without both, it is recommended to use Q4_0_4_4. However, in reality, Q4_0 can perform better for some phones, so you better try both and see which one is better.
With these support, the inference speed should be faster in the order of Q4_0_8_8 > Q4_0_4_8 > Q4_0_4_4 > Q4_0 without much effect on the quality of response.
This is a list of ARM CPUs that support different ARM instructions. Another list. Apparently, they only cover limited number of ARM CPUs. It is better you check for i8mm and sve support by yourself.
For Apple devices,
sysctl hw
For other ARM devices (ie most Android devices),
cat /proc/cpuinfo
There are also android apps that can display /proc/cpuinfo.
I was told that for Intel/AMD CPU inference, support for AVX2/AVX512 can also improve the performance of Q4_0_8_8.
On the other hand, Nvidia 3090 inference speed is significantly faster for Q4_0 than the other ggufs. That means for GPU inference, you better off using Q4_0.
Which Q4_0 model to use for ARM devices
| Brand | Series | Model | i8mm | sve | Quant Type |
|---|---|---|---|---|---|
| Apple | A | A4 to A14 | No | No | Q4_0_4_4 |
| Apple | A | A15 to A18 | Yes | No | Q4_0_4_8 |
| Apple | M | M1 | No | No | Q4_0_4_4 |
| Apple | M | M2/M3/M4 | Yes | No | Q4_0_4_8 |
| Tensor | G1,G2 | No | No | Q4_0_4_4 | |
| Tensor | G3,G4 | Yes | Yes | Q4_0_8_8 | |
| Samsung | Exynos | 2200,2400 | Yes | Yes | Q4_0_8_8 |
| Mediatek | Dimensity | 9000,9000+ | Yes | Yes | Q4_0_8_8 |
| Mediatek | Dimensity | 9300 | Yes | No | Q4_0_4_8 |
| Qualcomm | Snapdragon | 7+ Gen 2,8/8+ Gen 1 | Yes | Yes | Q4_0_8_8 |
| Qualcomm | Snapdragon | 8 Gen 2,8 Gen 3,X Elite | Yes | No | Q4_0_4_8 |
imatrix quantization
According to this blog, adding imatrix to low bit quant can significantly improve performance. The best dataset for Japanese is MTFMC/imatrix-dataset-for-japanese-llm. Therefore, I also created the imatrix versions of different Q4_0 quants.
However, based on my benchmarking results, it seems like imatrix does improve the performance of a non-Japanese optimized model but doesn't do much for a Japanese optimized model like gemma-2-2b-jpn-it.
Convert safetensors to f16 gguf
Make sure you have llama.cpp git cloned:
python3 convert_hf_to_gguf.py gemma-2-9b-it/ --outfile gemma-2-9b-it.f16.gguf --outtype f16
Convert f16 gguf to Q8_0 gguf without imatrix
Make sure you have llama.cpp compiled:
./llama-quantize gemma-2-9b-it.f16.gguf gemma-2-9b-it.Q8_0.gguf q8_0
Convert f16 gguf to other ggufs with imatrix
First, prepare imatrix from f16 gguf and c4_en_ja_imatrix.txt
./llama-imatrix -m gemma-2-9b-it.f16.gguf -f c4_en_ja_imatrix.txt -o gemma-2-9b-it.imatrix --chunks 32
Then, convert f16 gguf with imatrix to create imatrix gguf
./llama-quantize --imatrix gemma-2-9b-it.imatrix gemma-2-9b-it.f16.gguf gemma-2-9b-it-imatrix.Q4_0_8_8.gguf q4_0_8_8
Downloading using huggingface-cli
First, make sure you have hugginface-cli installed:
pip install -U "huggingface_hub[cli]"
Then, you can target the specific file you want:
huggingface-cli download ymcki/gemma-2-9b-it-GGUF --include "gemma-2-9b-it.Q8_0.gguf" --local-dir ./
Credits
Thank you bartowski for providing a README.md to get me started.
Thank you YoutechA320U for the ELYZA-tasks-100 auto evaluation tool.
- Downloads last month
- 80
4-bit
8-bit
16-bit