explaingit

ml-explore/mlx-examples

8,606PythonAudience · developerComplexity · 3/5Setup · moderate

TLDR

A collection of ready-to-run AI and machine learning example scripts for Apple Silicon Macs, covering language models, image generation, speech recognition, and more using Apple's MLX framework.

Mindmap

mindmap
  root((mlx-examples))
    What it does
      ML on Apple Silicon
      Example scripts
      Local AI inference
    Modalities
      Text and LLMs
      Image generation
      Audio and speech
      Multimodal
    Tech
      Python
      MLX framework
      Hugging Face
    Use cases
      Local LLM
      Fine-tuning
      Image generation
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Run large language models like LLaMA or Mistral locally on a Mac with an M-series chip.

USE CASE 2

Fine-tune an existing language model on your own data using LoRA directly on your Mac.

USE CASE 3

Generate images on a Mac using Stable Diffusion without any cloud API or GPU server.

USE CASE 4

Transcribe audio to text on-device using a Whisper model via the MLX audio example.

Tech stack

PythonMLXApple SiliconHugging Face

Getting it running

Difficulty · moderate Time to first run · 30min

Requires an Apple Silicon Mac (M1/M2/M3) and the MLX framework, model weights are downloaded separately from Hugging Face.

In plain English

This repository is a collection of example projects that demonstrate how to use MLX, Apple's machine learning framework for Apple Silicon chips (the M-series processors). Each example is a standalone script or small project focused on a specific task or model type, so you can read and run them independently without needing to understand the whole collection first. The examples cover a wide range of AI and machine learning tasks. On the text side, there are examples for training a language model from scratch, running large language models like LLaMA and Mistral, fine-tuning models with low-rank adaptation (LoRA), text classification with BERT, and a mixture-of-experts model. For images, there are examples for generating images with Stable Diffusion and FLUX, classifying images, and an autoencoder. Audio examples include speech recognition using OpenAI's Whisper model, audio compression with Meta's EnCodec, and music generation with MusicGen. There are also multimodal examples that combine text and images, including CLIP for joint embeddings, LLaVA for answering questions about images, and the Segment Anything model for image segmentation. The starting point recommended for newcomers is the MNIST digit classification example, which is simpler than the large model examples and shows the basic patterns of the MLX framework. The repository also points to a separate, more complete package called MLX LM for anyone who wants a fuller toolset for working with language models. Model weights for many of the examples are available through the MLX Community organization on Hugging Face, where the community also shares converted versions of public models ready to run with these scripts. The framework itself was developed at Apple by a small team of researchers.

Copy-paste prompts

Prompt 1
Walk me through running LLaMA 2 locally on my M2 MacBook Pro using the MLX-examples LLaMA script.
Prompt 2
Show me how to fine-tune a language model on my own text data using the LoRA example in mlx-examples.
Prompt 3
How do I generate images using Stable Diffusion from the mlx-examples repo on my M3 Mac?
Prompt 4
Help me set up the Whisper speech-to-text example in mlx-examples to transcribe a local audio file.
Open on GitHub → Explain another repo

← ml-explore on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.