Skip to main content

A domain-agnostic framework for orchestrating LLM-based data generation workflows

Reason this release was yanked:

change to lowercase

Project description

Polysome

Polysome is a generic data generation framework designed for transforming text attributes using Large Language Models. It serves as a powerful workflow builder for chaining prompts to generate synthetic data at scale.

While originally developed for computational pathology, Polysome is domain-agnostic and focuses purely on the data generation aspect of the pipeline. It allows you to define complex, multi-step text transformation workflows using a node-based architecture.

Key Features:

  • Workflow Engine: Define DAG-based pipelines to load data, process it with LLMs, and structure the output.
  • Synthetic Data Generation: Ideal for creating instruction tuning datasets, rewriting reports, or extracting structured information from unstructured text.
  • Prompt Chaining: distinct nodes for complex reasoning tasks, summarization, and translation.
  • High Performance: Supports batch processing and Data Parallelism via vLLM.

🚀 Quick Start

Installation

Install Polysome from PyPI (minimal install, HuggingFace only):

pip install polysome

For specific engines:

# vLLM (Recommended for Linux + NVIDIA GPU)
pip install "polysome[vllm]"

# llama.cpp (Recommended for CPU or Apple Silicon)
pip install "polysome[llama-cpp]"

# Install everything (for development/testing)
pip install "polysome[all]"

Convenience aliases:

  • pip install "polysome[gpu]" → installs vllm stack
  • pip install "polysome[cpu]" → installs llama-cpp stack

Create Your First Project

Initialize a new project with example workflows and prompts:

polysome init my-analysis
cd my-analysis

This creates:

  • workflows/ - Example workflow configurations
  • prompts/ - Prompt templates for your tasks
  • data/ - Directory for input data (with example file)
  • output/ - Results will be saved here

Run a Workflow

# Run the example workflow
polysome run workflows/basic_text_generation.json

# Run with custom settings
polysome run workflows/my_workflow.json --log-level DEBUG

Customize for Your Use Case

  1. Edit your workflow (workflows/basic_text_generation.json):

    • Change the model name
    • Adjust generation parameters
    • Add or remove processing nodes
  2. Customize prompts (prompts/simple_qa/):

    • system_prompt.txt: Define the AI's role
    • user_prompt.txt: Template with variables like {question}
    • few_shot.jsonl: Example inputs and outputs
  3. Prepare your data (data/input.json):

    • Format as JSON with fields matching your prompt variables
  4. Run and iterate:

    polysome run workflows/basic_text_generation.json
    

Using Docker (Alternative)

For reproducible environments or deployment:

# Pull the image
docker pull ghcr.io/computationalpathologygroup/polysome:latest

# Run with Docker
docker run --rm --gpus all \
  -v ./data:/data \
  -v ./output:/output \
  -v ./workflows:/workflows \
  -v ./prompts:/prompts \
  -e WORKFLOW_PATH=/workflows/basic_text_generation.json \
  ghcr.io/computationalpathologygroup/polysome:latest

For detailed Docker usage, see docs/docker_container.md.

🐍 Programmatic API

For advanced users, you can also use Polysome programmatically:

from polysome.workflow import Workflow

# Load and run a workflow
workflow = Workflow("workflows/my_workflow.json")
success = workflow.run()

# Access results
print(f"Results saved to: {workflow.output_dir}")

🛠️ Contributing & Development

Want to contribute or modify Polysome? See CONTRIBUTING.md for guidelines.

Local Development Setup

git clone https://github.com/computationalpathologygroup/Polysome.git
cd Polysome

# Install in development mode with dependencies
pip install -e .[gpu-dev]  # For GPU development
# OR
pip install -e .[cpu-dev]  # For CPU development

Running Tests

pytest
pytest --cov=polysome  # With coverage

🧩 Workflow Configuration

Workflows are defined in JSON files (DAGs) located in the workflows/ directory. They control how data is loaded, processed by LLMs, and saved.

For a detailed guide on creating nodes and configuring JSONs, see docs/text_preprocessing.md.

🎨 Prompt Engineering

Polysome includes a Streamlit-based Prompt Editor to help you design, manage, and test Jinja2 templates for your LLM tasks.

# Run the editor
streamlit run prompt_editor.py

For a user guide on managing templates and few-shot examples, see docs/prompt_editor.md.

⚡ High Performance Inference

For large-scale processing, Polysome supports Data Parallelism using vLLM to distribute batches across multiple GPUs.

To enable this, use the vllm_dp engine in your workflow configuration. See docs/data_parallelism.md for setup instructions and performance tuning.

📚 Documentation Index

📄 Citation

This framework was originally developed to support visual instruction tuning. If you use this code to generate data for such models, please consider citing the following paper:

@inproceedings{moonemans2025open,
  title={Democratizing Pathology Co-Pilots: An Open Pipeline and Dataset for Whole-Slide Vision-Language Modeling},
  author={Sander Moonemans and Sebastiaan Ram and Fr{\'e}d{\'e}rique Meeuwsen and Carlijn Lems and Jeroen van der Laak and Geert Litjens and Francesco Ciompi},
  booktitle={Submitted to Medical Imaging with Deep Learning},
  year={2025},
  url={https://openreview.net/forum?id=aGPowreqPi},
  note={under review}
}

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

polysome-0.1.0.tar.gz (110.4 kB view details)

Uploaded Source

Built Distribution

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

polysome-0.1.0-py3-none-any.whl (110.2 kB view details)

Uploaded Python 3

File details

Details for the file polysome-0.1.0.tar.gz.

File metadata

  • Download URL: polysome-0.1.0.tar.gz
  • Upload date:
  • Size: 110.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for polysome-0.1.0.tar.gz
Algorithm Hash digest
SHA256 47a33707543de74def328b91915d6a3ab30d7ff5a66dfc7c8c2ea33ffb7701fe
MD5 93de57d9832705178144ead4b828bdf4
BLAKE2b-256 bd5d9674eac0c9b55c25eadec861305c4dfea9e1a76f43ba49a72efab0fe7bb1

See more details on using hashes here.

File details

Details for the file polysome-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polysome-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 110.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for polysome-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 590ab537711b509686b00c4ae95d3a8b3657031a971b05245258ea74bbefde9a
MD5 cdd7eb21d81c6255e609ba6766a1c278
BLAKE2b-256 39f655ea59179bc829aa59c026f2349f4ea44de0f7a03f9c0e44075177c48aa1

See more details on using hashes here.

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