Skip to main content

Examples

Each example is a complete workflow for a machine-learning job, built from task definitions on Swale Hub. Its page lists its steps and the task definitions they run, its inputs and output, and the whole workflow file, with the commands that add it to a project and start a run.

The examples come from the swaleio/examples repository on GitHub.

Run an example​

New to Swale? Getting started takes you from a new account to your first run. Every example then runs the same way, as Run it on its page shows: add its workflow file to a project, create the secrets it reads, and start a run.

Inference, labeling and evaluation with LLMs​

ExampleWhat it doesGPU steps
Generate responses over a datasetAnswers every prompt in a dataset with a chat model, as ParquetvLLM batch
Label a text dataset with an LLMLabels texts with one of a fixed set of labels and measures agreementvLLM batch
Classify images with a vision-language modelLabels images with a vision-language model and measures agreementvLLM batch
Detect objects with a vision-language modelFinds objects as bounding boxes with a vision-language modelvLLM batch
Caption a videoCaptions a video frame by frame and summarizes itvLLM batch
OCR pages with a vision-language modelTranscribes a PDF page by page with a vision-language modelvLLM batch
Generate synthetic chain-of-thought dataBuilds a chain-of-thought dataset, judged against referencesvLLM batch
Score answers with an LLM as a judgeScores a model's answers from 1 to 10 with a judge modelvLLM batch

Datasets from documents, images, audio and text​

ExampleWhat it doesGPU steps
Convert PDFs to a Markdown datasetConverts PDFs to a Markdown dataset with Docling, one task per PDFnone
Extract text from scanned images with TesseractReads scanned pages with Tesseract, one task per scannone
Transcribe audioTranscribes audio or video files with whisper.cpp, one task per filewhisper.cpp
Build a speech datasetBuilds a speech-recognition dataset of transcribed clipswhisper.cpp
Profile, filter and re-pack a datasetProfiles, filters, deduplicates and re-packs a Parquet datasetnone
Embed a datasetEmbeds every row with Text Embeddings Inference and parallel clientsTEI
Build a retrieval indexBuilds a RAG index from PDFs and answers a test queryTEI
Remove semantic duplicates from a datasetDrops rows that mean nearly the samevLLM batch
Extract named entities with GLiNERExtracts named entities of types you name with GLiNERnone
Curate web text with datatroveFilters and deduplicates web text with datatrovenone

Training and aligning language models​

ExampleWhat it doesGPU steps
Fine-tune, evaluate, quantize and publishFine-tunes, evaluates, converts to GGUF, quantizes and publishesTRL SFT, lm-eval
Compare two fine-tunesFine-tunes twice with different settings and compares scoresTRL SFT, lm-eval
Fine-tune a model then serve it with vLLMFine-tunes a model and serves it with vLLM in the same runTRL SFT, vLLM
Align a model with DPOAligns a model with DPO and measures its win rate with a judgeTRL DPO, vLLM batch
Align a model with KTOAligns a model with KTO and measures its win rate with a judgeTRL KTO, vLLM batch
Train a reward modelTrains a reward model and scores held-out preference pairsTRL reward
Train math reasoning with GRPOTrains math reasoning with GRPO and a checked rewardTRL GRPO, lm-eval
Train math reasoning with RLOOTrains math reasoning with RLOO and a checked rewardTRL RLOO, lm-eval
Distill a larger model into a smaller oneDistills a larger model into a smaller oneTRL distillation, lm-eval
Fine-tune a vision-language modelFine-tunes a vision-language model and compares accuracyTRL SFT, vLLM batch

Merging, quantizing and serving​

ExampleWhat it doesGPU steps
Merge two fine-tunesMerges two fine-tunes with mergekit and scores all threelm-eval
Quantize a model and pick the best presetQuantizes to several presets and keeps the smallest good onellama.cpp
Score a GGUF model on a CPUScores a GGUF model's math answers on a CPU, with parallel clientsnone by default

Training task-specific models with scripts​

ExampleWhat it doesGPU steps
Fine-tune an encoder for text classificationFine-tunes an encoder to classify texttraining, prediction
Fine-tune an encoder for text regressionFine-tunes an encoder to predict a number per texttraining, prediction
Fine-tune an encoder for token classificationFine-tunes an encoder to tag named entitiestraining, tagging
Fine-tune a model for extractive question answeringFine-tunes a model to find answers in long documentstraining, scoring tokens
Fine-tune a model to write news summariesFine-tunes a sequence-to-sequence model to summarizetraining, generation
Fine-tune a translation modelFine-tunes a translation modeltraining, generation
Fine-tune sentence embeddings for retrievalFine-tunes a sentence-embedding model for retrievaltraining, embedding
Train a few-shot classifier with SetFitTrains a few-shot classifier with SetFittraining, prediction
Fine-tune a vision transformer for image classificationFine-tunes a vision transformer to classify imagestraining, prediction
Fine-tune a vision transformer for image regressionFine-tunes a vision transformer to predict a number per imagetraining, prediction
Fine-tune an object detection modelFine-tunes an object detector and scores its mAPtraining, detection
Train a gradient-boosted model on tabular dataTrains gradient-boosted trees on a tablenone