# ml-explore/mlx-examples

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/ml-explore-mlx-examples).**

8,254 stars · 1,124 forks · Python · mit

## Links

- GitHub: https://github.com/ml-explore/mlx-examples
- awesome-repositories: https://awesome-repositories.com/repository/ml-explore-mlx-examples.md

## Topics

`mlx`

## Description

This repository provides a collection of reference implementations and code examples for training and deploying machine learning models using the MLX framework. It serves as a practical guide for executing distributed training, fine-tuning large language models, converting model weights, and implementing multimodal generative workflows.

The project distinguishes itself through specialized examples for local hardware execution, featuring weight quantization to reduce memory usage and low-rank adaptation for parameter-efficient fine-tuning. It also includes scripts for transforming external model formats into MLX-compatible versions and merging adapter weights for standalone deployment.

The examples cover a broad range of capabilities, including natural language processing with decoder-only and mixture-of-experts architectures, computer vision for image classification and segmentation, and audio processing for speech-to-text and music generation. Additionally, it demonstrates generative AI workflows for text-to-image and text-to-video synthesis, alongside graph-based neural networks and multimodal systems that utilize shared embedding spaces.

## Tags

### Artificial Intelligence & ML

- [Reference Model Implementations](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/architectures/model-architecture-evaluation/model-repositories/reference-model-implementations.md) — Provides a comprehensive collection of reference implementations for training and deploying models using the MLX framework.
- [Generative AI Workflows](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-workflows.md) — Provides sequences of automated steps for creating images, video, music, and text using diffusion models and transformers.
- [Large Language Model Fine-Tuning](https://awesome-repositories.com/f/artificial-intelligence-ml/large-language-model-fine-tuning.md) — Offers code samples for adapting large language models using LoRA and quantization for local hardware.
- [Model Fine-Tuning](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/fine-tuning-and-customization/model-fine-tuning.md) — Implements procedures for adapting pre-trained models to specific datasets using parameter-efficient training.
- [Low-Rank Adaptation](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/fine-tuning-and-customization/model-fine-tuning/low-rank-adaptation.md) — Provides reference implementations for parameter-efficient fine-tuning using low-rank adaptation to reduce hardware requirements.
- [Language Model Training](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/model-fine-tuning-adaptation/language-model-training.md) — Implements transformer-based language models trained on text corpora to predict subsequent tokens. ([source](https://github.com/ml-explore/mlx-examples/tree/main/transformer_lm))
- [Weight Quantization](https://awesome-repositories.com/f/artificial-intelligence-ml/quantized-inference-runtimes/weight-quantization.md) — Includes techniques for compressing model weights into 4-bit or 8-bit precision to reduce memory footprint on local hardware.
- [Text Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/text-generation.md) — Enables the generation of human-like text by running large language models on local hardware. ([source](https://github.com/ml-explore/mlx-examples/blob/main/llms/llama))
- [MLX Format Conversions](https://awesome-repositories.com/f/artificial-intelligence-ml/universal-checkpointing/mlx-format-conversions.md) — Provides scripts to transform model weights into formats optimized for the MLX framework on Apple Silicon.
- [Mistral Model Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/artificial-intelligence-tooling/language-model-integrations/mistral-model-integrations.md) — Provides an optimized implementation for integrating and executing Mistral large language models. ([source](https://github.com/ml-explore/mlx-examples/blob/main/llms/mistral))
- [Multimodal Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/audio-generation-models/multimodal-generation.md) — Implements generative workflows for producing text, images, audio, and video from mixed-modal inputs.
- [Distributed Training](https://awesome-repositories.com/f/artificial-intelligence-ml/distributed-training.md) — Provides reference code for parallelizing model training and computation across multiple devices.
- [Data-Parallel Training](https://awesome-repositories.com/f/artificial-intelligence-ml/distributed-training-frameworks/data-parallel-training.md) — Includes examples for distributing training workloads across multiple hardware units by synchronizing gradients.
- [Text-to-Video Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-pipelines/text-to-video-generators.md) — Synthesizes high-resolution video sequences from textual descriptions using a diffusion transformer. ([source](https://github.com/ml-explore/mlx-examples/blob/main/video/wan2.1))
- [Latent Diffusion Models](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-models/latent-diffusion-models.md) — Implements generative architectures that perform iterative denoising within compressed latent spaces to create visual content.
- [Inference Acceleration](https://awesome-repositories.com/f/artificial-intelligence-ml/inference-acceleration.md) — Accelerates inference by skipping redundant transformer computations when embeddings remain similar. ([source](https://github.com/ml-explore/mlx-examples/blob/main/video/wan2.1))
- [Mixture of Experts](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/fine-tuning-and-customization/model-customization/mixture-of-experts.md) — Supports the execution of large-scale mixture-of-experts models for efficient text generation. ([source](https://github.com/ml-explore/mlx-examples/blob/main/llms/mixtral))
- [Adapter Fusion](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/fine-tuning-and-customization/model-fine-tuning/low-rank-adaptation/adapter-fusion.md) — Provides utilities to merge trained low-rank adaptation weights into the base model for standalone deployment.
- [Multi-Modal Embedding Models](https://awesome-repositories.com/f/artificial-intelligence-ml/multi-modal-tokenizers/multi-modal-embedding-models.md) — Implements neural networks that map images and text into a shared vector space for joint retrieval. ([source](https://github.com/ml-explore/mlx-examples/blob/main/clip))
- [Multimodal AI Systems](https://awesome-repositories.com/f/artificial-intelligence-ml/multimodal-ai-systems.md) — Implements systems that combine text, image, and audio data for joint embeddings and generative workflows.
- [Multimodal Embeddings](https://awesome-repositories.com/f/artificial-intelligence-ml/vector-embeddings/multimodal-embeddings.md) — Implements shared vector spaces that map images and text together to enable joint retrieval and multimodal generation.
- [Image-to-Video Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/video-generation/image-to-video-generation.md) — Transforms static images into animated video sequences using model parameters. ([source](https://github.com/ml-explore/mlx-examples/blob/main/video/wan2.1))

### Part of an Awesome List

- [Local Model Deployment](https://awesome-repositories.com/f/awesome-lists/ai/local-model-deployment.md) — Provides examples for running and managing large language models on local hardware using quantization.
- [Multimodal Generation](https://awesome-repositories.com/f/awesome-lists/ai/text-generation/multimodal-generation.md) — Enables the production of text descriptions and answers based on combined image and text inputs. ([source](https://github.com/ml-explore/mlx-examples/tree/main/llava))
- [Audio and Speech Models](https://awesome-repositories.com/f/awesome-lists/media/audio-and-speech-models.md) — Implements speech recognition, neural audio compression, and text-to-music generation using specialized acoustic models.

### Data & Databases

- [Model Weight Conversions](https://awesome-repositories.com/f/data-databases/vector-data-formats/format-conversion-utilities/model-weight-conversions.md) — Ships scripts for transforming model weights and formats into MLX-compatible versions with precision quantization.

### Scientific & Mathematical Computing

- [Unified Memory Systems](https://awesome-repositories.com/f/scientific-mathematical-computing/unified-memory-systems.md) — Leverages a shared memory pool between CPU and GPU to eliminate redundant data copying during tensor operations.
