Faiss
FaissReader #
基类: BaseReader
Faiss 阅读器。
通过现有的内存 Faiss 索引检索文档。这些文档可以在下游的 LlamaIndex 数据结构中使用。如果您希望使用 Faiss 本身作为索引来组织文档、插入文档并对其执行查询,请使用带有 FaissVectorStore 的 VectorStoreIndex。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
faiss_index
|
Index
|
一个 Faiss Index 对象 (必需) |
必需 |
源代码位于 llama-index-integrations/readers/llama-index-readers-faiss/llama_index/readers/faiss/base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
load_data #
load_data(query: ndarray, id_to_text_map: Dict[str, str], k: int = 4, separate_documents: bool = True) -> List[Document]
从 Faiss 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
query
|
ndarray
|
一个 2D numpy 数组形式的查询向量。 |
必需 |
id_to_text_map
|
Dict[str, str]
|
一个从 ID 映射到文本的字典。 |
必需 |
k
|
int
|
要检索的最近邻居数量。默认为 4。 |
4
|
separate_documents
|
Optional[bool]
|
是否返回单独的文档。默认为 True。 |
True
|
返回
类型 | 描述 |
---|---|
List[Document]
|
List[Document]: 文档列表。 |
源代码位于 llama-index-integrations/readers/llama-index-readers-faiss/llama_index/readers/faiss/base.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|