Building ML framework with Rust and Category Theory

The project 'Category Theory for Tiny ML in Rust' introduces a novel approach to building machine learning systems by bridging abstract mathematical concepts with executable Rust code. It provides a practical framework for optimizing tiny ML systems through the rigor of structural mathematics.
Category Theory for Tiny ML in Rust
A practical bridge between compositional mathematics, Rust types, and tiny machine-learning systems
Working Draft · Public Feedback Edition
Coauthored by Hamze Ghalebi and Farzad Jafarranmani, Category Theory for Tiny ML in Rust is a working draft that develops a small, explicit machine-learning system through the lens of category theory and Rust.
The book is designed for readers who want to understand machine learning not only as numerical computation, but as a structured pipeline of objects, transformations, composition, and constraints. Rather than treating category theory as decorative abstraction, this book uses it as an engineering tool:
- Domain objects become Rust types.
- Morphisms become typed transformations.
- Composition becomes executable program structure.
- Training becomes repeated transformation of model state.
- Tiny ML systems become a way to make mathematical structure concrete.
This is not a finalized edition. Chapters, examples, terminology, diagrams, code, and references may evolve as the work continues. The current public edition is still worth publishing: readers can use the existing chapters, run the Rust examples, and send evidence-shaped feedback while later completion passes continue.
About the Authors
Hamze Ghalebi is a Paris-based AI architect, CTO, and software builder associated with Remo Lab. His work focuses on production GenAI, regulated AI systems, auditable AI products, Rust systems, and the transition from AI prototypes to reliable production architectures. Hamze brings the engineering and product perspective: how to turn mathematical and machine-learning ideas into understandable, typed, maintainable systems.
Farzad Jafarranmani is a researcher and engineer in the Paris area, associated with Huawei and the Lagrange Mathematics and Computing Research Center. He holds a PhD in Mathematics and Computer Science from Université Paris Cité. Farzad brings the mathematical and theoretical foundation: category theory, denotational semantics, proof theory, and type-theoretic structure.
Feedback and Access
Public feedback is welcome while the book is still growing. Useful feedback includes unclear explanations, broken examples, missing references, or Rust examples that could be more idiomatic.
- The public book will always remain open access.
- The source code is published for inspection and testing.
- Commercial or organizational group reuse requires written permission.
Suggested reference format:
Ghalebi, H., & Jafarranmani, F.
Category Theory for Tiny ML in Rust.
Open-access working draft.
Book: https://hghalebi.github.io/category_theory_transformer_rs/
Source: https://github.com/hghalebi/category_theory_transformer_rs
Source: Hacker News

















