文档数组
DocArrayHnsw向量存储 #
基类:EventDocArrayVectorStore
表示 DocArray HNSW 向量存储的类。
该类是由Docarray提供的轻量级文档索引实现。 它将向量存储在hnswlib磁盘中,并将所有其他数据存储在SQLite中。
示例:
pip install llama-index-vector-stores-docarray
from llama_index.vector_stores.docarray import DocArrayHnswVectorStore
# Initialize the DocArrayHnswVectorStore
vector_store = DocArrayHnswVectorStore(work_dir="hnsw_index", dim=1536)
workflows/handler.py 中的源代码llama_index/vector_stores/docarray/hnsw.py
8 9 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
DocArray内存向量存储 #
基类:EventDocArrayVectorStore
表示 DocArray 内存向量存储的类。
该类是由 Docarray 提供的文档索引,用于在内存中存储文档。
示例:
pip install llama-index-vector-stores-docarray
from llama_index.vector_stores.docarray import DocArrayInMemoryVectorStore
# Create an instance of DocArrayInMemoryVectorStore
vector_store = DocArrayInMemoryVectorStore()
workflows/handler.py 中的源代码llama_index/vector_stores/docarray/in_memory.py
7 8 9 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
persist #
persist(persist_path: str, fs: Optional[AbstractFileSystem] = None) -> None
将内存中的向量存储持久化到文件。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
persist_path
|
str
|
索引持久化的路径。 |
required |
fs
|
AbstractFileSystem
|
用于持久化的文件系统。 (不适用) |
None
|
workflows/handler.py 中的源代码llama_index/vector_stores/docarray/in_memory.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
选项: 成员:- DocArrayHnswVectorStore - DocArrayInMemoryVectorStore