Skip to content

Introduce conversational guidelines scorer#19729

Merged
smoorjani merged 4 commits intomlflow:masterfrom
smoorjani:gwt-mlflow-ml-60372-sdk
Jan 6, 2026
Merged

Introduce conversational guidelines scorer#19729
smoorjani merged 4 commits intomlflow:masterfrom
smoorjani:gwt-mlflow-ml-60372-sdk

Conversation

@smoorjani
Copy link
Collaborator

@smoorjani smoorjani commented Jan 2, 2026

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/19729/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/19729/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/19729/merge

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

As titled.

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests
import mlflow
from mlflow.genai.scorers import ConversationalGuidelines
from mlflow.tracing.constant import TraceMetadataKey

...
session_id = "..."

traces = mlflow.search_traces(
    filter_string=f"metadata.`{TraceMetadataKey.TRACE_SESSION}` = '{session_id}'",
    return_type="list",
)

scorer = ConversationalGuidelines(
    guidelines=[
        "The assistant must respond professionally and courteously",
        "The assistant must not make promises about pricing or discounts",
    ],
    model="openai:/gpt-4o-mini"
)

result = scorer(session=traces)
print(f"Result: {result.value}")
print(f"Rationale: {result.rationale}")

output:

Result: no
Rationale: The assistant's responses throughout the conversation maintain a professional and courteous tone. However, the assistant makes specific references to actions taken on documents and changes made, which suggests a guarantee of action being completed, potentially leading to pricing or resource implications in a larger context. Additionally, there is a consistent implication of resolving issues based on user requests, which could be interpreted as promises of service without explicitly stating costs or guarantees. While the conversation does not directly state pricing or discounts, the responsibility of the assistant in document modification may imply a commitment that goes against guideline expectations.

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

Introduce the conversational guidelines scorer.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

Yes should be selected for bug fixes, documentation updates, and other small changes. No should be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.

What is a minor/patch release?
  • Minor release: a release that increments the second part of the version number (e.g., 1.2.0 -> 1.3.0).
    Bug fixes, doc updates and new features usually go into minor releases.
  • Patch release: a release that increments the third part of the version number (e.g., 1.2.0 -> 1.2.1).
    Bug fixes and doc updates usually go into patch releases.
  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

Signed-off-by: Samraj Moorjani <samraj.moorjani@databricks.com>
@github-actions github-actions bot added area/evaluation MLflow Evaluation rn/feature Mention under Features in Changelogs. labels Jan 2, 2026
Signed-off-by: Samraj Moorjani <samraj.moorjani@databricks.com>
Signed-off-by: Samraj Moorjani <samraj.moorjani@databricks.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Documentation preview for e84cc1b is available at:

Changed Pages (2)

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

Comment on lines +2605 to +2609
guidelines = self.guidelines
if isinstance(guidelines, str):
guidelines = [guidelines]
formatted_guidelines = "\n".join(f"<guideline>{g}</guideline>" for g in guidelines)
return CONVERSATIONAL_GUIDELINES_PROMPT.replace("{{ guidelines }}", formatted_guidelines)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this throw if guidelines is not a string or a list of strings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydantic will throw an error in this case before when initializing the scorer:

    scorer = ConversationalGuidelines(
  File "/Users/samraj.moorjani/personal_repos/gwt-mlflow-ml-60372-sdk/.venv/lib/python3.10/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for ConversationalGuidelines
guidelines.str
  Input should be a valid string [type=string_type, input_value=0.1234, input_type=float]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
guidelines.list[str]
  Input should be a valid list [type=list_type, input_value=0.1234, input_type=float]
    For further information visit https://errors.pydantic.dev/2.12/v/list_type


Evaluation criteria:
- Assess whether EVERY assistant response in the conversation follows ALL the provided guidelines.
- Focus only on the assistant's responses, not the user's messages.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: is it possible for user to provide guideline like "Whether the assistant addressed all requests by users" where user message would be needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make this clearer:
Focus on judging only the assistant's responses, not the user's messages.

- Focus only on the assistant's responses, not the user's messages.
- Only focus on the provided guidelines and not the correctness, relevance, or effectiveness of the responses.
- A guideline violation at ANY point in the conversation means the entire conversation fails.
- If none of the guidelines apply to the given conversation, the result must be "yes".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should this be "yes"? What does "apply to" mean here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If none of the guidelines are relevant (e.g., "Don't discuss Snowflake" for a conversation about cats and dogs), the assessment should not fail. We could alternatively add another class, but that will likely decrease accuracy and has the same impact as a passing assessment (user doesn't really look at it).

Copy link
Collaborator

@xsh310 xsh310 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, left 2 quick comments on the prompt.

Signed-off-by: Samraj Moorjani <samraj.moorjani@databricks.com>
@smoorjani smoorjani enabled auto-merge January 6, 2026 21:41
@smoorjani smoorjani added this pull request to the merge queue Jan 6, 2026
Merged via the queue into mlflow:master with commit ba37372 Jan 6, 2026
46 checks passed
@smoorjani smoorjani deleted the gwt-mlflow-ml-60372-sdk branch January 6, 2026 22:16
omarfarhoud pushed a commit to omarfarhoud/mlflow that referenced this pull request Jan 20, 2026
Signed-off-by: Samraj Moorjani <samraj.moorjani@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/evaluation MLflow Evaluation rn/feature Mention under Features in Changelogs. v3.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants