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

syntax = "proto3";

option optimize_for = LITE_RUNTIME;

package history_embeddings.proto;

// The packed value that encapsulates all the passages.
message PassagesValue {
  // The passages for the document in plaintext. Any encryption or compression
  // is applied to the whole proto message, not to individual passage strings.
  repeated string passages = 1;
}

// A single embedding vector for a single passage.
message EmbeddingVector {
  repeated float floats = 1;

  // Word count of the source passage for this embedding, needed to avoid
  // having to load and decrypt all passages for embeddings search.
  uint32 passage_word_count = 2;
}

// The packed storable value that encapsulates all embeddings vectors for all
// passages from a single source.
message EmbeddingsValue {
  repeated EmbeddingVector vectors = 1;
}

// Represents configurable parameters for word match boosting.
message WordMatchSearchParams {
  float minimum_embedding_score = 1;
  float score_boost_factor = 2;
  float word_match_limit = 3;
  float smoothing_factor = 4;
  float minimum_term_length = 5;
  uint32 max_term_count = 6;
  float required_term_ratio = 7;
}

// A single test case for word match boosting.
message WordMatchBoostTestCase {
  // Configuration for the word match boosting algorithm and formula.
  WordMatchSearchParams params = 1;

  // Raw query text.
  string query = 2;

  // Full set of passages for a hypothetical page.
  PassagesValue passages = 3;

  // This represents the boost term only, not including best embedding score.
  float expected_score_boost = 4;
}

// A composite of many test cases for word match boosting.
message WordMatchBoostTest {
  repeated string stop_words = 1;
  repeated WordMatchBoostTestCase cases = 2;
}
