naifu  by Mikubill

Trainer for generative models, supporting diverse configurations

Created 2 years ago
332 stars

Top 82.4% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

Naifu is a PyTorch Lightning-based framework for training generative models, primarily diffusion models and large language models. It targets researchers and developers looking for a flexible, configuration-driven approach to fine-tune or train models like Stable Diffusion XL, Stable Cascade, Pixart-Alpha, and various LLMs. The framework aims to simplify complex training setups with a unified interface.

How It Works

Naifu leverages PyTorch Lightning for distributed training and efficient checkpointing. It uses YAML configuration files to define training parameters, model architectures, datasets, and optimization strategies. This approach allows users to easily switch between different model types (e.g., SDXL, LLMs) and training techniques (e.g., LyCORIS, DPO, LCM) without modifying core code.

Quick Start & Requirements

  • Install:
    git clone --depth 1 https://github.com/mikubill/naifu
    cd naifu && pip install -r requirements.txt
    
  • Prerequisites: Python 3.9+. Specific models may require additional libraries (e.g., lycoris_lora, toml, fairscale). GPU with CUDA is highly recommended for practical training.
  • Usage: python trainer.py --config <config_file>
  • Docs: https://github.com/mikubill/naifu

Highlighted Details

  • Supports training for a wide array of models including SDXL, SDXL Refiner, Stable Diffusion 1.x/1.5, Pixart-Alpha, StableCascade, GPT2, and various LLMs (LLaMA, Qwen, Gemma, Mistral).
  • Integrates advanced training techniques like LyCORIS, LoRA/QLoRA, Diffusion DPO, and Latent Consistency Models (LCM).
  • Offers specialized branches for different model architectures and backends (e.g., sgm, sd3, hydit).
  • Includes scripts for data preprocessing, such as encoding images to latents for SDXL.

Maintenance & Community

The main branch is under active development. The repository is maintained by Mikubill. Community links are not explicitly provided in the README.

Licensing & Compatibility

The repository does not explicitly state a license in the README. Users should verify licensing for commercial use or integration into closed-source projects.

Limitations & Caveats

The main branch is under development and subject to change. Some specialized branches (e.g., sd3) are noted as experimental or potentially producing undesired results. Specific model training configurations may require careful tuning of parameters like resolution and beta values.

Health Check
Last Commit

9 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
3 stars in the last 30 days

Explore Similar Projects

Starred by Patrick von Platen Patrick von Platen(Author of Hugging Face Diffusers; Research Engineer at Mistral), Hanlin Tang Hanlin Tang(CTO Neural Networks at Databricks; Cofounder of MosaicML), and
1 more.

diffusion by mosaicml

0%
707
Diffusion model training code
Created 2 years ago
Updated 8 months ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Jeff Hammerbacher Jeff Hammerbacher(Cofounder of Cloudera), and
5 more.

ai-toolkit by ostris

0.9%
6k
Training toolkit for finetuning diffusion models
Created 2 years ago
Updated 13 hours ago
Starred by Tobi Lutke Tobi Lutke(Cofounder of Shopify), Yineng Zhang Yineng Zhang(Inference Lead at SGLang; Research Scientist at Together AI), and
26 more.

axolotl by axolotl-ai-cloud

0.5%
10k
CLI tool for streamlined post-training of AI models
Created 2 years ago
Updated 13 hours ago
Feedback? Help us improve.