Text Generation
Transformers
PyTorch
Safetensors
mistral
finetuned
mistral-common
conversational
Eval Results
text-generation-inference
Instructions to use mistralai/Mistral-7B-Instruct-v0.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mistralai/Mistral-7B-Instruct-v0.2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2") model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mistralai/Mistral-7B-Instruct-v0.2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Install mistral-common: pip install --upgrade mistral-common # Start the vLLM server: vllm serve "mistralai/Mistral-7B-Instruct-v0.2" --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mistralai/Mistral-7B-Instruct-v0.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mistralai/Mistral-7B-Instruct-v0.2
- SGLang
How to use mistralai/Mistral-7B-Instruct-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 "mistralai/Mistral-7B-Instruct-v0.2" \ --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": "mistralai/Mistral-7B-Instruct-v0.2", "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 "mistralai/Mistral-7B-Instruct-v0.2" \ --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": "mistralai/Mistral-7B-Instruct-v0.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mistralai/Mistral-7B-Instruct-v0.2 with Docker Model Runner:
docker model run hf.co/mistralai/Mistral-7B-Instruct-v0.2
Commit History
-
Remove warning from README.md
Verified signatureThis model didn't need any updates to match the `v1` tokenizer from `mistral-common`, so this PR removes the warning!ec9331b
-
Update README.md
Verified signature05bed4c
-
Align tokenizer with mistral-common (#141)
Verified signature- Align tokenizer with mistral-common (0f1833debcb4faed2994152f0fe564af400b1335) - Update chat template to handle sys messages (726f392523e26ac4ce81a081fcd83084cf6d98c4) Co-authored-by: Matthew Carrigan <Rocketknight1@users.noreply.huggingface.co>250544c
-
[AUTO] CVST Tokenizer Badger (#140)
Verified signature- [AUTO] CVST Tokenizer Badger (a114bdb8b30f55eea8072737b264969f5bd576dc) Co-authored-by: pandora <pandora-s@users.noreply.huggingface.co>9925900
-
Updating chat template, trying to make it match with `mistral_common` (#136)
Verified signature- Updating chat template, trying to make it match with `mistral_common` (cc66e08cd4914c3e82d30b744bce2a459505784a) Co-authored-by: pandora <pandora-s@users.noreply.huggingface.co>1296dc8
-
Update README.md (#70)
Verified signature- Update README.md (e37f8b7ca9b26b693bb3a2479e7ce2358c750da9) Co-authored-by: Devendra Singh Chaplot <devendrachaplot@users.noreply.huggingface.co>41b61a3
-
Enable inference & update examples in README to be compatible with soon-to-come ChatWidget (#54)
Verified signature- Enable inference & update examples in README to be compatible with soon-to-come ChatWidget (6ca1f9d73ef70b918f4ccdfdd59279a65f0923c6) Co-authored-by: Simon Brandeis <sbrandeis@users.noreply.huggingface.co>cf47bb3
-
Update config.json
Fixed on TGI: https://github.com/huggingface/text-generation-inference/releases/tag/v1.3.3 PR: https://github.com/huggingface/text-generation-inference/pull/1348 Is was never meant to support sliding window attentionb70aa86 -
Update README.md
Removing inference since it's confusing without the chat templating98d9793
-
Update config.json
Patch for HF Inference APIcb35ee2 -
Readme from_pretrained model version fix (#18)
- Readme from_pretrained model version fix (4208713cc4a830ecc383f5584e969b4f1fb020af) Co-authored-by: Aviral Joshi <dataviral@users.noreply.huggingface.co>a8d85f7
-
Inputs for widget using chat format (#6)
- Inputs for widget using chat format (7b1ce412fc4d4ac8da2bdbb22beb09e23c344c2d) Co-authored-by: Pedro Cuenca <pcuenq@users.noreply.huggingface.co>235b80c
-
Adding `safetensors` variant of this model (#1)
- initial commit (d9bc489fedbc84930231b3b86e637e1a081efe1d) - Add v0.2 (0bc32139daadaced65c1059b413f9d74f098cea3) - Create README.md (dd8e86073d74dd6a24edae0cc672681007af4e3e) - Update README.md (d1c29025e5e5c7471fcac133f19b7cfb72a26e51) - Update README.md (3331b5f4f997ee9dc86da1e6bbbfd932aeb8a616) - Adding `safetensors` variant of this model (fb54d4466863eafbd4aa2fa1f0aef4336c68723d) Co-authored-by: Thomas Wang <TimeRobber@users.noreply.huggingface.co> Co-authored-by: Safetensors convertbot <SFconvertbot@users.noreply.huggingface.co> Co-authored-by: timothee lacroix <timlacroix@users.noreply.huggingface.co>5a1029f
-
Update README.md
c72e5d1 -
Update README.md
76399c6 -
Create README.md
f1586aa -
Add v0.2
dca6e4b -
initial commit
e68448a