FaissReader#

class llama_index.readers.FaissReader(index: Any)#

Bases: BaseReader

Faiss reader.

Retrieves documents through an existing in-memory Faiss index. These documents can then be used in a downstream LlamaIndex data structure. If you wish use Faiss itself as an index to to organize documents, insert documents, and perform queries on them, please use VectorStoreIndex with FaissVectorStore.

Parameters

faiss_index (faiss.Index) – A Faiss Index object (required)

Methods Summary

load_data(query, id_to_text_map[, k, ...])

Load data from Faiss.

Methods Documentation

load_data(query: ndarray, id_to_text_map: Dict[str, str], k: int = 4, separate_documents: bool = True) List[Document]#

Load data from Faiss.

Parameters
  • query (np.ndarray) – A 2D numpy array of query vectors.

  • id_to_text_map (Dict[str, str]) – A map from ID’s to text.

  • k (int) – Number of nearest neighbors to retrieve. Defaults to 4.

  • separate_documents (Optional[bool]) – Whether to return separate documents. Defaults to True.

Returns

A list of documents.

Return type

List[Document]