logoalt Hacker News

Building ML framework with Rust and Category Theory

68 pointsby adamnemecekyesterday at 4:24 PM16 commentsview on HN

Comments

stschaeftoday at 1:16 PM

I don't see what we gain for the mention of category theory here, and I find the categorical content in the book to be pretty buried.

If we're talking about categories, then we should be able to provide definitions of objects and morphisms clearly and independently. I guess I expected this to give denotational semantics of machine learning in an appropriately structured category, and then afterwards we can provide an implementation of these abstractions in Rust; however, this doesn't seem to be the case in this book. Rather, the category theory does seem somewhat stapled on. I wished that this would talk about things like Markov categories (or some other appropriate appropriate semantic domain) and then characterized machine learning algorithms via adjunctions between certain categories, such as in https://link.springer.com/article/10.1007/s44163-025-00707-w

As it's written, I don't see much of an opportunity for deriving theorems about the implementation from abstract nonsense, which, to me, would be the biggest strength of such a categorical description. This seems to be a simultaneous high-level introduction to Rust, machine learning, and category theory. The writing suffers from this, as the reader doesn't have much of an opportunity here to detangle these ideas from each other or see how one aids in understanding the others. Instead, they are all provide at once, and to an insufficient level of detail (for the amount of skimming that I did).

dauertewigkeittoday at 9:28 AM

This is not a critque of the work, but I have now been often encountering category theory in many of the research topics I'm working on, and even as somebody who majored in math, I sort of feel like it doesn't add much. I know ML frameworks intimately, and you really don't need category theory to describe them. But this is maybe (probably) a failure of mine, because I have not yet groked what category theory is really bringing to the table.

show 3 replies
ctenbtoday at 8:44 AM

Maybe expand ML to Machine Learning to avoid confusing with the programming language

pshirshovtoday at 10:23 AM

> Rust

> No HKTs

> Category Theory

dtj1123today at 11:34 AM

The style of writing here feels very Claude...

Edit: The more I read the more I think that this has at least been edited using AI. The number of instances of "this is not X, it is Y" is not super high, but it's higher than I'd expect from a human.

jdw64today at 9:26 AM

It's nice to see that.

oerstedtoday at 9:38 AM

I don't understand, this looks to me like regular Rust, or regular programming for that matter.

You use types to represent domain objects, and the program is composed of functions that transform domain objects into other domain objects.

Sure types are used a bit more aggressively than usual to restrict domains, particularly the newtype pattern (`struct TokenId(usize)` instead of just `usize`). But it doesn't look too exotic to me, or Category Theory influenced, other than in the sense that Category Theory terminology can be used to describe the structure of a regular typed program.

It's possible that I'm wrong and I'm missing the point. Frankly I really struggled reading this because of the AI generated vibe of the language, more than usual. I generally hate when content is criticised for just being AI generated, you can write very good and valuable things with AI by guiding it properly with authorial intent, but this one does really reek of bloated slop.

harrymaticstoday at 11:57 AM

nice work

phoebe_buildstoday at 10:03 AM

[flagged]

hks0today at 9:01 AM

Off topic, removed

show 1 reply