Instructions to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-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 duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-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 duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
Use Docker
docker model run hf.co/duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
- SGLang
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF 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 "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with Ollama:
ollama run hf.co/duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
- Unsloth Studio
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-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 duyntnet/Mistral-Small-Instruct-2409-imatrix-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 duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF to start chatting
- Pi
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-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": "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with Docker Model Runner:
docker model run hf.co/duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
- Lemonade
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Mistral-Small-Instruct-2409-imatrix-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-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 duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "duyntnet/Mistral-Small-Instruct-2409-imatrix-GGUF:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Quantizations of https://huggingface.co/mistralai/Mistral-Small-Instruct-2409
Inference Clients/UIs
From original readme
Mistral-Small-Instruct-2409 is an instruct fine-tuned version with the following characteristics:
- 22B parameters
- Vocabulary to 32768
- Supports function calling
- 32k 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>
- Downloads last month
- 273
1-bit
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit