Hey everyone! π
I've been building MLX-Swift implementations of recent research papers and wanted to share them with the community. I've organized these under a new GitHub org: github.com/mlx-community
The goal is to be a community-driven complement to ml-explore β focusing on bleeding-edge techniques and native Swift implementations that aren't in the official repos yet.
π speculative-decoding
Native MLX-Swift implementation of speculative decoding for faster LLM inference.
- Draft-then-verify pipeline with any MLX-compatible models
- 2-3x speedups on Apple Silicon
- Streaming support, simple API
- Works with models from mlx-community on HF
let output = try await SpeculativeDecoding.generate(
prompt: "Explain quantum computing:",
draftModelId: "mlx-community/Qwen2.5-0.5B-Instruct-4bit",
targetModelId: "mlx-community/Qwen2.5-7B-Instruct-4bit"
)Benchmarks (M2 Max, 24GB):
| Method | Tokens/sec | Speedup |
|---|---|---|
| Standard | 45.2 | 1.0x |
| Speculative (warm) | 89.4 | 1.98x |
π§ nano-reasoning
FastRL + EAGLE adaptive drafter implementation. The drafter learns from target model rejections in real-time, improving acceptance rate during inference.
Based on:
- EAGLE: Speculative Sampling Requires Rethinking Feature Uncertainty
- FastRL: Adaptive Drafter for Efficient Reasoning
Features:
- Hardware-tiered configs (Entry/Pro/Elite for different Mac specs)
- Background training with GPU-aware scheduling
- Single-layer EAGLE head option for minimal overhead
- Multi-Armed Bandit for adaptive SD configuration
π paddleocr-vl-swift
Native Swift port of PaddleOCR-VL β a 0.9B vision-language model for document understanding.
- OCR, table parsing, formula extraction, chart analysis
- 109 language support
- NaViT-style dynamic resolution
- CLI + library interfaces
paddleocr-vl ocr document.png --task tableWorking on next:
- mamba-swift β Native Mamba/Mamba-2 SSM (no Swift implementation exists yet)
- medusa-swift β Multi-head speculative decoding
- lora-swift β LoRA training in native Swift
Most MLX community work is Python. But there's a huge opportunity for native Swift:
- Ship ML directly in iOS/macOS apps
- No Python runtime overhead
- Better integration with Apple ecosystem
- SwiftUI + MLX = native AI apps
Happy to take suggestions on what to implement next. PRs welcome!
β @lulzx