0
# Pipeline System
1
2
Pre-built and custom pipeline templates for orchestrating component workflows including QA, search, generation, and indexing pipelines.
3
4
## Core Imports
5
6
```python
7
from haystack import Pipeline
8
from haystack.pipelines import ExtractiveQAPipeline, GenerativeQAPipeline, DocumentSearchPipeline
9
```
10
11
## Base Pipeline
12
13
```python { .api }
14
from haystack import Pipeline
15
from haystack.nodes.base import BaseComponent
16
from typing import Dict, List, Any, Optional
17
18
class Pipeline:
19
def __init__(self):
20
"""Initialize an empty pipeline."""
21
22
def add_node(self, component: BaseComponent, name: str, inputs: List[str]) -> None:
23
"""
24
Add a component to the pipeline.
25
26
Args:
27
component: Component instance to add
28
name: Unique name for the component in pipeline
29
inputs: List of input names this component receives from
30
"""
31
32
def run(self, query: Optional[str] = None, file_paths: Optional[List[str]] = None,
33
labels: Optional[List] = None, documents: Optional[List] = None,
34
meta: Optional[Dict[str, Any]] = None, **kwargs) -> Dict[str, Any]:
35
"""
36
Run the pipeline with given inputs.
37
38
Args:
39
query: Query string for QA/search pipelines
40
file_paths: File paths for indexing pipelines
41
labels: Labels for evaluation pipelines
42
documents: Documents for processing
43
meta: Additional metadata
44
45
Returns:
46
Dictionary with pipeline results
47
"""
48
```
49
50
## Extractive QA Pipeline
51
52
```python { .api }
53
from haystack.pipelines import ExtractiveQAPipeline
54
from haystack.nodes.reader.base import BaseReader
55
from haystack.nodes.retriever.base import BaseRetriever
56
57
class ExtractiveQAPipeline(Pipeline):
58
def __init__(self, reader: BaseReader, retriever: BaseRetriever):
59
"""
60
Initialize extractive QA pipeline.
61
62
Args:
63
reader: Reader component for answer extraction
64
retriever: Retriever component for document retrieval
65
"""
66
```
67
68
## Generative QA Pipeline
69
70
```python { .api }
71
from haystack.pipelines import GenerativeQAPipeline
72
73
class GenerativeQAPipeline(Pipeline):
74
def __init__(self, generator, retriever):
75
"""
76
Initialize generative QA pipeline.
77
78
Args:
79
generator: Generator component for answer generation
80
retriever: Retriever component for document retrieval
81
"""
82
```
83
84
## Document Search Pipeline
85
86
```python { .api }
87
from haystack.pipelines import DocumentSearchPipeline
88
89
class DocumentSearchPipeline(Pipeline):
90
def __init__(self, retriever: BaseRetriever):
91
"""
92
Initialize document search pipeline.
93
94
Args:
95
retriever: Retriever component for document search
96
"""
97
```