raven-ml/raven

Modern scientific computing for OCaml

OCaml

406

1,798 commits

updated Sep 19, 2026

See the code

README

raven

modern scientific computing for OCaml

docs · install · issues


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 ())

Packages

PackageLikeWhat it does
nxNumPyN-dimensional arrays with linear algebra operations
tolktinygradMinimal ML compiler for GPU tensor computation
runeJAXAutomatic differentiation and functional transformations
kaunFlaxNeural networks and training
vegaOptaxComposable gradient-based optimizers
brotHF TokenizersFast, HuggingFace-compatible tokenization
talonPolarsFast and elegant dataframes with type-safe operations
huginMatplotlibPublication-quality plotting
quillJupyter + IPythonInteractive REPL and markdown notebooks
muninW&B / MLFlowLocal experiment tracking with live TUI dashboard

Contrib

Packages in contrib/ build against every change to the core and release on their own schedule.

PackageLikeWhat it does
nornBlackJAXMCMC sampling with automatic gradients
fehuGymnasiumReinforcement learning environments
sowiloOpenCVDifferentiable computer vision
nx-oxcamlExperimental Nx backend on OxCaml unboxed types

Getting started

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.

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.

Support Raven →

Thanks to our sponsors Ahrefs and Tarides.

License

ISC

Contributors

tmattio

1,694 commits

ghennequin

23 commits

gabyfle

21 commits

nirnayroy

19 commits

raven-ml/raven

Modern scientific computing for OCaml

OCaml

406

1,798 commits

updated Sep 19, 2026

See the code

README

raven

modern scientific computing for OCaml

docs · install · issues


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 ())

Packages

PackageLikeWhat it does
nxNumPyN-dimensional arrays with linear algebra operations
tolktinygradMinimal ML compiler for GPU tensor computation
runeJAXAutomatic differentiation and functional transformations
kaunFlaxNeural networks and training
vegaOptaxComposable gradient-based optimizers
brotHF TokenizersFast, HuggingFace-compatible tokenization
talonPolarsFast and elegant dataframes with type-safe operations
huginMatplotlibPublication-quality plotting
quillJupyter + IPythonInteractive REPL and markdown notebooks
muninW&B / MLFlowLocal experiment tracking with live TUI dashboard

Contrib

Packages in contrib/ build against every change to the core and release on their own schedule.

PackageLikeWhat it does
nornBlackJAXMCMC sampling with automatic gradients
fehuGymnasiumReinforcement learning environments
sowiloOpenCVDifferentiable computer vision
nx-oxcamlExperimental Nx backend on OxCaml unboxed types

Getting started

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.

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.

Support Raven →

Thanks to our sponsors Ahrefs and Tarides.

License

ISC

Contributors

tmattio

1,694 commits

ghennequin

23 commits

gabyfle

21 commits

nirnayroy

19 commits

Languages

OCaml

86.4%

C

9.1%

Python

3.0%