Skip to main content

Inference for Speech Models in MLX

This repo implements some speech models in MLX for better performance on Mac devices.

Currently, it supports the following models:

  • Qwen2.5-Omni (both original version and mlx-quant version), currently supported only speech model
  • Ultravox-0.5

Performance

Tested on MacBook M4-Pro (48GB RAM):

Model Prompt TPS Generation TPS
Qwen/Qwen2.5-Omni-7B 259.5 17.8
Qwen/Qwen2.5-Omni-3B 468.4 38.8
giangndm/qwen2.5-omni-7b-mlx-8bit 253.4 31.7
giangndm/qwen2.5-omni-7b-mlx-4bit 259.2 57.6
giangndm/qwen2.5-omni-3b-mlx-8bit 456.2 67.0
fixie-ai/ultravox-v0_5-llama-3_1-8b and mlx-community/Llama-3.1-8B-Instruct-4bit 188.5 40.4

How to use

uv add mlx-lm-omni 
# or
uv add https://github.com/giangndm/mlx-lm-omni.git
from mlx_lm_omni import load, generate
import librosa
from io import BytesIO
from urllib.request import urlopen

# model, tokenizer = load("giangndm/qwen2.5-omni-7b-mlx-4bit")
model, tokenizer = load("fixie-ai/ultravox-v0_5-llama-3_1-8b", model_config={"text_model_id": "mlx-community/Llama-3.1-8B-Instruct-4bit"})

audio_path = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/1272-128104-0000.flac"
audio = librosa.load(BytesIO(urlopen(audio_path).read()), sr=16000)[0]

messages = [
    {"role": "system", "content": "You are a speech recognition model."},
    {"role": "user", "content": "Transcribe the English audio into text without any punctuation marks.", "audio": audio},
]
prompt = tokenizer.apply_chat_template(
    messages, add_generation_prompt=True
)

text = generate(model, tokenizer, prompt=prompt, verbose=True)

Metadata

Release files for mlx-lm-omni 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlx-lm-omni 0.1.3
File Size Uploaded Provenance Actions
mlx_lm_omni-0.1.3.tar.gz 821.2 kB Without provenance Details for mlx_lm_omni-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mlx-lm-omni 0.1.3
File Interpreter ABI Platform Actions
mlx_lm_omni-0.1.3-py3-none-any.whl Python 3 none any Details for mlx_lm_omni-0.1.3-py3-none-any.whl

Total release size: 838.5 kB

Release files / mlx_lm_omni-0.1.3.tar.gz

Download URL mlx_lm_omni-0.1.3.tar.gz
Size 821.2 kB
Tags Source
SHA-256 checksum
How to use checksums
972a0dfac50e0182855c5aee28cafe55fae5160343b91089451642f95a49fe13
BLAKE2b-256 checksum
How to use checksums
610e7369115e07220514d813a02189a8099d1b9da43fc6109243c11527a8cba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.4

Release files / mlx_lm_omni-0.1.3-py3-none-any.whl

Download URL mlx_lm_omni-0.1.3-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c99f278830f3a144ff77cb50aa2d7f43e36a8391a8d228ecd68c5de17bf9cba0
BLAKE2b-256 checksum
How to use checksums
22940b4ca9e9c2728ccce015a61eb4d29d23e80c7aaab5e0646a95ff11c2c74a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.4

Security for mlx-lm-omni 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page