// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file is copied from chromium repo:
// //components/assist_ranker/proto/ranker_example.proto
// Contains features required for AssistRanker model inference and training.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package assist_ranker;
option go_package = "chromiumos/system_api/ml_proto";

message StringList {
  repeated bytes string_value = 1;
}

// A repeated list of float values.
message FloatList {
  repeated float float_value = 1;
}

// Generic message that can contain a variety of data types.
message Feature {
  oneof feature_type {
    // Bool values are used for scalar features.
    bool bool_value = 1;
    // Float and int values can be used for scalar and bucketized features.
    float float_value = 2;
    int32 int32_value = 3;
    // String values are used for one-hot features.
    bytes string_value = 4;
    // String list are used for sparse features.
    StringList string_list = 5;
    // Float lists represent vectorial features.
    FloatList float_list = 6;
  }
}

// RankerExample protos contain a set of features to be used as input for
// AssistRanker inference, and optionally a target for training.
message RankerExample {
  // Input features for the ranker model. This is the only field that is
  // required for inference.
  map<string, Feature> features = 1;
  // This field represents the ground truth that the ranker is
  // expected to predict, and is typically derived from user feedback. It is
  // used for training only and is not required for inference.
  // NOTE: this field will not be logged. If you want to log an outcome, add it
  // to the features field before calling LogExample.
  // TODO(chrome-ranker-team) Add a metadata field to log metrics that are not
  // used as model input.
  optional Feature target = 2;
}
