|
5 | 5 | import pandas as pd |
6 | 6 |
|
7 | 7 | from feast import ( |
| 8 | + ConflictPolicy, |
8 | 9 | Entity, |
9 | 10 | FeatureService, |
10 | 11 | FeatureView, |
11 | 12 | Field, |
12 | 13 | FileSource, |
| 14 | + LabelView, |
13 | 15 | Project, |
14 | 16 | PushSource, |
15 | 17 | RequestSource, |
@@ -165,3 +167,41 @@ def transformed_conv_rate_fresh(inputs: pd.DataFrame) -> pd.DataFrame: |
165 | 167 | name="driver_activity_v3", |
166 | 168 | features=[driver_stats_fresh_fv, transformed_conv_rate_fresh], |
167 | 169 | ) |
| 170 | + |
| 171 | +# --- Label Views --- |
| 172 | +# Label views manage mutable human labels for training data, RLHF, and evaluation. |
| 173 | +# They use PushSources so labels can be submitted from the UI or external tools. |
| 174 | + |
| 175 | +driver_quality_labels_source = PushSource( |
| 176 | + name="driver_quality_labels_push", |
| 177 | + batch_source=FileSource( |
| 178 | + name="driver_quality_labels_batch", |
| 179 | + path="%LABEL_DATA_PATH%", |
| 180 | + timestamp_field="event_timestamp", |
| 181 | + ), |
| 182 | +) |
| 183 | + |
| 184 | +driver_quality_labels = LabelView( |
| 185 | + name="driver_quality_labels", |
| 186 | + entities=[driver], |
| 187 | + schema=[ |
| 188 | + Field(name="is_reliable", dtype=Int64), |
| 189 | + Field(name="quality_score", dtype=Float32), |
| 190 | + Field(name="reviewer_notes", dtype=String), |
| 191 | + Field(name="labeler", dtype=String), |
| 192 | + ], |
| 193 | + source=driver_quality_labels_source, |
| 194 | + labeler_field="labeler", |
| 195 | + conflict_policy=ConflictPolicy.LAST_WRITE_WINS, |
| 196 | + description="Human quality labels for drivers - used for model training and evaluation", |
| 197 | + tags={ |
| 198 | + "feast.io/labeling-method": "table", |
| 199 | + "feast.io/field-role:is_reliable": "label", |
| 200 | + "feast.io/field-role:quality_score": "label", |
| 201 | + "feast.io/field-role:reviewer_notes": "metadata", |
| 202 | + "feast.io/label-values:is_reliable": "1,0", |
| 203 | + "feast.io/label-widget:is_reliable": "binary", |
| 204 | + "feast.io/label-widget:quality_score": "number", |
| 205 | + "feast.io/label-widget:reviewer_notes": "text", |
| 206 | + }, |
| 207 | +) |
0 commit comments