Doc2Answers
Doc2Answers converts retrieved Documents into Answers. It is useful if you have a Retriever-only pipeline that you want to run using the REST API. The REST API assumes that the output format of a Pipeline is an Answer. In such case, you can use Doc2Answers as the final node to match the expected format.
Position in a Pipeline | At the end of a querying Pipeline |
Input | Documents |
Output | Answers |
Classes | Docs2Answers |
Usage
To use it in a Pipeline:
Copied!
from haystack.nodes import Pipelinefrom haystack.nodes import Docs2Answers
docs2answers = Docs2Answers()
pipe = Pipeline()pipe.add_node(component=retriever, name="Retriever", inputs=["Query"])pipe.add_node(component=docs2answers, name="Doc2Answers", inputs=["Retriever"])res = pipe.run(query="What did Einstein work on?")