HomeGuidesAPI ReferenceTutorials
Haystack

Docs2Answers

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 PipelineAt the end of a querying pipeline
InputDocuments
OutputAnswers
ClassesDocs2Answers

Usage

To use it in a Pipeline, run:

from haystack.nodes import Pipeline
from 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?")

Related Links