mlflow/mlflow · error · MlflowException
INVALID_PARAMETER_VALUE
INVALID_PARAMETER_VALUE
Error message
The specified Hugging Face dataset does not contain the specified targets column '{targets}'. What it means
HuggingFaceDataset construction raises INVALID_PARAMETER_VALUE when a `targets` column name is given that does not exist in the datasets.Dataset's column_names. MLflow validates target presence at construction time so evaluation can group inputs/outputs later.
Source
Thrown at mlflow/data/huggingface_dataset.py:51
source: HuggingFaceDatasetSource,
targets: str | None = None,
name: str | None = None,
digest: str | None = None,
):
"""
Args:
ds: A Hugging Face dataset. Must be an instance of `datasets.Dataset`.
Other types, such as :py:class:`datasets.DatasetDict`, are not supported.
source: The source of the Hugging Face dataset.
targets: The optional name of the Hugging Face dataset column containing targets
(labels) for supervised learning.
name: The name of the dataset. E.g. "wiki_train". If unspecified, a name is
automatically generated.
digest: The digest (hash, fingerprint) of the dataset. If unspecified, a digest
is automatically computed.
"""
if targets is not None and targets not in ds.column_names:
raise MlflowException(
f"The specified Hugging Face dataset does not contain the specified targets column"
f" '{targets}'.",
INVALID_PARAMETER_VALUE,
)
self._ds = ds
self._targets = targets
super().__init__(source=source, name=name, digest=digest)
def _compute_digest(self) -> str:
"""
Computes a digest for the dataset. Called if the user doesn't supply
a digest when constructing the dataset.
"""
df = next(
self._ds.to_pandas(
batch_size=_MAX_ROWS_FOR_DIGEST_COMPUTATION_AND_SCHEMA_INFERENCE, batched=True
)View on GitHub (pinned to 6a27f2decc)
Solutions
- Set targets to one of ds.column_names (print them to verify).
- Load the split that contains the targets column.
- Pass targets=None if the dataset is inputs-only.
Example fix
// before
ds = load_dataset("imdb", split="test[0:100]")
ds_meta = mlflow.data.from_huggingface(ds, targets="target")
// after
ds_meta = mlflow.data.from_huggingface(ds, targets="label") # ds.column_names includes 'label' Defensive patterns
Strategy: validation
Validate before calling
if targets is not None and targets not in ds.column_names:
raise ValueError(
f"targets column {targets!r} not in dataset columns {ds.column_names}"
) Type guard
def has_column(ds, col: str) -> bool:
return col is None or col in ds.column_names Try / catch
from mlflow.exceptions import MlflowException
try:
meta = mlflow.data.from_huggingface(ds, targets=targets)
except MlflowException as e:
if "does not contain the specified targets column" in str(e):
meta = mlflow.data.from_huggingface(ds, targets=None)
else:
raise Prevention
- Print ds.column_names before choosing targets
- Load the split that actually contains the label column
- Watch for label vs labels naming differences
- Pass targets=None for inputs-only datasets
When it happens
Trigger: Calling mlflow.data.from_huggingface(ds, targets="label") where ds.column_names does not contain "label" (typo, wrong split, dataset without labels).
Common situations: Typo in the targets column name; loading a test split that lacks the label column present in train; datasets where the label column is named differently (e.g. "labels", "target", "answer").
Related errors
- INVALID_PARAMETER_VALUE
- INTERNAL_ERROR
- Found duplicated arguments in `HuggingFaceDatasetSource` and
- INVALID_PARAMETER_VALUE
- Failed to load base model '{effective_base_model}'. If the m
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/7d7c9dbe9aa5c5e4.
Report an issue: GitHub.