Query metadata from the model registry#
By initializing a Model
or ModelVersion
object, you can query and download metadata and files stored for that model or its version.
Use the Neptune ID and available methods to fetch what you need, in the same way as you would for runs.
Examples#
Downloading a model signature, if it exists#
import neptune
model = neptune.init_model(with_id="CLS-PRE") # ID of existing model
if model.exists("model/signature"):
model["model/signature"].download()
In the above example, CLS-PRE
is the ID of the model.
How do I find the ID?
The Neptune ID is a unique identifier for the object. It's shown in the leftmost column of the table view.
The ID is stored in the system namespace, in the "sys/id"
field.
Listing all versions of a model#
import neptune
model = neptune.init_model(with_id="CLS-PRE")
model_versions_df = model.fetch_model_versions_table().to_pandas()
Filtering by query#
To filter the model versions by a custom field and condition, you can pass an NQL string to the query
argument.
model_versions_df = model.fetch_model_versions_table(
query="(`data_version`:artifact = 9a113b799082e5fd628be178bedd52837bac24e91f",
columns=["sys/stage", "model_size", "test/acc"],
sort_by="model_size",
).to_pandas()
For the syntax and examples, see the Neptune Query Language (NQL) reference.
Fetching validation metrics of a model version#
import neptune
model_version = neptune.init_model_version(with_id="CLS-PRE-4")
val_metrics = model_version["validation/metrics"].fetch()
In the above example, CLS-PRE-4
is the ID of the model version.
Difference between model and run#
The available methods for run and model objects are the same, with the following notable exceptions:
change_stage()
→ only forModelVersion
objects-
fetch_model_versions_table()
→ only forModel
objectsNote
The
Project
class has a similar method for downloading the runs and models table, respectively:
API reference pages#
init_model()
functionModel
classinit_model_version()
functionModelVersion
class