1.1 KiB
1.1 KiB
Code Example: How to fine-tune your LLM with Supervised Fine-Tuning (SFT)
This folder contains the code for the Guides > Optimization > Supervised Fine-Tuning page in the documentation.
This example focuses on OpenAI, but TensorZero also integrates with other provides.
Prerequisites
- Set the
OPENAI_API_KEYenvironment variable - Set the
TENSORZERO_POSTGRES_URLenvironment variable (e.g.,postgres://postgres:postgres@localhost:5432/tensorzero)
Running the Example
-
Start the required services:
docker compose up -d -
Install dependencies:
uv sync -
Run the example:
uv run python main.py
The script will:
- Run inferences on the NER dataset
- Submit demonstration feedback with ground-truth labels
- Launch an SFT job with OpenAI
- Poll until the job completes
- Print the configuration needed to use the fine-tuned model