mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-05 12:48:12 +00:00
community: update Vectara integration (#27869)
Thank you for contributing to LangChain! - **Description:** Updated Vectara integration - **Issue:** refresh on descriptions across all demos and added UDF reranker - **Dependencies:** None - **Twitter handle:** @ofermend --------- Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
parent
14a71a6e77
commit
d7c39e6dbb
@ -4,15 +4,14 @@
|
|||||||
> which is grounded in the data, documents, and knowledge that they have (technically, it is Retrieval-Augmented-Generation-as-a-service).
|
> which is grounded in the data, documents, and knowledge that they have (technically, it is Retrieval-Augmented-Generation-as-a-service).
|
||||||
|
|
||||||
**Vectara Overview:**
|
**Vectara Overview:**
|
||||||
`Vectara` is RAG-as-a-service, providing all the components of RAG behind an easy-to-use API, including:
|
[Vectara](https://vectara.com/) is the trusted AI Assistant and Agent platform which focuses on enterprise readiness for mission-critical applications.
|
||||||
|
Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:
|
||||||
1. A way to extract text from files (PDF, PPT, DOCX, etc)
|
1. A way to extract text from files (PDF, PPT, DOCX, etc)
|
||||||
2. ML-based chunking that provides state of the art performance.
|
2. ML-based chunking that provides state of the art performance.
|
||||||
3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.
|
3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.
|
||||||
4. Its own internal vector database where text chunks and embedding vectors are stored.
|
4. Its own internal vector database where text chunks and embedding vectors are stored.
|
||||||
5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments
|
5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments, including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) as well as multiple reranking options such as the [multi-lingual relevance reranker](https://www.vectara.com/blog/deep-dive-into-vectara-multilingual-reranker-v1-state-of-the-art-reranker-across-100-languages), [MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/), [UDF reranker](https://www.vectara.com/blog/rag-with-user-defined-functions-based-reranking).
|
||||||
(including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) and
|
6. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.
|
||||||
[MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/))
|
|
||||||
7. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.
|
|
||||||
|
|
||||||
For more information:
|
For more information:
|
||||||
- [Documentation](https://docs.vectara.com/docs/)
|
- [Documentation](https://docs.vectara.com/docs/)
|
||||||
@ -22,7 +21,7 @@ For more information:
|
|||||||
## Installation and Setup
|
## Installation and Setup
|
||||||
|
|
||||||
To use `Vectara` with LangChain no special installation steps are required.
|
To use `Vectara` with LangChain no special installation steps are required.
|
||||||
To get started, [sign up](https://vectara.com/integrations/langchain) for a free Vectara account (if you don't already have one),
|
To get started, [sign up](https://vectara.com/integrations/langchain) for a free Vectara trial,
|
||||||
and follow the [quickstart](https://docs.vectara.com/docs/quickstart) guide to create a corpus and an API key.
|
and follow the [quickstart](https://docs.vectara.com/docs/quickstart) guide to create a corpus and an API key.
|
||||||
Once you have these, you can provide them as arguments to the Vectara `vectorstore`, or you can set them as environment variables.
|
Once you have these, you can provide them as arguments to the Vectara `vectorstore`, or you can set them as environment variables.
|
||||||
|
|
||||||
|
@ -7,19 +7,19 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"# Vectara Chat\n",
|
"# Vectara Chat\n",
|
||||||
"\n",
|
"\n",
|
||||||
"[Vectara](https://vectara.com/) provides a Trusted Generative AI platform, allowing organizations to rapidly create a ChatGPT-like experience (an AI assistant) which is grounded in the data, documents, and knowledge that they have (technically, it is Retrieval-Augmented-Generation-as-a-service). \n",
|
"[Vectara](https://vectara.com/) is the trusted AI Assistant and Agent platform which focuses on enterprise readiness for mission-critical applications.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:\n",
|
"Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:\n",
|
||||||
"1. A way to extract text from files (PDF, PPT, DOCX, etc)\n",
|
"1. A way to extract text from files (PDF, PPT, DOCX, etc)\n",
|
||||||
"2. ML-based chunking that provides state of the art performance.\n",
|
"2. ML-based chunking that provides state of the art performance.\n",
|
||||||
"3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.\n",
|
"3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.\n",
|
||||||
"4. Its own internal vector database where text chunks and embedding vectors are stored.\n",
|
"4. Its own internal vector database where text chunks and embedding vectors are stored.\n",
|
||||||
"5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments (including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) and [MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/))\n",
|
"5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments (including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) as well as multiple reranking options such as the [multi-lingual relevance reranker](https://www.vectara.com/blog/deep-dive-into-vectara-multilingual-reranker-v1-state-of-the-art-reranker-across-100-languages), [MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/), [UDF reranker](https://www.vectara.com/blog/rag-with-user-defined-functions-based-reranking). \n",
|
||||||
"7. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.\n",
|
"6. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"See the [Vectara API documentation](https://docs.vectara.com/docs/) for more information on how to use the API.\n",
|
"See the [Vectara API documentation](https://docs.vectara.com/docs/) for more information on how to use the API.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"This notebook shows how to use Vectara's [Chat](https://docs.vectara.com/docs/api-reference/chat-apis/chat-apis-overview) functionality."
|
"This notebook shows how to use Vectara's [Chat](https://docs.vectara.com/docs/api-reference/chat-apis/chat-apis-overview) functionality, which provides automatic storage of conversation history and ensures follow up questions consider that history."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@
|
|||||||
"# Getting Started\n",
|
"# Getting Started\n",
|
||||||
"\n",
|
"\n",
|
||||||
"To get started, use the following steps:\n",
|
"To get started, use the following steps:\n",
|
||||||
"1. If you don't already have one, [Sign up](https://www.vectara.com/integrations/langchain) for your free Vectara account. Once you have completed your sign up you will have a Vectara customer ID. You can find your customer ID by clicking on your name, on the top-right of the Vectara console window.\n",
|
"1. If you don't already have one, [Sign up](https://www.vectara.com/integrations/langchain) for your free Vectara trial. Once you have completed your sign up you will have a Vectara customer ID. You can find your customer ID by clicking on your name, on the top-right of the Vectara console window.\n",
|
||||||
"2. Within your account you can create one or more corpora. Each corpus represents an area that stores text data upon ingest from input documents. To create a corpus, use the **\"Create Corpus\"** button. You then provide a name to your corpus as well as a description. Optionally you can define filtering attributes and apply some advanced options. If you click on your created corpus, you can see its name and corpus ID right on the top.\n",
|
"2. Within your account you can create one or more corpora. Each corpus represents an area that stores text data upon ingest from input documents. To create a corpus, use the **\"Create Corpus\"** button. You then provide a name to your corpus as well as a description. Optionally you can define filtering attributes and apply some advanced options. If you click on your created corpus, you can see its name and corpus ID right on the top.\n",
|
||||||
"3. Next you'll need to create API keys to access the corpus. Click on the **\"Access Control\"** tab in the corpus view and then the **\"Create API Key\"** button. Give your key a name, and choose whether you want query-only or query+index for your key. Click \"Create\" and you now have an active API key. Keep this key confidential. \n",
|
"3. Next you'll need to create API keys to access the corpus. Click on the **\"Access Control\"** tab in the corpus view and then the **\"Create API Key\"** button. Give your key a name, and choose whether you want query-only or query+index for your key. Click \"Create\" and you now have an active API key. Keep this key confidential. \n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -7,15 +7,15 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"# Vectara self-querying \n",
|
"# Vectara self-querying \n",
|
||||||
"\n",
|
"\n",
|
||||||
"[Vectara](https://vectara.com/) provides a Trusted Generative AI platform, allowing organizations to rapidly create a ChatGPT-like experience (an AI assistant) which is grounded in the data, documents, and knowledge that they have (technically, it is Retrieval-Augmented-Generation-as-a-service). \n",
|
"[Vectara](https://vectara.com/) is the trusted AI Assistant and Agent platform which focuses on enterprise readiness for mission-critical applications.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:\n",
|
"Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:\n",
|
||||||
"1. A way to extract text from files (PDF, PPT, DOCX, etc)\n",
|
"1. A way to extract text from files (PDF, PPT, DOCX, etc)\n",
|
||||||
"2. ML-based chunking that provides state of the art performance.\n",
|
"2. ML-based chunking that provides state of the art performance.\n",
|
||||||
"3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.\n",
|
"3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.\n",
|
||||||
"4. Its own internal vector database where text chunks and embedding vectors are stored.\n",
|
"4. Its own internal vector database where text chunks and embedding vectors are stored.\n",
|
||||||
"5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments (including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) and [MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/))\n",
|
"5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments, including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) as well as multiple reranking options such as the [multi-lingual relevance reranker](https://www.vectara.com/blog/deep-dive-into-vectara-multilingual-reranker-v1-state-of-the-art-reranker-across-100-languages), [MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/), [UDF reranker](https://www.vectara.com/blog/rag-with-user-defined-functions-based-reranking). \n",
|
||||||
"7. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.\n",
|
"6. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"See the [Vectara API documentation](https://docs.vectara.com/docs/) for more information on how to use the API.\n",
|
"See the [Vectara API documentation](https://docs.vectara.com/docs/) for more information on how to use the API.\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -30,7 +30,7 @@
|
|||||||
"# Getting Started\n",
|
"# Getting Started\n",
|
||||||
"\n",
|
"\n",
|
||||||
"To get started, use the following steps:\n",
|
"To get started, use the following steps:\n",
|
||||||
"1. If you don't already have one, [Sign up](https://www.vectara.com/integrations/langchain) for your free Vectara account. Once you have completed your sign up you will have a Vectara customer ID. You can find your customer ID by clicking on your name, on the top-right of the Vectara console window.\n",
|
"1. If you don't already have one, [Sign up](https://www.vectara.com/integrations/langchain) for your free Vectara trial. Once you have completed your sign up you will have a Vectara customer ID. You can find your customer ID by clicking on your name, on the top-right of the Vectara console window.\n",
|
||||||
"2. Within your account you can create one or more corpora. Each corpus represents an area that stores text data upon ingest from input documents. To create a corpus, use the **\"Create Corpus\"** button. You then provide a name to your corpus as well as a description. Optionally you can define filtering attributes and apply some advanced options. If you click on your created corpus, you can see its name and corpus ID right on the top.\n",
|
"2. Within your account you can create one or more corpora. Each corpus represents an area that stores text data upon ingest from input documents. To create a corpus, use the **\"Create Corpus\"** button. You then provide a name to your corpus as well as a description. Optionally you can define filtering attributes and apply some advanced options. If you click on your created corpus, you can see its name and corpus ID right on the top.\n",
|
||||||
"3. Next you'll need to create API keys to access the corpus. Click on the **\"Access Control\"** tab in the corpus view and then the **\"Create API Key\"** button. Give your key a name, and choose whether you want query-only or query+index for your key. Click \"Create\" and you now have an active API key. Keep this key confidential. \n",
|
"3. Next you'll need to create API keys to access the corpus. Click on the **\"Access Control\"** tab in the corpus view and then the **\"Create API Key\"** button. Give your key a name, and choose whether you want query-only or query+index for your key. Click \"Create\" and you now have an active API key. Keep this key confidential. \n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -7,15 +7,15 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"# Vectara\n",
|
"# Vectara\n",
|
||||||
"\n",
|
"\n",
|
||||||
"[Vectara](https://vectara.com/) provides a Trusted Generative AI platform, allowing organizations to rapidly create a ChatGPT-like experience (an AI assistant) which is grounded in the data, documents, and knowledge that they have (technically, it is Retrieval-Augmented-Generation-as-a-service). \n",
|
"[Vectara](https://vectara.com/) is the trusted AI Assistant and Agent platform which focuses on enterprise readiness for mission-critical applications.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:\n",
|
"Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:\n",
|
||||||
"1. A way to extract text from files (PDF, PPT, DOCX, etc)\n",
|
"1. A way to extract text from files (PDF, PPT, DOCX, etc)\n",
|
||||||
"2. ML-based chunking that provides state of the art performance.\n",
|
"2. ML-based chunking that provides state of the art performance.\n",
|
||||||
"3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.\n",
|
"3. The [Boomerang](https://vectara.com/how-boomerang-takes-retrieval-augmented-generation-to-the-next-level-via-grounded-generation/) embeddings model.\n",
|
||||||
"4. Its own internal vector database where text chunks and embedding vectors are stored.\n",
|
"4. Its own internal vector database where text chunks and embedding vectors are stored.\n",
|
||||||
"5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments (including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) and [MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/))\n",
|
"5. A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments (including support for [Hybrid Search](https://docs.vectara.com/docs/api-reference/search-apis/lexical-matching) as well as multiple reranking options such as the [multi-lingual relevance reranker](https://www.vectara.com/blog/deep-dive-into-vectara-multilingual-reranker-v1-state-of-the-art-reranker-across-100-languages), [MMR](https://vectara.com/get-diverse-results-and-comprehensive-summaries-with-vectaras-mmr-reranker/), [UDF reranker](https://www.vectara.com/blog/rag-with-user-defined-functions-based-reranking). \n",
|
||||||
"7. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.\n",
|
"6. An LLM to for creating a [generative summary](https://docs.vectara.com/docs/learn/grounded-generation/grounded-generation-overview), based on the retrieved documents (context), including citations.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"See the [Vectara API documentation](https://docs.vectara.com/docs/) for more information on how to use the API.\n",
|
"See the [Vectara API documentation](https://docs.vectara.com/docs/) for more information on how to use the API.\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -32,7 +32,7 @@
|
|||||||
"# Getting Started\n",
|
"# Getting Started\n",
|
||||||
"\n",
|
"\n",
|
||||||
"To get started, use the following steps:\n",
|
"To get started, use the following steps:\n",
|
||||||
"1. If you don't already have one, [Sign up](https://www.vectara.com/integrations/langchain) for your free Vectara account. Once you have completed your sign up you will have a Vectara customer ID. You can find your customer ID by clicking on your name, on the top-right of the Vectara console window.\n",
|
"1. If you don't already have one, [Sign up](https://www.vectara.com/integrations/langchain) for your free Vectara trial. Once you have completed your sign up you will have a Vectara customer ID. You can find your customer ID by clicking on your name, on the top-right of the Vectara console window.\n",
|
||||||
"2. Within your account you can create one or more corpora. Each corpus represents an area that stores text data upon ingest from input documents. To create a corpus, use the **\"Create Corpus\"** button. You then provide a name to your corpus as well as a description. Optionally you can define filtering attributes and apply some advanced options. If you click on your created corpus, you can see its name and corpus ID right on the top.\n",
|
"2. Within your account you can create one or more corpora. Each corpus represents an area that stores text data upon ingest from input documents. To create a corpus, use the **\"Create Corpus\"** button. You then provide a name to your corpus as well as a description. Optionally you can define filtering attributes and apply some advanced options. If you click on your created corpus, you can see its name and corpus ID right on the top.\n",
|
||||||
"3. Next you'll need to create API keys to access the corpus. Click on the **\"Access Control\"** tab in the corpus view and then the **\"Create API Key\"** button. Give your key a name, and choose whether you want query-only or query+index for your key. Click \"Create\" and you now have an active API key. Keep this key confidential. \n",
|
"3. Next you'll need to create API keys to access the corpus. Click on the **\"Access Control\"** tab in the corpus view and then the **\"Create API Key\"** button. Give your key a name, and choose whether you want query-only or query+index for your key. Click \"Create\" and you now have an active API key. Keep this key confidential. \n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -22,6 +22,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
MMR_RERANKER_ID = 272725718
|
MMR_RERANKER_ID = 272725718
|
||||||
RERANKER_MULTILINGUAL_V1_ID = 272725719
|
RERANKER_MULTILINGUAL_V1_ID = 272725719
|
||||||
|
UDF_RERANKER_ID = 272725722
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -38,7 +39,7 @@ class SummaryConfig:
|
|||||||
is_enabled: bool = False
|
is_enabled: bool = False
|
||||||
max_results: int = 7
|
max_results: int = 7
|
||||||
response_lang: str = "eng"
|
response_lang: str = "eng"
|
||||||
prompt_name: str = "vectara-summary-ext-v1.2.0"
|
prompt_name: str = "vectara-summary-ext-24-05-med-omni"
|
||||||
stream: bool = False
|
stream: bool = False
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ class MMRConfig:
|
|||||||
class RerankConfig:
|
class RerankConfig:
|
||||||
"""Configuration for Reranker.
|
"""Configuration for Reranker.
|
||||||
|
|
||||||
reranker: "mmr", "rerank_multilingual_v1" or "none"
|
reranker: "mmr", "rerank_multilingual_v1", "udf" or "none"
|
||||||
rerank_k: number of results to fetch before reranking, defaults to 50
|
rerank_k: number of results to fetch before reranking, defaults to 50
|
||||||
mmr_diversity_bias: for MMR only - a number between 0 and 1 that determines
|
mmr_diversity_bias: for MMR only - a number between 0 and 1 that determines
|
||||||
the degree of diversity among the results with 0 corresponding
|
the degree of diversity among the results with 0 corresponding
|
||||||
@ -76,11 +77,13 @@ class RerankConfig:
|
|||||||
Note: mmr_diversity_bias is equivalent 1-lambda_mult
|
Note: mmr_diversity_bias is equivalent 1-lambda_mult
|
||||||
where lambda_mult is the value often used in max_marginal_relevance_search()
|
where lambda_mult is the value often used in max_marginal_relevance_search()
|
||||||
We chose to use that since we believe it's more intuitive to the user.
|
We chose to use that since we believe it's more intuitive to the user.
|
||||||
|
user_function: for UDF only - the user function to use for reranking.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
reranker: str = "none"
|
reranker: str = "none"
|
||||||
rerank_k: int = 50
|
rerank_k: int = 50
|
||||||
mmr_diversity_bias: float = 0.3
|
mmr_diversity_bias: float = 0.3
|
||||||
|
user_function: str = ""
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -445,7 +448,7 @@ class Vectara(VectorStore):
|
|||||||
config.rerank_config.rerank_k
|
config.rerank_config.rerank_k
|
||||||
if (
|
if (
|
||||||
config.rerank_config.reranker
|
config.rerank_config.reranker
|
||||||
in ["mmr", "rerank_multilingual_v1"]
|
in ["mmr", "udf", "rerank_multilingual_v1"]
|
||||||
)
|
)
|
||||||
else config.k
|
else config.k
|
||||||
),
|
),
|
||||||
@ -473,6 +476,11 @@ class Vectara(VectorStore):
|
|||||||
"rerankerId": MMR_RERANKER_ID,
|
"rerankerId": MMR_RERANKER_ID,
|
||||||
"mmrConfig": {"diversityBias": config.rerank_config.mmr_diversity_bias},
|
"mmrConfig": {"diversityBias": config.rerank_config.mmr_diversity_bias},
|
||||||
}
|
}
|
||||||
|
elif config.rerank_config.reranker == "udf":
|
||||||
|
body["query"][0]["rerankingConfig"] = {
|
||||||
|
"rerankerId": UDF_RERANKER_ID,
|
||||||
|
"userFunction": config.rerank_config.user_function,
|
||||||
|
}
|
||||||
elif config.rerank_config.reranker == "rerank_multilingual_v1":
|
elif config.rerank_config.reranker == "rerank_multilingual_v1":
|
||||||
body["query"][0]["rerankingConfig"] = {
|
body["query"][0]["rerankingConfig"] = {
|
||||||
"rerankerId": RERANKER_MULTILINGUAL_V1_ID,
|
"rerankerId": RERANKER_MULTILINGUAL_V1_ID,
|
||||||
|
@ -22,7 +22,7 @@ from langchain_community.vectorstores.vectara import (
|
|||||||
# VECTARA_API_KEY, VECTARA_CORPUS_ID and VECTARA_CUSTOMER_ID
|
# VECTARA_API_KEY, VECTARA_CORPUS_ID and VECTARA_CUSTOMER_ID
|
||||||
#
|
#
|
||||||
|
|
||||||
test_prompt_name = "vectara-experimental-summary-ext-2023-12-11-sml"
|
test_prompt_name = "vectara-summary-ext-24-05-med-omni"
|
||||||
|
|
||||||
|
|
||||||
def get_abbr(s: str) -> str:
|
def get_abbr(s: str) -> str:
|
||||||
@ -299,8 +299,36 @@ def test_vectara_with_langchain_mmr(vectara3: Vectara) -> None: # type: ignore[
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_vectara_mmr(vectara3: Vectara) -> None: # type: ignore[no-untyped-def]
|
def test_vectara_rerankers(vectara3: Vectara) -> None: # type: ignore[no-untyped-def]
|
||||||
# test MMR directly with rerank_config
|
# test Vectara multi-lingual reranker
|
||||||
|
summary_config = SummaryConfig(is_enabled=True, max_results=7, response_lang="eng")
|
||||||
|
rerank_config = RerankConfig(reranker="rerank_multilingual_v1", rerank_k=50)
|
||||||
|
config = VectaraQueryConfig(
|
||||||
|
k=10,
|
||||||
|
lambda_val=0.005,
|
||||||
|
rerank_config=rerank_config,
|
||||||
|
summary_config=summary_config,
|
||||||
|
)
|
||||||
|
rag = vectara3.as_rag(config)
|
||||||
|
output1 = rag.invoke("what is generative AI?")["answer"]
|
||||||
|
assert len(output1) > 0
|
||||||
|
|
||||||
|
# test Vectara udf reranker
|
||||||
|
summary_config = SummaryConfig(is_enabled=True, max_results=7, response_lang="eng")
|
||||||
|
rerank_config = RerankConfig(
|
||||||
|
reranker="udf", rerank_k=50, user_function="get('$.score')"
|
||||||
|
)
|
||||||
|
config = VectaraQueryConfig(
|
||||||
|
k=10,
|
||||||
|
lambda_val=0.005,
|
||||||
|
rerank_config=rerank_config,
|
||||||
|
summary_config=summary_config,
|
||||||
|
)
|
||||||
|
rag = vectara3.as_rag(config)
|
||||||
|
output1 = rag.invoke("what is generative AI?")["answer"]
|
||||||
|
assert len(output1) > 0
|
||||||
|
|
||||||
|
# test Vectara MMR reranker
|
||||||
summary_config = SummaryConfig(is_enabled=True, max_results=7, response_lang="eng")
|
summary_config = SummaryConfig(is_enabled=True, max_results=7, response_lang="eng")
|
||||||
rerank_config = RerankConfig(reranker="mmr", rerank_k=50, mmr_diversity_bias=0.2)
|
rerank_config = RerankConfig(reranker="mmr", rerank_k=50, mmr_diversity_bias=0.2)
|
||||||
config = VectaraQueryConfig(
|
config = VectaraQueryConfig(
|
||||||
|
Loading…
Reference in New Issue
Block a user