Text Generation
Transformers
Safetensors
English
mistral
unsloth
mistral-instruct
instruct
conversational
text-generation-inference
Instructions to use unsloth/Mistral-Small-24B-Instruct-2501 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Mistral-Small-24B-Instruct-2501 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsloth/Mistral-Small-24B-Instruct-2501", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("unsloth/Mistral-Small-24B-Instruct-2501") model = AutoModelForCausalLM.from_pretrained("unsloth/Mistral-Small-24B-Instruct-2501", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/Mistral-Small-24B-Instruct-2501 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/Mistral-Small-24B-Instruct-2501" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/Mistral-Small-24B-Instruct-2501", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/unsloth/Mistral-Small-24B-Instruct-2501
- SGLang
How to use unsloth/Mistral-Small-24B-Instruct-2501 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 "unsloth/Mistral-Small-24B-Instruct-2501" \ --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": "unsloth/Mistral-Small-24B-Instruct-2501", "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 "unsloth/Mistral-Small-24B-Instruct-2501" \ --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": "unsloth/Mistral-Small-24B-Instruct-2501", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use unsloth/Mistral-Small-24B-Instruct-2501 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 unsloth/Mistral-Small-24B-Instruct-2501 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 unsloth/Mistral-Small-24B-Instruct-2501 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/Mistral-Small-24B-Instruct-2501 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="unsloth/Mistral-Small-24B-Instruct-2501", max_seq_length=2048, ) - Docker Model Runner
How to use unsloth/Mistral-Small-24B-Instruct-2501 with Docker Model Runner:
docker model run hf.co/unsloth/Mistral-Small-24B-Instruct-2501
Adding tool call support in chat template
#3
by Navanit-AI - opened
- tokenizer_config.json +1 -1
tokenizer_config.json
CHANGED
|
@@ -9007,7 +9007,7 @@
|
|
| 9007 |
"<SPECIAL_999>"
|
| 9008 |
],
|
| 9009 |
"bos_token": "<s>",
|
| 9010 |
-
"chat_template":
|
| 9011 |
"clean_up_tokenization_spaces": false,
|
| 9012 |
"eos_token": "</s>",
|
| 9013 |
"extra_special_tokens": {},
|
|
|
|
| 9007 |
"<SPECIAL_999>"
|
| 9008 |
],
|
| 9009 |
"bos_token": "<s>",
|
| 9010 |
+
"chat_template": "{%- set today = strftime_now('%Y-%m-%d') -%}{%- set default_system_message = '[SYSTEM_PROMPT]You are Mistral Small 3, a Large Language Model (LLM) created by Mistral AI, a French startup headquartered in Paris.\\nYour knowledge base was last updated on 2023-10-01. The current date is ' + today + '.\\n\\nWhen you\\'re not sure about some information, you say that you don\\'t have the information and don\\'t make up anything.\\nIf the user\\'s question is not clear, ambiguous, or does not provide enough context for you to accurately answer the question, you do not try to answer it right away and you rather ask the user to clarify their request.[/SYSTEM_PROMPT]' %}{{ bos_token }}{%- if tools is defined -%}{%- set tool_instructions = '[AVAILABLE_TOOLS]You can use multiple tools by responding with JSON array like: [{\\\"name\\\": \\\"tool1\\\", \\\"parameters\\\": {}}, {\\\"name\\\": \\\"tool2\\\", \\\"parameters\\\": {}}][/AVAILABLE_TOOLS]' %}{%- set default_system_message = default_system_message + tool_instructions -%}{%- endif -%}{%- if messages[0]['role'] == 'system' -%}{%- set system_message = messages[0]['content'] -%}{%- set loop_messages = messages[1:] -%}{%- else -%}{%- set system_message = default_system_message -%}{%- set loop_messages = messages -%}{%- endif -%}[SYSTEM_PROMPT]{{ system_message }}[/SYSTEM_PROMPT]\\n{%- for message in loop_messages -%}{%- if message['role'] == 'user' -%}[INST]{{ message['content'] }}[/INST]\\n{%- elif message['role'] == 'assistant' -%}{%- if 'tool_calls' in message -%}[TOOL_CALLS][{%- for tool_call in message.tool_calls -%}{{'{\"name\": \"' + tool_call.function.name + '\", \"parameters\": ' + tool_call.function.arguments|tojson + '}'}}{%- if not loop.last -%}, {%- endif -%}{%- endfor -%}][/TOOL_CALLS]\\n{%- else -%}{{ message['content'] + eos_token }}\\n{%- endif -%}{%- elif message['role'] == 'tool' -%}[TOOL_CONTENT]{{ message['content']|string }}[/TOOL_CONTENT]\\n{%- elif message['role'] == 'system' -%}[SYSTEM_PROMPT]{{ message['content'] }}[/SYSTEM_PROMPT]\\n{%- else -%}{{ raise_exception('Only user, system, assistant, and tool roles are supported!') }}\\n{%- endif -%}{%- endfor -%}",
|
| 9011 |
"clean_up_tokenization_spaces": false,
|
| 9012 |
"eos_token": "</s>",
|
| 9013 |
"extra_special_tokens": {},
|