A class that wraps the FAISS (Facebook AI Similarity Search) vector database for efficient similarity search and clustering of dense vectors.

Hierarchy

Constructors

Properties

FilterType: string | object

Accessors

Methods

  • Adds an array of Document objects to the store.

    Parameters

    • documents: Document<Record<string, any>>[]

      An array of Document objects.

    • Optional options: {
          ids?: string[];
      }
      • Optional ids?: string[]

    Returns Promise<string[]>

    A Promise that resolves when the documents have been added.

  • Adds an array of vectors and their corresponding Document objects to the store.

    Parameters

    • vectors: number[][]

      An array of vectors.

    • documents: Document<Record<string, any>>[]

      An array of Document objects corresponding to the vectors.

    • Optional options: {
          ids?: string[];
      }
      • Optional ids?: string[]

    Returns Promise<string[]>

    A Promise that resolves with an array of document IDs when the vectors and documents have been added.

  • Merges the current FaissStore with another FaissStore.

    Parameters

    • targetIndex: FaissStore

      The FaissStore to merge with.

    Returns Promise<string[]>

    A Promise that resolves with an array of document IDs when the merge is complete.

  • Parameters

    • query: string
    • Optional k: number
    • Optional filter: string | object
    • Optional _callbacks: Callbacks

    Returns Promise<DocumentInterface<Record<string, any>>[]>

  • Performs a similarity search in the vector store using a query vector and returns the top k results along with their scores.

    Parameters

    • query: number[]

      A query vector.

    • k: number

      The number of top results to return.

    Returns Promise<[Document<Record<string, any>>, number][]>

    A Promise that resolves with an array of tuples, each containing a Document and its corresponding score.

  • Parameters

    • query: string
    • Optional k: number
    • Optional filter: string | object
    • Optional _callbacks: Callbacks

    Returns Promise<[DocumentInterface<Record<string, any>>, number][]>

  • Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.

    Parameters

    Returns Promise<DocumentInterface<Record<string, any>>[]>

    • List of documents selected by maximal marginal relevance.
  • Returns Promise<{
        NameRegistry: typeof NameRegistry;
        Parser: typeof Parser;
    }>

Generated using TypeDoc