Instructions to use unsloth/mistral-7b-v0.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/mistral-7b-v0.2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsloth/mistral-7b-v0.2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("unsloth/mistral-7b-v0.2") model = AutoModelForCausalLM.from_pretrained("unsloth/mistral-7b-v0.2") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/mistral-7b-v0.2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/mistral-7b-v0.2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/mistral-7b-v0.2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/unsloth/mistral-7b-v0.2
- SGLang
How to use unsloth/mistral-7b-v0.2 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 "unsloth/mistral-7b-v0.2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/mistral-7b-v0.2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "unsloth/mistral-7b-v0.2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/mistral-7b-v0.2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Studio
How to use unsloth/mistral-7b-v0.2 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 unsloth/mistral-7b-v0.2 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 unsloth/mistral-7b-v0.2 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/mistral-7b-v0.2 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="unsloth/mistral-7b-v0.2", max_seq_length=2048, ) - Docker Model Runner
How to use unsloth/mistral-7b-v0.2 with Docker Model Runner:
docker model run hf.co/unsloth/mistral-7b-v0.2
AQLM quantization version please
Hello, can you add an AQLM (https://arxiv.org/abs/2401.06118) quantization version of this model please ? And if possible a jupyter notebook to fine tune it faster ? Thank you! You are the best!
Thank you we'll take a look! Regarding notebooks, have you tried using our Mistral 7b v2 notebook? Here: https://twitter.com/danielhanchen/status/1771737648266178801
And thanks for the kind words! ❤️
Thanks for your answer! The speed of progress is really incredible. Just found out few days ago about AQLM 1 bit quantization and now it was discovered even better quantization of lower than 1 bit ... QMoE: Practical Sub-1-Bit Compression of Trillion-Parameter Models https://huggingface.co/papers/2310.16795 . Do not get me wrong ...you are already are doing wonderful things . I just put here what I found so that maybe we advance faster and obtain very powerful models at very low computation costs and affordable for anyone . If you get a chance look at those new quantization methods and try to adapt it to your already great work . Thank you again !
Yes thank you for your suggestions, we'll definitely be taking a look at doing more optimizations soon! If you have anymore advice/suggestions please send them our way! ^^
LOL. I can't even have time to read all revolutionary progress that is done in this AI wonder field of science :P . Here is another interesting direction for high optimization : "Quantized Embeddings are here! Unlike model quantization, embedding quantization is a post-processing step for embeddings that converts e.g. float32 embeddings to binary or int8 embeddings. This saves 32x or 4x memory & disk space, and these embeddings are much easier to compare!
Results show 25-45x speedups in retrieval compared to full-size embeddings, while keeping 96% of the performance! " https://huggingface.co/blog/embedding-quantization