Mistral-inference

Latest version: v1.6.0

Safety actively analyzes 723158 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 4

1.2.0

**Codestral-Mamba**


pip install packaging mamba-ssm causal-conv1d transformers


1. Download

export MAMBA_CODE=$HOME/7B_MAMBA_CODE
wget https://models.mistralcdn.com/codestral-mamba-7b-v0-1/codestral-mamba-7B-v0.1.tar
mkdir -p $MAMBA_CODE
tar -xf codestral-mamba-7B-v0.1.tar -C $MAMBA_CODE


2. Chat

mistral-chat $HOME/7B_MAMBA_CODE --instruct --max_tokens 256


**Mathstral**

1. Download

export MATHSTRAL=$HOME/7B_MATH
wget https://models.mistralcdn.com/mathstral-7b-v0-1/mathstral-7B-v0.1.tar
mkdir -p $MATHSTRAL
tar -xf mathstral-7B-v0.1.tar -C $MATHSTRAL


2. Chat

mistral-chat $HOME/7B_MATH --instruct --max_tokens 256


**Blogs:**
Blog Codestral Mamba 7B: [https://mistral.ai/news/codestral-mamba/](https://mistral.ai/news/codestral-mamba/) \
Blog Mathstral 7B: [https://mistral.ai/news/mathstral/](https://mistral.ai/news/mathstral/)

What's Changed
* add a note about GPU requirement by sophiamyang in https://github.com/mistralai/mistral-inference/pull/158
* Add codestral by patrickvonplaten in https://github.com/mistralai/mistral-inference/pull/164
* Update README.md by patrickvonplaten in https://github.com/mistralai/mistral-inference/pull/165
* fixing type in README.md by didier-durand in https://github.com/mistralai/mistral-inference/pull/175
* Fix: typo in ModelArgs: "infered" to "inferred" by CharlesCNorton in https://github.com/mistralai/mistral-inference/pull/174
* fix: typo in LoRALoaderMixin: correct "multipe" to "multiple" by CharlesCNorton in https://github.com/mistralai/mistral-inference/pull/173
* fix: Correct typo in classifier.ipynb from "alborithm" to "algorithm" by CharlesCNorton in https://github.com/mistralai/mistral-inference/pull/167
* Fix: typo in error message for state_dict validation by CharlesCNorton in https://github.com/mistralai/mistral-inference/pull/172
* fix: Correct misspelling in ModelArgs docstring by CharlesCNorton in https://github.com/mistralai/mistral-inference/pull/171
* Update README.md by patrickvonplaten in https://github.com/mistralai/mistral-inference/pull/168
* fix: typo in HF_TOKEN environment variable check message by CharlesCNorton in https://github.com/mistralai/mistral-inference/pull/179
* Adding Issue/Bug template. by pandora-s-git in https://github.com/mistralai/mistral-inference/pull/178
* typo in ModelArgs class docstring. by CharlesCNorton in https://github.com/mistralai/mistral-inference/pull/183
* Update README.md by Simontwice in https://github.com/mistralai/mistral-inference/pull/184
* Add mamba by patrickvonplaten in https://github.com/mistralai/mistral-inference/pull/187

New Contributors
* didier-durand made their first contribution in https://github.com/mistralai/mistral-inference/pull/175
* CharlesCNorton made their first contribution in https://github.com/mistralai/mistral-inference/pull/174
* pandora-s-git made their first contribution in https://github.com/mistralai/mistral-inference/pull/178
* Simontwice made their first contribution in https://github.com/mistralai/mistral-inference/pull/184

**Full Changelog**: https://github.com/mistralai/mistral-inference/compare/v1.1.0...v1.2.0

1.1.0

Having trained a 7B base LoRA, you can run `mistral-inference` as follows:

py
from mistral_inference.model import Transformer
from mistral_inference.generate import generate

from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from mistral_common.protocol.instruct.messages import UserMessage
from mistral_common.protocol.instruct.request import ChatCompletionRequest


MODEL_PATH = "path/to/downloaded/7B_base_dir"

tokenizer = MistralTokenizer.from_file(f"{MODEL_PATH}/tokenizer.model.v3") change to extracted tokenizer file
model = Transformer.from_folder(MODEL_PATH) change to extracted model dir
model.load_lora("/path/to/run_lora_dir/checkpoints/checkpoint_000300/consolidated/lora.safetensors")

completion_request = ChatCompletionRequest(messages=[UserMessage(content="Explain Machine Learning to me in a nutshell.")])

tokens = tokenizer.encode_chat_completion(completion_request).tokens

out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])

print(result)

1.0.4

Mistral-inference is the official inference library for all Mistral models: 7B, 8x7B, 8x22B.


Install with:

py
pip install mistral-inference


Run with:

py
from mistral_inference.model import Transformer
from mistral_inference.generate import generate

from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from mistral_common.protocol.instruct.messages import UserMessage
from mistral_common.protocol.instruct.request import ChatCompletionRequest
from mistral_common.protocol.instruct.tool_calls import Function, Tool

tokenizer = MistralTokenizer.from_file("/path/to/tokenizer/file") change to extracted tokenizer file
model = Transformer.from_folder("./path/to/model/folder") change to extracted model dir

from mistral_common.protocol.instruct.tool_calls import Function, Tool

completion_request = ChatCompletionRequest(
tools=[
Tool(
function=Function(
name="get_current_weather",
description="Get the current weather",
parameters={
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
"required": ["location", "format"],
},
)
)
],
messages=[
UserMessage(content="What's the weather like today in Paris?"),
],
)

tokens = tokenizer.encode_chat_completion(completion_request).tokens

out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])

print(result)

Page 4 of 4

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.