Convert Figma logo to code with AI

ludwig-ai logoludwig

Low-code framework for building custom LLMs, neural networks, and other AI models

11,137
1,193
11,137
266

Top Related Projects

14,014

An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.

33,421

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.

18,503

Open source platform for the machine learning lifecycle

10,708

A hyperparameter optimization framework

3,881

A fast library for AutoML and tuning. Join our Discord: https://discord.gg/Cppx2vSPVP.

17,783

Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.

Quick Overview

Ludwig is an open-source, declarative machine learning framework developed by Uber. It allows users to train and evaluate deep learning models without writing code, using a simple configuration file to define model architecture and training parameters. Ludwig supports a wide range of tasks, including natural language processing, computer vision, and tabular data analysis.

Pros

  • Easy to use, with a declarative approach that requires minimal coding
  • Supports a wide range of machine learning tasks and data types
  • Highly customizable and extensible
  • Integrates well with popular data science tools and frameworks

Cons

  • May have a steeper learning curve for users unfamiliar with YAML configuration files
  • Less flexibility compared to writing custom models from scratch
  • Performance may not always match highly optimized, task-specific models
  • Documentation can be sparse for some advanced features

Code Examples

  1. Training a text classification model:
from ludwig.api import LudwigModel

config = {
    'input_features': [{'name': 'text', 'type': 'text'}],
    'output_features': [{'name': 'class', 'type': 'category'}]
}

model = LudwigModel(config)
results = model.train(dataset='path/to/dataset.csv')
  1. Making predictions with a trained model:
predictions = model.predict(dataset='path/to/test_data.csv')
print(predictions)
  1. Visualizing model performance:
from ludwig.visualize import learning_curves, confusion_matrix

learning_curves(results.train_stats)
confusion_matrix(results.test_stats, top_n_classes=5)

Getting Started

To get started with Ludwig, follow these steps:

  1. Install Ludwig and its dependencies:
pip install ludwig
  1. Create a YAML configuration file (e.g., model_config.yaml) defining your model:
input_features:
    - name: text
      type: text
output_features:
    - name: class
      type: category
  1. Train your model:
from ludwig.api import LudwigModel

model = LudwigModel(config='model_config.yaml')
results = model.train(dataset='path/to/dataset.csv')
  1. Make predictions:
predictions = model.predict(dataset='path/to/test_data.csv')
print(predictions)

Competitor Comparisons

14,014

An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.

Pros of NNI

  • Broader scope: Supports AutoML, hyperparameter tuning, and neural architecture search across various frameworks
  • More extensive experiment management and visualization tools
  • Supports distributed training and multiple trial concurrency

Cons of NNI

  • Steeper learning curve due to its broader feature set
  • Less focus on declarative model definition compared to Ludwig
  • May be overkill for simpler machine learning tasks

Code Comparison

Ludwig:

input_features:
    - name: text
      type: text
output_features:
    - name: class
      type: category

NNI:

search_space = {
    'learning_rate': loguniform(0.0001, 0.1),
    'num_layers': choice(1, 2, 3, 4),
    'hidden_units': choice(128, 256, 512, 1024)
}

tuner = TPETuner(search_space)

Ludwig focuses on declarative model definition, while NNI emphasizes hyperparameter tuning and neural architecture search. Ludwig's YAML configuration is more straightforward for simple tasks, whereas NNI provides more flexibility for complex optimization scenarios.

33,421

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.

Pros of Ray

  • More versatile, supporting distributed computing across various domains
  • Larger community and ecosystem with extensive documentation
  • Better suited for large-scale distributed applications

Cons of Ray

  • Steeper learning curve due to its broader scope
  • May be overkill for simpler machine learning tasks
  • Less focused on AutoML compared to Ludwig

Code Comparison

Ray example:

import ray

@ray.remote
def f(x):
    return x * x

futures = [f.remote(i) for i in range(4)]
print(ray.get(futures))

Ludwig example:

from ludwig.api import LudwigModel

model = LudwigModel(config='config.yaml')
results = model.train(dataset='data.csv')
predictions = model.predict(dataset='test.csv')

Ray is a distributed computing framework that excels in scaling Python applications across clusters, while Ludwig focuses on simplifying the machine learning workflow with AutoML capabilities. Ray offers more flexibility for various distributed computing tasks, but Ludwig provides a more straightforward approach for building and training machine learning models without extensive coding.

18,503

Open source platform for the machine learning lifecycle

Pros of MLflow

  • More comprehensive MLOps platform, covering experiment tracking, model management, and deployment
  • Wider adoption and larger community support
  • Language-agnostic, supporting multiple programming languages and frameworks

Cons of MLflow

  • Steeper learning curve due to its broader feature set
  • May be overkill for simpler machine learning projects
  • Requires more setup and configuration compared to Ludwig

Code Comparison

MLflow:

import mlflow

mlflow.start_run()
mlflow.log_param("param1", value1)
mlflow.log_metric("metric1", value2)
mlflow.end_run()

Ludwig:

from ludwig.api import LudwigModel

model = LudwigModel(config)
results = model.train(dataset=train_data)
predictions = model.predict(dataset=test_data)

Ludwig focuses on simplifying the machine learning workflow with a declarative approach, while MLflow provides a more comprehensive suite of tools for managing the entire machine learning lifecycle. Ludwig offers a higher-level abstraction, making it easier for beginners to get started, whereas MLflow provides more flexibility and control over the ML process. The choice between the two depends on the specific needs of the project and the user's experience level.

10,708

A hyperparameter optimization framework

Pros of Optuna

  • More flexible and general-purpose hyperparameter optimization framework
  • Supports a wider range of optimization algorithms and search spaces
  • Integrates well with various machine learning libraries and frameworks

Cons of Optuna

  • Requires more manual configuration and code implementation
  • Less suitable for users seeking an end-to-end ML pipeline solution
  • May have a steeper learning curve for beginners in hyperparameter tuning

Code Comparison

Ludwig:

from ludwig.api import LudwigModel

model = LudwigModel(config)
results = model.train(dataset=train_data)
predictions = model.predict(dataset=test_data)

Optuna:

import optuna

def objective(trial):
    params = {
        'learning_rate': trial.suggest_loguniform('learning_rate', 1e-5, 1e-1),
        'max_depth': trial.suggest_int('max_depth', 1, 30),
    }
    model = YourModel(**params)
    return model.fit(X_train, y_train).score(X_test, y_test)

study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100)

Ludwig is designed for quick and easy model creation with minimal code, while Optuna provides a more customizable approach to hyperparameter optimization across various ML frameworks.

3,881

A fast library for AutoML and tuning. Join our Discord: https://discord.gg/Cppx2vSPVP.

Pros of FLAML

  • Focuses on automated machine learning (AutoML) with efficient hyperparameter optimization
  • Supports a wide range of ML tasks and integrates well with scikit-learn
  • Lightweight and easy to install with minimal dependencies

Cons of FLAML

  • Less comprehensive in terms of deep learning capabilities
  • Fewer built-in model architectures compared to Ludwig
  • Limited support for complex data preprocessing pipelines

Code Comparison

FLAML:

from flaml import AutoML
automl = AutoML()
automl.fit(X_train, y_train, task="classification")
predictions = automl.predict(X_test)

Ludwig:

from ludwig.api import LudwigModel
model = LudwigModel(config)
results = model.train(dataset=train_df)
predictions = model.predict(dataset=test_df)

Both FLAML and Ludwig aim to simplify machine learning workflows, but they have different focuses. FLAML excels in AutoML and efficient hyperparameter tuning, making it suitable for quick prototyping and optimization of traditional ML models. Ludwig, on the other hand, provides a more comprehensive deep learning framework with support for various data types and model architectures.

FLAML is more lightweight and integrates well with scikit-learn, while Ludwig offers a higher-level abstraction for building complex deep learning models. The choice between the two depends on the specific requirements of your project and the level of control you need over the model architecture.

17,783

Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.

Pros of Luigi

  • More mature project with a larger community and extensive documentation
  • Flexible workflow management system for complex data pipelines
  • Supports a wide range of task types and integrations

Cons of Luigi

  • Steeper learning curve compared to Ludwig
  • Requires more code and configuration for simple tasks
  • Less focus on machine learning and deep learning workflows

Code Comparison

Ludwig:

from ludwig.api import LudwigModel

model = LudwigModel(config)
results = model.train(dataset=train_data)
predictions = model.predict(dataset=test_data)

Luigi:

import luigi

class MyTask(luigi.Task):
    def requires(self):
        return SomeOtherTask()

    def run(self):
        # Task logic here
        pass

if __name__ == '__main__':
    luigi.run()

Summary

Ludwig is focused on simplifying machine learning workflows with a declarative approach, while Luigi is a more general-purpose task scheduler and workflow management system. Ludwig excels in quick prototyping and experimentation for ML projects, whereas Luigi shines in building complex data pipelines and managing dependencies between tasks. The choice between the two depends on the specific needs of your project and the level of control you require over the workflow.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Declarative deep learning framework built for scale and efficiency.

PyPI version Discord DockerHub Downloads License X

[!IMPORTANT] Our community has moved to Discord -- please join us there!

📖 What is Ludwig?

Ludwig is a low-code framework for building custom AI models like LLMs and other deep neural networks.

Key features:

  • 🛠 Build custom models with ease: a declarative YAML configuration file is all you need to train a state-of-the-art LLM on your data. Support for multi-task and multi-modality learning. Comprehensive config validation detects invalid parameter combinations and prevents runtime failures.
  • ⚡ Optimized for scale and efficiency: automatic batch size selection, distributed training (DDP, DeepSpeed), parameter efficient fine-tuning (PEFT), 4-bit quantization (QLoRA), paged and 8-bit optimizers, and larger-than-memory datasets.
  • 📐 Expert level control: retain full control of your models down to the activation functions. Support for hyperparameter optimization, explainability, and rich metric visualizations.
  • 🧱 Modular and extensible: experiment with different model architectures, tasks, features, and modalities with just a few parameter changes in the config. Think building blocks for deep learning.
  • 🚢 Engineered for production: prebuilt Docker containers, native support for running with Ray on Kubernetes, export models to Torchscript and Triton, upload to HuggingFace with one command.

Ludwig is hosted by the Linux Foundation AI & Data.

img

💾 Installation

Install from PyPi. Be aware that Ludwig requires Python 3.8+.

pip install ludwig

Or install with all optional dependencies:

pip install ludwig[full]

Please see contributing for more detailed installation instructions.

🚂 Getting Started

Want to take a quick peek at some of the Ludwig 0.8 features? Check out this Colab Notebook 🚀 Open In Colab

Looking to fine-tune Llama-2 or Mistral? Check out these notebooks:

  1. Fine-Tune Llama-2-7b: Open In Colab
  2. Fine-Tune Llama-2-13b: Open In Colab
  3. Fine-Tune Mistral-7b: Open In Colab

For a full tutorial, check out the official getting started guide, or take a look at end-to-end Examples.

Large Language Model Fine-Tuning

Open In Colab

Let's fine-tune a pretrained LLaMA-2-7b large language model to follow instructions like a chatbot ("instruction tuning").

Prerequisites

Running

We'll use the Stanford Alpaca dataset, which will be formatted as a table-like file that looks like this:

instructioninputoutput
Give three tips for staying healthy.1.Eat a balanced diet and make sure to include...
Arrange the items given below in the order to ...cake, me, eatingI eating cake.
Write an introductory paragraph about a famous...Michelle ObamaMichelle Obama is an inspirational woman who r...
.........

Create a YAML config file named model.yaml with the following:

model_type: llm
base_model: meta-llama/Llama-2-7b-hf

quantization:
  bits: 4

adapter:
  type: lora

prompt:
  template: |
    Below is an instruction that describes a task, paired with an input that may provide further context.
    Write a response that appropriately completes the request.

    ### 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

preprocessing:
  sample_ratio: 0.1

backend:
  type: local

And now let's train the model:

export HUGGING_FACE_HUB_TOKEN = "<api_token>"

ludwig train --config model.yaml --dataset "ludwig://alpaca"

Supervised ML

Let's build a neural network that predicts whether a given movie critic's review on Rotten Tomatoes was positive or negative.

Our dataset will be a CSV file that looks like this:

movie_titlecontent_ratinggenresruntimetop_criticreview_contentrecommended
Deliver Us from EvilRAction & Adventure, Horror117.0TRUEDirector Scott Derrickson and his co-writer, Paul Harris Boardman, deliver a routine procedural with unremarkable frights.0
BarbaraPG-13Art House & International, Drama105.0FALSESomehow, in this stirring narrative, Barbara manages to keep hold of her principles, and her humanity and courage, and battles to save a dissident teenage girl whose life the Communists are trying to destroy.1
Horrible BossesRComedy98.0FALSEThese bosses cannot justify either murder or lasting comic memories, fatally compromising a farce that could have been great but ends up merely mediocre.0
.....................

Download a sample of the dataset from here.

wget https://ludwig.ai/latest/data/rotten_tomatoes.csv

Next create a YAML config file named model.yaml with the following:

input_features:
  - name: genres
    type: set
    preprocessing:
      tokenizer: comma
  - name: content_rating
    type: category
  - name: top_critic
    type: binary
  - name: runtime
    type: number
  - name: review_content
    type: text
    encoder:
      type: embed
output_features:
  - name: recommended
    type: binary

That's it! Now let's train the model:

ludwig train --config model.yaml --dataset rotten_tomatoes.csv

Happy modeling

Try applying Ludwig to your data. Reach out on Discord if you have any questions.

❓ Why you should use Ludwig

  • Minimal machine learning boilerplate

    Ludwig takes care of the engineering complexity of machine learning out of the box, enabling research scientists to focus on building models at the highest level of abstraction. Data preprocessing, hyperparameter optimization, device management, and distributed training for torch.nn.Module models come completely free.

  • Easily build your benchmarks

    Creating a state-of-the-art baseline and comparing it with a new model is a simple config change.

  • Easily apply new architectures to multiple problems and datasets

    Apply new models across the extensive set of tasks and datasets that Ludwig supports. Ludwig includes a full benchmarking toolkit accessible to any user, for running experiments with multiple models across multiple datasets with just a simple configuration.

  • Highly configurable data preprocessing, modeling, and metrics

    Any and all aspects of the model architecture, training loop, hyperparameter search, and backend infrastructure can be modified as additional fields in the declarative configuration to customize the pipeline to meet your requirements. For details on what can be configured, check out Ludwig Configuration docs.

  • Multi-modal, multi-task learning out-of-the-box

    Mix and match tabular data, text, images, and even audio into complex model configurations without writing code.

  • Rich model exporting and tracking

    Automatically track all trials and metrics with tools like Tensorboard, Comet ML, Weights & Biases, MLFlow, and Aim Stack.

  • Automatically scale training to multi-GPU, multi-node clusters

    Go from training on your local machine to the cloud without code changes.

  • Low-code interface for state-of-the-art models, including pre-trained Huggingface Transformers

    Ludwig also natively integrates with pre-trained models, such as the ones available in Huggingface Transformers. Users can choose from a vast collection of state-of-the-art pre-trained PyTorch models to use without needing to write any code at all. For example, training a BERT-based sentiment analysis model with Ludwig is as simple as:

    ludwig train --dataset sst5 --config_str "{input_features: [{name: sentence, type: text, encoder: bert}], output_features: [{name: label, type: category}]}"
    
  • Low-code interface for AutoML

    Ludwig AutoML allows users to obtain trained models by providing just a dataset, the target column, and a time budget.

    auto_train_results = ludwig.automl.auto_train(dataset=my_dataset_df, target=target_column_name, time_limit_s=7200)
    
  • Easy productionisation

    Ludwig makes it easy to serve deep learning models, including on GPUs. Launch a REST API for your trained Ludwig model.

    ludwig serve --model_path=/path/to/model
    

    Ludwig supports exporting models to efficient Torchscript bundles.

    ludwig export_torchscript -–model_path=/path/to/model
    

📚 Tutorials

🔬 Example Use Cases

💡 More Information

Read our publications on Ludwig, declarative ML, and Ludwig’s SoTA benchmarks.

Learn more about how Ludwig works, how to get started, and work through more examples.

If you are interested in contributing, have questions, comments, or thoughts to share, or if you just want to be in the know, please consider joining our Community Discord and follow us on X!

🤝 Join the community to build Ludwig with us

Ludwig is an actively managed open-source project that relies on contributions from folks just like you. Consider joining the active group of Ludwig contributors to make Ludwig an even more accessible and feature rich framework for everyone to use!


Star History

Star History Chart

👋 Getting Involved