|
| 1 | +syntax = "proto3"; |
| 2 | + |
| 3 | +package google.cloud.aiplatform.container.v1beta1; |
| 4 | + |
| 5 | +import "google/rpc/status.proto"; |
| 6 | + |
| 7 | +// MatchService is a Google managed service for efficient vector similarity |
| 8 | +// search at scale. |
| 9 | +service MatchService { |
| 10 | + // Returns the nearest neighbors for the query. If it is a sharded |
| 11 | + // deployment, calls the other shards and aggregates the responses. |
| 12 | + rpc Match(MatchRequest) returns (MatchResponse) {} |
| 13 | + |
| 14 | + // Returns the nearest neighbors for batch queries. If it is a sharded |
| 15 | + // deployment, calls the other shards and aggregates the responses. |
| 16 | + rpc BatchMatch(BatchMatchRequest) returns (BatchMatchResponse) {} |
| 17 | +} |
| 18 | + |
| 19 | +// Parameters for a match query. |
| 20 | +message MatchRequest { |
| 21 | + // The ID of the DeploydIndex that will serve the request. |
| 22 | + // This MatchRequest is sent to a specific IndexEndpoint of the Control API, |
| 23 | + // as per the IndexEndpoint.network. That IndexEndpoint also has |
| 24 | + // IndexEndpoint.deployed_indexes, and each such index has an |
| 25 | + // DeployedIndex.id field. |
| 26 | + // The value of the field below must equal one of the DeployedIndex.id |
| 27 | + // fields of the IndexEndpoint that is being called for this request. |
| 28 | + string deployed_index_id = 1; |
| 29 | + |
| 30 | + // The embedding values. |
| 31 | + repeated float float_val = 2; |
| 32 | + |
| 33 | + // The number of nearest neighbors to be retrieved from database for |
| 34 | + // each query. If not set, will use the default from |
| 35 | + // the service configuration. |
| 36 | + int32 num_neighbors = 3; |
| 37 | + |
| 38 | + // The list of restricts. |
| 39 | + repeated Namespace restricts = 4; |
| 40 | + |
| 41 | + // Crowding is a constraint on a neighbor list produced by nearest neighbor |
| 42 | + // search requiring that no more than some value k' of the k neighbors |
| 43 | + // returned have the same value of crowding_attribute. |
| 44 | + // It's used for improving result diversity. |
| 45 | + // This field is the maximum number of matches with the same crowding tag. |
| 46 | + int32 per_crowding_attribute_num_neighbors = 5; |
| 47 | + |
| 48 | + // The number of neighbors to find via approximate search before |
| 49 | + // exact reordering is performed. If not set, the default value from scam |
| 50 | + // config is used; if set, this value must be > 0. |
| 51 | + int32 approx_num_neighbors = 6; |
| 52 | + |
| 53 | + // The fraction of the number of leaves to search, set at query time allows |
| 54 | + // user to tune search performance. This value increase result in both search |
| 55 | + // accuracy and latency increase. The value should be between 0.0 and 1.0. If |
| 56 | + // not set or set to 0.0, query uses the default value specified in |
| 57 | + // NearestNeighborSearchConfig.TreeAHConfig.leaf_nodes_to_search_percent. |
| 58 | + int32 leaf_nodes_to_search_percent_override = 7; |
| 59 | +} |
| 60 | + |
| 61 | +// Response of a match query. |
| 62 | +message MatchResponse { |
| 63 | + message Neighbor { |
| 64 | + // The ids of the matches. |
| 65 | + string id = 1; |
| 66 | + |
| 67 | + // The distances of the matches. |
| 68 | + double distance = 2; |
| 69 | + } |
| 70 | + // All its neighbors. |
| 71 | + repeated Neighbor neighbor = 1; |
| 72 | +} |
| 73 | + |
| 74 | +// Parameters for a batch match query. |
| 75 | +message BatchMatchRequest { |
| 76 | + // Batched requests against one index. |
| 77 | + message BatchMatchRequestPerIndex { |
| 78 | + // The ID of the DeploydIndex that will serve the request. |
| 79 | + string deployed_index_id = 1; |
| 80 | + |
| 81 | + // The requests against the index identified by the above deployed_index_id. |
| 82 | + repeated MatchRequest requests = 2; |
| 83 | + |
| 84 | + // Selects the optimal batch size to use for low-level batching. Queries |
| 85 | + // within each low level batch are executed sequentially while low level |
| 86 | + // batches are executed in parallel. |
| 87 | + // This field is optional, defaults to 0 if not set. A non-positive number |
| 88 | + // disables low level batching, i.e. all queries are executed sequentially. |
| 89 | + int32 low_level_batch_size = 3; |
| 90 | + } |
| 91 | + |
| 92 | + // The batch requests grouped by indexes. |
| 93 | + repeated BatchMatchRequestPerIndex requests = 1; |
| 94 | +} |
| 95 | + |
| 96 | +// Response of a batch match query. |
| 97 | +message BatchMatchResponse { |
| 98 | + // Batched responses for one index. |
| 99 | + message BatchMatchResponsePerIndex { |
| 100 | + // The ID of the DeployedIndex that produced the responses. |
| 101 | + string deployed_index_id = 1; |
| 102 | + |
| 103 | + // The match responses produced by the index identified by the above |
| 104 | + // deployed_index_id. This field is set only when the query against that |
| 105 | + // index succeed. |
| 106 | + repeated MatchResponse responses = 2; |
| 107 | + |
| 108 | + // The status of response for the batch query identified by the above |
| 109 | + // deployed_index_id. |
| 110 | + google.rpc.Status status = 3; |
| 111 | + } |
| 112 | + |
| 113 | + // The batched responses grouped by indexes. |
| 114 | + repeated BatchMatchResponsePerIndex responses = 1; |
| 115 | +} |
| 116 | + |
| 117 | +// Namespace specifies the rules for determining the datapoints that are |
| 118 | +// eligible for each matching query, overall query is an AND across namespaces. |
| 119 | +message Namespace { |
| 120 | + // The string name of the namespace that this proto is specifying, |
| 121 | + // such as "color", "shape", "geo", or "tags". |
| 122 | + string name = 1; |
| 123 | + |
| 124 | + // The allowed tokens in the namespace. |
| 125 | + repeated string allow_tokens = 2; |
| 126 | + |
| 127 | + // The denied tokens in the namespace. |
| 128 | + // The denied tokens have exactly the same format as the token fields, but |
| 129 | + // represents a negation. When a token is denied, then matches will be |
| 130 | + // excluded whenever the other datapoint has that token. |
| 131 | + // |
| 132 | + // For example, if a query specifies {color: red, blue, !purple}, then that |
| 133 | + // query will match datapoints that are red or blue, but if those points are |
| 134 | + // also purple, then they will be excluded even if they are red/blue. |
| 135 | + repeated string deny_tokens = 3; |
| 136 | +} |
0 commit comments