This repo contains a step-by-step guide for fine-tuning gpt-3.5-turbo
model.
We will use the Titanic dataset for this tutorial. We will first build a (simple) classification model using the target label survived
. Then we will use Shapley analysis to identify features that contributed to each passenger's survival estimate. The ouput from Shapley analysis will then be used to fine-tune an LLM model.
We will fine-tune a GPT model in such a way that when we provide the output data points from the Shapley analysis to the LLM model, it should be able to generate a summary in plain English that explains why the passenger did or did not survive.
Here's the overall wireframe of this approach:
Here are the steps we will follow:
- Read the Titanic dataset and prepare the data for modeling.
- Build a simple classification model.
- Perform Shapley analysis to identify the top contributors for each passanger.
- Prepare training data for fine-tuning a GPT model (by converting Shapley output into plain English).
- Fine-tune
gpt-3.5-turbo
using the training data prepared in the previous step. - Make inference on a new passenger (not in the training data) to make sure that the fine-tuned model is working as expected.
- Build a Gradio UI where a user can choose a passanger and view the results.
Here's the list of all tools used in this tutorial:
- SHAP (SHapley Additive exPlanations) package
- OpenAI API for fine-tuning a GPT model
- Gradio for creating a web-app
Check out the Jupyter Notebook for the full tutorial.
- The Titanic dataset is from here.
- OpenAI Cookbook for How to fine-tune chat models