Vectara
VectaraIndex #
Bases: BaseManagedIndex
Vectara Index.
The Vectara index implements a managed index that uses Vectara as the backend. Vectara performs a lot of the functions in traditional indexes in the backend: - breaks down a document into chunks (nodes) - Creates the embedding for each chunk (node) - Performs the search for the top k most similar nodes to a query - Optionally can perform summarization of the top k nodes
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_progress
|
bool
|
Whether to show tqdm progress bars. Defaults to False. |
False
|
Source code in llama_index/indices/managed/vectara/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 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 | |
add_document #
add_document(doc: Document, corpus_key: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, max_chars_per_chunk: Optional[int] = None) -> None
Indexes a document into a corpus using the Vectara Structured Document format.
Full API Docs: https://docs.vectara.com/docs/api-reference/indexing-apis/indexing#structured-document-object-definition
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
The document object to be indexed. You should provide the value you want for the document id in the corpus as the id_ member of this object. You should provide any document_metadata in the metadata member of this object. |
required |
corpus_key
|
str
|
If multiple corpora are provided for this index, the corpus_key of the corpus you want to add the document to. |
None
|
title
|
str
|
The title of the document. |
None
|
description
|
str
|
The description of the document. |
None
|
max_chars_per_chunk
|
int
|
The maximum number of characters per chunk. |
None
|
Source code in llama_index/indices/managed/vectara/base.py
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 | |
add_nodes #
add_nodes(nodes: Sequence[Node], document_id: str, document_metadata: Optional[Dict] = {}, corpus_key: Optional[str] = None) -> None
Indexes a document into a corpus using the Vectara Core Document format.
Full API Docs: https://docs.vectara.com/docs/api-reference/indexing-apis/indexing#core-document-object-definition
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
Sequence[Node]
|
The user-specified document parts. You should provide any part_metadata in the metadata member of each node. |
required |
document_id
|
str
|
The document id (must be unique for the corpus). |
required |
document_metadata
|
Dict
|
The document_metadata to be associated with this document. |
{}
|
corpus_key
|
str
|
If multiple corpora are provided for this index, the corpus_key of the corpus you want to add the document to. |
None
|
Source code in llama_index/indices/managed/vectara/base.py
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 | |
insert_file #
insert_file(file_path: str, metadata: Optional[dict] = None, chunking_strategy: Optional[dict] = None, enable_table_extraction: Optional[bool] = False, filename: Optional[str] = None, corpus_key: Optional[str] = None, **insert_kwargs: Any) -> Optional[str]
Vectara provides a way to add files (binary or text) directly via our API where pre-processing and chunking occurs internally in an optimal way This method provides a way to use that API in Llama_index.
ruff: noqa: E501#
Full API Docs: https://docs.vectara.com/docs/rest-api/upload-file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
local file path Files could be text, HTML, PDF, markdown, doc/docx, ppt/pptx, etc. see API docs for full list |
required |
metadata
|
Optional[dict]
|
Optional dict of metadata associated with the file |
None
|
chunking_strategy
|
Optional[dict]
|
Optional dict specifying max number of characters per chunk |
None
|
enable_table_extraction
|
Optional[bool]
|
Optional bool specifying whether or not to extract tables from document |
False
|
filename
|
Optional[str]
|
Optional string specifying the filename |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
List of ids associated with each of the files indexed |
Source code in llama_index/indices/managed/vectara/base.py
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 | |
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = True, **delete_kwargs: Any) -> None
Delete a document from a Vectara corpus.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_doc_id
|
str
|
ID of the document to delete |
required |
delete_from_docstore
|
bool
|
Whether to delete the document from the corpus. If False, no change is made to the index or corpus. |
True
|
corpus_key
|
str
|
corpus key to delete the document from. This should be specified if there are multiple corpora in the index. |
required |
Source code in llama_index/indices/managed/vectara/base.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
update_ref_doc #
update_ref_doc(document: Document, **update_kwargs: Any) -> None
Update a document's metadata in a Vectara corpus.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
document
|
Document
|
The document to update. Make sure to include id_ argument for proper identification within the corpus. |
required |
corpus_key
|
str
|
corpus key to modify the document from. This should be specified if there are multiple corpora in the index. |
required |
metadata
|
dict
|
dictionary specifying any modifications or additions to the document's metadata. |
required |
Source code in llama_index/indices/managed/vectara/base.py
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 | |
as_retriever #
as_retriever(**kwargs: Any) -> BaseRetriever
Return a Retriever for this managed index.
Source code in llama_index/indices/managed/vectara/base.py
461 462 463 464 465 466 467 | |
from_documents
classmethod
#
from_documents(documents: Sequence[Document], show_progress: bool = False, callback_manager: Optional[CallbackManager] = None, transformations: Optional[List[TransformComponent]] = None, **kwargs: Any) -> IndexType
Build a Vectara index from a sequence of documents.
Source code in llama_index/indices/managed/vectara/base.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
VectaraAutoRetriever #
Bases: VectorIndexAutoRetriever
Managed Index auto retriever.
A retriever for a Vectara index that uses an LLM to automatically set filtering query parameters. Based on VectorStoreAutoRetriever, and uses some of the vector_store types that are associated with auto retrieval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
VectaraIndex
|
Vectara Index instance |
required |
vector_store_info
|
VectorStoreInfo
|
additional information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters. |
required |
Source code in llama_index/indices/managed/vectara/retriever.py
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
VectaraRetriever #
Bases: BaseRetriever
Vectara Retriever.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
VectaraIndex
|
the Vectara Index |
required |
similarity_top_k
|
int
|
number of top k results to return, defaults to 5. |
10
|
offset
|
int
|
number of results to skip, defaults to 0. |
0
|
lambda_val
|
Union[List[float], float]
|
for hybrid search. 0 = neural search only. 1 = keyword match only. In between values are a linear interpolation. Provide single value for one corpus or a list of values for each corpus. |
0.005
|
semantics
|
Union[List[str], str]
|
Indicates whether the query is intended as a query or response. Provide single value for one corpus or a list of values for each corpus. |
'default'
|
custom_dimensions
|
Dict
|
Custom dimensions for the query. See (https://docs.vectara.com/docs/learn/semantic-search/add-custom-dimensions) for more details about usage. Provide single dict for one corpus or a list of dicts for each corpus. |
{}
|
n_sentences_before
|
int
|
number of sentences before the matched sentence to return in the node |
2
|
n_sentences_after
|
int
|
number of sentences after the matched sentence to return in the node |
2
|
filter
|
Union[List[str], str]
|
metadata filter (if specified). Provide single string for one corpus or a list of strings to specify the filter for each corpus (if multiple corpora). |
''
|
reranker
|
str
|
reranker to use: none, mmr, slingshot/multilingual_reranker_v1, userfn, or chain. |
NONE
|
rerank_k
|
int
|
number of results to fetch for Reranking, defaults to 50. |
50
|
rerank_limit
|
int
|
maximum number of results to return after reranking, defaults to 50. Don't specify this for chain reranking. Instead, put the "limit" parameter in the dict for each individual reranker. |
None
|
rerank_cutoff
|
float
|
minimum score threshold for results to include after reranking, defaults to 0. Don't specify this for chain reranking. Instead, put the "chain" parameter in the dict for each individual reranker. |
None
|
mmr_diversity_bias
|
float
|
number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to minimum diversity and 1 to maximum diversity. Defaults to 0.3. |
0.3
|
udf_expression
|
str
|
the user defined expression for reranking results. See (https://docs.vectara.com/docs/learn/user-defined-function-reranker) for more details about syntax for udf reranker expressions. |
None
|
rerank_chain
|
List[Dict]
|
a list of rerankers to be applied in a sequence and their associated parameters for the chain reranker. Each element should specify the "type" of reranker (mmr, slingshot, userfn) and any other parameters (e.g. "limit" or "cutoff" for any type, "diversity_bias" for mmr, and "user_function" for userfn). If using slingshot/multilingual_reranker_v1, it must be first in the list. |
None
|
summary_enabled
|
bool
|
whether to generate summaries or not. Defaults to False. |
False
|
summary_response_lang
|
str
|
language to use for summary generation. |
'eng'
|
summary_num_results
|
int
|
number of results to use for summary generation. |
7
|
summary_prompt_name
|
str
|
name of the prompt to use for summary generation. To use Vectara's Mockingbird LLM designed specifically for RAG, set to "mockingbird-1.0-2024-07-16". If you are indexing documents with tables, we recommend "vectara-summary-table-query-ext-dec-2024-gpt-4o". See (https://docs.vectara.com/docs/learn/grounded-generation/select-a-summarizer) for all available prompts. |
'vectara-summary-ext-24-05-med-omni'
|
prompt_text
|
str
|
the custom prompt, using appropriate prompt variables and functions. See (https://docs.vectara.com/docs/1.0/prompts/custom-prompts-with-metadata) for more details. |
None
|
max_response_chars
|
int
|
the desired maximum number of characters for the generated summary. |
None
|
max_tokens
|
int
|
the maximum number of tokens to be returned by the LLM. |
None
|
temperature
|
float
|
The sampling temperature; higher values lead to more randomness. |
None
|
frequency_penalty
|
float
|
How much to penalize repeating tokens in the response, reducing likelihood of repeating the same line. |
None
|
presence_penalty
|
float
|
How much to penalize repeating tokens in the response, increasing the diversity of topics. |
None
|
citations_style
|
str
|
The style of the citations in the summary generation, either "numeric", "html", "markdown", or "none". Defaults to None. |
None
|
citations_url_pattern
|
str
|
URL pattern for html and markdown citations. If non-empty, specifies the URL pattern to use for citations; e.g. "{doc.url}". See (https://docs.vectara.com/docs/api-reference/search-apis/search #citation-format-in-summary) for more details. Defaults to None. |
None
|
citations_text_pattern
|
str
|
The displayed text for citations. If not specified, numeric citations are displayed for text. |
None
|
save_history
|
bool
|
Whether to save the query in history. Defaults to False. |
False
|
Source code in llama_index/indices/managed/vectara/retriever.py
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 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 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | |
VectaraQueryEngine #
Bases: BaseQueryEngine
Retriever query engine for Vectara.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retriever
|
VectaraRetriever
|
A retriever object. |
required |
streaming
|
bool
|
whether to use streaming mode. |
False
|
summary_response_lang
|
str
|
response language for summary (ISO 639-2 code) |
'eng'
|
summary_num_results
|
int
|
number of results to use for summary generation. |
5
|
summary_prompt_name
|
str
|
name of the prompt to use for summary generation. |
'vectara-summary-ext-24-05-med-omni'
|
Source code in llama_index/indices/managed/vectara/query.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
from_args
classmethod
#
from_args(retriever: VectaraRetriever, streaming: bool = False, summary_enabled: bool = False, **kwargs: Any) -> VectaraQueryEngine
Initialize a VectaraQueryEngine object.".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retriever
|
VectaraRetriever
|
A Vectara retriever object. |
required |
summary_enabled
|
bool
|
is summary enabled |
False
|
Source code in llama_index/indices/managed/vectara/query.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
options: members: - VectaraIndex