Skip to content

Creating a model version#

Once you have registered a model, you can create and store versions of it. This lets you track the stage, binaries, and relevant metadata of each model version separately.

Before you start

You need to have a model registered in a Neptune project. You can find your models under the Models tab.

For instructions, see Registering a model.

To create and store a model version:

  1. Import Neptune and initialize a ModelVersion object based on the ID of an existing model:

    import neptune.new as neptune
    
    model_version = neptune.init_model_version(
        model="CLS-PRE",  # (1)
    )
    
    1. Neptune ID of the model, which comes from the project key and model key put together. You can find it in the leftmost column of the models table.

    The first model version will have the ID CLS-PRE-1.

  2. (optional) Log some model parameters and other metadata:

    model_params = {
        "eta": 0.3,
        "gamma": 0.0001,
        "max_depth": 2,
        ...
    }
    
    model_version["model/parameters"] = model_params
    model_version["model/environment"].upload("environment.yml")
    model_version["validation/dataset"].track_files("s3://datasets/validation")
    model_version["validation/acc"] = 0.97
    
  3. (optional) Upload the trained model weights as a binary file:

    model_version["model/binary"].upload("model.pt")
    
  4. To stop the connection to Neptune and sync all data, call the stop() method and execute the script or cell:

    model_version.stop()
    

To view the created model version in Neptune, click the link in the console output.

Next steps#

Back to top