package nx
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=96d35ce03dfbebd2313657273e24c2e2d20f9e6c7825b8518b69bd1d6ed5870f
sha512=90c5053731d4108f37c19430e45456063e872b04b8a1bbad064c356e1b18e69222de8bfcf4ec14757e71f18164ec6e4630ba770dbcb1291665de5418827d1465
doc/README.html
modern scientific computing for OCaml
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.
(* 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 -> Rune.sum (Rune.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 model = Kaun.Layer.sequential [
Kaun.Layer.linear ~in_features:768 ~out_features:128 ();
Kaun.Layer.relu ();
Kaun.Layer.linear ~in_features:128 ~out_features:10 ();
]
(* 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 ())Packages
Package | Like | What it does | |
|---|---|---|---|
NumPy | N-dimensional arrays with linear algebra operations | ||
ᚱ | JAX | Automatic differentiation and functional transformations | |
ᚲ | Flax | Neural networks and training | |
ᚨ | HF Tokenizers | Fast, HuggingFace-compatible tokenization | |
ᛃ | Polars | Fast and elegant dataframes with type-safe operations | |
ᛞ | Matplotlib | Publication-quality plotting | |
ᛈ | Jupyter + IPython | Interactive REPL and markdown notebooks | |
ᚠ | Gymnasium | Reinforcement learning environments | |
ᛋ | OpenCV | Differentiable computer vision |
Getting started
opam install ravenThis installs the full 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.
Support
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.