Skip to content

Commit

Permalink
Update Chain Reranker topic about the array and examples (#330)
Browse files Browse the repository at this point in the history
* Update Chain Reranker topic about the array and examples

* Updates based on comments

* Updates
  • Loading branch information
pwoznic authored Oct 2, 2024
1 parent ed86a05 commit 8d5ab1d
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 24 deletions.
23 changes: 17 additions & 6 deletions www/docs/api-reference/search-apis/reranking.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,22 @@ accurate results.

We currently provides the following rerankers:

* [**Multilingual Reranker v1**](/docs/learn/vectara-multi-lingual-reranker) (`type=customer_specific` and `reranker_id=rnk_272725719`) for accurate results across over 100 languages.
* [**Maximal Marginal Relevance (MMR) Reranker**](/docs/learn/mmr-reranker) (`type=mmr`) for diversifying results while maintaining relevance.
* [**User Defined Function Reranker**](/docs/learn/user-defined-function-reranker) (`type=userfn`) for custom scoring based on metadata.
* [**Chain Reranker**](/docs/learn/chain-reranker) (`type=chain`) for combining multiple reranking strategies in sequence to meet
more complex search requirements.
* [**Multilingual Reranker v1**](/docs/learn/vectara-multi-lingual-reranker) (`type=customer_specific` and
`reranker_name=Rerank_Multilingual_v1`) provides more accurate neural ranking than the
initial Boomerang retrieval. While computationally more expensive, it offers
improved text scoring across a wide range of languages, making it suitable
for diverse content.
* [**Maximal Marginal Relevance (MMR) Reranker**](/docs/learn/mmr-reranker) (`type=mmr`) for diversifying
results while maintaining relevance.
* [**User Defined Function Reranker**](/docs/learn/user-defined-function-reranker) (`type=userfn`) for custom
scoring based on metadata.

### Chain reranking

The Vectara Chain Reranker (`type=chain`) lets you combine multiple reranking
strategies in sequence to meet more complex search requirements. This lets you
completely customize the functionality of Vectara to your needs by giving you
absolute control over the ranking functions. For details, see [Chain Reranker](/docs/learn/chain-reranker).

## Enable reranking

Expand All @@ -42,7 +53,7 @@ this simplified example intentionally omits several parameter values.
{
"query": "What is my question?",
"stream_response": false,
"search": {
"search": {
"start": 0,
"limit": 25,
"context_configuration": {},
Expand Down
7 changes: 5 additions & 2 deletions www/docs/api-reference/search-apis/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ more rarely, as a response.
The `reranker` object enables the reranking of query results, to further
increase relevance in certain scenarios. For more details, see [Rerank Search Results](/docs/api-reference/search-apis/reranking):

* Specify the `type` as `customer_reranker` to use the [Multilingual Reranker v1](/docs/api-reference/search-apis/reranking#vectara-multilingual-reranker-v1).
* Specify the `type` as `mmr` to use the [Maximal Marginal Relevance (MMR) Reranker](/docs/learn/mmr-reranker). This reranker lets you specify a `diversity_bias` value between `0.0` and `1.0`.
* Specify the `type` as `customer_reranker` and `reranker_name` as
`Rerank_Multilingual_v1` to use the [Multilingual Reranker v1](/docs/api-reference/search-apis/reranking#vectara-multilingual-reranker-v1),
also known as Slingshot.
* Specify the `type` as `mmr` to use the [Maximal Marginal Relevance (MMR) Reranker](/docs/learn/mmr-reranker).
This reranker lets you specify a `diversity_bias` value between `0.0` and `1.0`.
* Specify the `type` as `userfn` to use the [User Defined Function Reranker(/docs/learn/user-defined-function-reranker)].
* Specify the `type` as `chain` to use the [Chain Reranker](/docs/learn/chain-reranker).
* If you do not want to use a reranker, set the type to `none`.
Expand Down
98 changes: 87 additions & 11 deletions www/docs/learn/chain-reranker.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,48 @@ import {vars} from '@site/static/variables.json';

When refining query results where relevance and diversity are critical to
getting the best answers, relying on a single ranking strategy may not be
enough for business-critical search scenarios. The Chain Reranker addresses
this challenge by enabling you to apply two ranking strategies sequentially.
flexible enough for some scenarios. The Vectara Chain Reranker
addresses this challenge by enabling you to apply multiple ranking strategies
sequentially, giving you absolute control over the ranking process.

This is particularly useful in complex search scenarios that require multiple
dimensions of relevance. For example, enhancing diversity with the
[Maximal Marginal Relevance (MMR) reranker](/docs/learn/mmr-reranker) while also boosting documents
with specific metadata.
This powerful capability enables you to completely customize Vectara's
functionality to your specific needs, ensuring that your search results and
generative AI applications align with your business requirements precisely.

## Why use the chain reranker?

Chaining multiple rerankers is particularly useful in complex search scenarios
that require several dimensions of ranking. For example, enhancing
diversity with the [Maximal Marginal Relevance (MMR) reranker](/docs/learn/mmr-reranker), refining
the results across multiple languages, and then boosting documents with
specific metadata or other custom business logic with the
[User Defined Function reranker](/docs/learn/user-defined-function-reranker) to finalize the results.

1. **Multidimensional relevance**: Combine multiple ranking strategies in sequence
to optimize query results across various dimensions and meeting complex
business scenarios.
2. **Enhance RAG outcomes**: Improve the retrieval process by sequentially
applying multiple rerankers that balance relevance, diversity, and custom
business priorities to produce more contextually appropriate AI-generated
responses in Retrieval Augmented Generation (RAG) systems.
3. **Absolute control**: Tailor the ranking process to your exact specifications,
ensuring that the query results reflect your custom business logic.


## Enable the chain reranker

To enable the chain reranker, set the `type` to `chain` and then specify the
two rerankers that you want to combine.
To enable the chain reranker, set the `reranker` object `type` to `chain` and then
specify the multiple rerankers that you want to combine in a `rerankers` array.
You can specify up to 50 rerankers in a chain.

## Chain reranker examples

In this example, the Vectara Multilingual Reranker first refines the results
with improved text scoring, while the [User Defined Function reranker](/docs/learn/user-defined-function-reranker)
then boosts relevance based on metadata for popularity. This simple chain
example can be useful for multilingual content platforms such as blogs, news
aggregators, and knowledge bases.


```json
{
Expand All @@ -40,7 +70,53 @@ two rerankers that you want to combine.
}

```
Now let's take a look at a more complex chain reranker example. In this
e-commerce example, the Vectara Multilingual Reranker first refines the
initial results, providing a better ranking order than Boomerang. This
improves the overall relevance of the product results. The MMR reranker then
diversifies the results so that the customer sees some variety, rather than
only very similar products.

```json
{
"type": "mmr",
"diversity_bias": 0.2
},
```

We set the diversity bias to `0.2` to have more emphasis on relevance while
still providing some diversity. You can increase this value to `0.3` or `0.4`
for more diversity.

Finally, we apply a User Defined Function that combines several e-commerce
factors including a relevance score boost of 60%, a 20% boost if the product
is currently in stock, and then another 20% boost that favors products with
better customer reviews.

This chain reranker maintains a balance between showing relevant products that
match what the customer is looking for, ensuring that the products are in
stock, and also takes into account customer satisfaction rating of the
products.

```json
{
"reranker": {
"type": "chain",
"rerankers": [
{
"type": "customer_specific",
"reranker_name": "Rerank_Multilingual_v1"
},
{
"type": "mmr",
"diversity_bias": 0.2
},
{
"type": "userfn",
"user_function": "get('$.metadata.relevance_score') * 0.6 + (get('$.metadata.in_stock') ? 0.2 : 0) + get('$.metadata.customer_rating') * 0.2"
}
]
}
}
```

In this example, the Vectara Multilingual Reranker refines the results across
over 100 languages, while the [User Defined Function reranker](/docs/learn/user-defined-function-reranker) boosts
relevance based on metadata for popularity.
37 changes: 32 additions & 5 deletions www/docs/learn/vectara-multi-lingual-reranker.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,45 @@ import TabItem from '@theme/TabItem';
import {Config} from '@site/docs/definitions.md';
import {vars} from '@site/static/variables.json';

The new Vectara Multilingual Reranker V1 is a state-of-the-art reranking model
that significantly enhances the precision of retrieved results across 100+
languages. Using this reranker requires both the `type` and `reranker_id` in the
`reranker` object. Set the `type` as `customer_reranker` and the `reranker_id` as `rnk_272725719`.
Generative AI applications often struggle with ranking the most relevant
information, leading to hallucinations and irrelevant responses. The new
Vectara Multilingual Reranker V1, also known as Slingshot, is a
state-of-the-art reranking model that significantly enhances the precision of
retrieved results. Providing advanced neural ranking, it refines the output of
initial models like [Boomerang](https://vectara.com/blog/introducing-boomerang-vectaras-new-and-improved-retrieval-model/),
offering even more accurate document scoring and response quality in Retrieval
Augmented Generation (RAG) pipelines.

The Vectara Multilingual Reranker operates as a second-pass refinement tool,
building on Boomerang’s high-recall capabilities. While Boomerang quickly
retrieves a broad set of relevant documents, the Multilingual Reranker
delivers more precise results, ensuring that the top-ranked documents are the
most relevant. This reranker also excels across both English and multilingual
datasets, making it a powerful tool for global use cases.

While more computationally expensive and introducing some additional latency,
the multilingual reranker improves neural ranking beyond Boomerang’s initial
selection by providing more precise text scoring. Think of the Slingshot
reranker as a "better Boomerang" for refining results, with the multilingual
capability serving primarily as a differentiator from other rerankers in the
market, which are often English-only.

Using this reranker requires both the `type` and `reranker_id` in the
`reranker` object. Set the `type` as `customer_reranker` and the `reranker_name`
as `Rerank_Multilingual_v1`.

```json
"reranker": {
"type": "customer_reranker",
"reranker_id": "rnk_272725719"
"reranker_name": "Rerank_Multilingual_v1"
}
```

:::note
The `reranker_id` and `rnk_272725719` have been deprecated. Use `reranker_name` and
`Rerank_Multilingual_v1` instead.
:::

The Vectara Multilingual Reranker ensures impressive zero-shot performance on
unseen data and domains, and it **never** trains on customer data. In RAG use
cases, this reranker distinguishes the scores of relevant and irrelevant
Expand Down

0 comments on commit 8d5ab1d

Please sign in to comment.