mlx-examples: Practical Examples for the MLX Machine Learning Framework

mlx-examples: Practical Examples for the MLX Machine Learning Framework

Summary

mlx-examples is a comprehensive GitHub repository showcasing a variety of standalone examples built using the MLX framework. It provides practical implementations across text, image, audio, and multimodal models, serving as an excellent resource for developers exploring MLX. This collection helps users understand and apply MLX for diverse machine learning tasks.

Repository Info

Updated on November 18, 2025
View on GitHub

Tags

Click on any tag to explore related repositories

Introduction

The mlx-examples repository, maintained by ml-explore, serves as a comprehensive collection of standalone examples built upon the MLX framework. MLX is an open-source machine learning framework optimized for Apple silicon, designed for efficient model training and deployment. This repository is an invaluable resource for developers looking to understand and implement various machine learning models using MLX.

Installation

To get started with mlx-examples, you'll first need to ensure the MLX framework is installed. While the repository itself doesn't require a complex installation, you typically clone it and install any specific dependencies for the examples you wish to run.

# Clone the repository
git clone https://github.com/ml-explore/mlx-examples.git
cd mlx-examples

# Install MLX (if not already installed)
# Refer to the official MLX documentation for the most up-to-date installation instructions.
# Example: pip install mlx

# Navigate to an example directory and install its specific requirements
# For instance, for the MNIST example:
cd mnist
pip install -r requirements.txt
python mnist.py

It's recommended to check the requirements.txt file within each example's directory for precise dependency management.

Examples

mlx-examples offers a rich array of models categorized for easy navigation:

  • Text Models: Explore implementations of Transformer language models, large-scale text generation with LLaMA, Mistral, and Mixtral 8x7B, parameter-efficient fine-tuning with LoRA/QLoRA, T5, and BERT.
  • Image Models: Discover examples for generating images with FLUX, Stable Diffusion, and SDXL, image classification using ResNets on CIFAR-10, and convolutional variational autoencoders (CVAE) on MNIST.
  • Audio Models: Dive into speech recognition with OpenAI's Whisper, audio compression and generation with Meta's EnCodec, and music generation with Meta's MusicGen.
  • Multimodal Models: Learn about joint text and image embeddings with CLIP, text generation from image and text inputs with LLaVA, and image segmentation with Segment Anything (SAM).
  • Other Models: Find examples like semi-supervised learning on graph-structured data with GCN and Real NVP normalizing flows.

Why Use mlx-examples?

Using mlx-examples provides several key advantages:

  • Practical Learning: It serves as an excellent hands-on guide for learning the MLX framework through concrete, runnable examples.
  • Diverse Applications: The repository covers a wide spectrum of machine learning domains, from natural language processing to computer vision and audio processing.
  • Apple Silicon Optimization: Leverage the performance benefits of MLX, which is specifically designed for Apple silicon.
  • Community Engagement: The project encourages contributions and provides a pathway to join the MLX community on Hugging Face, fostering collaboration and model sharing.
  • Ready-to-Use Models: Many examples are based on popular and state-of-the-art models, providing a solid foundation for your own projects.

Links

Explore the mlx-examples repository and the MLX ecosystem further: