MLflowDataset
MLflowDataset
Bases: Dataset
Dataset backed by an MLflow evaluation dataset.
MLflow evaluation datasets (mlflow.genai.datasets) are stored in the
tracking server and curated from the MLflow UI, from traces, or from
code. Every record carries an inputs dict and, when labeled, an
expectations dict. This loader renders each record through the
Jinja2 input_template / output_template to JSON, validates it
against the corresponding DataModel, and yields batches of size
batch_size, the same contract as HuggingFaceDataset and the other
loaders. Records are exposed to the templates as inputs,
expectations, outputs, tags and record_id.
Evaluation datasets need a SQL-backed tracking store (sqlite:///...
or a tracking server), not the default ./mlruns file store.
Example:
ds = synalinks.MLflowDataset(
name="qa_golden_set",
tracking_uri="http://localhost:5000",
input_data_model=Question,
input_template='{"question": {{ inputs.question | tojson }}}',
output_data_model=Answer,
output_template='{"answer": {{ expectations.answer | tojson }}}',
batch_size=8,
)
program.evaluate(x=ds())
# Push in-memory arrays to MLflow; each example becomes one record with
# its input JSON under `inputs` and its target JSON under `expectations`.
synalinks.MLflowDataset.create(
name="qa_golden_set", x=x_train, y=y_train, experiment_id="1"
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The evaluation dataset name. Either |
None
|
dataset_id
|
str
|
Optional. The evaluation dataset id, when a name is ambiguous or unknown. |
None
|
tracking_uri
|
str
|
Optional. MLflow tracking URI. Defaults to the
value from |
None
|
input_data_model
|
DataModel
|
See |
None
|
input_schema
|
dict | str
|
See |
None
|
input_template
|
str
|
See |
None
|
output_data_model
|
DataModel
|
See |
None
|
output_schema
|
dict | str
|
See |
None
|
output_template
|
str
|
See |
None
|
batch_size
|
int
|
Examples per yielded batch. Defaults to |
1
|
limit
|
int
|
Optional. See |
None
|
repeat
|
int
|
See |
1
|
Source code in synalinks/src/datasets/mlflow_dataset.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
create(name, x, y=None, *, experiment_id=None, tags=None, tracking_uri=None)
classmethod
Create an MLflow evaluation dataset from in-memory arrays.
Each input's JSON becomes a record's inputs and, when y is
given, the matching target's JSON its expectations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The evaluation dataset name. |
required |
x
|
ndarray | list
|
The inputs, |
required |
y
|
ndarray | list
|
Optional. The targets, |
None
|
experiment_id
|
str | list
|
Optional. Experiment id(s) the dataset is associated with. |
None
|
tags
|
dict
|
Optional. Tags set on the dataset. |
None
|
tracking_uri
|
str
|
Optional. MLflow tracking URI
(see |
None
|
Returns:
| Type | Description |
|---|---|
EvaluationDataset
|
The MLflow evaluation dataset. |