ludwig README

The project's README from github.com/ludwig-ai/ludwig. As one markdown file: README.md.

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

PyPI version Discord DockerHub Downloads License X

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 file
model_type: llm
base_model: meta-llama/Llama-3.1-8B
adapter:
  type: lora
trainer:
  type: finetune
  epochs: 3
input_features:
  - name: instruction
    type: text
output_features:
  - name: response
    type: 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

Feature Description
PatchTST & N-BEATS encoders State-of-the-art timeseries forecasting encoders with MASE/sMAPE metrics
Advanced PEFT adapters PiSSA, EVA, CorDA/LoftQ initializers; TinyLoRA, OFT, HRA, WaveFT, LN-Tuning, VBLoRA, C3A adapter types
VLM fine-tuning Train LLaVA, Qwen2-VL, InternVL via is_multimodal: true with gated cross-attention
HyperNetwork combiner Conditioning-based feature fusion — one feature generates weights for others
Nash-MTL & Pareto-MTL Game-theoretic and preference-based multi-task loss balancing
LLM config generation ludwig generate_config "describe your task" — LLM writes the YAML for you
ModelInspector Architecture analysis, weight collection, feature importance proxy
Ray Serve & KServe Distributed and Kubernetes-native model deployment shims
GRPO alignment Reward-model-free RLHF via Group Relative Policy Optimization
torchao quantization + QAT PyTorch-native int4/int8/float8 with Quantization-Aware Training
Multi-adapter PEFT Multiple named LoRA adapters with weighted merging (TIES, DARE, SVD)
Native Optuna executor GPT/TPE/CMA-ES samplers, pruning, resumable SQLite/PostgreSQL storage
Timeseries forecasting model.forecast(dataset, horizon=N) API with TimeseriesOutputFeature
Muon & ScheduleFreeAdamW New optimizers for large-scale pretraining and fine-tuning
Image segmentation decoders UNet, 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:

Technique Config key
Supervised fine-tuning (SFT) trainer.type: finetune
DPO / KTO / ORPO / GRPO alignment trainer.type: dpo (or kto, orpo, grpo)
LoRA / DoRA / VeRA / PiSSA adapter.type: lora (or dora, vera, lora + init_weights: pissa)
4-bit QLoRA (bitsandbytes) quantization.bits: 4
torchao + QAT quantization.backend: torchao
Multi-adapter with merging adapters: dict + merge: block
VLM (vision-language) is_multimodal: true
model_type: llm
base_model: meta-llama/Llama-3.1-8B

quantization:
  bits: 4

adapter:
  type: lora

prompt:
  template: |
    ### Instruction: {instruction}
    ### Input: {input}
    ### Response:

input_features:
  - name: prompt
    type: text

output_features:
  - name: output
    type: text

trainer:
  type: finetune
  learning_rate: 0.0001
  batch_size: 1
  gradient_accumulation_steps: 16
  epochs: 3
  learning_rate_scheduler:
    decay: cosine
    warmup_fraction: 0.01

backend:
  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_text
    type: text
    encoder:
      type: bert
  - name: star_rating
    type: number
  - name: product_image
    type: image
    encoder:
      type: dinov2

output_features:
  - name: recommended
    type: 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 Case Link
LLM instruction tuning (LoRA + QLoRA) examples/llm
DPO / GRPO alignment examples/llm/alignment
Advanced PEFT (PiSSA, OFT, VBLoRA, …) examples/llms/peft_advanced
VLM fine-tuning (LLaVA, Qwen2-VL) examples/vlm

Tabular & Multimodal

Use Case Link
Binary classification (Titanic) examples/titanic
Tabular classification (census income) examples/adult_census_income
Multimodal classification examples/multimodal_classification
Multi-task learning examples/multi_task

Timeseries & Vision

Use Case Link
Timeseries forecasting (PatchTST, N-BEATS) examples/forecasting
Weather forecasting examples/weather
Image classification (MNIST) examples/mnist
Semantic segmentation examples/semantic_segmentation

NLP & Audio

Use Case Link
Text classification examples/text_classification
Named entity recognition examples/ner_tagging
Machine translation examples/machine_translation
Speech recognition examples/speech_recognition
Speaker verification examples/speaker_verification

Why Ludwig?


Publications


Community

Discord

ludwig (ludwig-ai/ludwig)

Searching Database…

11.8K ·GitHub
这是什么?Ludwig 是一个声明式深度学习框架,让你可以训练、微调和部署 AI 模型,从大语言模型微调到表格分类都能做。只需一个 YAML 配置文件,几乎不用编写 Python 样板代码。
这是我可以导入的库,还是可以在命令行中运行的工具?两者都是。它是一个带命令行工具的 Python 框架,完全由 YAML 配置驱动,命令包括 ludwig train、ludwig experiment 和 ludwig serve,因此你无需自己编写训练循环或数据管道代码。
我该如何让它运行起来?在 Python 3.12+ 上安装(完整依赖矩阵请查看 CONTRIBUTING),编写一个描述输入/输出特征的 YAML 配置文件,然后运行 ludwig train 或 ludwig experiment 等命令,或者用 ludwig serve 启动 REST API。
它底层用的是什么技术栈?核心技术栈包括 Python 3.12、PyTorch 2.7+、Pydantic 2 和 Transformers 5,另外还引入了 Ray 2.54,用于分布式训练和超参数搜索。
把数据集快速变成训练好的模型,最快的方法是什么?编写一个 YAML 配置,列出输入/输出特征,然后运行 ludwig train。Ludwig 的 AutoML 模块(ludwig.automl.autotrain())甚至可以在只提供数据集和时间预算的情况下自动生成配置。
它能用对齐技术微调 Llama 或 Qwen 这类模型吗?可以。它支持从监督微调到 DPO/KTO/ORPO/GRPO 对齐的全流程,还支持 PEFT 适配器(LoRA、DoRA、VeRA、PiSSA),以及针对 LLaVA、Qwen2-VL 等模型的 VLM 微调。
模型训练好之后,我该如何部署?可以通过内置的 FastAPI REST 服务器(ludwig serve)提供服务,导出到 vLLM 以实现兼容 OpenAI 的服务,或使用 Ray Serve、Kubernetes 原生的 KServe 进行部署。导出格式包括 SafeTensors、ONNX 和 torch.export。
Ludwig 只能处理大语言模型吗?不是。同一套声明式配置还可以驱动表格分类/回归、图像分类和分割、时间序列预测(PatchTST、N-BEATS)、命名实体识别(NER)以及语音识别。
Creator
ludwig-ai
Size
34.9 MB
Stars
11.8K
Age
7y
Commits · 90 Days