# Ludwig

> Declarative deep learning: train and fine-tune AI models from a YAML config

- Category: Training & Fine-Tuning / AutoML & Low-Code Training
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/ludwig-ai/ludwig
- Website: https://ludwig.ai
- Canonical page: https://ai-tldr.dev/tools/ludwig/

## In short

Ludwig is a declarative deep learning framework that lets you train, fine-tune, and deploy AI models with a YAML config file instead of hand-written training code. You describe your input and output features and the kind of model you want, and Ludwig handles the rest. It sits in the AutoML & Low-Code Training category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Ludwig is a declarative deep learning framework that lets you train, fine-tune, and deploy AI models with a YAML config file instead of hand-written training code. You describe your input and output features and the kind of model you want, and Ludwig handles the rest.

It covers a wide range of tasks in one tool, from LLM instruction tuning to multimodal classifiers that mix text, numbers, and images, all the way to tabular prediction. Because the model is defined as configuration, you can swap encoders, adapters, and trainers by editing a few lines rather than rewriting code.

Ludwig is hosted by the Linux Foundation AI & Data and builds on PyTorch, Transformers, and Ray, so the same config can run locally or scale out to distributed training and deployment.

## What it does

- Define an entire model, its features, encoders, and trainer, in a single declarative YAML config
- Fine-tune LLMs with LoRA, DoRA, QLoRA, and other PEFT adapters, plus 4-bit and 8-bit quantization
- Alignment training without a separate reward model via DPO, KTO, ORPO, and GRPO
- Build multimodal and tabular models that mix text, numbers, categories, images, audio, and timeseries inputs
- Generate a starting config from a plain-English description with the generate_config command
- Run predictions in batch or serve a model behind a REST API with a single command

## Getting started

Ludwig requires Python 3.12+. Install it with pip, write a YAML config for your task, then train and serve with the command-line tool.

1. Install Ludwig

   Install the core package, or add an extra for all dependencies or for LLM fine-tuning only.

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

2. Write a config

   Describe the model in a YAML file. This example fine-tunes Llama-3.1 with a LoRA adapter on instruction and response text.

```yaml
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
```

3. Train your model

   Point the train command at your config and dataset to start training.

```bash
ludwig train --config model.yaml --dataset my_data.csv
```

4. Predict or serve

   Run batch predictions against a trained model, or launch a REST API to serve it.

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

## When to use it

- Fine-tuning open LLMs like Llama-3.1 with LoRA or QLoRA on your own instruction data
- Aligning a model with DPO, KTO, ORPO, or GRPO without standing up a separate reward model
- Building multimodal classifiers that combine text reviews, numeric ratings, and product images
- Training tabular prediction models, such as loan default scoring, from a CSV without writing training code
- Serving a trained model behind a REST API for downstream applications
