HomeGuidesAPI ReferenceTutorials
Haystack

Pipeline Nodes Overview

Nodes are the core components that process and route incoming text. They perform preprocessing, retrieving, or summarizing text while routing queries through different branches of a pipeline. This page is a summary of all nodes available in Haystack.

Nodes are chained together using a pipeline and they function like building blocks that can be easily switched out for each other. A node takes the output of the previous node (or nodes) as input.

Usage

All nodes are designed to be useable within a pipeline. When you add a node to a pipeline and call Pipeline.run(), it calls each node's run() method in the predefined sequence. The same is true for Pipeline.run_batch() that you can use if you want to ask multiple queries. It calls each node's run_batch() method. For more information, see the pipelines page.

Alternatively, you can also call the nodes outside of the pipeline. See each individual node's documentation page to learn more about its available methods.

Available Nodes

NodeClassesDescription
FileClassifierFileTypeClassifierDistinguishes between text, PDF, Markdown, Docx and HTML files
FileConvertersPDFToTextConverter, DocxToTextConverter, AzureConverter, ImageToTextConverter, MarkdownConverterPerforms cleaning and splitting on Documents
CrawlerCrawlerScrapes websites and returns text
PreProcessorPreProcessorPerforms cleaning and splitting on Documents
RetrieverBM25Retriever, ElasticsearchRetriever, DensePassageRetriever, TableTextRetriever, EmbeddingRetriever, TfidfRetriever, ElasticsearchFilterOnlyRetrieverLooks into a coupled Document Store and fetches Documents that are relevant to a given Query
ReaderFARMReader, TransformersReaderFinds an answer to a question by selecting a text span in the provided Documents
Answer GeneratorRAGenerator, Seq2SeqGenerator, OpenAIAnswerGeneratorGenerates an answer to a question by reading through the provided documents and composing an answer word-by-word
SummarizerTransformersSummarizerCreates a shorter overview of a given Document
TranslatorTransformersTranslatorTranslate text from one language into another
RankerSentenceTransformersRankerReorders a set of Documents based on their relevance to the Query
Query ClassifierTransformersQueryClassifier, SklearnQueryClassifierDistinguishes between queries that are keywords, questions or statements and routes accordingly
Question GeneratorQuestionGeneratortakes a Document as input and generates questions which it believes can be answered by the Document
Document ClassifierTransformersDocumentClassifierPerforms classification on Documents and attaches it as metadata
Entity ExtractorEntityExtractorExtracts predefined entities out of a piece of text
Route DocumentsRouteDocumentsRoutes documents based on their content type or a metadata field
Join DocumentsJoinDocumentsTakes Documents from multiple Nodes and joins them to form one list of Documents.
Join AnswersJoinAnswersTakes Answers from two or more Reader or Generator nodes and joins them to produce a single list of Answers
Docs2AnswersDocs2AnswersConverts retrieved Documents into predicted Answers format.

Decision Nodes

You can add decision nodes where only one "branch" is executed afterwards. You can use decision nodes to classify an incoming query and, depending on the result, route it to different modules. To find a ready-made example of a decision node, have a look at QueryClassifier.

352352

A pipeline with a QueryClassifier functioning as a decision Node.

You can also create a custom decision node. To do this, create a class that looks like this:

    class QueryClassifier(BaseComponent):
        outgoing_edges = 2

        def run(self, query):
            if "?" in query:
                return {}, "output_1"

            else:
                return {}, "output_2"

    pipe = Pipeline()
    pipe.add_node(component=QueryClassifier(), name="QueryClassifier", inputs=["Query"])
    pipe.add_node(component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_1"])
    pipe.add_node(component=dpr_retriever, name="DPRRetriever", inputs=["QueryClassifier.output_2"])
    pipe.add_node(component=JoinDocuments(join_mode="concatenate"), name="JoinResults",
                  inputs=["ESRetriever", "DPRRetriever"])
    pipe.add_node(component=reader, name="QAReader", inputs=["JoinResults"])
    res = p.run(query="What did Einstein work on?", params={"ESRetriever": {"top_k": 1}, "DPRRetriever": {"top_k": 3}})