Fine-Tuning

Make your models better and faster!

While engineering a good prompt and providing in context examples in your inputs can help improve your llm performance, sometimes it is not enough, or may be too costly. This is where you can choose to fine-tune your model on a much bigger set of examples of your task. This has several advantages:

  • You don't need to craft a specific prompt,
  • You don't need to include examples in your input, saving token cost and improving inference latency,
  • The model gets to learn more deeply from many more examples than what you can fit in one input.

Spellbook currently offers fine-tuning on OpenAI models as well as FLAN-T5.

Fine-tuning in Spellbook

3564

The Fine-Tuning tab in Spellbook

When creating a new fine-tuned variant, you must specify a few parameters:

  • Fine-tuned variant name, which you use to find and deploy your fine-tuned variant in the View Fine-Tuned Variants tab,
  • Fine-tuned model name, which will be a selectable model option within Spellbook after your fine-tuning is complete,
  • Base model, which is the pretrained model that you will fine-tune. Spellbook currently supports OpenAI's GPT series and FLAN-T5,
  • Train dataset, which contains examples of inputs and their respective target outputs for the model to learn from. For classification tasks, 100 examples is enough. For harder generation tasks such as summarization, 500-1000 examples is recommended.
  • Advanced settings, which depend on what model and fine-tuning method you select.

Fine-tuning FLAN-T5

FLAN-T5 is the current best open source model available. It is fine-tuned on instruction prompts and closely rivals Davinci in performance, especially when fine-tuned.

3074

Validation Dataset for FLAN-T5

For FLAN-T5 specifically, you can optionally specify a validation dataset. When fine-tuning FLAN, at every epoch Spellbook checks the validation loss and returns the model checkpoint with the best validation loss, which may not be the last epoch due to overfitting. If a user does not specify a validation dataset, then 20% of the training dataset will be randomly sampled as the validation dataset.

For fine-tuning, there are a few parameters to set:

  • Epochs, which represent how many times your model trains over your entire dataset.
  • Learning Rate Modifier, which is multiplicatively applied to the recommended learning rate. A smaller modifier (<1) will make training slower, but coupled with more epochs, can result in higher quality training than a larger modifier.

Fine-tuning OpenAI

For fine-tuning OpenAI models, Spellbook supports setting two parameters:

  • Epochs, which represent how many times your model trains over your entire dataset.
  • Include prompt, which lets you choose a guiding prompt to transform your inputs to before inference and training. This option is recommended if you have relatively few training examples in your dataset (<100 for classification, <500 for generation).