A domain-agnostic framework for orchestrating LLM-based data generation workflows
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 or features:
# vLLM (Recommended for Linux + NVIDIA GPU)
pip install "polysome[vllm]"
# llama.cpp (Recommended for CPU or Apple Silicon)
pip install "polysome[llama-cpp]"
# UI / Prompt Editor
pip install "polysome[ui]"
# Install everything (for development/testing)
pip install "polysome[all]"
Convenience aliases:
pip install "polysome[gpu]"→ installsvllmstackpip install "polysome[cpu]"→ installsllama-cppstack
🔑 Hugging Face Authentication
Many models (like Gemma-3) are gated and require authentication. Before running workflows with these models, log in via the CLI:
pip install huggingface_hub
huggingface-cli login
Alternatively, set the HF_TOKEN environment variable.
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 configurationsprompts/- Prompt templates for your tasksdata/- 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
-
Edit your workflow (
workflows/basic_text_generation.json):- Change the model name (default:
google/gemma-3-4b-it) - Adjust generation parameters
- Add or remove processing nodes
- Change the model name (default:
-
Customize prompts (
prompts/simple_qa/):system_prompt.txt: Define the AI's roleuser_prompt.txt: Template with variables like{{ question }}few_shot.jsonl: Example inputs and outputs
-
Prepare your data (
data/input.json):- Format as JSON with fields matching your prompt variables
-
Run and iterate:
polysome run workflows/basic_text_generation.json
Using Docker (Alternative)
For reproducible environments or deployment:
# Run with Docker
docker run --rm --gpus all \
-v ./data:/data \
-v ./output:/output \
-v ./workflows:/workflows \
-v ./prompts:/prompts \
-v ~/.cache/huggingface:/root/.cache/huggingface \
-e WORKFLOW_PATH=/workflows/basic_text_generation.json \
ghcr.io/computationalpathologygroup/polysome:latest
Note: We recommend mounting your Hugging Face cache to avoid re-downloading models.
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
polysome-gui
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polysome-0.1.1.tar.gz.
File metadata
- Download URL: polysome-0.1.1.tar.gz
- Upload date:
- Size: 132.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c9d4a9fa6f0e292742d9c35920198e63085598fc93d8768fb1ddec3e99f17e8
|
|
| MD5 |
ae9bae7844a2d917d61c5d9f913f8cea
|
|
| BLAKE2b-256 |
705ce3c90652a457dc77497fb50a0ab297c6716c0e4c7db6579a49dadc226b34
|
File details
Details for the file polysome-0.1.1-py3-none-any.whl.
File metadata
- Download URL: polysome-0.1.1-py3-none-any.whl
- Upload date:
- Size: 129.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
723794a37a93d669baaf5285a83bec17e8303aeea80d39edaeb64020a0198a39
|
|
| MD5 |
99bee57404e994f1cc2fa332bb8cc713
|
|
| BLAKE2b-256 |
6bd5e85ff2f1fddae06a74d3bd9566c97887a0da09bcf652b59f5c58b5e57238
|