Package: ludwig
Declarative deep learning framework built for scale and efficiency.📖 What is Ludwig?Ludwig is alow-codeframework for buildingcustomAI models likeLLMsand 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:prebuiltDockercontainers, native support for running withRayonKubernetes, export models toTorchscriptandTriton, upload toHuggingFacewith one command.Ludwig is hosted by theLinux Foundation AI & Data.💾 InstallationInstall from PyPi. Be aware that Ludwig requires Python 3.8+.pipinstallludwigOr install with all optional dependencies:pipinstallludwig[full]Please seecontributingfor more detailed installation instructions.🚂 Getting StartedWant to take a quick peak at some of the Ludwig 0.8 features? Check out this Colab Notebook 🚀Looking to fine-tune Llama-2 or Mistral? Check out these notebooks:Fine-Tune Llama-2-7b:Fine-Tune Llama-2-13b:Fine-Tune Mistral-7b:For a full tutorial, check out the officialgetting started guide, or take a look at end-to-endExamples.Large Language Model Fine-TuningLet's fine-tune a pretrained LLaMA-2-7b large language model to follow instructions like a chatbot ("instruction tuning").PrerequisitesHuggingFace API TokenAccess approval toLlama2-7b-hfGPU with at least 12 GiB of VRAM (in our tests, we used an Nvidia T4)RunningWe'll use theStanford Alpacadataset, which will be formatted as a table-like file that looks like this:instructioninputoutputGive 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 namedmodel.yamlwith the following:model_type:llmbase_model:meta-llama/Llama-2-7b-hfquantization:bits:4adapter:type:loraprompt: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:prompttype:textoutput_features:-name:outputtype:texttrainer:type:finetunelearning_rate:0.0001batch_size:1gradient_accumulation_steps:16epochs:3learning_rate_scheduler:decay:cosinewarmup_fraction:0.01preprocessing:sample_ratio:0.1backend:type:localAnd now let's train the model:exportHUGGING_FACE_HUB_TOKEN="<api_token>"ludwigtrain--configmodel.yaml--dataset"ludwig://alpaca"Supervised MLLet's build a neural network that predicts whether a given movie critic's review onRotten Tomatoeswas positive or negative.Our dataset will be a CSV file that looks like this:movie_titlecontent_ratinggenresruntimetop_criticreview_contentrecommendedDeliver Us from EvilRAction & Adventure, Horror117.0TRUEDirector Scott Derrickson and his co-writer, Paul Harris Boardman, deliver a routine procedural with unremarkable frights.0BarbaraPG-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.1Horrible 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 fromhere.wgethttps://ludwig.ai/latest/data/rotten_tomatoes.csvNext create a YAML config file namedmodel.yamlwith the following:input_features:-name:genrestype:setpreprocessing:tokenizer:comma-name:content_ratingtype:category-name:top_critictype:binary-name:runtimetype:number-name:review_contenttype:textencoder:type:embedoutput_features:-name:recommendedtype:binaryThat's it! Now let's train the model:ludwigtrain--configmodel.yaml--datasetrotten_tomatoes.csvHappy modelingTry applying Ludwig to your data.Reach outif you have any questions.❓ Why you should use LudwigMinimal machine learning boilerplateLudwig 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 fortorch.nn.Modulemodels come completely free.Easily build your benchmarksCreating 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 datasetsApply new models across the extensive set of tasks and datasets that Ludwig
supports. Ludwig includes afull benchmarking toolkitaccessible to
any user, for running experiments with multiple models across multiple
datasets with just a simple configuration.Highly configurable data preprocessing, modeling, and metricsAny 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 outLudwig Configurationdocs.Multi-modal, multi-task learning out-of-the-boxMix and match tabular data, text, images, and even audio into complex model
configurations without writing code.Rich model exporting and trackingAutomatically 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 clustersGo 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 TransformersLudwig also natively integrates with pre-trained models, such as the ones
available inHuggingface 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:ludwigtrain--datasetsst5--config_str"{input_features: [{name: sentence, type: text, encoder: bert}], output_features: [{name: label, type: category}]}"Low-code interface for AutoMLLudwig AutoMLallows 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 productionisationLudwig makes it easy to serve deep learning models, including on GPUs.
Launch a REST API for your trained Ludwig model.ludwigserve--model_path=/path/to/modelLudwig supports exporting models to efficient Torchscript bundles.ludwigexport_torchscript-–model_path=/path/to/model📚 TutorialsText ClassificationTabular Data ClassificationImage ClassificationMultimodal Classification🔬 Example Use CasesNamed Entity Recognition TaggingNatural Language UnderstandingMachine TranslationChit-Chat Dialogue Modeling through seq2seqSentiment AnalysisOne-shot Learning with Siamese NetworksVisual Question AnsweringSpoken Digit Speech RecognitionSpeaker VerificationBinary Classification (Titanic)Timeseries forecastingTimeseries forecasting (Weather)Movie rating predictionMulti-label classificationMulti-Task LearningSimple Regression: Fuel Efficiency PredictionFraud Detection💡 More InformationRead our publications onLudwig,declarative ML, andLudwig’s SoTA benchmarks.Learn more abouthow Ludwig works,how to get started, and work through moreexamples.If you are interested incontributing, have questions, comments, or thoughts to share, or if you just want to be in the
know, please considerjoining the Ludwig Slackand follow us onTwitter!🤝 Join the community to build Ludwig with usLudwig 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👋 Getting InvolvedSlackTwitterMediumGitHub Issues