Class IndexIVFFlat

IndexIVFFlat Index. Inverted file with stored vectors.

Param

Param

The dimensionality of index.

Param

Number of clusters.

Param

Metric type (defaults to L2).

Hierarchy

Accessors

  • get dims(): number
  • Returns number

    The dimensionality of vectors.

  • get ids(): BigInt[]
  • Vector identifiers, size ntotal.

    Returns BigInt[]

  • get indexType(): IndexType
  • Returns IndexType

    The type of index.

  • get isTrained(): boolean
  • returns a boolean that indicates whether training is required.

    Returns boolean

    Whether training is required.

  • get metricArg(): number
  • Returns number

    Argument of the metric type.

  • get metricType(): MetricType
  • Returns MetricType

    The metric of the index.

  • get nprobe(): number
  • Cells to search.

    Returns number

  • set nprobe(value): void
  • Cells to search.

    Parameters

    • value: number

      The value to set.

    Returns void

  • get ntotal(): number
  • Returns number

    The number of verctors currently indexed.

Methods

  • Add n vectors of dimension d to the index. Vectors are implicitly assigned labels ntotal .. ntotal + n - 1

    Parameters

    • x: number[]

      Input matrix, size n * d

    Returns void

  • Add n vectors of dimension d to the index using the provided labels.

    Parameters

    • x: number[]

      Input matrix, size n * d

    • y: (number | BigInt)[]

      Vector identifiers

    Returns void

  • Add n vectors of dimension d to the index with ID's.

    Parameters

    • x: number[]

      Input matrix, size n * d

    • ids: BigInt[]

      Vector identifiers

    Returns void

  • Free all resources associated with the index. Further calls to the index will throw.

    Returns void

  • Merge the current index with another IndexIVFFlat instance.

    Parameters

    • otherIndex: IndexIVFFlat

      The other IndexIVFFlat instance to merge from.

    Returns void

  • Reconstruct desired vector from index. Will throw if not supported by the index type.

    Parameters

    • key: number | BigInt

      Key of vector to reconstruct.

    Returns number[]

    Reconstructed vector of length dims.

  • Reconstruct a batch of vectors from index. Will throw if not supported by the index type.

    Parameters

    • keys: (number | BigInt)[]

    Returns number[]

    Reconstructed vector of length dims.

  • Remove IDs from the index.

    Parameters

    • ids: BigInt[]

      IDs to read.

    Returns number

    number of IDs removed.

  • Reset the index, resulting in a ntotal of 0.

    Returns void

  • Query n vectors of dimension d to the index. return at most k vectors. If there are not enough results for a query, the result array is padded with -1s.

    Parameters

    • x: number[]

      Input vectors to search, size n * d.

    • k: number

      The number of nearest neighbors to search for.

    Returns SearchResult

    Output of the search result.

  • Train n vectors of dimension d to the index. Vectors are implicitly assigned labels ntotal .. ntotal + n - 1

    Parameters

    • x: number[]

      Input matrix, size n * d

    Returns void

  • Write index to a file.

    Parameters

    • fname: string

      File path to write.

    Returns void

  • Construct an index from factory descriptor.

    Parameters

    • dims: number

      Buffer to create index from.

    • descriptor: string

      Factory descriptor.

    • Optional metric: MetricType

      Metric type (defaults to L2).

    Returns Index

    The index read.

  • Merge trained & untrained IVF indexes on disk.

    Parameters

    • mergePaths: string[]
    • outputIndexPath: string

      Path of final merged index file.

    • outputDataPath: string

      Path of final merged data file.

    Returns void

Generated using TypeDoc