Skip to main content

SigmaFlow is a Python package designed to optimize the performance of task-flow related to LLMs or MLLMs

Project description

banner

访问量统计 license issue resolution

👋 join us on WeChat

🚀 SigmaFlow

SigmaFlow is a Python package designed to optimize the performance of task-flow related to LLMs/MLLMs or Multi-agent. comfyUI demo

pipe demo

perf demo

🎉 News

  • [2025.04.15]🎯📢SigmaFlow support command line use & file node! Please refer to the example directory.
  • [2025.04.01]🎯📢SigmaFlow first release pypi!

Introduction

SigmaFlow is a Python package designed to optimize the performance of task-flow related to Large Language Models (LLMs) or Multimodal Large Language Models (MLLMs) or Multi-agent system. It ensures efficient parallel execution of task-flow while maintaining dependency constraints, significantly enhancing the overall performance.

SigmaFlow 是一个 Python 包,旨在优化与大模型 (LLMs or MLLMs) 相关任务流的性能。在满足依赖关系的前提下,确保任务流的高效并行执行,从而显著提高整体性能。

Features

  • Dependency Management: Handles task dependencies efficiently, ensuring correct execution order.

    依赖管理:高效处理任务依赖关系,确保正确的执行顺序。

  • Parallel Execution: Maximizes parallelism to improve performance.

    并行执行:最大化并行性以提高性能。

  • Loop Handling: Supports tasks with loop structures.

    循环处理:支持带有循环结构的任务。

  • Easy Integration: Simple and intuitive API for easy integration with existing projects.

    易于集成:简单直观的 API,便于与现有项目集成。

Installation

You can install SigmaFlow via pip:

你可以通过 pip 安装 SigmaFlow:

pip install SigmaFlow

# or editable install from source
git clone https://github.com/maokangkun/SigmaFlow.git && cd SigmaFlow
pip install --no-build-isolation -e .

Quick Start

Here is a basic example to get you started:

下面是一个基本示例,帮助你快速入门:

Example Code
from SigmaFlow import SigmaFlow, Prompt

# set custom prompt
example_prompt = Prompt("""
...
{inp1}
xxx
""", keys=['{inp1}'])

# set api
def llm_api(inp):
    ...
    return out

def rag_api(inp):
    ...
    return out

# set input data
data = {
    'inp': 'test input text ...',
}

# set pipeline
demo_pipe = {
    'process_input': {
        'prompt': example_prompt,
        'format': {'out1': list, 'out2': str}, # check return json format
        'inp': ['inp'],
        'out': ['out1', 'out2'],
        'next': ['rag1', 'loop_A'], # specify the next pipeline
    },
    'rag1': {
        'rag_backend': rag_api2, # specific api can be set for the current pipe via 'rag_backend' or 'llm_backend'.
        'inp': ['out2'],
        'out': 'out8',
    },
    'loop_A': { # here is iterating over a list 'out1'
        'inp': 'out1',
        'pipe_in_loop': ['rag2', 'llm_process', 'rag3', 'rag4', 'llm_process2', 'llm_process3'],
        'next': ['exit'], # 'exit' is specific pipe mean to end
    },
    'rag2': {
        'inp': ['out1'],
        'out': 'out3',
    },
    'llm_process2': {
        'prompt': llm_process2_prompt,
        'format': {'xxx': str, "xxx": str},
        'inp': ['inp', 'out4', 'out8'],
        'out': 'final_out1',
    },
    ...
}

# running pipeline
pipeline = SigmaFlow(demo_pipe, llm_api, rag_api)
result, info = pipeline.run(data, core_num=4, save_pref=True)

Logs are stored in the logs folder. If save_pref is true, you can see the relevant performance report.

日志存储在logs文件夹下,如果save_preftrue,你可以看到相关的性能报告。

For a complete example, please refer to the example directory.

完整示例请参考example目录。

Start with CLI Mode

We have updated a more easy-to-use command to run pipeline.

sigmaflow -p example/demo_pipeline.py -i example/demo_data.json -m async

Command Options:

options:
  -h, --help            show this help message and exit
  -p PIPELINE, --pipeline PIPELINE
                        specify the pipeline to run
  -i INPUT, --input INPUT
                        specify input data
  -o OUTPUT, --output OUTPUT
                        specify output data
  -m {async,mp,seq}, --mode {async,mp,seq}
                        specify the run mode
  --split SPLIT         split the data into parts to run
  --png                 export graph as png
  --test                run test

Documentation

For detailed documentation, please visit our official documentation page.

有关详细文档,请访问我们的官方文档页面。

Contributing

We welcome contributions from the community. Please read our contributing guide to get started.

我们欢迎来自社区的贡献。请阅读我们的贡献指南开始。

License

SigmaFlow is licensed under the Apache License Version 2.0. See the LICENSE file for more details.

SigmaFlow 采用 Apache License Version 2.0 许可证。有关详细信息,请参阅许可证文件。

Acknowledgements

Special thanks to all contributors and the open-source community for their support.

特别感谢所有贡献者和开源社区的支持。

Contact

For any questions or issues, please open an issue on our GitHub repository.

如有任何问题或意见,请在我们的GitHub 仓库提交 issue。

Star History

Contribution

Thank you to all our contributors!

🌟Citation

@book{Mao2025maokangkun,
	title = {maokangkun/SigmaFlow},
	url = {https://github.com/maokangkun/SigmaFlow},
	author = {Mao, Kangkun},
	date = {2025-04-01},
	year = {2025},
	month = {4},
	day = {1},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sigmaflow-0.0.34.tar.gz (17.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sigmaflow-0.0.34-py3-none-any.whl (18.1 MB view details)

Uploaded Python 3

File details

Details for the file sigmaflow-0.0.34.tar.gz.

File metadata

  • Download URL: sigmaflow-0.0.34.tar.gz
  • Upload date:
  • Size: 17.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sigmaflow-0.0.34.tar.gz
Algorithm Hash digest
SHA256 a4a066911bd6c45daabcdc9f1968ad437af370d15ffe7f8219d52683045b0eb6
MD5 25aa3e63b7ffbbc9b421ab412fff0991
BLAKE2b-256 73be58c2b66d1a619d63722fdc9b0c47b7d42fece67dfa84c0d759310cc8cd6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sigmaflow-0.0.34.tar.gz:

Publisher: release.yml on maokangkun/SigmaFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sigmaflow-0.0.34-py3-none-any.whl.

File metadata

  • Download URL: sigmaflow-0.0.34-py3-none-any.whl
  • Upload date:
  • Size: 18.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sigmaflow-0.0.34-py3-none-any.whl
Algorithm Hash digest
SHA256 98ab86ae3e649bad4d98ac36e07e805d87ae9b92f245ef0c051bbc3f003a1cc9
MD5 3614cc614c69e1117884cc5696c23f72
BLAKE2b-256 51444c87131a6c426fc83c56652bfb4424c01af8d073e4c42007d1f908f81a6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sigmaflow-0.0.34-py3-none-any.whl:

Publisher: release.yml on maokangkun/SigmaFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page