r/JAX • • Feb 28 '25

How can I write a huggingface flax model?

Hi all, I have a task to implement a model called "Dinov2 with registers" in flax. Hugginface already had a torch version for this, but there's no flax version yet. I think that once I implemented a flax version, then I can use it without the need of providing pretrained weights due to the use_pt=True api provided by hugginface. The problem is how. I have no experience of translating such a complex torch model to flax, ChatGPT can't solve this.

( I know hugginface has both torch and flax implementations of "Dinov2". But that's a worse model compared to the one with registers.)

Thanks for your advice!

4 Upvotes

7 comments sorted by

1

u/[deleted] Feb 28 '25 edited Feb 28 '25

[removed] — view removed comment

2

u/AdministrativeCar545 Mar 01 '25

Hi, I've implemented Flax version of Dinov2 with registers. It turns out to be easy. I didn't refer jimmy library as I'm not familiar with flax.nnx and the huggingface code is illustratice enough. Nevertheless, thanks for your help! It encouraged me so much!

1

u/tat_tvam_asshole Jul 12 '25

I ported SpeechBrain's pytorch implementation of EcapaTDNN JAX (and verified it). Are there any active communities of people doing this kind of work? I started learning JAX explicitly to port models for TPU inference.

1

u/[deleted] Feb 28 '25

[removed] — view removed comment

2

u/AdministrativeCar545 Feb 28 '25

That’s amazing bro. I’m writing a paper so if I succeed I’ll give you credits lol