Skip to content
swaleioPublic

About

Swale's example workflow definitions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Swale example workflows

Ready-to-run Swale workflows for the jobs machine-learning teams run over and over: batch inference and labeling with an LLM, building datasets from documents, images and audio, fine-tuning and aligning models, evaluating, merging, quantizing and serving them. Each workflow is a YAML file built from the task definitions published by swaleio on Swale Hub, and splits its job into separate tasks, so a run's graph shows each step, its logs and its outputs, and only the steps that need a GPU hold one.

Some workflows also run short Python scripts kept next to them in this repository. Those workflows clone this repository at the branch, tag or full commit SHA their examples_ref input names, main by default; pin a commit's full SHA to keep a workflow's scripts fixed.

Running a workflow

  1. Clone this repository, or download a workflow's workflow.yaml, and add it to a project with the CLI or with Add Workflow → Upload File in the app:

    swale workflow create --project-name my-project --file workflows/generate-responses/workflow.yaml

    Import from GitHub reads only repositories on GitHub accounts that the Swale GitHub App is installed on and that your GitHub user can access, so it cannot read this repository. To import a workflow from GitHub instead, fork this repository to such an account and import it from your fork.

  2. Workflows that download gated models or upload to the Hugging Face Hub read a secret named hf_token; uploading needs a token with write access. Every upload step runs only when its hub_repo input is set.

  3. Start a run, overriding any input:

    swale workflow run start --project-name my-project --workflow-id <id> --input limit=50

The Swale documentation covers workflows, task definitions and compute types.

Layout

workflows/<name>/workflow.yaml   the workflow
workflows/<name>/README.md       what it does, its steps, inputs, outputs and licenses
workflows/<name>/*.py            the scripts it runs, if any
requirements/*.txt               the pinned packages scripts install
tools/check_workflows.py         the check CI runs on every workflow

Workflows

Inference, labeling and evaluation with LLMs

Workflow What it does GPU steps
generate-responses Answers every prompt in a dataset with a chat model, as Parquet vLLM batch
label-text Labels texts with one of a fixed set of labels and measures agreement vLLM batch
classify-images Labels images with a vision-language model and measures agreement vLLM batch
detect-objects Finds objects as bounding boxes with a vision-language model vLLM batch
caption-video Captions a video frame by frame and summarizes it vLLM batch
ocr-pages Transcribes a PDF page by page with a vision-language model vLLM batch
synthetic-reasoning-data Builds a chain-of-thought dataset, judged against references vLLM batch
llm-as-a-judge Scores a model's answers from 1 to 10 with a judge model vLLM batch

Datasets from documents, images, audio and text

Workflow What it does GPU steps
pdfs-to-markdown Converts PDFs to a Markdown dataset with Docling, one task per PDF none
scans-to-text Reads scanned pages with Tesseract, one task per scan none
transcribe-audio Transcribes audio or video files with whisper.cpp, one task per file whisper.cpp
speech-dataset Builds a speech-recognition dataset of transcribed clips whisper.cpp
dataset-statistics Profiles, filters, deduplicates and re-packs a Parquet dataset none
embed-dataset Embeds every row with Text Embeddings Inference and parallel clients TEI
retrieval-index Builds a RAG index from PDFs and answers a test query TEI
semantic-deduplication Drops rows that mean nearly the same vLLM batch
entity-extraction Extracts named entities of types you name with GLiNER none
web-text-curation Filters and deduplicates web text with datatrove none

Training and aligning language models

Workflow What it does GPU steps
fine-tune-evaluate-quantize Fine-tunes, evaluates, converts to GGUF, quantizes and publishes TRL SFT, lm-eval
compare-fine-tunes Fine-tunes twice with different settings and compares scores TRL SFT, lm-eval
train-then-serve Fine-tunes a model and serves it with vLLM in the same run TRL SFT, vLLM
dpo-alignment Aligns a model with DPO and measures its win rate with a judge TRL DPO, vLLM batch
kto-alignment Aligns a model with KTO and measures its win rate with a judge TRL KTO, vLLM batch
reward-model Trains a reward model and scores held-out preference pairs TRL reward
grpo-math Trains math reasoning with GRPO and a checked reward TRL GRPO, lm-eval
rloo-math Trains math reasoning with RLOO and a checked reward TRL RLOO, lm-eval
distill-model Distills a larger model into a smaller one TRL distillation, lm-eval
fine-tune-vision-language-model Fine-tunes a vision-language model and compares accuracy TRL SFT, vLLM batch

Merging, quantizing and serving

Workflow What it does GPU steps
merge-models Merges two fine-tunes with mergekit and scores all three lm-eval
quantize-and-pick Quantizes to several presets and keeps the smallest good one llama.cpp
score-gguf Scores a GGUF model's math answers on a CPU, with parallel clients none by default

Training task-specific models with scripts

Workflow What it does GPU steps
text-classification Fine-tunes an encoder to classify text training, prediction
text-regression Fine-tunes an encoder to predict a number per text training, prediction
token-classification Fine-tunes an encoder to tag named entities training, tagging
extractive-question-answering Fine-tunes a model to find answers in long documents training, scoring tokens
summarization Fine-tunes a sequence-to-sequence model to summarize training, generation
translation Fine-tunes a translation model training, generation
sentence-embeddings Fine-tunes a sentence-embedding model for retrieval training, embedding
setfit-classifier Trains a few-shot classifier with SetFit training, prediction
image-classification Fine-tunes a vision transformer to classify images training, prediction
image-regression Fine-tunes a vision transformer to predict a number per image training, prediction
object-detection Fine-tunes an object detector and scores its mAP training, detection
tabular-gradient-boosting Trains gradient-boosted trees on a table none

Each workflow's README lists its steps, says which part stays one script and why, and gives the licenses of its default model, data and the packages its scripts install.

Licenses

The workflows, scripts and tools in this repository are licensed under the MIT License. The models, datasets, documents and packages they use keep their own licenses, listed in each workflow's README. Defaults are chosen under licenses that allow commercial use; check the license of anything you put in their place.

About

Swale's example workflow definitions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages