Text Generation
Transformers
PyTorch
Safetensors
mistral
finetuned
mistral-common
conversational
Eval Results
text-generation-inference
Instructions to use mistralai/Mistral-7B-Instruct-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mistralai/Mistral-7B-Instruct-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1") model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mistralai/Mistral-7B-Instruct-v0.1 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.1" --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.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mistralai/Mistral-7B-Instruct-v0.1
- SGLang
How to use mistralai/Mistral-7B-Instruct-v0.1 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.1" \ --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.1", "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.1" \ --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.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mistralai/Mistral-7B-Instruct-v0.1 with Docker Model Runner:
docker model run hf.co/mistralai/Mistral-7B-Instruct-v0.1
Commit ·
4464348
1
Parent(s): 54766df
Update tokenizer (#43)
Browse files- update tokenizer (e07e4b84e961faa4f73aa872717edd91fbd8c303)
- Merge branch 'main' into pr/43 (5e7d80dd74aa548303f9d873318bb4234ad32ffe)
Co-authored-by: Lucile Saulnier <SaulLu@users.noreply.huggingface.co>
- tokenizer.json +3 -3
- tokenizer_config.json +3 -4
tokenizer.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
"single_word": false,
|
| 10 |
"lstrip": false,
|
| 11 |
"rstrip": false,
|
| 12 |
-
"normalized":
|
| 13 |
"special": true
|
| 14 |
},
|
| 15 |
{
|
|
@@ -18,7 +18,7 @@
|
|
| 18 |
"single_word": false,
|
| 19 |
"lstrip": false,
|
| 20 |
"rstrip": false,
|
| 21 |
-
"normalized":
|
| 22 |
"special": true
|
| 23 |
},
|
| 24 |
{
|
|
@@ -27,7 +27,7 @@
|
|
| 27 |
"single_word": false,
|
| 28 |
"lstrip": false,
|
| 29 |
"rstrip": false,
|
| 30 |
-
"normalized":
|
| 31 |
"special": true
|
| 32 |
}
|
| 33 |
],
|
|
|
|
| 9 |
"single_word": false,
|
| 10 |
"lstrip": false,
|
| 11 |
"rstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
"special": true
|
| 14 |
},
|
| 15 |
{
|
|
|
|
| 18 |
"single_word": false,
|
| 19 |
"lstrip": false,
|
| 20 |
"rstrip": false,
|
| 21 |
+
"normalized": false,
|
| 22 |
"special": true
|
| 23 |
},
|
| 24 |
{
|
|
|
|
| 27 |
"single_word": false,
|
| 28 |
"lstrip": false,
|
| 29 |
"rstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
"special": true
|
| 32 |
}
|
| 33 |
],
|
tokenizer_config.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
"0": {
|
| 6 |
"content": "<unk>",
|
| 7 |
"lstrip": false,
|
| 8 |
-
"normalized":
|
| 9 |
"rstrip": false,
|
| 10 |
"single_word": false,
|
| 11 |
"special": true
|
|
@@ -13,7 +13,7 @@
|
|
| 13 |
"1": {
|
| 14 |
"content": "<s>",
|
| 15 |
"lstrip": false,
|
| 16 |
-
"normalized":
|
| 17 |
"rstrip": false,
|
| 18 |
"single_word": false,
|
| 19 |
"special": true
|
|
@@ -21,7 +21,7 @@
|
|
| 21 |
"2": {
|
| 22 |
"content": "</s>",
|
| 23 |
"lstrip": false,
|
| 24 |
-
"normalized":
|
| 25 |
"rstrip": false,
|
| 26 |
"single_word": false,
|
| 27 |
"special": true
|
|
@@ -29,7 +29,6 @@
|
|
| 29 |
},
|
| 30 |
"additional_special_tokens": [],
|
| 31 |
"bos_token": "<s>",
|
| 32 |
-
"chat_template": "{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token + ' ' }}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}",
|
| 33 |
"clean_up_tokenization_spaces": false,
|
| 34 |
"eos_token": "</s>",
|
| 35 |
"legacy": true,
|
|
|
|
| 5 |
"0": {
|
| 6 |
"content": "<unk>",
|
| 7 |
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
"rstrip": false,
|
| 10 |
"single_word": false,
|
| 11 |
"special": true
|
|
|
|
| 13 |
"1": {
|
| 14 |
"content": "<s>",
|
| 15 |
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
"rstrip": false,
|
| 18 |
"single_word": false,
|
| 19 |
"special": true
|
|
|
|
| 21 |
"2": {
|
| 22 |
"content": "</s>",
|
| 23 |
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
"rstrip": false,
|
| 26 |
"single_word": false,
|
| 27 |
"special": true
|
|
|
|
| 29 |
},
|
| 30 |
"additional_special_tokens": [],
|
| 31 |
"bos_token": "<s>",
|
|
|
|
| 32 |
"clean_up_tokenization_spaces": false,
|
| 33 |
"eos_token": "</s>",
|
| 34 |
"legacy": true,
|