Skip to main content

Fast and easy LLM serving.

Project description

mistral.rs

mistralrs is a Python package which provides an easy to use API for mistral.rs.

Example

More examples can be found here!

from mistralrs import Runner, Which, ChatCompletionRequest

runner = Runner(
    which=Which.Plain(
        model_id="microsoft/Phi-3.5-mini-instruct",
    ),
    in_situ_quant="Q4K",
)

res = runner.send_chat_completion_request(
    ChatCompletionRequest(
        model="mistral",
        messages=[
            {"role": "user", "content": "Tell me a story about the Rust type system."}
        ],
        max_tokens=256,
        presence_penalty=1.0,
        top_p=0.1,
        temperature=0.1,
    )
)
print(res.choices[0].message.content)
print(res.usage)

Multimodal (audio + image) example

mistralrs also supports multimodal vision models that can reason over both images and audio clips via the same OpenAI-style audio_url / image_url format. The example below queries the Phi-4-Multimodal model with a single image and an audio recording – notice how the text prompt references them via <|audio_1|> and <|image_1|> tokens (indexing starts at 1):

from mistralrs import Runner, Which, ChatCompletionRequest, VisionArchitecture

runner = Runner(
    which=Which.VisionPlain(
        model_id="microsoft/Phi-4-multimodal-instruct",
        arch=VisionArchitecture.Phi4MM,
    ),
)

IMAGE_URL = "https://www.allaboutbirds.org/guide/assets/og/528129121-1200px.jpg"
AUDIO_URL = "https://upload.wikimedia.org/wikipedia/commons/4/42/Bird_singing.ogg"

response = runner.send_chat_completion_request(
    ChatCompletionRequest(
        model="phi4mm",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "audio_url", "audio_url": {"url": AUDIO_URL}},
                    {"type": "image_url", "image_url": {"url": IMAGE_URL}},
                    {
                        "type": "text",
                        "text": "<|audio_1|><|image_1|> Describe in detail what is happening, referencing both what you hear and what you see.",
                    },
                ],
            }
        ],
        max_tokens=256,
        temperature=0.2,
        top_p=0.9,
    )
)

print(response.choices[0].message.content)

See examples/python/phi4mm_audio.py for a ready-to-run version.

Please find API docs here and the type stubs here, which are another great form of documentation.

We also provide a cookbook here!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mistralrs_mkl-0.6.0-cp312-none-win_amd64.whl (19.9 MB view details)

Uploaded CPython 3.12Windows x86-64

mistralrs_mkl-0.6.0-cp312-cp312-manylinux_2_39_x86_64.whl (22.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

mistralrs_mkl-0.6.0-cp311-none-win_amd64.whl (19.9 MB view details)

Uploaded CPython 3.11Windows x86-64

mistralrs_mkl-0.6.0-cp311-cp311-manylinux_2_39_x86_64.whl (22.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

mistralrs_mkl-0.6.0-cp310-none-win_amd64.whl (19.9 MB view details)

Uploaded CPython 3.10Windows x86-64

mistralrs_mkl-0.6.0-cp310-cp310-manylinux_2_39_x86_64.whl (22.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

File details

Details for the file mistralrs_mkl-0.6.0-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for mistralrs_mkl-0.6.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 e3a21f5ba3d4d5c6c124ba826632817a019ae68108063db6b98a7ed44448c2fe
MD5 7142574fc50a7ad6059c4a5e3ba48fec
BLAKE2b-256 ccb753d8a667fa1e8c642d52b01d7a76e9189d3c5b63ae89251e31b92e999e56

See more details on using hashes here.

File details

Details for the file mistralrs_mkl-0.6.0-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mistralrs_mkl-0.6.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 997ade979ccf38d3f8e23d72b53001ff2ac00f542e43337ca0d01f195d54b760
MD5 bb1b3e8e335f13cf43006fc101b3385e
BLAKE2b-256 37efff1afc4d2e476277db67275ea1dd42e3484d3f9fa1ec62615a42584d282f

See more details on using hashes here.

File details

Details for the file mistralrs_mkl-0.6.0-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for mistralrs_mkl-0.6.0-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 3abc7dfd82edeeda2aaac4af155e1c19e3d0910c9eedcea9d6561ad98c03099d
MD5 f22daf38ff1be5ac08453528b40dda60
BLAKE2b-256 ce9af3bab579d07b64d3aba07d860d24015078379d28246865d6e3b23efd6db5

See more details on using hashes here.

File details

Details for the file mistralrs_mkl-0.6.0-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mistralrs_mkl-0.6.0-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d91f577d8e60d76a3e6975b324da74f91c1223a486a92fff6f3f56d3d0245181
MD5 f5ecc8552592a4f0288e8b656ba1d6ba
BLAKE2b-256 72780636c46e4d04a78265ee9ad6cee65708ae4c5f63c639378aa0819e242d46

See more details on using hashes here.

File details

Details for the file mistralrs_mkl-0.6.0-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for mistralrs_mkl-0.6.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 8e6050f164a017678cbef7d4b27dfe0c6694cef9cbd8ccf127006db43ce9791c
MD5 a8fb2615822d4b116eddb1b678aedb29
BLAKE2b-256 38b31221ad069d112afcd8e8c010f35cadd13aa62fcff6013a9348e671b62c3f

See more details on using hashes here.

File details

Details for the file mistralrs_mkl-0.6.0-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mistralrs_mkl-0.6.0-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d62c770f7ef32494b4e79cbf7919305759f93d5117863478ada6ecf5ff5ade7b
MD5 b8fd9fee5d30855bbad2150b15d16515
BLAKE2b-256 8504039880b65c1b5812793e3578646e47022dffa6a2b7b142288e8ffc11abe1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page