Model Fine-Tuning

πŸ‘

What you'll learn

  • Deploy a Fine-Tuning Job
  • Creating a ML Repo
  • Uploading dataset files to AWS S3

This is a guide to deploying a Fine-Tuning Job from Model Catalogue

Step 1: Preparing Training Data

Your data must be a JSON Lines (.jsonl) file, where each line is a prompt and completion pair corresponding to a training example. Following is an example of prompt-completion pairs:

{"prompt": "What is 2 + 2?", "completion": "The answer to 2 + 2 is 4"}
{"prompt": "Flip a coin", "completion": "I flipped a coin and the result is heads!"}
{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
...

If you want to instruction tune, you can format the prompt to include the instruction and the rest of t

Step 2: Deploying Fine-Tuning Job from Model Catalogue

TrueFoundry's Model Catalogue can be found under the Models tab.

Here, you may choose any model that you want to fine-tune. Click on the Finetune button to configure the deployment of the fine-tuning job.

Where would you like to deploy?: Enter the workspace name where you would like to deploy the job

Preconfig Deployment Options: Here, you will find different deployment options using GPUs and only CPUs. The name of the configuration gives an idea about any GPU used (if any).

Click on Next Step when done configuring the workspace and deployment options. You will see something like this:

In this view, you will see options like Endpoints, ENVs, GPU, CPU, Memory, and Storage resources pre-populated based on workspace and deployment options.

Click on Submit to complete deploying the fine-tuning job.

Step 3.1: Creating a ML Repo (From Dashboard)

In order to create a ML Repo from the dashboard, click on ML Repos tab and then click on + New ML Repo button.

After that, you will see something like this:

Name: Enter a name for your ML Repo

(Optional) Description: Enter a description for your ML Repo

Storage Integration: Here, you will find different options, such as AWS S3, AZURE BLOB STORAGE, GCP GCS.

Click on Create to finish creating an ML Repo.

Step 3.2: Providing ML Repo Access to Workspace Containing Fine-Tuning Job

In Step 2, the workspace in which fine-tuning job was created now needs access to ML Repo created in Step 3.1. To give access to this ML Repo, click on Workspaces tab and then search for the workspace used in Step 2.

Once the workspace is found, click on the edit button, and you will see something like this:

Now you can add the ML Repo created in Step 3.1 under ML Repo Access. Be sure to give at least a Project Editor level access. Click on Update to finish updating the workspace.

Step 4: Upload Training Data By Generating Pre-Signed URL

Generating a pre-signed URL can be done via a Python snippet or CLI:

  1. CLI

    If your training data is not already in S3 Bucket, then you can upload it using the following command:

    aws s3 cp "path-to-training-data-file-locally" s3://bucket-name/dir-to-store-file
    

    To generate a pre-signed URL of an S3 Object, use the following command:

    aws s3 presign s3://bucket-name/path-to-training-data-file-in-s3
    

Similarly, you can also upload to AZURE BLOB and GCP GCS.

The output of uploading the training file to AWS S3, alongside the pre-signed URL:

Step 5: Trigger Fine-Tuning Job

To trigger the fine-tuning job deployed in Step 2, click on Deployments and under Jobs to find your deployed job (like finetune-pythia-70m). You will see something like this:

Click on Run Job to configure the job before triggering it. You will see something like this:

ml repo: Choose the ML Repo created in Step 3.1.
train data: Enter the Pre-Signed URL of the training data generated in Step 4.

Fill in other input variables according to your requirements. After configuring inputs to the job, click on Run Job to trigger the job.

Step 6: Monitoring Fine-Tuning

After the job is triggered and it has successfully completed, it should look this:

Here, click on finetune-2023-05-25T09-36-29 (= Run Name) under Run Details to check the results of the completed job.