Skip to main content

How to Add Tags to a Registered Model in MLflow

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Some facts belong to a model as a whole, whatever version is current: what task it does, which team owns it. MLflow keeps those as registered model tags, separate from the tags on each version. This guide creates a registered model, tags it, and deletes a tag, with real output from MLflow 3.18.0.

Syntax​

Syntax
client = MlflowClient()
client.create_registered_model(name)
client.set_registered_model_tag(name, key, value)
client.delete_registered_model_tag(name, key)
client.get_registered_model(name).tags
PartWhat it means
create_registered_model(name)Creates an empty registered model, with no versions yet
nameThe registered model
key, valueThe tag's name and its value; setting a key that exists replaces its value
.tagsA dictionary of the registered model's tags

The references: set_registered_model_tag, "Set a tag for the registered model.", and delete_registered_model_tag, "Delete a tag associated with the registered model."

Prerequisites​

  • An MLflow tracking server with a database backend at http://127.0.0.1:8080, such as mlflow server --port 8080 with its default SQLite database. The registry needs one.
  • mlflow in your project, for example with uv add mlflow.

Step 1: Tag the Registered Model​

A registered model doesn't need a version to carry tags, so the example creates flower-classifier on its own. It sets a task and a team tag, prints the tags, deletes team and prints them again:

The model_tags.py script in a macOS-style code window: create_registered_model flower-classifier, set_registered_model_tag task classification and team botany, print the tags, delete_registered_model_tag team, print them again.

model_tags.py
import mlflow
from mlflow import MlflowClient

mlflow.set_tracking_uri("http://127.0.0.1:8080")
client = MlflowClient()
name = "flower-classifier"

client.create_registered_model(name)
client.set_registered_model_tag(name, "task", "classification")
client.set_registered_model_tag(name, "team", "botany")
print("Tags: ", client.get_registered_model(name).tags)

client.delete_registered_model_tag(name, "team")
print("After a delete:", client.get_registered_model(name).tags)
Terminal
uv run python model_tags.py
Output
Tags: {'task': 'classification', 'team': 'botany'}
After a delete: {'task': 'classification'}

The output in a terminal: the tags task classification and team botany, then only task classification after the delete.

Both tags were on flower-classifier, and after the delete only task is left. The tags belong to the registered model itself, not to any version, which is why it could carry them before it had a single version.

Common Mistakes​

MistakeWhat happensDo this instead
Putting a fact about one version on the registered modelIt reads as true for every versionUse a model version tag for that version
Running the script a second timecreate_registered_model fails, because the name existsCreate the registered model once; tag it as often as you like

Troubleshooting​

SymptomLikely causeFix
RESOURCE_ALREADY_EXISTS: Registered Model (name=flower-classifier) already exists.create_registered_model ran for a name that existsSkip the create, or pick another name
RESOURCE_DOES_NOT_EXIST: Registered Model with name=... not foundThe registered model's name is misspelled, or it hasn't been createdCheck the name in the Model Registry

FAQ​

Can I find registered models by their tags?​

Yes, with a filter such as tags.team = 'growth': How to List and Filter Registered Models in MLflow.

How do I tag one version instead?​

With set_model_version_tag: How to Add Tags to a Model Version in MLflow.

Conclusion​

set_registered_model_tag gave flower-classifier its task and team tags, get_registered_model(name).tags read them back, and delete_registered_model_tag removed team.

Additional Resources​