# Vectara RAG Pack
This LlamaPack provides an end-to-end Retrieval Augmented Generation flow using Vectara.
Before you start, if you have not done so already, you would need to follow these steps:
- Create a [free Vectara account](https://vectara.com/integrations/llamaindex).
- Create a [corpus](https://docs.vectara.com/docs/console-ui/creating-a-corpus) to store your data
- Create an [API key](https://docs.vectara.com/docs/common-use-cases/app-authn-authz/api-keys) with QueryService and IndexService access so you can access this corpus
You can configure your `.env` file or provide these arguments directly when creating your VectaraIndex:
```
VECTARA_CUSTOMER_ID=your_customer_id
VECTARA_CORPUS_ID=your_corpus_id
VECTARA_API_KEY=your-vectara-api-key
```
## CLI Usage
You can download the Vectara llamapack directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:
```bash
llamaindex-cli download-llamapack VectaraRagPack --download-dir ./vectara_rag_pack
```
Feel free to inspect the files at `./vectara_rag_pack` and use them as a template for your own project!
## Code Usage
You can download the pack to a `./vectara_rag_pack` directory:
```python
from llama_index.core.llama_pack import download_llama_pack
VectaraRAG = download_llama_pack("VectaraRagPack", "./vectara_rag_pack")
```
Then, you can set up the pack in two ways:
1. If you want to ingest documents into the Vectara Corpus:
```python
nodes = [...]
vectara = VectaraRAG(nodes=nodes)
```
2. If you already indexed data on Vectara, and just want to use the retrieval/query functionality:
```python
vectara = VectaraRAG()
```
Additional optional arguments to VectaraRAG:
- `similarity_top_k`: determines the number of results to return. Defaults to 5.
- `n_sentences_before` and `n_sentences_after`: determine the number of sentences before/after the
matching fact to use with the summarization LLM. defaults to 2.
- `vectara_query_mode`: 'default' or 'mmr'
- `summary_enabled`: whether to generate summaries or not. Defaults to True.
- When summary_enabled is True, you can set the following:
- `summary_response_lang`: language to use (ISO 639-2 code) for summary generation. defaults to "eng".
- `summary_num_results`: number of results to use for summary generation. Defaults to 7.
- `summary_prompt_name`: name of the prompt to use for summary generation.
Defaults to 'vectara-summary-ext-v1.2.0'.
Scale customers can use 'vectara-summary-ext-v1.3.0
- when `vectara_query_mode` is "mmr", you can set the following to control MMR:
- `mmr_k`: number of results to fetch for MMR, defaults to 50
- `mmr_diversity_bias`: 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.
For example to use maximal diversity with MMR:
```python
vectara = VectaraRAG(
vectara_query_mode="mmr", mmr_k=50, mmr_diversity_bias=1.0
)
```
Or if you want to include more results in the Vectara generated summarization you can try:
```python
vectara = VectaraRAG(summary_num_results=12)
```
Once you have the Vectara RAG object, you can now use it as a retriever:
```python
# use the retriever
nodes = vectara.retrieve("Is light a wave or a particle?")
```
Or as a query engine (with Vectara summarization call):
```python
# use the query engine
response = vectara._query_engine.query(
"Is light a wave or a particle?"
).response
```
Note that the `run()` function is a light wrapper around `query_engine.query()`.
```python
response = vectara.run("Is light a wave or a particle?").response
```
Enjoy your Vectara RAG pack!
Raw data
{
"_id": null,
"home_page": "",
"name": "llama-index-packs-vectara-rag",
"maintainer": "ofermend",
"docs_url": null,
"requires_python": ">=3.8.1,<4.0",
"maintainer_email": "",
"keywords": "embeddings,rag,retrieval,vectara",
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/fd/7b/66a5122da72213ab135a823c3706f7a4c1ff0bef930ceb5176b60ec5fbab/llama_index_packs_vectara_rag-0.1.3.tar.gz",
"platform": null,
"description": "# Vectara RAG Pack\n\nThis LlamaPack provides an end-to-end Retrieval Augmented Generation flow using Vectara.\n\nBefore you start, if you have not done so already, you would need to follow these steps:\n\n- Create a [free Vectara account](https://vectara.com/integrations/llamaindex).\n- Create a [corpus](https://docs.vectara.com/docs/console-ui/creating-a-corpus) to store your data\n- Create an [API key](https://docs.vectara.com/docs/common-use-cases/app-authn-authz/api-keys) with QueryService and IndexService access so you can access this corpus\n\nYou can configure your `.env` file or provide these arguments directly when creating your VectaraIndex:\n\n```\nVECTARA_CUSTOMER_ID=your_customer_id\nVECTARA_CORPUS_ID=your_corpus_id\nVECTARA_API_KEY=your-vectara-api-key\n```\n\n## CLI Usage\n\nYou can download the Vectara llamapack directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:\n\n```bash\nllamaindex-cli download-llamapack VectaraRagPack --download-dir ./vectara_rag_pack\n```\n\nFeel free to inspect the files at `./vectara_rag_pack` and use them as a template for your own project!\n\n## Code Usage\n\nYou can download the pack to a `./vectara_rag_pack` directory:\n\n```python\nfrom llama_index.core.llama_pack import download_llama_pack\n\nVectaraRAG = download_llama_pack(\"VectaraRagPack\", \"./vectara_rag_pack\")\n```\n\nThen, you can set up the pack in two ways:\n\n1. If you want to ingest documents into the Vectara Corpus:\n\n```python\nnodes = [...]\nvectara = VectaraRAG(nodes=nodes)\n```\n\n2. If you already indexed data on Vectara, and just want to use the retrieval/query functionality:\n\n```python\nvectara = VectaraRAG()\n```\n\nAdditional optional arguments to VectaraRAG:\n\n- `similarity_top_k`: determines the number of results to return. Defaults to 5.\n- `n_sentences_before` and `n_sentences_after`: determine the number of sentences before/after the\n matching fact to use with the summarization LLM. defaults to 2.\n- `vectara_query_mode`: 'default' or 'mmr'\n- `summary_enabled`: whether to generate summaries or not. Defaults to True.\n- When summary_enabled is True, you can set the following:\n - `summary_response_lang`: language to use (ISO 639-2 code) for summary generation. defaults to \"eng\".\n - `summary_num_results`: number of results to use for summary generation. Defaults to 7.\n - `summary_prompt_name`: name of the prompt to use for summary generation.\n Defaults to 'vectara-summary-ext-v1.2.0'.\n Scale customers can use 'vectara-summary-ext-v1.3.0\n- when `vectara_query_mode` is \"mmr\", you can set the following to control MMR:\n - `mmr_k`: number of results to fetch for MMR, defaults to 50\n - `mmr_diversity_bias`: number between 0 and 1 that determines the degree\n of diversity among the results with 0 corresponding\n to minimum diversity and 1 to maximum diversity. Defaults to 0.3.\n\nFor example to use maximal diversity with MMR:\n\n```python\nvectara = VectaraRAG(\n vectara_query_mode=\"mmr\", mmr_k=50, mmr_diversity_bias=1.0\n)\n```\n\nOr if you want to include more results in the Vectara generated summarization you can try:\n\n```python\nvectara = VectaraRAG(summary_num_results=12)\n```\n\nOnce you have the Vectara RAG object, you can now use it as a retriever:\n\n```python\n# use the retriever\nnodes = vectara.retrieve(\"Is light a wave or a particle?\")\n```\n\nOr as a query engine (with Vectara summarization call):\n\n```python\n# use the query engine\nresponse = vectara._query_engine.query(\n \"Is light a wave or a particle?\"\n).response\n```\n\nNote that the `run()` function is a light wrapper around `query_engine.query()`.\n\n```python\nresponse = vectara.run(\"Is light a wave or a particle?\").response\n```\n\nEnjoy your Vectara RAG pack!\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index packs vectara_rag integration",
"version": "0.1.3",
"project_urls": null,
"split_keywords": [
"embeddings",
"rag",
"retrieval",
"vectara"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "74387603bf0d25044843d8d8d4b4d8df2fb03d7a5cd69cbb7303c91ed1f9479d",
"md5": "731c687c14e5efa3dc6c64c6e22ef21b",
"sha256": "24b66591f4e54d477900dfa5fce553a2bca7e5a305a358620fc4d3b632c03271"
},
"downloads": -1,
"filename": "llama_index_packs_vectara_rag-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "731c687c14e5efa3dc6c64c6e22ef21b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<4.0",
"size": 3584,
"upload_time": "2024-02-22T01:45:50",
"upload_time_iso_8601": "2024-02-22T01:45:50.850350Z",
"url": "https://files.pythonhosted.org/packages/74/38/7603bf0d25044843d8d8d4b4d8df2fb03d7a5cd69cbb7303c91ed1f9479d/llama_index_packs_vectara_rag-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fd7b66a5122da72213ab135a823c3706f7a4c1ff0bef930ceb5176b60ec5fbab",
"md5": "cf80b2ee6e83cf740891f6a7c9cc0ef8",
"sha256": "184a565ddaeac3699a6455a76db9d79f90c2bacc11ad7ef349c54fb9dc5e6eb9"
},
"downloads": -1,
"filename": "llama_index_packs_vectara_rag-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "cf80b2ee6e83cf740891f6a7c9cc0ef8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<4.0",
"size": 3370,
"upload_time": "2024-02-22T01:45:51",
"upload_time_iso_8601": "2024-02-22T01:45:51.872891Z",
"url": "https://files.pythonhosted.org/packages/fd/7b/66a5122da72213ab135a823c3706f7a4c1ff0bef930ceb5176b60ec5fbab/llama_index_packs_vectara_rag-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-22 01:45:51",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-packs-vectara-rag"
}