Notebooks
E
Elastic
Llamaindex Rerank Notebook

Llamaindex Rerank Notebook

openai-chatgptllamaindex-re-ranker-and-elasticsearch-re-rankerlangchain-pythonchatgptgenaielasticsearchelasticopenaiAIchatlogvectordatabasePythonsearchgenaistacksupporting-blog-contentvectorelasticsearch-labslangchainapplications

LlamaIndex re-ranker and Elasticsearch re-ranker: Comparison review

This notebook is based on the article LlamaIndex re-ranker and Elasticsearch re-ranker: Comparison review and has the main goal to compare the performance of the LlamaIndex re-ranker and the Elasticsearch re-ranker.

Dataset

[ ]
[25]

Setup keys

[3]

Elasticsearch client

[26]

Mappings

The mappings are defined to create the index in Elasticsearch. The metadata field is a nested field that contains the product information. The semantic_field is a field that is used to store the semantic representation of the product. The embeddings field is a dense vector field that is used to store the embeddings of the product used to perform the re-ranking with LlamaIndex.

[ ]
[15]

User question

[16]

LlamaIndex Reranking

In this section we will use the LlamaIndex re-ranker to re-rank the results of the search query.

Indexing data to Elasticsearch

The documents are indexed to Elasticsearch using the ElasticsearchStore class. This is a wrapper around the Elasticsearch client and inserts the documents into the Elasticsearch index in a metadata field.

[ ]

LLM setup

[18]

LlamaIndex rerank feature

[19]
[20]

Without rerank

[ ]

With rerank

[ ]

Elasticsearch Reranking

In this section we will use the Elasticsearch re-ranker to re-rank the results of the search query.

Creating inference rerank endpoint

[ ]

Function to execute search queries

[27]
[28]

Semantic query

[ ]
[ ]

Cleaning environment

Delete the resources used to prevent them from consuming resources.

[ ]