Show HN: MLX-Ruby – Ruby Bindings for Apple's MLX ML Framework
github.comHi HN, I ported the Python MLX bindings to Ruby (https://github.com/ml-explore/mlx).
GitHub: https://github.com/skryl/mlx-ruby
MLX-Ruby is a native C++ extension that wraps the upstream MLX runtime, giving Ruby full access to the array framework, neural network layers, optimizers, and Metal GPU acceleration on Apple silicon.
What’s included: ∙Lazy arrays with dynamic graph construction ∙Function transforms: grad, value_and_grad, vmap, jvp, vjp, compile ∙Full NN module system: Conv2d, Linear, Embedding, Transformer layers, RNNs, etc. ∙Optimizers: Adam, AdamW, SGD, and more ∙A Ruby DSL for declarative model definition, training loops, and checkpointing ∙CPU and Metal GPU support
Working examples (https://github.com/skryl/mlx-ruby-examples):
∙LLaMA inference
∙Stable Diffusion
∙Whisper
∙Transformer language model
∙LoRA fine-tuning Performance is competitive with Python MLX. On small models, Ruby is within 0.55-1.54x of Python depending on model type and device. The heavy lifting happens in the same C++ / Metal runtime either way. Ruby deserves better ML tooling. The language is expressive enough that model definitions can actually be more readable than their Python equivalents. gem install mlx to try it out.