Skip to main content

How to Add Tags to an MLflow Run

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Tags are labels on a run: the model type, the dataset, who owns it. Unlike parameters, you can change them later, and unlike metrics, they're text. MLflow also adds its own tags to every run, such as who ran it and which Git commit the code was at. This guide sets tags, overwrites one, adds a run description, and lists everything MLflow recorded, with real output from MLflow 3.18.0.

Syntax​

Syntax
mlflow.set_tag("<key>", <value>)
mlflow.set_tags({"<key>": <value>, "<key>": <value>})
PartWhat it means
mlflow.set_tag(key, value)Sets one tag on the active run. Setting it again replaces the value
mlflow.set_tags(dictionary)Sets several at once
keyThe tag's name, with the same allowed characters as a parameter's. Names that start with mlflow. are MLflow's own
valueAny value, stored as text

Prerequisites​

Step 1: Set Tags​

Create tags_demo.py:

tags_demo.py
import mlflow

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("tags-demo")

with mlflow.start_run(run_name="tags-demo") as run:
mlflow.set_tag("model_type", "random_forest")
mlflow.set_tags({"dataset": "california_housing", "owner": "data-team"})
mlflow.set_tag("mlflow.note.content", "Baseline run with the default settings.")
mlflow.set_tag("model_type", "gradient_boosting")

for key, value in sorted(mlflow.get_run(run.info.run_id).data.tags.items()):
print(f"{key} = {value}")
  • mlflow.set_tag(key, value) sets one tag; mlflow.set_tags(dict) sets several.
  • mlflow.note.content is a special tag: its value is the run's description.
  • The last set_tag gives model_type a new value. Tags can change; parameters can't.
Terminal
uv run python tags_demo.py
Output
2026/11/13 17:08:42 INFO mlflow.tracking.fluent: Experiment with name 'tags-demo' does not exist. Creating a new experiment.
🏃 View run tags-demo at: http://127.0.0.1:8080/#/experiments/7/runs/e27baeb3f0e249e197abf77c7324d299
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/7
dataset = california_housing
mlflow.note.content = Baseline run with the default settings.
mlflow.runName = tags-demo
mlflow.source.git.branch = main
mlflow.source.git.commit = 08ee202798775b8b1efbee4533f43d584056a14c
mlflow.source.name = tags_demo.py
mlflow.source.type = LOCAL
mlflow.user = you
model_type = gradient_boosting
owner = data-team

Step 2: Read the Tags​

Your three tags are there, and model_type has its new value, gradient_boosting. The rest, starting with mlflow., are system tags MLflow set by itself:

System tagWhat it records
mlflow.runNameThe run's name
mlflow.userYour computer's user name (you on this page)
mlflow.source.nameThe script or command that ran
mlflow.source.typeLOCAL, for code run on your computer
mlflow.source.git.commitThe Git commit the code was at, when you run it inside a Git repository
mlflow.source.git.branchThe Git branch
mlflow.note.contentThe description, here set by the script

The Git tags are worth a lot: they tie each run to the exact code that produced it. They only appear when the code runs inside a Git repository with at least one commit.

Step 3: See Them in the UI​

The run page shows your own tags under Tags, and the description at the top. System tags aren't in the Tags list, but the Source row shows three of them: the script, the Git branch and the short commit:

The tags-demo run page in MLflow with the description "Baseline run with the default settings.", the tags model_type gradient_boosting, dataset california_housing and owner data-team, and a Source row showing tags_demo.py, the branch main and the commit 08ee202.

The pencil icons next to Tags and Description edit them by hand, which is handy for adding a note after you've compared runs.

Common Mistakes​

MistakeWhat happensDo this instead
Logging a setting as a tagIt can be changed later, so it doesn't reliably describe how the run was set upLog settings as parameters
Naming your own tags mlflow.somethingYou can overwrite MLflow's system tagsUse your own names, such as model_type
Expecting Git tags outside a repositoryThey're missingRun the code from a Git repository with a commit

Troubleshooting​

SymptomLikely causeFix
No mlflow.source.git.commit tagThe code didn't run in a Git repository, or the repository has no commits yetCommit your code, then run again
The description is emptymlflow.note.content wasn't setSet it in code, or use the pencil icon in the UI

FAQ​

What's the difference between tags and parameters?​

Parameters are a run's settings, logged once and fixed. Tags are labels you can add or change at any time: How to Log Parameters in MLflow.

Can I filter runs by tag?​

Yes. In the runs table's search box, tags.model_type = "random_forest" shows only those runs.

Why does mlflow.user show you?​

MLflow records your computer's user name; on this page it's you. You'll see your own.

Conclusion​

mlflow.set_tag() and mlflow.set_tags() labeled the run, a second set_tag() changed model_type, and mlflow.note.content became the run's description. MLflow added its own system tags: the run name, the user, the source, and, inside a Git repository, the commit and branch.

Additional Resources​