faiss

package
v1.7.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package faiss provides implementation of Go API for https://github.com/facebookresearch/faiss

Package faiss provides implementation of Go API for https://github.com/facebookresearch/faiss

Index

Constants

View Source
const (
	// -------------------------------------------------------------
	// Metric Type Definition
	// (https://github.com/facebookresearch/faiss/wiki/MetricType-and-distances)
	// -------------------------------------------------------------
	// DistanceNone is unknown distance type.
	DistanceNone metricType = iota - 1
	// InnerProduct is inner product.
	InnerProduct
	// L2 is l2 norm.
	L2

	// -------------------------------------------------------------
	// ErrorCode is false
	// -------------------------------------------------------------.
	ErrorCode = C._Bool(false)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Faiss

type Faiss interface {
	// SaveIndex stores faiss index to strage.
	SaveIndex() error

	// SaveIndexWithPath stores faiss index to specified storage.
	SaveIndexWithPath(idxPath string) error

	// Train trains faiss index.
	Train(nb int, xb []float32) error

	// Add returns faiss ntotal.
	Add(nb int, xb []float32, xids []int64) (int, error)

	// Search returns search result as []algorithm.SearchResult.
	Search(k, nq int, xq []float32) ([]algorithm.SearchResult, error)

	// Remove removes from faiss index.
	Remove(size int, ids []int64) (int, error)

	// Close faiss index.
	Close()
}

Faiss is core interface.

func Load

func Load(opts ...Option) (Faiss, error)

func New

func New(opts ...Option) (Faiss, error)

New returns Faiss instance with recreating empty index file.

type Option

type Option func(*faiss) error

Option represents the functional option for faiss.

func WithDimension

func WithDimension(dim int) Option

WithDimension represents the option to set the dimension for faiss.

func WithIndexPath

func WithIndexPath(idxPath string) Option

WithIndexPath represents the option to set the index path for faiss.

func WithM

func WithM(m int) Option

WithM represents the option to set the m for faiss.

func WithMetricType

func WithMetricType(metricType string) Option

WithMetricType represents the option to set the metric type for faiss.

func WithNbitsPerIdx

func WithNbitsPerIdx(nbitsPerIdx int) Option

WithNbitsPerIdx represents the option to set the n bits per index for faiss.

func WithNlist

func WithNlist(nlist int) Option

WithNlist represents the option to set the nlist for faiss.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL