CoolFace
Modelpublic

ymcki/gemma-2-2b-jpn-it-GGUF

sourceHugging Facegemmaupdated 2y agoView on Hugging Face
1likes300downloads
Model Card

Original model: https://huggingface.co/google/gemma-2-2b-jpn-it

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.

FilenameQuant typeFile SizeELIZA-Tasks-100Nvidia 3090Description
gemma-2-2b-jpn-it.f16.gguff165.24GB2.9098t/sFull F16 weights.
gemma-2-2b-jpn-it.Q8_0.ggufQ8_02.78GB3.06140t/sExtremely high quality, recommended.
gemma-2-2b-jpn-it-imatrix.Q4_0.ggufQ4_01.63GB2.89137t/sGood quality, recommended for edge devices <8GB RAM.
gemma-2-2b-jpn-it-imatrix.Q4_0_8_8.ggufQ408_81.63GB2.782.79t/sGood quality, recommended for edge devices <8GB RAM.
gemma-2-2b-jpn-it-imatrix.Q4_0_4_8.ggufQ404_81.63GB2.772.61t/sGood quality, recommended for edge devices <8GB RAM.
gemma-2-2b-jpn-it-imatrix.Q4_0_4_4.ggufQ404_41.63GB2.653.09t/sGood quality, recommended for edge devices <8GB RAM.
gemma-2-2b-jpn-it.Q4_0.ggufQ4_01.63GB2.77159t/sGood quality, recommended for edge devices <8GB RAM
gemma-2-2b-jpn-it.Q4_0_8_8.ggufQ408_81.63GB2.922.85t/sGood quality, recommended for edge devices <8GB RAM
gemma-2-2b-jpn-it.Q4_0_4_8.ggufQ404_81.63GB2.742.56t/sGood quality, recommended for edge devices <8GB RAM
gemma-2-2b-jpn-it.Q4_0_4_4.ggufQ404_41.63GB2.703.10t/sGood quality, recommended for edge devices <8GB RAM.

How to check i8mm and sve support for ARM devices

ARM i8mm support is necessary to take advantage of Q404_8 gguf. All ARM architecture >= ARMv8.6-A supports i8mm.

ARM sve support is necessary to take advantage of Q408_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 Q404_4.

With these support, the inference speed should be faster in the order of Q4088 > Q4048 > Q4044 > Q40 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 covers 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 Q408_8.

On the other hand, Nvidia 3090 inference speed is significantly faster for Q40 than the other ggufs. That means for GPU inference, you better off using Q40.

Which Q4_0 model to use for ARM devices

BrandSeriesModeli8mmsveQuant Type
AppleAA4 to A14NoNoQ404_4
AppleAA15 to A18YesNoQ404_8
AppleMM1NoNoQ404_4
AppleMM2/M3/M4YesNoQ404_8
GoogleTensorG1,G2NoNoQ404_4
GoogleTensorG3,G4YesYesQ408_8
SamsungExynos2200,2400YesYesQ408_8
MediatekDimensity9000,9000+YesYesQ408_8
MediatekDimensity9300YesNoQ404_8
QualcommSnapdragon7+ Gen 2,8/8+ Gen 1YesYesQ408_8
QualcommSnapdragon8 Gen 2,8 Gen 3,X EliteYesNoQ404_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, the difference is not significant.

Convert safetensors to f16 gguf

Make sure you have llama.cpp git cloned:

python3 convert_hf_to_gguf.py gemma-2-2b-jpn-it/ --outfile gemma-2-2b-jpn-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-2b-jpn-it.f16.gguf gemma-2-2b-jpn-it.Q8_0.gguf q8_0

Convert f16 gguf to other ggufs with imatrix

First, prepare imatrix from f16 gguf and c4enja_imatrix.txt

./llama-imatrix -m gemma-2-2b-jpn-it.f16.gguf -f c4_en_ja_imatrix.txt -o gemma-2-2b-jpn-it.imatrix --chunks 32

Then, convert f16 gguf with imatrix to create imatrix gguf

./llama-quantize --imatrix gemma-2-2b-jpn-it.imatrix gemma-2-2b-jpn-it.f16.gguf gemma-2-2b-jpn-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-2b-jpn-it-GGUF --include "gemma-2-2b-jpn-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.