Support for conversational datasets with persona, goal, and context#19686
Support for conversational datasets with persona, goal, and context#19686SomtochiUmeh merged 6 commits intomasterfrom
Conversation
Signed-off-by: SomtochiUmeh <somtochiumeh@gmail.com>
|
Documentation preview for b91c2a8 is available at: More info
|
Signed-off-by: SomtochiUmeh <somtochiumeh@gmail.com>
| record_type = self._classify_input_fields(input_keys) | ||
|
|
||
| if record_type == DatasetSchemaType.UNKNOWN: | ||
| custom_fields = input_keys - MULTITURN_INPUT_FIELDS |
There was a problem hiding this comment.
can this be UNKNOWN for reasons other than multiturn? maybe we should make the error message more generic?
There was a problem hiding this comment.
UNKNOWN happens with mixed schemas (both multiturn and custom) present or if there's nothing in the records. We continue to the next record if the record is empty:
if not input_keys:
continueSo UNKNOWN here means mixed schema
|
|
||
| if batch_schema_type is None: | ||
| batch_schema_type = record_type | ||
| elif batch_schema_type != record_type: |
There was a problem hiding this comment.
It'd be good to compute the schema of each row and then do this comparison so the user can tell if there's a significant number of mismatches. e.g., All records must use the same schema type. Found N records for ... and M records for ....
| batch_schema_type = batch_schema_type or DatasetSchemaType.UNKNOWN | ||
| existing_schema_type = self._get_existing_schema_type() | ||
|
|
||
| if DatasetSchemaType.UNKNOWN in {batch_schema_type, existing_schema_type}: |
There was a problem hiding this comment.
shouldn't this thrown an error?
There was a problem hiding this comment.
Nah, this shouldn't be an error state
UNKNOWN means the records are either empty or have mixed schema types.
At this point, the validation for mixed schema types has already been done earlier in _validate_schema:
if record_type == DatasetSchemaType.UNKNOWN:
custom_fields = input_keys - MULTITURN_INPUT_FIELDS
raise MlflowException.invalid_parameter_value(So the only reason to still have UNKNOWN is that either the existing or new schema is empty
Signed-off-by: SomtochiUmeh <somtochiumeh@gmail.com>
smoorjani
left a comment
There was a problem hiding this comment.
LGTM, but let's hold for approval from someone on the MLflow team as well.
Signed-off-by: SomtochiUmeh <somtochiumeh@gmail.com>
Signed-off-by: SomtochiUmeh <somtochiumeh@gmail.com>
smoorjani
left a comment
There was a problem hiding this comment.
left a few minor questions/comments - mostly LGTM. thanks for iterating!
| if record_type == DatasetGranularity.UNKNOWN: | ||
| session_fields = input_keys & SESSION_IDENTIFIER_FIELDS | ||
| other_fields = input_keys - SESSION_INPUT_FIELDS | ||
| raise MlflowException.invalid_parameter_value( |
There was a problem hiding this comment.
nit: this case can also happen if inputs has no keys, so this error message may not make sense.
There was a problem hiding this comment.
the loop skips if no input keys (lines 361-362):
if not input_keys:
continueso it shouldn't error
There was a problem hiding this comment.
ah you're right - should we error in this case? it seems unintended to have a row without inputs
There was a problem hiding this comment.
Filed a ticket: https://databricks.atlassian.net/browse/ML-61094
Will check with Ben/Yuki whether it's possible for regular datasets to have empty inputs
| return DatasetGranularity.UNKNOWN | ||
| try: | ||
| schema = json.loads(self._schema) | ||
| input_keys = set(schema.get("inputs", {}).keys()) |
There was a problem hiding this comment.
I don't fully understand this part - how is it that the schema contains input keys? wouldn't you need to get the actual records?
There was a problem hiding this comment.
I set the schema in lines 276, after getting an existing dataset:
try:
existing_dataset = tracking_store.get_dataset(self.dataset_id)
self._schema = existing_dataset.schema
except Exception as e:The schema will look like this, for example:
{"inputs": {"goal": "string", "context": "object", "persona": "string"}, "outputs": {}, "expectations": {"expected_output": "string", "quality": "string"}, "version": "1.0"}
So we can extract the input keys
| assert isinstance(dataset, WrapperEvaluationDataset) | ||
| assert not isinstance(dataset, EntityEvaluationDataset) | ||
| assert isinstance(dataset, (WrapperEvaluationDataset, EntityEvaluationDataset)) | ||
|
|
There was a problem hiding this comment.
is this in the wrong file? should this in test_evaluation_dataset.py?
There was a problem hiding this comment.
Most of the existing merge_records tests are in this file. The only merge_records test in test_evaluation_dataset.py only checks that the correct dataset instance is returned:
| except (json.JSONDecodeError, TypeError): | ||
| return DatasetGranularity.UNKNOWN | ||
|
|
||
| def _classify_input_fields(self, input_keys: set[str]) -> DatasetGranularity: |
There was a problem hiding this comment.
I know this is private, but could we add some tests for this?
There was a problem hiding this comment.
Good call; added
Signed-off-by: SomtochiUmeh <somtochiumeh@gmail.com>
smoorjani
left a comment
There was a problem hiding this comment.
LGTM! Thanks for iterating! left one minor comment
| if record_type == DatasetGranularity.UNKNOWN: | ||
| session_fields = input_keys & SESSION_IDENTIFIER_FIELDS | ||
| other_fields = input_keys - SESSION_INPUT_FIELDS | ||
| raise MlflowException.invalid_parameter_value( |
There was a problem hiding this comment.
ah you're right - should we error in this case? it seems unintended to have a row without inputs
…lflow#19686) Signed-off-by: SomtochiUmeh <somtochiumeh@gmail.com>

🛠 DevTools 🛠
Install mlflow from this PR
For Databricks, use the following command:
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
Adds
persona,goal, andcontextfields for multiturn evaluation datasets. These can be nested directly insideinputs:Validations:
context, not alongside multiturn fieldsmerge_records()call must use the same schema (multiturn or regular)How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow 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" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould 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?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.