Vespa
VespaVectorStore 永久链接
Vespa 向量存储。
可以通过以下几种方式初始化:1. (默认) 使用默认的混合模板和本地(Docker)部署来初始化 Vespa 向量存储。2. 通过提供在 pyvespa 中创建的应用包来初始化(可部署到本地或 Vespa 云)。3. 通过提供 URL 从先前部署的 Vespa 应用初始化。(本地或云部署)
应用必须设置以下字段:- id: 文档 ID - text: 文本字段 - embedding: 存储嵌入向量的字段。 - metadata: 元数据字段(所有元数据将存储在此处)
应用必须设置以下排序配置文件:- bm25: 用于文本搜索 - semantic: 用于语义搜索 - fusion: 用于语义混合搜索
从 VespaVectorStore 创建 VectorStoreIndex 时,索引将向 Vespa 应用添加文档。请注意,如果未在部署之间删除 Vespa 容器,则将重复使用容器,以避免数据重复。在查询时,索引会查询 Vespa 应用以获取排名靠前的 k 个最相关的结果。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
application_package
|
ApplicationPackage
|
应用包 |
hybrid_template
|
deployment_target
|
str
|
部署目标,可以是 |
'local'
|
port
|
int
|
Vespa 应用将运行的端口。仅在 deployment_target 是 |
8080
|
default_schema_name
|
str
|
Vespa 应用中的模式名称 |
'doc'
|
namespace
|
str
|
Vespa 应用中的命名空间。参见 https://docs.vespa.ai/en/documents.html#namespace。默认为 |
'default'
|
embeddings_outside_vespa
|
bool
|
嵌入是否在 Vespa 外部创建 |
False
|
url
|
Optional[str]
|
已部署 Vespa 应用的 URL |
无
|
groupname
|
Optional[str]
|
Vespa 应用中的组名,仅在 |
无
|
tenant
|
Optional[str]
|
Vespa 应用的租户。仅当 deployment_target 是 |
无
|
key_location
|
Optional[str]
|
用于签署到 Vespa Cloud 的 HTTP 请求的控制平面密钥位置 |
无
|
key_content
|
Optional[str]
|
用于签署到 Vespa Cloud 的 HTTP 请求的控制平面密钥内容。仅在密钥文件不可用时使用 |
无
|
auth_client_token_id
|
Optional[str]
|
使用基于令牌的数据平面认证。这是在 Vespa Cloud Console 中配置的令牌名称。用于配置 Vespa services.xml。该令牌具有读写权限。 |
无
|
kwargs
|
Any
|
Vespa 应用的其他 kwargs |
{}
|
示例
pip install llama-index-vector-stores-vespa
from llama_index.core import VectorStoreIndex
from llama_index.vector_stores.vespa import VespaVectorStore
vector_store = VespaVectorStore()
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex(nodes, storage_context=storage_context)
retriever = index.as_retriever()
retriever.retrieve("Who directed inception?")
源代码位于 llama-index-integrations/vector_stores/llama-index-vector-stores-vespa/llama_index/vector_stores/vespa/base.py
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 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
|
add 永久链接
add(nodes: List[BaseNode], schema: Optional[str] = None, callback: Optional[Callable[[VespaResponse, str], None]] = callback) -> List[str]
添加节点到向量存储
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nodes
|
List[BaseNode]
|
要添加的节点列表 |
必需 |
schema
|
Optional[str]
|
要添加节点的 Vespa 应用中的模式名称。默认为 |
无
|
源代码位于 llama-index-integrations/vector_stores/llama-index-vector-stores-vespa/llama_index/vector_stores/vespa/base.py
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 |
|
async_add async
永久链接
async_add(nodes: List[BaseNode], schema: Optional[str] = None, callback: Optional[Callable[[VespaResponse, str], None]] = callback, max_connections: int = 10, num_concurrent_requests: int = 1000, total_timeout: int = 60, **kwargs: Any) -> List[str]
异步添加节点到向量存储
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nodes
|
List[BaseNode]
|
要添加的节点列表 |
必需 |
schema
|
Optional[str]
|
要添加节点的 Vespa 应用中的模式名称。默认为 |
无
|
max_connections
|
int
|
与 Vespa 应用的最大连接数 |
10
|
num_concurrent_requests
|
int
|
最大并发请求数 |
1000
|
total_timeout
|
int
|
所有请求的总超时时间 |
60
|
kwargs
|
Any
|
Vespa 应用的其他 kwargs |
{}
|
源代码位于 llama-index-integrations/vector_stores/llama-index-vector-stores-vespa/llama_index/vector_stores/vespa/base.py
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 |
|
delete 永久链接
delete(ref_doc_id: str, namespace: Optional[str] = None, **delete_kwargs: Any) -> None
使用 ref_doc_id 删除节点
源代码位于 llama-index-integrations/vector_stores/llama-index-vector-stores-vespa/llama_index/vector_stores/vespa/base.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
adelete async
永久链接
adelete(ref_doc_id: str, namespace: Optional[str] = None, **delete_kwargs: Any) -> None
使用 ref_doc_id 删除节点。注意:并非所有向量存储都实现了此功能。如果未实现,则会同步调用 delete。
源代码位于 llama-index-integrations/vector_stores/llama-index-vector-stores-vespa/llama_index/vector_stores/vespa/base.py
351 352 353 354 355 356 357 358 359 360 361 362 363 |
|
query 永久链接
query(query: VectorStoreQuery, sources: Optional[List[str]] = None, rank_profile: Optional[str] = None, vector_top_k: int = 10, **kwargs: Any) -> VectorStoreQueryResult
查询向量存储
源代码位于 llama-index-integrations/vector_stores/llama-index-vector-stores-vespa/llama_index/vector_stores/vespa/base.py
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 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
|
aquery async
永久链接
aquery(query: VectorStoreQuery, sources: Optional[List[str]] = None, rank_profile: Optional[str] = None, vector_top_k: int = 10, **kwargs: Any) -> VectorStoreQueryResult
异步查询向量存储。注意:并非所有向量存储都实现了此功能。如果未实现,则会同步调用 query。
源代码位于 llama-index-integrations/vector_stores/llama-index-vector-stores-vespa/llama_index/vector_stores/vespa/base.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
|