向量
LlamaIndex 数据结构。
可组合图 #
可组合图。
workflows/handler.py 中的源代码llama_index/core/indices/composability/graph.py
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 | |
from_indices
classmethod
#
from_indices(root_index_cls: Type[BaseIndex], children_indices: Sequence[BaseIndex], index_summaries: Optional[Sequence[str]] = None, storage_context: Optional[StorageContext] = None, **kwargs: Any) -> ComposableGraph
使用此索引类作为根节点创建可组合图。
workflows/handler.py 中的源代码llama_index/core/indices/composability/graph.py
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 | |
get_index #
get_index(index_struct_id: Optional[str] = None) -> BaseIndex
根据索引结构ID获取索引。
workflows/handler.py 中的源代码llama_index/core/indices/composability/graph.py
115 116 117 118 119 | |
文档摘要索引 #
基类:EventBaseIndex[IndexDocumentSummary]
文档摘要索引。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
response_synthesizer
|
BaseSynthesizer
|
一个用于生成摘要的响应合成器。 |
None
|
summary_query
|
str
|
用于为每个文档生成摘要的查询。 |
DEFAULT_SUMMARY_QUERY
|
show_progress
|
bool
|
是否显示tqdm进度条。 默认为 False。 |
False
|
embed_summaries
|
bool
|
是否嵌入摘要。 运行基于嵌入的默认检索器时需要此项。 默认为 True。 |
True
|
workflows/handler.py 中的源代码llama_index/core/indices/document_summary/base.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
as_retriever #
as_retriever(retriever_mode: Union[str, _RetrieverMode] = EMBEDDING, **kwargs: Any) -> BaseRetriever
获取检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
retriever_mode
|
Union[str, DocumentSummaryRetrieverMode]
|
检索器模式。 默认为 DocumentSummaryRetrieverMode.EMBEDDING。 |
EMBEDDING
|
workflows/handler.py 中的源代码llama_index/core/indices/document_summary/base.py
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 139 140 141 142 143 144 145 146 147 148 149 150 | |
get_document_summary #
get_document_summary(doc_id: str) -> str
根据文档ID获取文档摘要。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
doc_id
|
str
|
一个文档标识符。 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/document_summary/base.py
152 153 154 155 156 157 158 159 160 161 162 163 | |
delete_nodes #
delete_nodes(node_ids: List[str], delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
从索引中删除节点列表。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
node_ids
|
List[str]
|
要删除的节点对应的节点ID列表 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/document_summary/base.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
从索引中删除文档。 索引中与该文档相关的所有节点将被删除。
workflows/handler.py 中的源代码llama_index/core/indices/document_summary/base.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
空索引 #
基类:EventBaseIndex[EmptyIndexStruct]
空索引。
一个不包含任何文档的索引。用于纯LLM调用。 注意:存在此索引是因为空索引允许某些特性, 例如能够与其他索引组合 + 令牌计数 + 其他功能。
workflows/handler.py 中的源代码llama_index/core/indices/empty/base.py
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 | |
关键词表索引 #
基类:EventBaseKeywordTableIndex
关键词表索引。
该索引使用GPT模型从文本中提取关键词。
workflows/handler.py 中的源代码llama_index/core/indices/keyword_table/base.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
RAKE关键词表索引 #
基类:EventBaseKeywordTableIndex
RAKE关键词表索引。
该索引使用RAKE关键词提取器从文本中提取关键词。
workflows/handler.py 中的源代码llama_index/core/indices/keyword_table/rake_base.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
简单关键词表索引 #
基类:EventBaseKeywordTableIndex
简单关键词表格索引。
该索引使用简单的正则表达式提取器从文本中提取关键词。
workflows/handler.py 中的源代码llama_index/core/indices/keyword_table/simple_base.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
知识图谱索引 #
基类:EventBaseIndex[KG]
知识图谱索引。
通过提取三元组构建知识图谱,并在查询时利用该知识图谱。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
kg_triplet_extract_template
|
BasePromptTemplate
|
用于提取三元组的提示词。 |
None
|
max_triplets_per_chunk
|
int
|
要提取的三元组最大数量。 |
10
|
storage_context
|
Optional[StorageContext]
|
要使用的存储上下文。 |
None
|
graph_store
|
Optional[GraphStore]
|
要使用的图存储。 |
required |
show_progress
|
bool
|
是否显示tqdm进度条。默认为False。 |
False
|
include_embeddings
|
bool
|
是否在索引中包含嵌入向量。 默认为 False。 |
False
|
max_object_length
|
int
|
三元组中对象的最大长度。 默认为128。 |
128
|
kg_triplet_extract_fn
|
Optional[Callable]
|
用于提取三元组的函数。默认为 None。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/knowledge_graph/base.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
upsert_triplet #
upsert_triplet(triplet: Tuple[str, str, str], include_embeddings: bool = False) -> None
插入三元组及可选的嵌入向量。
用于手动插入知识图谱三元组(形式为(主体,关系,客体))。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
triplet
|
tuple
|
知识三元组 |
required |
embedding
|
Any
|
三元组的嵌入选项。默认为 None。 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/knowledge_graph/base.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
add_node #
add_node(keywords: List[str], node: BaseNode) -> None
添加节点。
用于手动插入节点(通过关键词索引)。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
keywords
|
List[str]
|
用于索引节点的关键词。 |
required |
node
|
Node
|
待索引的节点。 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/knowledge_graph/base.py
277 278 279 280 281 282 283 284 285 286 287 288 289 | |
upsert_triplet_and_node #
upsert_triplet_and_node(triplet: Tuple[str, str, str], node: BaseNode, include_embeddings: bool = False) -> None
更新知识图谱三元组与节点。
同时调用 upsert_triplet 和 add_node。 该行为是幂等的;如果节点已存在, 则仅会添加三元组。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
keywords
|
List[str]
|
用于索引节点的关键词。 |
required |
node
|
Node
|
待索引的节点。 |
required |
include_embeddings
|
bool
|
为三元组添加嵌入的可选项。默认为 False |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/knowledge_graph/base.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
get_networkx_graph #
get_networkx_graph(limit: int = 100) -> Any
获取图结构的networkx表示。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
limit
|
int
|
图中包含的起始节点数量。 |
100
|
注意:此功能需要安装 networkx。 注意:这是一个测试版功能。
workflows/handler.py 中的源代码llama_index/core/indices/knowledge_graph/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
摘要索引 #
基类:EventBaseIndex[IndexList]
摘要索引。
摘要索引是一种简单的数据结构,其中节点按顺序存储。在索引构建过程中,文档文本被分割成块,转换为节点,并存储在列表中。
在查询期间,摘要索引会遍历所有节点 (可使用一些可选筛选参数),并从所有节点中 综合生成答案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
text_qa_template
|
Optional[BasePromptTemplate]
|
问答提示
(参见 :ref: |
required |
show_progress
|
bool
|
是否显示tqdm进度条。默认为False。 |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/list/base.py
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 139 140 141 142 143 144 145 146 147 148 149 | |
多模态向量存储索引 #
基类:EventVectorStoreIndex
多模态向量存储索引。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
use_async
|
bool
|
是否使用异步调用。默认为 False。 |
False
|
show_progress
|
bool
|
是否显示tqdm进度条。默认为False。 |
False
|
store_nodes_override
|
bool
|
设置为True以始终在索引存储和文档存储中存储节点对象,即使向量存储保留文本。默认为False |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/multi_modal/base.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
通过使用 ref_doc_id 删除文档及其节点。
workflows/handler.py 中的源代码llama_index/core/indices/multi_modal/base.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
SQL结构存储索引 #
基类:EventBaseStructStoreIndex[SQLStructTable]
SQL 结构存储索引。
SQLStructStoreIndex 是一种底层使用 SQL 数据库的索引。在索引构建过程中,数据可以通过模式提取提示从非结构化文档中推断得出,也可以预先加载到数据库中。
在查询时,用户既可以指定原始SQL查询,也可以使用自然语言查询来检索其数据。
注意:此功能已弃用。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
documents
|
Optional[Sequence[DOCUMENTS_INPUT]]
|
要索引的文档。 注意:在SQL索引中,这是一个可选字段。 |
required |
sql_database
|
Optional[SQLDatabase]
|
要使用的SQL数据库,
包括需要指定的表名。
更多详情请参阅 :ref: |
None
|
table_name
|
Optional[str]
|
用于提取数据的表名。 必须指定 table_name 或 table 其中之一。 |
None
|
table
|
Optional[Table]
|
要使用的SQLAlchemy表对象。 明确指定表对象而非表名,允许您传入视图。 必须指定table_name或table。 |
None
|
sql_context_container
|
Optional[SQLContextContainer]
|
SQL上下文容器。
可通过SQLContextContainerBuilder生成。
更多详情请参阅: |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/struct_store/sql.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
树状索引 #
基类:EventBaseIndex[IndexGraph]
树状索引。
树状索引是一种树形结构的索引,其中每个节点都是子节点的摘要。在索引构建过程中,该树以自底向上的方式构建,直到我们得到一组根节点。
在查询时有几种不同的选项(参见:Ref-Query)。
主要选项是从根节点向下遍历树。
另一种方法是从根节点直接合成答案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
summary_template
|
Optional[BasePromptTemplate]
|
一个摘要提示
(参见 :ref: |
None
|
insert_prompt
|
Optional[BasePromptTemplate]
|
树形插入提示
(参见 :ref: |
None
|
num_children
|
int
|
每个节点应拥有的子节点数量。 |
10
|
build_tree
|
bool
|
是否在索引构建期间构建树。 |
True
|
show_progress
|
bool
|
是否显示进度条。默认为 False。 |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/tree/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 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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
向量存储索引 #
基类:EventBaseIndex[IndexDict]
向量存储索引。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
use_async
|
bool
|
是否使用异步调用。默认为 False。 |
False
|
show_progress
|
bool
|
是否显示tqdm进度条。默认为False。 |
False
|
store_nodes_override
|
bool
|
设置为True以始终在索引存储和文档存储中存储节点对象,即使向量存储保留文本。默认为False |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
build_index_from_nodes #
build_index_from_nodes(nodes: Sequence[BaseNode], **insert_kwargs: Any) -> IndexDict
从节点构建索引。
Overrides BaseIndex.build_index_from_nodes.
如果向量存储不存储文本,VectorStoreIndex 仅在文档存储中存储节点
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
ainsert_nodes
async
#
ainsert_nodes(nodes: Sequence[BaseNode], **insert_kwargs: Any) -> None
插入节点。
overrides BaseIndex.ainsert_nodes.
如果向量存储不存储文本,VectorStoreIndex 仅在文档存储中存储节点
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
insert_nodes #
insert_nodes(nodes: Sequence[BaseNode], **insert_kwargs: Any) -> None
插入节点。
overrides BaseIndex.insert_nodes.
如果向量存储不存储文本,VectorStoreIndex 仅在文档存储中存储节点
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 | |
adelete_nodes
async
#
adelete_nodes(node_ids: List[str], delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
从索引中删除节点列表。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
node_ids
|
List[str]
|
要删除的节点对应的节点ID列表 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
delete_nodes #
delete_nodes(node_ids: List[str], delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
从索引中删除节点列表。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
node_ids
|
List[str]
|
要删除的节点对应的节点ID列表 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
通过使用 ref_doc_id 删除文档及其节点。
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
424 425 426 427 428 429 430 431 432 | |
adelete_ref_doc
async
#
adelete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
通过使用 ref_doc_id 删除文档及其节点。
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/base.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
属性图索引 #
基类:EventBaseIndex[IndexLPG]
属性图的索引。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
nodes
|
Optional[Sequence[BaseNode]]
|
要插入索引的节点列表。 |
None
|
llm
|
Optional[大语言模型]
|
用于提取三元组的语言模型。默认为 |
None
|
kg_extractors
|
Optional[List[TransformComponent]]
|
应用于节点以提取三元组的转换列表。
默认为 |
None
|
property_graph_store
|
Optional[PropertyGraphStore]
|
要使用的属性图存储。如果未提供,将创建一个新的 |
None
|
vector_store
|
Optional[BasePydanticVectorStore]
|
如果图存储不支持向量查询,则使用的向量存储索引。 |
None
|
use_async
|
bool
|
是否对转换使用异步模式。默认为 |
True
|
embed_model
|
Optional[EmbedType]
|
用于嵌入节点的嵌入模型。
如果未提供,当 |
None
|
embed_kg_nodes
|
bool
|
是否嵌入知识图谱节点。默认为 |
True
|
callback_manager
|
Optional[CallbackManager]
|
要使用的回调管理器。 |
None
|
transformations
|
Optional[List[TransformComponent]]
|
在将节点插入索引之前应用的一系列转换。
这些转换在 |
None
|
storage_context
|
Optional[StorageContext]
|
要使用的存储上下文。 |
None
|
show_progress
|
bool
|
是否显示转换进度条。默认为 |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/base.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
from_existing
classmethod
#
from_existing(property_graph_store: PropertyGraphStore, vector_store: Optional[BasePydanticVectorStore] = None, llm: Optional[大语言模型] = None, kg_extractors: Optional[List[TransformComponent]] = None, use_async: bool = True, embed_model: Optional[EmbedType] = None, embed_kg_nodes: bool = True, callback_manager: Optional[CallbackManager] = None, transformations: Optional[List[TransformComponent]] = None, storage_context: Optional[StorageContext] = None, show_progress: bool = False, **kwargs: Any) -> PropertyGraphIndex
从现有的属性图存储(及可选的向量存储)创建索引。
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/base.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
as_retriever #
as_retriever(sub_retrievers: Optional[List[BasePGRetriever]] = None, include_text: bool = True, **kwargs: Any) -> BaseRetriever
返回索引的检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
sub_retrievers
|
Optional[List[BasePGRetriever]]
|
要使用的子检索器列表。如果未提供,将使用默认列表:如果图存储支持向量查询,则使用 |
None
|
include_text
|
bool
|
是否在检索器结果中包含源文本。 |
True
|
**kwargs
|
Any
|
传递给检索器的额外关键字参数。 |
{}
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/base.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
load_graph_from_storage #
load_graph_from_storage(storage_context: StorageContext, root_id: str, **kwargs: Any) -> ComposableGraph
从存储上下文中加载可组合图。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
storage_context
|
StorageContext
|
包含文档存储、索引存储和向量存储的存储上下文。 |
required |
root_id
|
str
|
图的根索引ID。 |
required |
**kwargs
|
Any
|
传递给索引构造函数的额外关键字参数。 |
{}
|
workflows/handler.py 中的源代码llama_index/core/indices/loading.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
load_index_from_storage #
load_index_from_storage(storage_context: StorageContext, index_id: Optional[str] = None, **kwargs: Any) -> BaseIndex
从存储上下文中加载索引。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
storage_context
|
StorageContext
|
包含文档存储、索引存储和向量存储的存储上下文。 |
required |
index_id
|
Optional[str]
|
要加载的索引ID。 默认为None,表示假设索引存储中只有一个索引并加载它。 |
None
|
**kwargs
|
Any
|
传递给索引构造函数的额外关键字参数。 |
{}
|
workflows/handler.py 中的源代码llama_index/core/indices/loading.py
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 | |
load_indices_from_storage #
load_indices_from_storage(storage_context: StorageContext, index_ids: Optional[Sequence[str]] = None, **kwargs: Any) -> List[BaseIndex]
从存储上下文中加载多个索引。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
storage_context
|
StorageContext
|
包含文档存储、索引存储和向量存储的存储上下文。 |
required |
index_id
|
Optional[Sequence[str]]
|
要加载的索引ID。 默认为None,表示加载索引存储中的所有索引。 |
required |
**kwargs
|
Any
|
传递给索引构造函数的额外关键字参数。 |
{}
|
workflows/handler.py 中的源代码llama_index/core/indices/loading.py
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 | |
选项: 成员:- VectorStoreIndex