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|
To initialize the Node:
from haystack.nodes import JoinAnswersjoin_answers = JoinAnswers(join_mode="concatenate",sort_by_score=True)
There are two available
concatenate: Combines documents from multiple readers
merge: Aggregates scores of individual answers. If you use this option, you can also specify the
weightsparameter 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.
A typical use case for
JoinAnswers is as follows:
- Your documents contain different types of data, for example tables and text
- You use the
RouteDocumentsnode 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
JoinAnswersnode to join the answers in a single list
Here's what an example pipeline with the
JoinAnswers node could look like: