Skip to content
@elixir-nx

Numerical Elixir (Nx)

Welcome to Numerical Elixir!

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.

Key projects

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

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

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

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

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

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.


Why Elixir?

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

Resources

Here is a non-exhaustive list of resources put together by Numerical Elixir contributors.

Books

Videos

Articles

Pinned

  1. nx nx Public

    Multi-dimensional arrays (tensors) and numerical definitions for Elixir

    Elixir 2.5k 184

  2. axon axon Public

    Nx-powered Neural Networks

    Elixir 1.4k 99

  3. scholar scholar Public

    Traditional machine learning on top of Nx

    Elixir 344 41

  4. bumblebee bumblebee Public

    Pre-trained Neural Network models in Axon (+ 🤗 Models integration)

    Elixir 1.2k 86

  5. ortex ortex Public

    ONNX Runtime bindings for Elixir

    Elixir 95 10

Repositories

Showing 10 of 17 repositories

Top languages

Elixir C++

Most used topics

Loading…