Skip to content

Releases: mistralai/mistral-common

v1.8.6: rm Python 3.9, bug fixes.

30 Nov 22:02
c9c189c

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.8.5...v1.8.6

v1.8.5: Patch Release

12 Sep 06:50
5921a03

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.8.4...v1.8.5

v1.8.4: optional dependencies and allow random padding on ChatCompletionResponseStreamResponse

20 Aug 07:26
51e3728

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.8.3...v1.8.4

v1.8.3: Add an experimental REST API

25 Jul 16:16
f47fb16

Choose a tag to compare

What's Changed

We released an experimental REST API leveraging Fast API to handle requests from tokenization, through generation via calls to an engine, to detokenization.

For a detailed documentation see [https://mistralai.github.io/mistral-common/usage/experimental/].

Here is how to launch the server:

pip install mistral-common[server]

mistral_common serve mistralai/Magistral-Small-2507 \
--host 127.0.0.1 --port 8000 \
--engine-url http://127.0.0.1:8080 --engine-backend llama_cpp \
--timeout 60

Then you can see the Swagger at: http://localhost:8000.

Full Changelog: v1.8.2...v1.8.3

v1.8.2: Add ThinkChunk

24 Jul 08:42
4b55642

Choose a tag to compare

What's Changed

Now you can use TextChunk and ThinkChunk in your SystemMessage or AssistantMessage:

from mistral_common.protocol.instruct.messages import SystemMessage, TextChunk, ThinkChunk

system_message = SystemMessage(
    content = [
        TextChunk(text="First draft your thinking process (inner monologue) until you arrive at a response. Format your response using Markdown, and use LaTeX for any mathematical equations. Write both your thoughts and the response in the same language as the input.\n\nYour thinking process must follow the template below:"),
        ThinkChunk(
            thinking="Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate the response. Use the same language as the input.",
            closed=True,
        ),
        TextChunk(text="Here, provide a self-contained response.")
    ],
)

Full Changelog: v1.8.1...v1.8.2

v1.8.1: Add AudioURLChunk

16 Jul 11:20
a153ac8

Choose a tag to compare

What's Changed

Now you can use http(s) URLs, file paths and base64 string (without specifying format) in your content chunks thanks to AudioURLChunk !

from mistral_common.protocol.instruct.messages import AudioURL, AudioURLChunk, TextChunk, UserMessage
from mistral_common.protocol.instruct.request import ChatCompletionRequest
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer

repo_id = "mistralai/Voxtral-Mini-3B-2507"
tokenizer = MistralTokenizer.from_hf_hub(repo_id)

text_chunk = TextChunk(
    text="Wat do you think about this audio?"
)
user_msg = UserMessage(
    content=[
        AudioURLChunk(audio_url=AudioURL(url="https://freewavesamples.com/files/Ouch-6.wav")),
        text_chunk,
    ]
)

request = ChatCompletionRequest(messages=[user_msg])
tokenized = tokenizer.encode_chat_completion(request)

# pass tokenized.tokens to your favorite audio model
print(tokenized.tokens)
print(tokenized.audios)

# print text to visually see tokens
print(tokenized.text)

Full Changelog: v1.8.0...v1.8.1

v1.8.0 - Mistral welcomes 📢

15 Jul 09:39
d201d12

Choose a tag to compare

What's Changed

Full Changelog: v1.7.0...v1.8.0

Audio chat example:

from mistral_common.protocol.instruct.messages import TextChunk, AudioChunk, UserMessage, AssistantMessage, RawAudio
from mistral_common.protocol.instruct.request import ChatCompletionRequest
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
from mistral_common.audio import Audio
from huggingface_hub import hf_hub_download

repo_id = "mistralai/voxtral-mini"
tokenizer = MistralTokenizer.from_hf_hub(repo_id)

obama_file = hf_hub_download("patrickvonplaten/audio_samples", "obama.mp3", repo_type="dataset")
bcn_file = hf_hub_download("patrickvonplaten/audio_samples", "bcn_weather.mp3", repo_type="dataset")

def file_to_chunk(file: str) -> AudioChunk:
    audio = Audio.from_file(file, strict=False)
    return AudioChunk.from_audio(audio)

text_chunk = TextChunk(text="Which speaker do you prefer between the two? Why? How are they different from each other?")
user_msg = UserMessage(content=[file_to_chunk(obama_file), file_to_chunk(bcn_file), text_chunk]).to_openai()


request = ChatCompletionRequest(messages=[user_msg])
tokenized = tokenizer.encode_chat_completion(request)

# pass tokenized.tokens to your favorite audio model
print(tokenized.tokens)
print(tokenized.audios)

# print text to visually see tokens
print(tokenized.text)

Audio transcription example:

from mistral_common.protocol.transcription.request import TranscriptionRequest
from mistral_common.protocol.instruct.messages import RawAudio
from mistral_common.audio import Audio
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer

from huggingface_hub import hf_hub_download

repo_id = "mistralai/voxtral-mini"
tokenizer = MistralTokenizer.from_hf_hub(repo_id)

obama_file = hf_hub_download("patrickvonplaten/audio_samples", "obama.mp3", repo_type="dataset")
audio = Audio.from_file(obama_file, strict=False)

audio = RawAudio.from_audio(audio)
request = TranscriptionRequest(model=repo_id, audio=audio, language="en")

tokenized = tokenizer.encode_transcription(request)

# pass tokenized.tokens to your favorite audio model
print(tokenized.tokens)
print(tokenized.audios)

# print text to visually see tokens
print(tokenized.text)

v1.7.0 - v13 instruct tokenizer, rename multi-modal to image

10 Jul 07:31
6e4070b

Choose a tag to compare

What's Changed

Full Changelog: v1.6.3...v1.7.0

v1.6.3 - Improved from_hf_hub, support multiprocessing, ...

10 Jul 07:29

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.6.0...v1.6.3

Patch release: v1.6.2

12 Jun 15:26

Choose a tag to compare

Ensure that pypi version includes tokenizer files.

See: [BUG: data directory not installed for 1.6.0