Numerical Elixir is an effort started in 2021 to bring the power of numerical computing to Elixir (and vice-versa). This organization hosts several projects that empowers Elixir in the areas of data, machine learning, AI, and more. Our beloved mascot is the Numbat.
There are 5 key projects in our Numerical Elixir effort. We will briefly summarize them below and draw comparisons to other ecosystems to help developers familiarize with our work.
Nx stands for Numerical Elixir and it is the project that started it all.
Nx is a multi-dimensional tensors library with multi-staged compilation to the CPU/GPU. It plays a similar role to Numpy
in the Elixir community. It is inspired by Google's JAX
and ships with its own Tensor
Serving implementation that can run concurrently, distributed over multiple nodes, as well as partitioned across several GPUs.
Livebook brings the next generation of open-source local-first notebooks to Elixir. With Livebook you can write interactive and collaborative notebooks, which are truly reproducible, all the way to package management. If you are not yet familiar with Elixir, Livebook and its smart cells are one of the best ways to get started, and it features a growing ecosystem of integrations for databases, messaging, visualization, and more.
Explorer brings series (one-dimensional) and dataframes (two-dimensional) for fast and elegant data exploration to Elixir. It brings the power of Rust via the Polars library and it is inspired by dplyr (from the R community).
Axon is a Nx-powered Neural Network library. It splits out into three components: a Functional API of numerical functions, a high-level Model Creation API, and a Training API inspired by PyTorch Ignite.
Also check out the Bumblebee project, which provides several pre-trained Neural Networks with Hugging Face Models integration. Together with Livebook, it only takes 3 clicks to get your first Neural Network running in Elixir.
For integration with other platforms, see Ortex which provides full-blown compatibility for running ONNX models via ONNX Runtime bindings. Alternatively, see AxonONNX to convert ONNX models to Axon models whenever possible to achieve better integration with Nx.
Scholar is the most recent addition to the Nx ecosystem and it focus on traditional machine learning techniques, such as classification, regression, clustering, dimensionality reduction, metrics, and preprocessing. Because Scholar is fully built on top of Nx, it is fully GPU-ready, vectorizable, distributable, and more.
The goal of the Nx project is to marry the power of numerical computing with the Erlang VM capabilities for building concurrent, scalable, and fault-tolerant systems.
Elixir is a functional programming language that runs on the Erlang VM. And, at this point, you might ask: is functional programming a good fit for numerical computing? One of the main concerns is that immutability can lead to high memory usage when working with large blobs of memory. And that's true!
However, it turns out that the most efficient way of executing numerical computations is by first building a graph of all computations, then compiling that graph to run on your CPUs/GPUs. This reduces the back-and-forth between the host language (Elixir, Python, etc) and the numerical core and it allows your code to be further optimized. At this point, your numerical computing code becomes a function:
input -> [compiled numerical computing graph] -> output
The input
is an Elixir data-structure. Inside the function, the algorithm is highly optimized and free to mutate the data in any way
it seems fit. Then we get an output that once again must obey Elixir semantics.
To build those graphs, immutability becomes an indispensable tool both in terms of implementation and reasoning. As an example, the JAX library for Python, which has been one of the inspirations for Nx, also promotes functional and immutable principles:
JAX is intended to be used with a functional style of programming
— JAX Docs
Unlike NumPy arrays, JAX arrays are always immutable
— JAX Docs
At the end of the day, Elixir provides the functional foundation and a powerful macro system that allows us to compile a subset of Elixir to the CPU/GPU.
With the addition of Nx.Serving
, we started to marry the benefits of the Erlang VM with numerical computing. With Nx.Serving
, you can
batch numerical computing requests, as well as load balance requests over a cluster of machines
(see the announcement).
This makes it easy to embed and scale Nx code within your existing Elixir systems, both horizontally and vertically, and without a need
for third-party services. Our goal is to apply those principles to our whole Numerical Elixir stack.
We also expect numerical computing to complement the Elixir ecosystem in different ways, such as:
-
running Machine Learning models in real-time within your Phoenix web application
-
deploying models, signal processing, and data modelling inside embedded systems via Nerves
-
incorporating data analysis and classification algorithms inside concurrent data pipelines powered by Broadway
-
adding audio and video processing and AI capabilities to media systems through Membrane
Here is a non-exhaustive list of resources put together by Numerical Elixir contributors.
-
(2024) Keynote: Ship it! A Roadmap for putting Nx into Production by Chris Grainger (Nx, Explorer, Scholar, Bumblebee, Livebook)
-
(2024) Adding Nx Functionality to Your LiveView App by Paulo Valente
-
(2023) A year in production with Machine Learning on the BEAM by Chris Grainger (Explorer, Scholar, Bumblebee, Livebook)
-
(2023) Nx-powered decision trees by Andrés Alejos (Nx, EXGBoost)
-
(2023) MLOps in Elixir: Simplifying traditional MLOps with Elixir by Sean Moriarity (Nx, Bumbleblee)
-
(2023) Fine-tuning language models with Axon by Toran Billups (Axon)
-
(2023) Data wrangling with Livebook and Explorer (Livebook, Explorer)
-
(2023) Build and deploy a Machine Learning powered chat app to Hugging Face in 15 minutes (Nx, Livebook, Bumblebee)
-
(2023) Distributed² Machine Learning notebooks with Elixir and Livebook (Nx, Livebook, Bumblebee)
-
(2022) The Future AI Stack by Chris Grainger (Explorer, Axon)
-
(2022) Announcing Bumblebee: pre-trained machine learning models for GPT2, StableDiffusion, and more (Livebook, Bumblebee)
-
(2022) Axon: functional programming for deep learning by Sean Moriarity (Axon)
-
(2021) Build a neural network from scratch with Nx @ Lambda Days by José Valim (Nx)
-
(2024) Elixir Machine Learning: Training Models in Axon is Getting Better by Sean Moriarity
-
(2023) Three Years of Nx: Growing the Elixir Machine Learning Ecosystem by Sean Moriarity
-
(2023) Audio Speech Recognition in Elixir with Whisper Bumblebee by Sean Moriarity
-
(2022) Catching fraud with Elixir and Axon by Sean Moriarity