scann-core 0.2.1

Rust bindings for scann-core: ScaNN's approximate nearest-neighbour vector search core as a standalone library (derived from Google's ScaNN; not an official Google product)
Documentation
// Copyright 2026 The Google Research Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Modified in 2026 by Elias Benali (@ebenali) and TheCleaners for
// scann-core (a derived work of ScaNN, not an official Google product);
// see NOTICE.



syntax = "proto2";

package research_scann;

import "scann/proto/auto_tuning.proto";
import "scann/proto/brute_force.proto";
import "scann/proto/crowding.proto";
import "scann/proto/disjoint_restrict_token.proto";
import "scann/proto/distance_measure.proto";
import "scann/proto/exact_reordering.proto";
import "scann/proto/hash.proto";
import "scann/proto/input_output.proto";
import "scann/proto/metadata.proto";
import "scann/proto/min_distance.proto";
import "scann/proto/partitioning.proto";

message ScannConfig {
  extensions 1000 to max;

  optional string dataset_name = 32;

  optional int32 num_neighbors = 3 [default = 2147483647];

  optional float epsilon_distance = 4 [default = inf];

  optional MinDistanceConfig min_distance = 44;

  reserved 24, 37, 39;

  optional Crowding crowding = 29;

  optional DistanceMeasureConfig distance_measure = 5;

  optional ExactReordering exact_reordering = 17;

  optional InputOutputConfig input_output = 6;

  optional BruteForceConfig brute_force = 7;

  optional PartitioningConfig partitioning = 8;

  optional HashConfig hash = 13;

  optional MetadataConfig metadata = 20;

  optional int32 num_single_shard_neighbors = 21;

  optional bytes custom_search_method = 22;

  reserved 23;

  optional DisjointRestrictToken disjoint_restrict_token = 31;

  optional AutopilotConfig autopilot = 43;

  // scann-core: squared-L2 search through an inner-product index; see
  // L2AsDotProductConfig. Upstream ScaNN doesn't have this field.
  optional L2AsDotProductConfig l2_as_dot_product = 900;

  reserved 11;
  reserved 14;
  reserved 15;
  reserved 19;
  reserved 26;
  reserved 27;
  reserved 28;
  reserved 30;
  reserved 34;
  reserved 35;
  reserved 36;
  reserved 38;
  reserved 40;
  reserved "all_pair";
  reserved "offline_distributed_config";
  reserved "chunked_hamming";
  reserved "sparse_logistic";
  reserved "generalized_hash_search_config";
  reserved "random_searcher";
  reserved "sparse_dense_hybrid_batched";
  reserved "inverted_index";
  reserved "incremental_updates";
  reserved "auto_tuning";
  reserved "scoring_extension";

  reserved 16, 33, 18;
  reserved "chunked_inverted_index";
  reserved "legacy_inverted_index";
  reserved "pruned_inverted_index_cosine";

  enum SearchParadigm {
    QUERY_DATABASE = 0;
    ALL_PAIR = 1;
  }
  optional SearchParadigm search_paradigm = 1;

  enum SearchType {
    KNN = 0;
    ENN = 1;
    HYBRID = 2;
  }
  optional SearchType search_type = 2;

  reserved 25;
}

// scann-core: the exact L2 -> inner-product (MIPS) reduction. With it, an
// index whose distance_measure is SquaredL2Distance is searched as an
// inner-product index over one more dimension: each datapoint x is stored as
// x' = [x, (center - |x|^2) / (2 scale)] and each query q is searched as
// q' = [q, scale]. Then q'.x' = q.x - |x|^2 / 2 + center / 2, so the largest
// q'.x' is exactly the smallest |q - x|^2, and ScaNN's inner-product-only
// techniques (residual and anisotropic AH, tree AVQ, SOAR) apply to
// euclidean data. research_scann::ScannInterface applies the reduction to
// the dataset, queries and upserts, and returns squared L2 distances
// (|q|^2 + center - 2 q'.x'). The rest of the config (partitioning, hash,
// reordering) is that of a DotProductDistance index over dimensionality + 1
// dimensions; pure_dynamic_config.dimensionality is the data's
// dimensionality (without the extra coordinate). Saved indexes record this
// message and a distance_measure that loaders without it reject.
message L2AsDotProductConfig {
  // The query's extra coordinate (> 0). Unset when building: 0.4 times the
  // dataset's RMS norm, 0.4 sqrt(mean |x|^2) (0.4 sqrt(center) for an empty
  // dataset). It sets how much the extra coordinate weighs in partitioning
  // and quantization, not the results' exactness; see docs/tuning.md for
  // the measurements behind 0.4. Relative to the norm, so scaling the data
  // scales the whole index.
  optional double scale = 1;
  // Any constant; it only centres the datapoints' extra coordinate. Unset
  // when building: the dataset's mean |x|^2 (0 for an empty dataset).
  optional double center = 2;
}