 Hello. So the next thing I want to talk about is how to actually log a model to the model registry and link a model from a run to the model registry. And before I get into the code and all the different moving parts, I just want to remind you about the documentation. So anytime that you get lost in what I'm saying or you want to know more information a really good resource is the weights and biases Docs it's actually out of all the tools I use I would say weights and biases does a pretty good job of keeping their Docs up to date and so the way I like to use Docs is I like to use on on Mac anyways it's command K and you just search so in this case you know model registry I have caps lock on sorry about that model registry and I like to start with tutorials so in this case register models is a really good place to start. And it has a great walkthrough of real end-to-end example of how to log models and create artifacts and do all the things I'm going to show you today. But more specifically, there's also these docs, which go through almost the exact example that I'm going to show you and kind of explain that from a more of an API perspective of like how what's going on in that code so I highly recommend at least going through this this log models and this is in the guides so there's tutorials also guides so this is under this is one of the guides called Log Models. And please take a look at this. So next, let's jump into the code. So this is the code that we'll be using to link the model to the model registry. So first thing you want to do is install weights and biases. And you want to make sure you install the latest version of weights and biases. So pip install dash u. Next thing you want to do is some setup. So first, we want to attach to a project that we already have or create a new project. So that's what this 1db init is doing. And then we're going to create the artifact. In this case, we're creating a dummy artifact, which is a text file. So what is artifact? An artifact is a file that saves some kind of state about your model that you can use downstream for further training or inference. In this case, we're just creating a dummy file that is just a text file. But that doesn't matter. This is just to make sure that this example is minimal, so you can concentrate on understanding how to log a model and link it to the registry. The next step after you know what asset you have, or where your asset is, is to actually create an artifact. And so you so this is a good API to use one db.logmodel. One db log model is a shortcut for logging an artifact of type model. And so what we do here is we pass in the name of the artifact, which is just model dash 1db.runid, give it the path to the artifact, which in this case is just this text file, and then aliases. Aliases are metadata that you can attach to an artifact that flag the lifecycle of the artifact. You can use it any way you want, but what I recommend is you try to create aliases that sort of give you an idea of where that I like to use are dev, staging, review, production. All of these different aliases are good aliases. I'm going to go ahead and run this code. code and it's going to upload this artifact into the run and it's going to give me a link. Let's go ahead and click this link. Okay, so there's nothing logged to this run except for the artifacts. So I'm going to in this view, so this is the overview of that specific run. Nothing really happened in this run, but there's artifacts. And in this case, we have that artifact that we logged of type model. I can click on that artifact and the next thing that you'll notice here is there's the ability to link this artifact to a registry. Now there's many different ways to link to a registry. There's really two ways. One is with the UI and one is with code. I want to show you how to do it with the UI first just so you get a good mental model of how things work. But feel free to, you know, after you how things work but feel free to you know after you learn how to use the ui you know you can use the code and you'll see here the different aliases that we that we used in our code plus some other default ones so weights and biases will automatically add the latest and have like semantic versioning, alias already added for you. Noah, do you want to talk about these two tags, these ones that are added by default by waste and biases and how that works? Yeah, sure. As Hamel mentioned, the way we like to use aliases are the idea of being able to attach aliases to model version is to serve as semantically friendly identifiers for a specific model version. So you don't necessarily have to remember, oh, this is the third version of this artifact that I'm working on. So in this specific case, our artifact only has one version. But you can imagine a case where you've done a bunch of versioning, maybe tuned some of the hyperparameters, or you're kind of logging a model at every checkpoint. And so you might have an artifact with 100 checkpoints. And so you might have an artifact with 100 checkpoints. And aliases are a way to use, again, a semantically friendly identifier so that later in your code you can reference the artifact rather than remembering the specific version number. So latest is one of the default aliases and we add aliases and essentially make sure that there's always a pointer to the latest alias. The latest alias serves as a pointer to the most recent model version that you added to an artifact. And so this way, you know, wherever, if you're referencing or using this model in your code, you can use the latest alias to make sure that as the model is being versioned, that there's kind of always a way to make sure that you're pointing to the most recent version. And the other alias here that we also add, again, by default is what you'll see, like the v, v zero. So as you increase the number of versions, we're gonna keep count and automatically increment as any of the files change in your artifact, we'll increment kind of to the next version.
Logging Models
Here is the Model Registry documentation (http://wandb.me/ModelRegistry), where you can find code examples, explanations, tutorials and many more valuable insights. Before we dive in, to set the stage, we will be starting with the Log Models section. (http://wandb.me/LogModels)

To try it yourself, follow my code here. (http://wandb.me/LogModelDemo)

First, we will install wandb and create our first artifact, which in this case will be a logged model. To this artifact we will add aliases, I like to use aliases that indicate the model stage for example 'staging', 'production' etc. You can use them however they fit into your process!