JoinAnswers
This node takes answers generated by multiple Readers or Generators (such as PromptNode) and joins them into a single list of answers.
This is a utility node that simply merges multiple lists of answers to produce a single list. It can be useful if you're using multiple PromptNodes, each generating an answer, followed by a node that accepts a single answer rather than multiple lists of answers. You can then use JoinAnswers after the PromptNodes.
Basic Information
- Pipeline type: Used in query pipelines.
- Nodes that can precede it in a pipeline: AnswerDeduplication, PromptNode with AnswerParser to make sure it outputs Answer, Reader, ReferencePredictor
- Nodes that can follow it in a pipeline: AnswerDeduplication, ReferencePredictor
- Node input: Answers
- Node output:Answer
- Available node classes: JoinAnswers
Join Modes
There are two join modes you can choose:
concatenate
: Simply combines the answers into a single list.merge
: Aggregates scores of individual answers. With this mode, you can also specify theweights
parameter, which assigns importance to the input nodes. By default, all nodes have equal weight.
Answers from LLMs
Note that answers coming from a large language model (LLM) have no score. Set
sort_by_score=False
to join the LLM's answers with answers from other nodes.
For more information, see the Arguments section below.
Usage Example
One use case for JoinAnswers could be that your documents contain different types of data, for example tables and text. In your pipeline, you're using RouteDocuments to route the documents to different readers, depending on their content type. Each reader returns predicted answers, and you can then use JoinAnswers to produce a final single list of answers.
components:
- name: Retriever
type: TableTextRetriever
- name: DocumentStore
type: DeepsetCloudDocumentStore
params:
embedding_dim: 768
similarity: cosine
- name: Router
type: RouteDocuments
- name: TextReader
type: TransformersReader
- name: TableReader
type: TableReader
- name: JoinAnswers
type: JoinAnswers
params:
join_mode: concatenate
top_k_join: 10
...
pipelines:
- name: query
nodes:
- name: Retriever
inputs: [Query]
- name: Router
inputs: [Retriever]
- name: TextReader
inputs: [RouteDocuments.output_1]
- name: TableReader
inputs: [RouteDocuments.output_2]
- name: JoinAnswers
inputs: [TextReader, TableReader]
...
Parameters
You can specify the following parameters for FileTypeClassifier
in the pipeline YAML:
Parameter | Type | Possible Values | Description |
---|---|---|---|
join_mode | String | concatenate merge Default: concatenate | The mode to use for joining answer lists. concatenate - Combines answers into a single list. merge - Aggregates scores of individual answers. Required. |
weights | List of float values | Default: none | Used with the merge join mode. Assigns the importance to the input nodes. By default, answers from all nodes are assigned equal weight.Optional. |
top_k_join | Integer | Default: none | The final number of answers to return in the resulting list. Optional. |
sort_by_score | Boolean | True False Default: True | Sorts the incoming answers by their score. If any of the answers come from a Generator (like PromptNode), set this parameter to False , as these answers have no score.Required. |
Updated 9 months ago