Team Ai
Apppublic

KBaba7/llama.cpp

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
README.md34 linesDownload Raw Back to imatrix
1# llama.cpp/examples/imatrix2 3Compute an importance matrix for a model and given text dataset. Can be used during quantization to enchance the quality of the quantized models.4More information is available here: https://github.com/ggerganov/llama.cpp/pull/48615 6## Usage7 8```9./llama-imatrix \10    -m model.gguf -f some-text.txt [-o imatrix.dat] [--process-output] [--verbosity 1] \11    [--no-ppl] [--chunk 123] [--output-frequency 10] [--save-frequency 0] \12    [--in-file imatrix-prev-0.dat --in-file imatrix-prev-1.dat ...]13```14 15Here `-m` with a model name and `-f` with a file containing training data (such as e.g. `wiki.train.raw`) are mandatory.16The parameters in square brackets are optional and have the following meaning:17* `-o` (or `--output-file`) specifies the name of the file where the computed data will be stored. If missing `imatrix.dat` is used.18* `--verbosity` specifies the verbosity level. If set to `0`, no output other than the perplexity of the processed chunks will be generated. If set to `1`, each time the results are saved a message is written to `stderr`. If `>=2`, a message is output each time data is collected for any tensor. Default verbosity level is `1`.19* `--output-frequency` specifies how often the so far computed result is saved to disk. Default is 10 (i.e., every 10 chunks)20* `--save-frequency` specifies how often to save a copy of the imatrix in a separate file. Default is 0 (i.e., never)21* `--process-output` specifies if data will be collected for the `output.weight` tensor. My experience is that it is better to not utilize the importance matrix when quantizing `output.weight`, so this is set to `false` by default.22 23For faster computation, make sure to use GPU offloading via the `-ngl` argument24 25## Example26 27```bash28# generate importance matrix (imatrix.dat)29./llama-imatrix -m ggml-model-f16.gguf -f train-data.txt -ngl 9930 31# use the imatrix to perform a Q4_K_M quantization32./llama-quantize --imatrix imatrix.dat ggml-model-f16.gguf ./ggml-model-q4_k_m.gguf q4_k_m33```34