{"record":{"id":"254a921146ccbc95","repo":"mlflow/mlflow","slug":"invalid-parameter-value-254a92","errorCode":"INVALID_PARAMETER_VALUE","errorMessage":"Failed to find answer similarity metric for version {metric_version}. Please check the version","messagePattern":"Failed to find answer similarity metric for version (.+?)\\. Please check the version","errorType":"error_code","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/metrics/genai/metric_definitions.py","lineNumber":69,"sourceCode":"            the default parameters defined in the metric implementation.\n        extra_headers: (Optional) Dictionary of extra headers to be passed to the judge model.\n        proxy_url: (Optional) Proxy URL to be used for the judge model. This is useful when the\n            judge model is served via a proxy endpoint, not directly via LLM provider services.\n            If not specified, the default URL for the LLM provider will be used\n            (e.g., https://api.openai.com/v1/chat/completions for OpenAI chat models).\n        max_workers: (Optional) The maximum number of workers to use for judge scoring.\n            Defaults to 10 workers.\n\n    Returns:\n        A metric object\n    \"\"\"\n    if metric_version is None:\n        metric_version = _get_latest_metric_version()\n    class_name = f\"mlflow.metrics.genai.prompts.{metric_version}.AnswerSimilarityMetric\"\n    try:\n        answer_similarity_class_module = _get_class_from_string(class_name)\n    except ModuleNotFoundError:\n        raise MlflowException(\n            f\"Failed to find answer similarity metric for version {metric_version}.\"\n            f\" Please check the version\",\n            error_code=INVALID_PARAMETER_VALUE,\n        ) from None\n    except Exception as e:\n        raise MlflowException(\n            f\"Failed to construct answer similarity metric {metric_version}. Error: {e!r}\",\n            error_code=INTERNAL_ERROR,\n        ) from None\n\n    if examples is None:\n        examples = answer_similarity_class_module.default_examples\n    if model is None:\n        model = answer_similarity_class_module.default_model\n\n    return make_genai_metric(\n        name=\"answer_similarity\",\n        definition=answer_similarity_class_module.definition,","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/metrics/genai/metric_definitions.py#L51-L87","documentation":"answer_similarity() imports mlflow.metrics.genai.prompts.<metric_version>.AnswerSimilarityMetric by class name derived from metric_version. If that module does not exist (ModuleNotFoundError), MLflow raises INVALID_PARAMETER_VALUE telling you to check the version.","triggerScenarios":"Calling answer_similarity(metric_version='vX') where prompts/vX does not exist — a typo like 'V1' vs 'v1', a version from docs of a newer MLflow, or metric_version=None defaulting to a version not present in the installed mlflow.","commonSituations":"Following a blog/tutorial referencing a prompt version not in your installed mlflow; downgrading mlflow while keeping code that names a newer version; case typos in the version string.","solutions":["Run mlflow.__version__ and use a metric_version that exists in mlflow/metrics/genai/prompts/ of that install","Omit metric_version to use _get_latest_metric_version()'s default","Upgrade mlflow if you need a newer prompt version","Fix case/typo in the version string (versions are lowercase like 'v1')"],"exampleFix":"// before\nanswer_similarity(metric_version=\"V2\", model=\"openai:/gpt-4o-mini\")\n// after\nanswer_similarity(metric_version=\"v1\", model=\"openai:/gpt-4o-mini\")","handlingStrategy":"validation","validationCode":"import mlflow, importlib.util\nif metric_version and not importlib.util.find_spec(f\"mlflow.metrics.genai.prompts.{metric_version}\"):\n    raise ValueError(f\"metric_version {metric_version} not in mlflow {mlflow.__version__}\")","typeGuard":"def known_metric_version(v):\n    return v is None or (isinstance(v, str) and importlib.util.find_spec(f\"mlflow.metrics.genai.prompts.{v}\") is not None)","tryCatchPattern":"from mlflow.exceptions import MlflowException\ntry:\n    m = answer_similarity(metric_version=v, model=model)\nexcept MlflowException as e:\n    if e.error_code == \"INVALID_PARAMETER_VALUE\":\n        m = answer_similarity(model=model)  # fall back to latest default\n    else:\n        raise","preventionTips":["Omit metric_version unless you specifically need a pinned prompt version","Verify the version exists in your installed mlflow before referencing it in code","Pin mlflow in requirements to keep versions and code in sync"],"tags":["mlflow","genai-metrics","invalid-parameter","version-mismatch"],"backgroundTag":"metric-version-not-found","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}