ChristianAzinn's picture
Create README.md
ab038c8 verified
|
raw
history blame
No virus
10.3 kB
---
base_model: mistral-community/Mixtral-8x22B-v0.1
inference: false
language:
- en
license: apache-2.0
model_creator: MODELCREATOR
model_name: MODELNAMEU
model_type: TODO
quantized_by: ChristianAzinn
library_name: transformers
pipeline_tag: text-generation
tags:
- quantized
- 2-bit
- 3-bit
- 4-bit
- 5-bit
- 6-bit
- 8-bit
- 16-bit
- GGUF
- mixtral
- moe
---
# mixtral-8x22b-v0.1-imatrix
Model creator: [Mistral AI](https://huggingface.co/mistralai)
Original model: [Mixtral-8x22B-v0.1](https://huggingface.co/mistral-community/Mixtral-8x22B-v0.1).
## Original Description
None so far, but check back when Mistral releases the model officially on HF Hub.
## Description
This repo contains GGUF format files for the Mixtral-8x22B-v0.1 text generation model.
These files were converted and quantized with [llama.cpp](https://github.com/ggerganov/llama.cpp) on a consumer RTX 4090.
This model supports a 65536 context window.
### Quantizer's Notes
Be warned that this model is ENORMOUS and will not run on most consumer hardware! Consider using an I quant (IQ2_XXS, IQ2_XS, IQ3_XS) for better performance per bit.
This repo also contains files uniquely quantized using an **importance matrix**, which increases response quality at little cost otherwise, supported by llama.cpp as of [PR #4861](https://github.com/ggerganov/llama.cpp/pull/4861) and supported for K-quants as of [PR #4930](https://github.com/ggerganov/llama.cpp/pull/4930). The imatrix does nothing to Q8_0, fp16, or fp32, so use another repository for those quantizations.
The files are split in a weird way because `llama.cpp/gguf-split` bugs out with extra-large models like Mixtral 8x22B. This may be fixed later.
Speaking of which, these files are split because HuggingFace limits file size to 50GB. You may need to merge them using llama.cpp's [`gguf-split`](https://github.com/ggerganov/llama.cpp/pull/6135) merge functionality, but both llama.cpp and LM Studio (as of latest release) support loading directly from model shards.
The "Original Model" link above links to a repository of HF Transformers-compatible safetensors on the Hub, but the files in this repository (the one whose README you are reading) were quantized directly from a local conversion of the original torrent.
## Compatibility
These files are compatible with [llama.cpp](https://github.com/ggerganov/llama.cpp), [LM Studio](https://lmstudio.ai/), [Ollama](https://ollama.com/), and any other service built on top of llama.cpp.
# Meta-information
## Provided Files
There's no good way for me to make a Provided Files section since each is sharded. However, I provide the following quantizations: IQ2_XXS, IQ2_XS, Q2_K, IQ3_XXS, Q3_K_S, Q3_K_M, Q3_K_L, Q4_K_S, Q4_K_M, Q5_K_S, Q5_K_M, Q6_K.
# Examples
## How to download GGUF files
**Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.
The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
* LM Studio
* LoLLMS Web UI
* Faraday.dev
### In `text-generation-webui`
Under Download Model, you can enter the model repo: ChristianAzinn/mixtral-8x22b-v0.1-imatrix and below it, a specific filename to download, such as: mixtral-8x22b-v0.1-imatrix.Q4_K_M.gguf.
Then click Download.
### On the command line, including multiple files at once
I recommend using the `huggingface-hub` Python library:
```shell
pip3 install huggingface-hub
```
Then you can download any individual model file to the current directory, at high speed, with a command like this:
```shell
huggingface-cli download ChristianAzinn/mixtral-8x22b-v0.1-imatrix mixtral-8x22b-v0.1-imatrix.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
```
<details>
<summary>More advanced huggingface-cli download usage (click to read)</summary>
You can also download multiple files at once with a pattern:
```shell
huggingface-cli download ChristianAzinn/mixtral-8x22b-v0.1-imatrix --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
```
For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
```shell
pip3 install hf_transfer
```
And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
```shell
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download ChristianAzinn/mixtral-8x22b-v0.1-imatrix mixtral-8x22b-v0.1-imatrix.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
```
Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
</details>
<!-- README_GGUF.md-how-to-download end -->
<!-- README_GGUF.md-how-to-run start -->
## Example `llama.cpp` command
Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
```shell
./main -ngl 35 -m mixtral-8x22b-v0.1-imatrix.Q4_K_M.gguf --color -c 32768 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<s>[INST] {prompt} [/INST]"
```
Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
Change `-c 32768` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
## How to run in `text-generation-webui`
Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
## How to run from Python code
You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) or [ctransformers](https://github.com/marella/ctransformers) libraries. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.
### How to load this model in Python code, using llama-cpp-python
For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
#### First install the package
Run one of the following commands, according to your system:
```shell
# Base ctransformers with no GPU acceleration
pip install llama-cpp-python
# With NVidia CUDA acceleration
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
# Or with OpenBLAS acceleration
CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
# Or with CLBLast acceleration
CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
# Or with AMD ROCm GPU acceleration (Linux only)
CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
# Or with Metal GPU acceleration for macOS systems only
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
$env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
pip install llama-cpp-python
```
#### Simple llama-cpp-python example code
```python
from llama_cpp import Llama
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
llm = Llama(
model_path="./mistral-7b-instruct-v0.2.Q4_K_M.gguf", # Download the model file first
n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
)
# Simple inference example
output = llm(
"<s>[INST] {prompt} [/INST]", # Prompt
max_tokens=512, # Generate up to 512 tokens
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
echo=True # Whether to echo the prompt
)
# Chat Completion API
llm = Llama(model_path="./mistral-7b-instruct-v0.2.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
llm.create_chat_completion(
messages = [
{"role": "system", "content": "You are a story writing assistant."},
{
"role": "user",
"content": "Write a story about llamas."
}
]
)
```
## How to use with LangChain
Here are guides on using llama-cpp-python and ctransformers with LangChain:
* [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
* [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
## How to use with LM Studio
Here are guides on using [LM Studio](https://lmstudio.ai/) to serve this model. The chat UI is very intuitive to get up and running, but don't be afraid to ask in the Discord if you have any trouble. LM Studio also supports [serving with the OpenAI API format](https://lmstudio.ai/docs/local-server), running multiple models at once, and serving [embedding models](https://huggingface.co/collections/ChristianAzinn/embedding-ggufs-6615e9f216917dfdc6773fa3).
* [LM Studio Documentation](https://lmstudio.ai/docs/welcome)
* [LM Studio Discord](https://discord.gg/aPQfnNkxGC)
## Acknowledgements
This README is inspired by those of the legendary [TheBloke](https://huggingface.co/TheBloke). They say imitation is the sincerest form of flattery, and I've elected to reuse his "Examples" section because he did it very well and I see no reason to reinvent the wheel.