Migrating from MapRerankDocumentsChain
MapRerankDocumentsChain implements a strategy for analyzing long texts. The strategy is as follows:
- Split a text into smaller documents;
- Map a process to the set of documents, where the process includes generating a score;
- Rank the results by score and return the maximum.
A common process in this scenario is question-answering using pieces of context from a document. Forcing the model to generate score along with its answer helps to select for answers generated only by relevant context.
An LangGraph implementation allows for the incorporation of tool calling and other features for this problem. Below we will go through both MapRerankDocumentsChain
and a corresponding LangGraph implementation on a simple example for illustrative purposes.