JoinAnswers
The JoinAnswers
node takes Answers from two or more Reader or Generator nodes and joins them to produce a single list of answers.
Position in a Pipeline | Joins the output of two or more Nodes that return Answers |
Input | Answers |
Output | Answers |
Classes | JoinAnswers |
Usage
To initialize the Node:
Copied!
from haystack.nodes import JoinAnswers
join_answers = JoinAnswers( join_mode="concatenate", sort_by_score=True)
There are two available join_mode
s:
concatenate
: Combines documents from multiple readersmerge
: Aggregates scores of individual answers. If you use this option, you can also specify theweights
parameter which assigns importance to the input nodes. By default, all nodes are assigned equal weight.
Optionally, you can use the top_k
parameter to specify the number of answers to be displayed.
Note: Answers coming from a Generator have no score.
You will need to set sort_by_score=False
to join these with Answers coming from other sources.
Use Case
A typical use case for JoinAnswers
is as follows:
- Your documents contain different types of data, for example tables and text
- You use the
RouteDocuments
node to split your documents by content type - You use a different reader for each document type and you get predicted answers form each reader separately
- You use the
JoinAnswers
node to join the answers in a single list
Here's what an example pipeline with the JoinAnswers
node could look like: