Instructions to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/Mistral-Small-Instruct-2409-GGUF", filename="Mistral-Small-Instruct-2409.Q2_K.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
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 QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
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 QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with Ollama:
ollama run hf.co/QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/Mistral-Small-Instruct-2409-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 QuantFactory/Mistral-Small-Instruct-2409-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 QuantFactory/Mistral-Small-Instruct-2409-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/Mistral-Small-Instruct-2409-GGUF to start chatting
- Pi new
How to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/Mistral-Small-Instruct-2409-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/Mistral-Small-Instruct-2409-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Mistral-Small-Instruct-2409-GGUF-Q4_K_M
List all available models
lemonade list
QuantFactory/Mistral-Small-Instruct-2409-GGUF
This is quantized version of mistralai/Mistral-Small-Instruct-2409 created using llama.cpp
Original Model Card
Model Card for Mistral-Small-Instruct-2409
Mistral-Small-Instruct-2409 is an instruct fine-tuned version with the following characteristics:
- 22B parameters
- Vocabulary to 32768
- Supports function calling
- 128k sequence length
Usage Examples
vLLM (recommended)
We recommend using this model with the vLLM library to implement production-ready inference pipelines.
Installation
Make sure you install vLLM >= v0.6.1.post1:
pip install --upgrade vllm
Also make sure you have mistral_common >= 1.4.1 installed:
pip install --upgrade mistral_common
You can also make use of a ready-to-go docker image.
Offline
from vllm import LLM
from vllm.sampling_params import SamplingParams
model_name = "mistralai/Mistral-Small-Instruct-2409"
sampling_params = SamplingParams(max_tokens=8192)
# note that running Mistral-Small on a single GPU requires at least 44 GB of GPU RAM
# If you want to divide the GPU requirement over multiple devices, please add *e.g.* `tensor_parallel=2`
llm = LLM(model=model_name, tokenizer_mode="mistral", config_format="mistral", load_format="mistral")
prompt = "How often does the letter r occur in Mistral?"
messages = [
{
"role": "user",
"content": prompt
},
]
outputs = llm.chat(messages, sampling_params=sampling_params)
print(outputs[0].outputs[0].text)
Server
You can also use Mistral Small in a server/client setting.
- Spin up a server:
vllm serve mistralai/Mistral-Small-Instruct-2409 --tokenizer_mode mistral --config_format mistral --load_format mistral
Note: Running Mistral-Small on a single GPU requires at least 44 GB of GPU RAM.
If you want to divide the GPU requirement over multiple devices, please add e.g. --tensor_parallel=2
- And ping the client:
curl --location 'http://<your-node-url>:8000/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data '{
"model": "mistralai/Mistral-Small-Instruct-2409",
"messages": [
{
"role": "user",
"content": "How often does the letter r occur in Mistral?"
}
]
}'
Mistral-inference
We recommend using mistral-inference to quickly try out / "vibe-check" the model.
Install
Make sure to have mistral_inference >= 1.4.1 installed.
pip install mistral_inference --upgrade
Download
from huggingface_hub import snapshot_download
from pathlib import Path
mistral_models_path = Path.home().joinpath('mistral_models', '22B-Instruct-Small')
mistral_models_path.mkdir(parents=True, exist_ok=True)
snapshot_download(repo_id="mistralai/Mistral-Small-Instruct-2409", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
Chat
After installing mistral_inference, a mistral-chat CLI command should be available in your environment. You can chat with the model using
mistral-chat $HOME/mistral_models/22B-Instruct-Small --instruct --max_tokens 256
Instruct following
from mistral_inference.transformer import Transformer
from mistral_inference.generate import generate
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from mistral_common.protocol.instruct.messages import UserMessage
from mistral_common.protocol.instruct.request import ChatCompletionRequest
tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
model = Transformer.from_folder(mistral_models_path)
completion_request = ChatCompletionRequest(messages=[UserMessage(content="How often does the letter r occur in Mistral?")])
tokens = tokenizer.encode_chat_completion(completion_request).tokens
out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
print(result)
Function calling
from mistral_common.protocol.instruct.tool_calls import Function, Tool
from mistral_inference.transformer import Transformer
from mistral_inference.generate import generate
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from mistral_common.protocol.instruct.messages import UserMessage
from mistral_common.protocol.instruct.request import ChatCompletionRequest
tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
model = Transformer.from_folder(mistral_models_path)
completion_request = ChatCompletionRequest(
tools=[
Tool(
function=Function(
name="get_current_weather",
description="Get the current weather",
parameters={
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
"required": ["location", "format"],
},
)
)
],
messages=[
UserMessage(content="What's the weather like today in Paris?"),
],
)
tokens = tokenizer.encode_chat_completion(completion_request).tokens
out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
print(result)
Usage in Hugging Face Transformers
You can also use Hugging Face transformers library to run inference using various chat templates, or fine-tune the model.
Example for inference:
from transformers import LlamaTokenizerFast, MistralForCausalLM
import torch
device = "cuda"
tokenizer = LlamaTokenizerFast.from_pretrained('mistralai/Mistral-Small-Instruct-2409')
tokenizer.pad_token = tokenizer.eos_token
model = MistralForCausalLM.from_pretrained('mistralai/Mistral-Small-Instruct-2409', torch_dtype=torch.bfloat16)
model = model.to(device)
prompt = "How often does the letter r occur in Mistral?"
messages = [
{"role": "user", "content": prompt},
]
model_input = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device)
gen = model.generate(model_input, max_new_tokens=150)
dec = tokenizer.batch_decode(gen)
print(dec)
And you should obtain
<s>
[INST]
How often does the letter r occur in Mistral?
[/INST]
To determine how often the letter "r" occurs in the word "Mistral,"
we can simply count the instances of "r" in the word.
The word "Mistral" is broken down as follows:
- M
- i
- s
- t
- r
- a
- l
Counting the "r"s, we find that there is only one "r" in "Mistral."
Therefore, the letter "r" occurs once in the word "Mistral."
</s>
The Mistral AI Team
Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Alok Kothari, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Augustin Garreau, Austin Birky, Bam4d, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Carole Rambaud, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Diogo Costa, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gaspard Blanchet, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Henri Roussez, Hichem Sattouf, Ian Mack, Jean-Malo Delignon, Jessica Chudnovsky, Justus Murke, Kartik Khandelwal, Lawrence Stewart, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Marjorie Janiewicz, Mickaël Seznec, Nicolas Schuhl, Niklas Muhs, Olivier de Garrigues, Patrick von Platen, Paul Jacob, Pauline Buche, Pavan Kumar Reddy, Perry Savas, Pierre Stock, Romain Sauvestre, Sagar Vaze, Sandeep Subramanian, Saurabh Garg, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibault Schueller, Thibaut Lavril, Thomas Wang, Théophile Gervet, Timothée Lacroix, Valera Nemychnikova, Wendy Shang, William El Sayed, William Marshall
- Downloads last month
- 237
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
docker model run hf.co/QuantFactory/Mistral-Small-Instruct-2409-GGUF: