Skip to main content
Version: 0.91

Foundation model fine-tuning

Snorkel Flow allows you to easily fine-tune Foundation Models (FMs) for your end model.

note

This page is specifically related to GPT-3. Our platform also includes fine-tuning smaller models locally, such as Roberta or DistilBert, which are already integrated into the platform and not covered in this guide.

Prerequisite

Before you can start using this feature, you need to insert your OpenAI API Key into Snorkel's secure database. For full instructions, see Utilizing external models. As an admin user, you can accomplish this by inserting your secret API key in the SDK as follows:

sf.set_secret("openai_api_key", "your_openai_api_key_here")

Model training

If you're using a supported application type, navigate to Studio, go to the Models section, choose "Train new Model," and ensure the "Custom Model" tab is selected.

Once you have inserted your API key, you can customize your models in the Model Options section with the available hyperparameters, including

  • model (str): The GPT3 model type, such as ada, babbage, curie, or davinci.
  • n_epochs (int): The number of epochs to train the model for.
  • batch_size (int): The number of training examples used to train a single forward and backward pass.
  • learning_rate_multiplier (float): The original learning rate used for pretraining multiplied by this multiplier.
  • max_text_chars (int): The maximum number of characters to avoid GPT3's maximum number of tokens overflow.
  • max_timeout_minutes (int): The maximum number of minutes to wait before we cut the connection to OpenAI. If you're working with a large dataset, please set this to a large number.
  • secret_store_key (str): The secret key associated with your OpenAI API Key. Please refer to the "Prerequisite" section above.
  • model_id (str): If provided, use this OpenAI's fine-tuned model and skip fine-tuning steps.
  • cancel_if_timeout (bool): Default True. If provided as False, we won't cancel the fine-tune job on OpenAI when it times out. You can retrieve this model_id later from your OpenAI dashboard.

For more information, please refer to the OpenAI's hyperparameters documentation.

After you initiate a fine-tuning job, Snorkel Flow will provide you with an estimated cost. Please remember that this is only an estimate, and the actual cost may vary.

Once you receive the estimated cost, you can proceed to train the model and continue the iterative loop inside Snorkel Flow.

Notes and requirements

  • To use the fine-tuning feature, you must install Snorkel version 2023.R1 LTS (v0.74) or higher.

  • Your Snorkel Flow installation must have internet access

  • Understand that you will send data to a 3rd party provider (OpenAI) to use this feature.

  • All fine-tuning steps are performed on OpenAI servers.

  • While OpenAI has a demonstrated record of taking security seriously, some risk is always associated with outsourcing sensitive data to a third party.

  • Outsourcing model training to a third-party service like OpenAI is not recommended for customers with sensitive data.

  • You must set up an OpenAI account and API key to use this feature.

  • Snorkel will send fine-tuning requests to your OpenAI account, and OpenAI will charge your account directly for this service.

  • Fine-tuning of Foundation Models (FM) is currently supported for the following app types:

  • Classification

  • Utterance Classification

  • PDF Classification

  • Candidate Extraction

  • PDF Extraction