Instructions to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF", dtype="auto") - llama-cpp-python
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF", filename="codestral-22b-v0.1-hf-bf16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf qwp4w3hyb/Codestral-22B-v0.1-iMat-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 qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf qwp4w3hyb/Codestral-22B-v0.1-iMat-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 qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf qwp4w3hyb/Codestral-22B-v0.1-iMat-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 qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M
Use Docker
docker model run hf.co/qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M
- SGLang
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-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 "qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF" \ --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": "qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF", "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 "qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF" \ --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": "qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with Ollama:
ollama run hf.co/qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M
- Unsloth Studio new
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-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 qwp4w3hyb/Codestral-22B-v0.1-iMat-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 qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF to start chatting
- Docker Model Runner
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with Docker Model Runner:
docker model run hf.co/qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M
- Lemonade
How to use qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Codestral-22B-v0.1-iMat-GGUF-Q4_K_M
List all available models
lemonade list
Quant Infos
- Includes tokenizer fixes that were bugged in the initial version
- quants done with an importance matrix for improved quantization loss
- ggufs & imatrix generated from bf16 for "optimal" accuracy loss
- Wide coverage of different gguf quant types from Q_8_0 down to IQ1_S
- Quantized with llama.cpp commit 5921b8f089d3b7bda86aac5a66825df6a6c10603 (master as of 2024-05-30)
- Imatrix generated with this multi-purpose dataset by bartowski.
./imatrix -c 512 -m $model_name-bf16.gguf -f calibration_datav3.txt -o $model_name.imatrix
Original Model Card:
Model Card for Codestral-22B-v0.1
Codestrall-22B-v0.1 is trained on a diverse dataset of 80+ programming languages, including the most popular ones, such as Python, Java, C, C++, JavaScript, and Bash (more details in the Blogpost). The model can be queried:
- As instruct, for instance to answer any questions about a code snippet (write documentation, explain, factorize) or to generate code following specific indications
- As Fill in the Middle (FIM), to predict the middle tokens between a prefix and a suffix (very useful for software development add-ons like in VS Code)
Installation
It is recommended to use mistralai/Codestral-22B-v0.1 with mistral-inference.
pip install mistral_inference
Download
from huggingface_hub import snapshot_download
from pathlib import Path
mistral_models_path = Path.home().joinpath('mistral_models', 'Codestral-22B-v0.1')
mistral_models_path.mkdir(parents=True, exist_ok=True)
snapshot_download(repo_id="mistralai/Codestral-22B-v0.1", 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.
mistral-chat $HOME/mistral_models/Codestral-22B-v0.1 --instruct --max_tokens 256
Will generate an answer to "Write me a function that computes fibonacci in Rust" and should give something along the following lines:
Sure, here's a simple implementation of a function that computes the Fibonacci sequence in Rust. This function takes an integer `n` as an argument and returns the `n`th Fibonacci number.
fn fibonacci(n: u32) -> u32 {
match n {
0 => 0,
1 => 1,
_ => fibonacci(n - 1) + fibonacci(n - 2),
}
}
fn main() {
let n = 10;
println!("The {}th Fibonacci number is: {}", n, fibonacci(n));
}
This function uses recursion to calculate the Fibonacci number. However, it's not the most efficient solution because it performs a lot of redundant calculations. A more efficient solution would use a loop to iteratively calculate the Fibonacci numbers.
Fill-in-the-middle (FIM)
After installing mistral_inference and running pip install --upgrade mistral_common to make sure to have mistral_common>=1.2 installed:
from mistral_inference.model import Transformer
from mistral_inference.generate import generate
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from mistral_common.tokens.instruct.request import FIMRequest
tokenizer = MistralTokenizer.v3()
model = Transformer.from_folder("~/codestral-22B-240529")
prefix = """def add("""
suffix = """ return sum"""
request = FIMRequest(prompt=prefix, suffix=suffix)
tokens = tokenizer.encode_fim(request).tokens
out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
result = tokenizer.decode(out_tokens[0])
middle = result.split(suffix)[0].strip()
print(middle)
Should give something along the following lines:
num1, num2):
# Add two numbers
sum = num1 + num2
# return the sum
Limitations
The Codestral-22B-v0.1 does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
License
Codestral-22B-v0.1 is released under the MNLP-0.1 license.
The Mistral AI Team
Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Bam4d, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Henri Roussez, Jean-Malo Delignon, Jia Li, 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, Mickael Seznec, Nicolas Schuhl, Patrick von Platen, Romain Sauvestre, Pierre Stock, Sandeep Subramanian, Saurabh Garg, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibaut Lavril, Thibault Schueller, Timothée Lacroix, Théophile Gervet, Thomas Wang, Valera Nemychnikova, Wendy Shang, William El Sayed, William Marshall
- Downloads last month
- 374
1-bit
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
16-bit
Model tree for qwp4w3hyb/Codestral-22B-v0.1-iMat-GGUF
Base model
mistralai/Codestral-22B-v0.1