Modern scientific computing for OCaml
See the code
Raven is an ecosystem of OCaml libraries for numerical computing, machine learning, and data science. Everything you know from Python — NumPy, JAX, PyTorch, Matplotlib, Jupyter — rebuilt with type safety.
Raven is alpha. APIs will change. Feedback welcome.
(* nx — n-dimensional arrays *)
let x = Nx.linspace float32 0. 10. 100
let y = Nx.sin x
(* rune — automatic differentiation *)
let grad_f = Rune.grad' (fun x -> Nx.sum (Nx.mul x x)) x
(* brot — tokenization *)
let tokenizer = Brot.from_file "tokenizer.json" |> Result.get_ok
let ids = Brot.encode_ids tokenizer "The meaning of life is"
(* kaun — neural networks *)
let layer = Kaun.Linear.init ~inputs:768 ~outputs:10
let logits = Kaun.Linear.apply layer x
(* talon — dataframes *)
let df = Talon.create [
"name", Talon.Col.string_list [ "Alice"; "Bob"; "Charlie" ];
"score", Talon.Col.float64_list [ 85.5; 92.0; 78.5 ];
]
(* hugin — plotting *)
let () = Hugin.(figure () |> subplot |> Plotting.plot ~x ~y |> ignore; show ())
| Package | Like | What it does | |
|---|---|---|---|
| nx | NumPy | N-dimensional arrays with linear algebra operations | |
| ᛏ | tolk | tinygrad | Minimal ML compiler for GPU tensor computation |
| ᚱ | rune | JAX | Automatic differentiation and functional transformations |
| ᚲ | kaun | Flax | Neural networks and training |
| ᚹ | vega | Optax | Composable gradient-based optimizers |
| ᚨ | brot | HF Tokenizers | Fast, HuggingFace-compatible tokenization |
| ᛃ | talon | Polars | Fast and elegant dataframes with type-safe operations |
| ᛞ | hugin | Matplotlib | Publication-quality plotting |
| ᛈ | quill | Jupyter + IPython | Interactive REPL and markdown notebooks |
| ᛗ | munin | W&B / MLFlow | Local experiment tracking with live TUI dashboard |
Packages in contrib/ build against every change to the core and release on their own schedule.
| Package | Like | What it does | |
|---|---|---|---|
| ᚾ | norn | BlackJAX | MCMC sampling with automatic gradients |
| ᚠ | fehu | Gymnasium | Reinforcement learning environments |
| ᛋ | sowilo | OpenCV | Differentiable computer vision |
| nx-oxcaml | Experimental Nx backend on OxCaml unboxed types |
opam install raven
This installs the core ecosystem. You can also install only what you need — e.g. opam install kaun for neural networks, or opam install nx for just arrays.
Add to your dune file:
(executable
(name main)
(libraries raven))
See the installation guide for system dependencies and editor setup.
Building a scientific computing ecosystem takes sustained effort. Sponsorships help us ship JIT compilation, distributed training, better developer tooling, and production deployment through MirageOS.
Thanks to our sponsors Ahrefs and Tarides.
OCaml
86.4%
C
9.1%
Python
3.0%
Modern scientific computing for OCaml
See the code
Raven is an ecosystem of OCaml libraries for numerical computing, machine learning, and data science. Everything you know from Python — NumPy, JAX, PyTorch, Matplotlib, Jupyter — rebuilt with type safety.
Raven is alpha. APIs will change. Feedback welcome.
(* nx — n-dimensional arrays *)
let x = Nx.linspace float32 0. 10. 100
let y = Nx.sin x
(* rune — automatic differentiation *)
let grad_f = Rune.grad' (fun x -> Nx.sum (Nx.mul x x)) x
(* brot — tokenization *)
let tokenizer = Brot.from_file "tokenizer.json" |> Result.get_ok
let ids = Brot.encode_ids tokenizer "The meaning of life is"
(* kaun — neural networks *)
let layer = Kaun.Linear.init ~inputs:768 ~outputs:10
let logits = Kaun.Linear.apply layer x
(* talon — dataframes *)
let df = Talon.create [
"name", Talon.Col.string_list [ "Alice"; "Bob"; "Charlie" ];
"score", Talon.Col.float64_list [ 85.5; 92.0; 78.5 ];
]
(* hugin — plotting *)
let () = Hugin.(figure () |> subplot |> Plotting.plot ~x ~y |> ignore; show ())
| Package | Like | What it does | |
|---|---|---|---|
| nx | NumPy | N-dimensional arrays with linear algebra operations | |
| ᛏ | tolk | tinygrad | Minimal ML compiler for GPU tensor computation |
| ᚱ | rune | JAX | Automatic differentiation and functional transformations |
| ᚲ | kaun | Flax | Neural networks and training |
| ᚹ | vega | Optax | Composable gradient-based optimizers |
| ᚨ | brot | HF Tokenizers | Fast, HuggingFace-compatible tokenization |
| ᛃ | talon | Polars | Fast and elegant dataframes with type-safe operations |
| ᛞ | hugin | Matplotlib | Publication-quality plotting |
| ᛈ | quill | Jupyter + IPython | Interactive REPL and markdown notebooks |
| ᛗ | munin | W&B / MLFlow | Local experiment tracking with live TUI dashboard |
Packages in contrib/ build against every change to the core and release on their own schedule.
| Package | Like | What it does | |
|---|---|---|---|
| ᚾ | norn | BlackJAX | MCMC sampling with automatic gradients |
| ᚠ | fehu | Gymnasium | Reinforcement learning environments |
| ᛋ | sowilo | OpenCV | Differentiable computer vision |
| nx-oxcaml | Experimental Nx backend on OxCaml unboxed types |
opam install raven
This installs the core ecosystem. You can also install only what you need — e.g. opam install kaun for neural networks, or opam install nx for just arrays.
Add to your dune file:
(executable
(name main)
(libraries raven))
See the installation guide for system dependencies and editor setup.
Building a scientific computing ecosystem takes sustained effort. Sponsorships help us ship JIT compilation, distributed training, better developer tooling, and production deployment through MirageOS.
Thanks to our sponsors Ahrefs and Tarides.
OCaml
86.4%
C
9.1%
Python
3.0%