Hi everyone.
Thanks for that.
Sorry about that delay.
I have a great privilege to introduce Benjamin to us.
Everyone give Benjamin a round of applause.
Thanks.
Okay.
So today I'm going to introduce to you Re-finals which is a micro framework we developed at
Fine Grand.
And I would like also in this talk to give you, to inspire you to, if you're deaf or
you're not into ML or you haven't trained a model before, I think what I'm going to
show you today is a great way to start and get started with ML training.
So why is it so daunting right now to train ML?
I think that's because we're in a phase called, we could call like the foundational models
phase where those huge companies are training big, big models and it's really hard to do.
And the goal of course when training those foundational models will be to reach the AGI.
So I have a very weak and restrictive definition of AGI but I have a 100% scientifically accurate
definition which is we're going to reach AGI when everyone in this room is going to lose
its job and become unemployed engineers.
In the meantime, sorry, what can we do?
So generally we do two kinds of things, right?
So you say you can either become a prompt engineer, you don't touch ML, you're just
relying on an external API or something like that to try to make the foundational model
do what you want it actually to do or you can like do the training and it's very good
for bragging but you cannot build it in open source because it's really costly, you need
GPUs, you need data and it's risky.
Like if you want to actually solve something, you train your MLM, you don't know if it's
going to solve it.
So there is a third way in between prompt engineering and training for a national model
and the idea is the idea of adapters.
So an adapter is just a way to patch a foundational model.
So generally a foundational model or like chains of transformer layers and then for instance
you could just inject some new weights into it and freeze the rest and you train those.
And the advantage is that you require a lot less VRAM and you use the foundation on which
the foundation model is built to train something very powerful and the idea is that you get
a lot more flexibility than using prompt engineering.
So it's something that's really exploding right now.
So for instance that's a list of all adapters that exist for large-rengorge models.
There's a lot.
Also for generative image, there's a lot of adapters that allows you to generate images
exactly like you want and unlock new possibilities that for instance table diffusion, the foundational
model cannot do.
And like every week you get two new papers on that domain.
So it's really, really exploding right now.
Okay, so let's talk a bit about why did we do that?
So most of AI codes today is written in PyTorch, which is an imperative language to write deep
learning model.
It's very convenient because the only thing you have to do is to write your operation
in a procedural way like with the NumPy API and everything works for you.
And that's really great.
But the issue is that when you want to patch or modify your model, you cannot do it because
the code is already written.
So you could monkey patch it, but you get into huge complications when you have multiple
adapters or you want to compose them, et cetera.
So we wrote yet another machine learning framework to solve that.
So maybe that's not a good idea.
So we wrote a micro framework.
And what we mean by that is that Refiners is built on top of PyTorch.
So everything is intercompatible.
So if you train a model with Refiners, it's going to work in PyTorch.
And if you have some elements you have already in PyTorch, it's going to work in Refiners.
So Refiners is based on three key concepts, the chain, the context, and the adapter.
And I'm going to go through each one to show you a bit how it works.
So the idea of a chain is instead of writing just operation by operation in your code,
you write each model as three of different layers.
And what you get is that it's easy to edit dynamically.
And it's completely explicit because when you see the graph of computation, you know
what your model do.
You don't have to look at the actual code.
You just have to look at the model.
So here's a comparison of PyTorch code.
So you define your layers and you write all the operations.
And on the right, what you will do with Refiners, where you just put each layer one after another.
So that seems very basic.
But so what you get is we have a very good representation of everything.
And now you have a lot of helpers to help do some operation on it.
So for instance, you can wrap model, pop them up, add some others.
And then when you look at the rep of the model, everything is explicit.
But you know what everything does.
So even if you change the name of a layer, you still see that it's a chain.
So now the chain is powerful.
But you say, what if I want to do really complex models?
Some models have some data that can pass through different layers.
So we need something to simplify the flow of the chains.
And so we introduce the context API that works a bit like in UI framework where you have a store.
And everything nested down there can have access to that store.
And so the idea is that even if you have a very nested chain, you can set the context.
And then every sub-layer is going to inherit from it.
And even in very complex models, you just add something like deep nested in the model.
You can have access from the outside to any tensor you add to it.
So for adaptation, it's very convenient.
And the third and last concept is the idea of adapter.
And the idea is to have an abstraction that make it easy to perform model surgery.
Because when you're patching, you want maybe to add some parts, remove some parts, and
let everything connected together again.
So obviously, you're not going to do all the operation by hand every time.
And so we have the adapter class.
And the idea is, let's say, for instance, we want to target this linear, add some more logic to it.
Then we can write an adapter that's going to plug itself into it.
In terms of code, it just looks like that.
We have a mixing called the adapter.
And you can just rub it into it.
And you get for free an inject method.
And the inject method is going to do exactly that.
We place the linear by the adapter.
So for instance, this schema, it's
look like the adapter that's called the Lora adapter, which is really common.
OK.
And so now we're using this to train new adapters.
And we're doing it in the open.
So you can have a look.
We have a page called Boonties, where you can come and train adapters.
For instance, the color palette adapter is currently being trained by someone who
hasn't had ML training for monitoring before.
And so if you could come and do some stuff with us, that would be really nice.
Thank you.
Thank you for listening.
Any questions?
No?
Cool.
All right, let's give them another round of applause.