Overview
A pipeline is a workflow designed to execute multiple tasks in a predefined sequence, providing full control and flexibility. They are powerful solutions for deterministic automation flows.
Key Features
- Full control and flexibility: Manage every aspect of your pipeline, from the sequence of tasks and agents to the specifics of input processing. Implement conditional logic and branching to enhance reliability and adaptability.
- Parallel execution: Run multiple processes concurrently to maximize efficiency and reduce execution time.
- Modularity and extensibility: Independently develop and test each node within the pipeline, ensuring flexibility and ease of updates. Extend functionality seamlessly by adding tasks without altering the deployed endpoint.
- Asset swapping: Effortlessly replace assets within nodes to trial different models or utilities, maintaining the pipeline structure intact.
- Batching: Process inputs in batches to boost efficiency and throughput. Explore batching strategies here.
- Reusability: Built pipelines can be reused within different agents, serving as a versatile tool for various applications.
Components
- Input Node: Accepts input data to the pipeline. The accepted data types and formats are determined by the node connected to the input node.
- Output Node: Provides pipeline output.
- Model Node: Processes data based on the populated asset e.g., a translation asset would translate input data, a scarper asset will scrape the input url.
- Script Node: Executes custom python code.
- Decision Node: Applies logical conditions to direct the flow within the pipeline.
- Router Node: Distributes incoming data to different paths based on predefined rules.
- Metric Node: Uses metric assets to evaluate input data based on reference data.
Create a pipeline
This example pipeline takes text input, translates it into another language, and performs sentiment analysis on the translated text. The pipeline has:
- 1 input node: Accepts text input.
- 2 processing nodes: Performs translation and sentiment analysis.
- 2 output nodes: Outputs the translated text and its sentiment analysis results.
from aixplain.factories.pipeline_factory import PipelineFactory
from aixplain.modules.pipeline.designer import Input
pipeline = PipelineFactory.init("Multi Input-Output Pipeline")
text_input_node = Input(data="text_input", data_types=["TEXT"], pipeline=pipeline)
TRANSLATION_ASSET_ID = '60ddefbe8d38c51c5885f98a'
translation_node = pipeline.translation(asset_id=TRANSLATION_ASSET_ID)
SENTIMENT_ASSET_ID = '61728750720b09325cbcdc36'
sentiment_node = pipeline.sentiment_analysis(asset_id=SENTIMENT_ASSET_ID)
text_input_node.link(translation_node, 'input', 'text')
translation_node.link(sentiment_node, 'data', 'text')
translated_output_node = translation_node.use_output('data')
sentiment_output_node = sentiment_node.use_output('data')
pipeline.save()
outputs = pipeline.run({
'text_input': 'This is example text to translate.'
})
print(outputs)
Guide to Building the Example Pipeline
Initialize Pipeline
from aixplain.factories.pipeline_factory import PipelineFactory
pipeline = PipelineFactory.init("Multi Input-Output Pipeline")
Add input and output nodes
Input Nodes
Define the input node for text input.
from aixplain.modules.pipeline.designer import Input
text_input_node = Input(data="text_input", data_types=["TEXT"], pipeline=pipeline)
Output Nodes
Add nodes to output the translated text and sentiment analysis results.
translated_output_node = translation_node.use_output('data')
sentiment_output_node = sentiment_node.use_output('data')