Strands MLX: Apple Silicon Model Provider 🍎
Run Strands Agents locally on Apple Silicon with inference, fine-tuning, and vision.
MLX provider for Strands Agents with LoRA training pipelines.
Installation
Quick Start
from strands import Agent
from strands_mlx import MLXModel
from strands_tools import calculator
model = MLXModel(model_id="mlx-community/Qwen3-1.7B-4bit")
agent = Agent(model=model, tools=[calculator])
agent("What is 29 * 42?")
Architecture
graph LR
A[Agent Conversations] -->|MLXSessionManager| B[Training Data JSONL]
B -->|dataset_splitter| C[train/valid/test]
C -->|mlx_trainer| D[LoRA Adapter]
D -->|MLXModel| E[Domain Expert Agent]
E -.->|Continuous Learning| A
style A fill:#e1f5ff
style E fill:#d4edda
style D fill:#fff3cd
The complete training cycle: Agents collect their own training data → fine-tune themselves → become domain experts → continue learning.
Train Your Own Model
1. Collect Training Data
from strands import Agent
from strands_tools import calculator
from strands_mlx import MLXModel, MLXSessionManager, dataset_splitter, mlx_trainer
agent = Agent(
model=MLXModel(model_id="mlx-community/Qwen3-1.7B-4bit"),
session_manager=MLXSessionManager(session_id="my_training", storage_dir="./dataset"),
tools=[calculator, dataset_splitter, mlx_trainer],
)
# Have conversations - auto-saved to JSONL
agent("Teach me about quantum computing")
agent("Calculate 15 * 7")
# Saved to: ./dataset/my_training.jsonl
2. Split Dataset
agent.tool.dataset_splitter(
input_path="./dataset/my_training.jsonl"
)
# Creates train.jsonl, valid.jsonl, test.jsonl (80/10/10 split)
3. Train with LoRA
agent.tool.mlx_trainer(
action="train",
config={
"model": "mlx-community/Qwen3-1.7B-4bit",
"data": "./dataset/my_training",
"adapter_path": "./adapter",
"iters": 200,
"learning_rate": 1e-5,
"batch_size": 1
}
)
4. Use Trained Model
from strands import Agent
from strands_mlx import MLXModel
trained = MLXModel("mlx-community/Qwen3-1.7B-4bit", adapter_path="./adapter")
agent = Agent(model=trained)
agent("Explain quantum computing") # Uses trained knowledge!
Vision Models
from strands_mlx import MLXVisionModel
model = MLXVisionModel(model_id="mlx-community/Qwen2-VL-2B-Instruct-4bit")
agent = Agent(model=model)
agent("Describe: <image>photo.jpg</image>")
agent("Transcribe: <audio>speech.wav</audio>")
agent("What happens: <video>clip.mp4</video>")
Training Tools
| Tool | Purpose |
|---|---|
mlx_trainer |
Background LoRA training |
dataset_splitter |
Split JSONL → train/valid/test |
validate_training_data |
Check format & token counts |
mlx_invoke |
Runtime model switching |
Recommended Models
| Model | Size | Use Case |
|---|---|---|
mlx-community/Qwen3-1.7B-4bit |
~1GB | Fast local inference |
mlx-community/Qwen3-8B-4bit |
~4GB | Balanced performance |
mlx-community/Qwen2-VL-2B-Instruct-4bit |
~2GB | Vision tasks |
Why MLX?
- Native Apple Silicon: Optimized for M1/M2/M3/M4 chips
- No GPU drivers: Uses Metal directly
- Fast inference: Comparable to server GPUs
- Local privacy: No data leaves your machine
- Fine-tuning: LoRA training on consumer hardware
Train your own domain expert agent—right on your Mac. 🍎