raven

modern scientific computing for OCaml

raven

Raven is an ecosystem of composable libraries for numerical computing in OCaml. Tensors, automatic differentiation, neural networks, dataframes, plotting, tokenization, computer vision, reinforcement learning, and interactive notebooks — each library does one thing well, and they compose cleanly together.

Built on OCaml 5's effect system, Raven uses function transformations — grad, vmap, jit — that compose freely because they are nested effect handlers. The same code that runs a training loop on your laptop can target Metal or CUDA. Types catch shape and dtype mismatches at compile time.


see it in action

Tokenize text, build a classifier, and train it — three libraries working together:

open Kaun

(* Tokenize text with Brot *)
let tokenizer = Brot.from_file "tokenizer.json" |> Result.get_ok
let encode text = Brot.encode_ids tokenizer text

(* Build a model with Kaun *)
let model = Layer.sequential [
  Layer.embedding ~vocab_size:30522 ~embed_dim:128 ();
  Layer.relu ();
  Layer.linear ~in_features:128 ~out_features:2 ();
]

(* Train with automatic differentiation — Rune under the hood *)
let trainer = Train.make ~model
  ~optimizer:(Optim.adam ~lr:(Optim.Schedule.constant 1e-3) ())
let st = Train.init trainer ~dtype:Nx.Float32
let st = Train.fit trainer st train_data

the ecosystem

foundation

nx N-dimensional arrays with pluggable backends (NumPy)
rune Automatic differentiation and vectorizing maps (JAX)

machine learning

kaun Neural networks and training (Flax / PyTorch)
brot Tokenization for language models (HuggingFace Tokenizers)
sowilo Differentiable computer vision (OpenCV)
fehu Reinforcement learning environments (Gymnasium)

data and visualization

talon Dataframes with type-safe columns (pandas / Polars)
hugin Publication-quality plotting (Matplotlib)

tools

quill Interactive notebooks as markdown files (Jupyter)
kaun-board Training dashboard and metrics logger

get involved

Raven is built in public. We need your help:

View on GitHub →


support the project

Building a scientific computing ecosystem takes time and focus. Your sponsorship helps us deliver on our roadmap — GPU backends, performance parity, and comprehensive documentation.

Support Raven →