Hugging Face Announces Bumblebee: Transformers and Stable Diffusion in Pure Elixir
TL;DR
Hugging Face introduced Bumblebee, a pure‑Elixir library that ports Hugging Face Transformers—including GPT‑2 and Stable Diffusion—to the Elixir runtime, allowing developers to run inference on CPU or GPU without third‑party binaries.
What Bumblebee Provides
- Model coverage: Pre‑trained models ranging from text generation (GPT‑2) to image synthesis (Stable Diffusion) are available as Elixir modules.
- Zero external dependencies: Models compile to native CPU/GPU code using the Erlang VM’s concurrency and distribution features; no Python or C libraries are required.
- Livebook integration: Livebook’s “Smart cells” let users scaffold neural‑network tasks in three clicks, turning notebooks into interactive ML environments.
- Phoenix, Broadway, Nerves support: Bumblebee models can be embedded in Phoenix web apps, streamed through Broadway pipelines, or deployed on Nerves embedded devices.
Technical Foundations
- Nx tensors: Bumblebee builds on the Nx library, which provides multi‑dimensional tensors and a subset of Elixir that compiles to XLA (via EXLA) or Libtorch (via Torchx) for hardware acceleration.
- Axon: Functional, composable neural‑network definitions are supplied by Axon, inspired by Flax and PyTorch Ignite.
- Explorer: Data‑frame operations leverage Explorer, borrowing concepts from dplyr and Polars for efficient data manipulation.
- Tokenizers: A native Elixir tokenizer library handles the preprocessing steps required by Transformer models.
How to Get Started
- Install Livebook v0.8 and use the “+ Smart” cell menu to generate a neural‑network task template.
- Run example Phoenix apps from the Bumblebee repository to see inference inside a web server with LiveView.
- Explore notebooks in the Bumblebee
notebooks/directory for hands‑on tutorials.
Future Roadmap
- Training & transfer learning: The team plans to enable fine‑tuning of pre‑trained models directly in Elixir, allowing businesses to adapt models to domain‑specific data.
- Traditional ML algorithms: Additional work on classic machine‑learning methods is slated for upcoming releases.
- Expanded platform support: Livebook is being ported to more environments, including Hugging Face Spaces.
Community Involvement
- Contributions that add new model architectures to Bumblebee are welcomed.
- Opportunities exist across compiler work, model building, and integration with Elixir’s concurrent ecosystem.
- The project emphasizes a “concurrent, distributed, and fun” future for machine learning in Elixir.
The announcement was posted on the Hugging Face blog on 9 December 2022.