This notebook shows how to use PineconeRerank for two-stage vector retrieval reranking using Pinecone’s hosted reranking API as demonstrated in langchain_pinecone/libs/pinecone/rerank.py
.
langchain-pinecone
package.
PineconeRerank
to rerank a list of documents by relevance to a query.
top_n
to limit the number of returned documents.
rank_fields
to specify the field to rank on.
truncate
) directly to .rerank()
.
How to handle inputs longer than those supported by the model. Accepted values: END or NONE.
END truncates the input sequence at the input token limit. NONE returns an error when the input exceeds the input token limit.
PineconeRerank(model, top_n, rank_fields, return_documents)
.rerank(documents, query, rank_fields=None, model=None, top_n=None, truncate="END")
.compress_documents(documents, query)
(returns Document
objects with relevance_score
in metadata)