Skip to main content
This example uses Curator to move a skill from a large model to a much smaller 8B parameter model. GPT-4o labels the sentiment of Yelp restaurant reviews, and those labels are used to fine-tune Llama 3.1 8B Instruct with the Together fine-tuning API. You can also run this example in Colab. The model reads a review and returns a sentiment for each aspect of the restaurant. Take this review as an example.
It returns this JSON. The full output also has ambience_sentiment, price_sentiment, and overall_sentiment.

Setup

Label the data

The prompt asks the model to rate five aspects of a review. This example does not use structured output, because the same LLM class also runs the small base model later, and many small models do not support structured output. The prompt asks for JSON in a code block instead.
Load the Yelp reviews. You can upload them to the Curator Viewer to look through them first.
Label the reviews with GPT-4o.

Split the data

Rename the label columns with a _gt suffix, for ground truth. Then use 90% of the rows for training and 10% for testing.

Evaluate the base model

This function compares the model output with the GPT-4o labels and returns the accuracy for each aspect.
Run the base Llama 3.1 8B model on the test set through Together and LiteLLM.
The base model agrees with GPT-4o on 82.7% of the labels overall, and does worst on ambience.

Fine-tune the model

Turn each training row into a chat example, where the assistant message is the GPT-4o label. Then upload the file to Together.
Start a LoRA fine-tuning job.
Check the job until it finishes. Replace ft-xyz with your job ID.

Evaluate the fine-tuned model

When the job is done, find your model ID on the Together models page and run it on the test set.

Compare the results

The fine-tuned model agrees with GPT-4o more often than the base model does, overall and for every aspect. It is also much cheaper to run. When this example was written, the 8B model cost 0.18permilliontokensonTogether,andGPT−4ocost0.18 per million tokens on Together, and GPT-4o cost 2.50 per million input tokens. To get closer to GPT-4o, you can label a larger dataset and tune the training settings.