// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Experimental Translation Assist Model to allow/suppress translation prompts.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

import "translate_ranker_model.proto";
import "generic_logistic_regression_model.proto";

package assist_ranker;

// Metadata for a ranker model instance. This data describes how the ranker
// model should be interpreted/used.
message RankerModelMetadata {
  // An identifier denoting the type or purpose of this model. E.g. "Translate".
  optional string name = 1;

  // An identifier denoting the specific instance of this model. For example:
  // "Experiment B"
  optional string label = 2;

  // An identifier, typically a URL, denoting the source from which this model
  // was obtained. The model referenced with a given source is presumed to be
  // immutable; this can be used as a cache control mechanism. If the currently
  // configured model source matches the source of a cached model, and the
  // cached model has not expired then there is no need to refresh the model.
  optional string source = 3;

  // The timestamp at which this model was downloaded. This will be set by the
  // model loader before it caches the model to disk.
  optional int64 last_modified_sec = 4;

  // The (optional) number of seconds after which this model should be
  // considered expired. If the value is zero or not set, then the cached
  // instance of the model never expires. A new download can be triggered by
  // changing the configured source URL for the model loader.
  optional int64 cache_duration_sec = 5;

  // The version of the model. E.g. 20171027.
  optional uint32 model_version = 6;

  // If true, feature names are hex hashes of the original feature names, and
  // hashing must be applied on feature names at prediction time.
  optional bool input_features_names_are_hex_hashes = 7;
}

// Defines an envelope/wrapper for general models.
message RankerModelProto {
  // Metadata.
  optional RankerModelMetadata metadata = 1;

  oneof model {
    TranslateRankerModel translate = 2;
    GenericLogisticRegressionModel logistic_regression = 3;
  }
}
