Skip to content

Latest commit

History

4,138 Commits

Folders and files

NameName
Last commit message
Last commit date

Declarative deep learning framework for LLMs, multimodal models, and tabular AI.

PyPI versionDiscordDockerHubDownloadsLicenseX

Docs · Getting Started · Examples · Discord


What is Ludwig?

Ludwig is a declarative deep learning framework that lets you train, fine-tune, and deploy AI models — from LLM fine-tuning to tabular classification — using a YAML config file and zero boilerplate Python.

# Fine-tune Llama-3.1 with LoRA in one config filemodel_type: llmbase_model: meta-llama/Llama-3.1-8Badapter:
type: loratrainer:
type: finetuneepochs: 3input_features:
- name: instructiontype: textoutput_features:
- name: responsetype: text
ludwig train --config model.yaml --dataset my_data.csv

Tech stack: Python 3.12 · PyTorch 2.7+ · Pydantic 2 · Transformers 5 · Ray 2.54

Ludwig is hosted by the Linux Foundation AI & Data.


What's New in Ludwig 0.16

FeatureDescription
PatchTST & N-BEATS encodersState-of-the-art timeseries forecasting encoders with MASE/sMAPE metrics
Advanced PEFT adaptersPiSSA, EVA, CorDA/LoftQ initializers; TinyLoRA, OFT, HRA, WaveFT, LN-Tuning, VBLoRA, C3A adapter types
VLM fine-tuningTrain LLaVA, Qwen2-VL, InternVL via is_multimodal: true with gated cross-attention
HyperNetwork combinerConditioning-based feature fusion — one feature generates weights for others
Nash-MTL & Pareto-MTLGame-theoretic and preference-based multi-task loss balancing
LLM config generationludwig generate_config "describe your task" — LLM writes the YAML for you
ModelInspectorArchitecture analysis, weight collection, feature importance proxy
Ray Serve & KServeDistributed and Kubernetes-native model deployment shims
GRPO alignmentReward-model-free RLHF via Group Relative Policy Optimization
torchao quantization + QATPyTorch-native int4/int8/float8 with Quantization-Aware Training
Multi-adapter PEFTMultiple named LoRA adapters with weighted merging (TIES, DARE, SVD)
Native Optuna executorGPT/TPE/CMA-ES samplers, pruning, resumable SQLite/PostgreSQL storage
Timeseries forecastingmodel.forecast(dataset, horizon=N) API with TimeseriesOutputFeature
Muon & ScheduleFreeAdamWNew optimizers for large-scale pretraining and fine-tuning
Image segmentation decodersUNet, SegFormer, FPN decoders for semantic segmentation

Installation

pip install ludwig # core
pip install ludwig[full] # all optional dependencies
pip install ludwig[llm] # LLM fine-tuning only

Requires Python 3.12+. See contributing for a full dependency matrix.


Quick Start

Fine-tune an LLM (instruction tuning)

Open In Colab

Ludwig supports the full LLM fine-tuning spectrum:

TechniqueConfig key
Supervised fine-tuning (SFT)trainer.type: finetune
DPO / KTO / ORPO / GRPO alignmenttrainer.type: dpo (or kto, orpo, grpo)
LoRA / DoRA / VeRA / PiSSAadapter.type: lora (or dora, vera, lora + init_weights: pissa)
4-bit QLoRA (bitsandbytes)quantization.bits: 4
torchao + QATquantization.backend: torchao
Multi-adapter with mergingadapters: dict + merge: block
VLM (vision-language)is_multimodal: true
model_type: llmbase_model: meta-llama/Llama-3.1-8Bquantization:
bits: 4adapter:
type: loraprompt:
template: | ### Instruction: {instruction} ### Input: {input} ### Response:input_features:
- name: prompttype: textoutput_features:
- name: outputtype: texttrainer:
type: finetunelearning_rate: 0.0001batch_size: 1gradient_accumulation_steps: 16epochs: 3learning_rate_scheduler:
decay: cosinewarmup_fraction: 0.01backend:
type: local
export HUGGING_FACE_HUB_TOKEN="<your_token>"
ludwig train --config model.yaml --dataset "ludwig://alpaca"

Train a multimodal classifier

input_features:
- name: review_texttype: textencoder:
type: bert
- name: star_ratingtype: number
- name: product_imagetype: imageencoder:
type: dinov2output_features:
- name: recommendedtype: binary
ludwig train --config model.yaml --dataset reviews.csv

Generate a config from natural language

ludwig generate_config "I have a CSV with age, income, education level, and I want to predict loan default"

Make predictions

ludwig predict --model_path results/experiment_run/model --dataset new_data.csv

Launch a REST API

ludwig serve --model_path results/experiment_run/model
# POST http://localhost:8000/predict

Capabilities

LLM Fine-Tuning
  • Supervised fine-tuning (SFT) on instruction/response pairs
  • Alignment training: DPO, KTO, ORPO, GRPO (reward-model-free RLHF)
  • PEFT adapters: LoRA, DoRA, VeRA, LoRA+, TinyLoRA, OFT, HRA, WaveFT, LN-Tuning, VBLoRA, C3A
  • LoRA initializers: PiSSA, EVA, CorDA, LoftQ for improved convergence
  • Multi-adapter PEFT: multiple named adapters on one base model, switchable at runtime; merge with TIES, DARE, SVD, magnitude pruning
  • Quantization: 4-bit/8-bit QLoRA (bitsandbytes), torchao int4/int8/float8 with QAT
  • VLM fine-tuning: LLaVA, Qwen2-VL, InternVL via is_multimodal: true
  • Sequence packing for efficient training on variable-length inputs
  • Paged and 8-bit optimizers for memory-efficient training
Multimodal & Tabular Models
  • Input modalities: text, numbers, categories, binary, sets, bags, sequences, images, audio, timeseries, vectors, dates
  • Text encoders: any HuggingFace Transformer (BERT, RoBERTa, ModernBERT, Qwen3, Llama-3.1, etc.), plus Mamba-2, Jamba
  • Image encoders: DINOv2, ConvNeXt, EfficientNet, ViT, CAFormer, ConvFormer, PoolFormer, TIMM (1000+ models)
  • Timeseries encoders: PatchTST, N-BEATS, CNN, RNN, Transformer; MASE and sMAPE metrics; model.forecast() API
  • Combiners: concat, transformer, tab_transformer, FT-Transformer, TabNet, TabPFN v2, HyperNetwork, ProjectAggregate, GatedFusion, Perceiver
  • Multi-task learning: multiple output features in a single model; Nash-MTL, Pareto-MTL, FAMO, GradNorm, uncertainty loss balancing
  • Image segmentation: UNet, SegFormer, FPN decoders
Training Infrastructure
  • Distributed training: HuggingFace Accelerate with DDP, FSDP, DeepSpeed (zero-code changes)
  • Ray backend: training across a Ray cluster, larger-than-memory datasets via Ray Data
  • Automatic batch size selection and learning rate range test
  • Mixed precision (fp16/bf16), gradient checkpointing, gradient accumulation
  • Optimizers: AdamW, Adafactor, SGD, Muon, ScheduleFreeAdamW, Lion, paged/8-bit variants
  • Learning rate schedulers: cosine, linear, polynomial, reduce-on-plateau, OneCycleLR
  • Model Soup: uniform and greedy checkpoint averaging for better generalization at zero inference cost
  • Modality dropout for robust multimodal models
Hyperparameter Optimization
  • Executors: Ray Tune (ASHA, PBT, Bayesian) and native Optuna (auto/GP/TPE/CMA-ES)
  • Optuna persistence: SQLite or PostgreSQL for resumable HPO runs
  • Pruning with Optuna's MedianPruner and HyperbandPruner
  • Search spaces: uniform, log-uniform, choice, randint, quantized
  • Full Ludwig config is searchable — any nested parameter can be a hyperparameter
Production & Deployment
  • REST API: FastAPI server with Prometheus metrics and structured logging (ludwig serve)
  • vLLM serving: OpenAI-compatible API with PagedAttention and continuous batching
  • Ray Serve: distributed deployment with auto-scaling and traffic splitting
  • KServe: Kubernetes-native deployment with Open Inference Protocol v2
  • Model export: SafeTensors (default), torch.export.pt2 bundles, ONNX
  • HuggingFace Hub: ludwig upload hf_hub — push model + auto-generated model card
  • Docker: prebuilt containers at ludwigai/ludwig
Tooling & Integrations
  • Experiment tracking: TensorBoard, Weights & Biases, Comet ML, MLflow, Aim Stack
  • Model inspection: ModelInspector — weight enumeration, architecture summary, feature importance proxy
  • Visualizations: learning curves, confusion matrices, calibration plots, ROC curves, hyperopt analysis
  • AutoML: ludwig.automl.auto_train() — give it a dataset and a time budget; the YAML-driven search space samples encoder/combiner/decoder combinations and validates them before training
  • Dataset quality checks: from ludwig.utils.dataset_quality import check_dataset_quality — validates a DataFrame before training (missing values, class imbalance, near-duplicate columns, ID leakage, …)
  • OpenML integration: load any OpenML task directly — OpenMLLoader fetches by task ID and caches locally as Parquet
  • LLM config generation: ludwig generate_config "describe your task" — LLM writes the YAML
  • K-fold cross-validation: ludwig experiment --k_fold N
  • Dataset Zoo: 70+ built-in benchmark datasets (ludwig://mnist, ludwig://alpaca, …)

Examples

LLM & Alignment

Use CaseLink
LLM instruction tuning (LoRA + QLoRA)examples/llm
DPO / GRPO alignmentexamples/llm/alignment
Advanced PEFT (PiSSA, OFT, VBLoRA, …)examples/llms/peft_advanced
VLM fine-tuning (LLaVA, Qwen2-VL)examples/vlm

Tabular & Multimodal

Use CaseLink
Binary classification (Titanic)examples/titanic
Tabular classification (census income)examples/adult_census_income
Multimodal classificationexamples/multimodal_classification
Multi-task learningexamples/multi_task

Timeseries & Vision

Use CaseLink
Timeseries forecasting (PatchTST, N-BEATS)examples/forecasting
Weather forecastingexamples/weather
Image classification (MNIST)examples/mnist
Semantic segmentationexamples/semantic_segmentation

NLP & Audio

Use CaseLink
Text classificationexamples/text_classification
Named entity recognitionexamples/ner_tagging
Machine translationexamples/machine_translation
Speech recognitionexamples/speech_recognition
Speaker verificationexamples/speaker_verification

Why Ludwig?

  • Zero boilerplate — no training loop, no data pipeline, no evaluation code. The YAML config is the entire program.
  • Best-in-class LLM support — full spectrum from LoRA to GRPO alignment, torchao QAT, and VLM fine-tuning, all in config.
  • Multimodal out of the box — mix text, images, numbers, audio, and timeseries with one config change.
  • Scale without code changes — go from laptop → multi-GPU → Ray cluster by changing backend.type.
  • Expert control when you need it — every activation function, scheduler, and optimizer is configurable.
  • Reproducible research — every run is logged and the full config is saved. Compare experiments with ludwig visualize.

Publications


Community

Discord