Sign In

On-Site Lora Training Settings Guide by Diamond (For Pony, but still useful for others)

On-Site Lora Training Settings Guide by Diamond (For Pony, but still useful for others)

Hello Civitai users. On the road to developing my first lora, I found a great number of resources to draw upon and eventually made something pretty good. However, I forgot to bookmark any of them and had to look into finding them again when I eventually wanted to make a second one. For simplicity sake, here is my condensed guide so you don't have to weigh the advisements of multiple guides as I did. Feel free to navigate using ctrl+f.

  • Sample image prompts

    • While technically not in the "advanced settings", I want to preface this by letting you know to never let the generator pick prompts automatically. It's a jumpled mish-mash of whatever tags you used, and you more often get something ugly. Try to prompt for a diverse set of locations and contexts, such as day/night, 1boy/1girl, or anything else you trained it on to test it out early. Don't forget your activator phrase, if you used one, or (for pony diffusion) that score stuff pony makes you put at the beginning of the prompt.

  • Steps: A function of training image count, epochs, number of repeats (num repeats), and training batch size (train batch size)

    • Steps=(training image count x epochs x number of repeats)/ training batch size

    • Epochs: The lora as it was saved after a round of training. For every epoch, your lora will be save, and re-trained on your images for however many epochs you set it too. It will show you how each epoch generates using your sample prompts for reference. You can choose which ever looks best from the epochs. Keep epochs between 10 and 20. You can go higher if you want I suppose.

        • Note: This is an example image from when I was seeing if I could train a lora using 3 sample images. In case you are curious, it did not go so hot.

    • I see a lot of people use 1000-3000 steps in examples, but my first one used 470 and was pretty good, and the step count people use on-site seems to vary from 440 to 4400, so I guess there is some room for choice. Any less than that and the results are not very good. holostrawberry recommends that you make sure that the epoch is high (anywhere from 10 to 20) as opposed to the repeats so that you may be able to get a better view of how your lora is progressing as the steps go on, and pick the epoch at it's best point more accurately. Only really bump up the repeats if you don't have enough sample images to make it to a good step count. Batch size makes it train multiple images in single steps for the sake of speed, but making this too high may sacrifice accuracy. I predict you should should increase it proportional to the number of training images.

    • Sources: https://civitai.com/articles/4/make-your-own-loras-easy-and-free and https://github.com/bmaltais/kohya_ss/wiki/LoRA-training-parameters

  • Resolution: Resolution is proportional to detail quality.

  • Enable bucket: Turn it on.

  • Shuffle tags: It shuffles tags so the lora will understand that prompt order is variable. Turn it on.

  • Keep tokens: The number of tags at the beginning of the prompt it will keep in place without shuffling.

  • Clip skip: Always 2 for pony.

  • Flip Augmentation: No one talks about this, but the description I've seen talk about how it helps with symmetrical lora subjects by adding flipped versions of the training data to the sample. Apparently, it's bad to use this in other situations according to a comment by NanashiAnon.

  • Learning Rate: Based on my research from when I was looking into how convolutional neural networks work, I think this is a multiplier on how much the error calculated in every training step influences the weights and biases of the lora in subsequent training steps or in the end product, with there being two learning rates for image reproduction and word association respectively.

  • Min SNR Gamma: It has something to do with compensating for something in the training process.

  • Network Dim (network dimension) and Network Alpha: The dim and alpha are used in a fraction together. Dimension is the degree to which a lora is able to remember details of an image. Alpha makes the learning process slower to force it to learn the more consistent details.

  • Noise Offset: Adds noise to the training. Can be anything from 0 to 1.

    • Just keep it at 0.03 I guess. No one talks about it, but I used it and it worked out fine.

  • Optimizer: There are more of these out there, but Civit only supports adafactor and prodigy for Pony.

    • Set to adafactor to use cosine with restarts.

    • I will mention that prodigy and 8-bit adam have redeeming qualities that plenty of people debate the advantages of, but cosine with restarts is really what we are looking at here for on site training.

Write back if anyone made a lora using this guide. I'd love to hear it.

32

Comments