Instructions to use ikarius/Mistral-Small-24B-NF4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ikarius/Mistral-Small-24B-NF4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ikarius/Mistral-Small-24B-NF4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ikarius/Mistral-Small-24B-NF4") model = AutoModelForCausalLM.from_pretrained("ikarius/Mistral-Small-24B-NF4") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ikarius/Mistral-Small-24B-NF4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ikarius/Mistral-Small-24B-NF4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ikarius/Mistral-Small-24B-NF4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ikarius/Mistral-Small-24B-NF4
- SGLang
How to use ikarius/Mistral-Small-24B-NF4 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 "ikarius/Mistral-Small-24B-NF4" \ --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": "ikarius/Mistral-Small-24B-NF4", "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 "ikarius/Mistral-Small-24B-NF4" \ --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": "ikarius/Mistral-Small-24B-NF4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ikarius/Mistral-Small-24B-NF4 with Docker Model Runner:
docker model run hf.co/ikarius/Mistral-Small-24B-NF4
Mistral-Small-24B-NF4
This repository contains a 4-bit quantized version of Mistral-Small-24B, optimized with NF4 (NormalFloat 4) via bitsandbytes. This version is designed to run efficiently on consumer hardware (GPUs with less VRAM) without significant performance loss.
Model Description
Mistral-Small-24B is a powerful language model that balances reasoning capabilities and speed. Using NF4 quantization reduces the model size to approximately 14.2 GB, making it available for setups with 16GB or 24GB VRAM.
- Architecture: Mistral
- Precision: 4-bit (NF4)
- Quantization method:
bitsandbytes - Format: Safetensors
Installation and usage
To use this model you need transformers, bitsandbytes and accelerate.
pip install -U transformers bitsandbytes accelerate
Example of use (Python)
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "ikarius/Mistral-Small-24B-NF4"
# Load the model with NF4 configuration
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Simple chat test
messages = [
{"role": "user", "content": "Hi! Can you explain the benefit of NF4 quantization?"}
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to("cuda")
outputs = model.generate(inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Files in this repository
model.safetensors: The actual model weights in 4-bit format.config.json&generation_config.json: Configuration files for model architecture and generation.tokenizer.json&tokenizer_config.json: Tokenizer settings for correct text processing.chat_template.jinja: Template for formatting chats (Instruct format).
License
Please see the original Mistral-Small guidelines for terms of use. This model is distributed assuming the user follows the Mistral AI license agreement.
- Downloads last month
- 1
Model tree for ikarius/Mistral-Small-24B-NF4
Base model
mistralai/Mistral-Small-24B-Base-2501