500 Internal Server Error when fine tuning a fine tuned model

My apologies. You are right. The file upload is independent from whether or not the file is saved.

def fine_tune_model(client, dataset_path, base_model, suffix, validation_path=None, epoch=None):
    """
    Fine-tune a model on a specified dataset.
    Args:
        dataset_path (str): Path to the JSONL file with training data.
        base_model (str): The base model to fine-tune.
        suffix (str): The suffix to identify the fine-tuned model.
    Returns:
        str: The ID of the fine-tuned model.
    """
    file_id=None
    validation_file_id = None
    
    if validation_path:
        print(f"Uploading validation set: {validation_path}")
        validation_file_response = client.files.create(
            file=open(validation_path, "rb"),
            purpose='fine-tune'
        )
        validation_file_id = validation_file_response.id
        print(f"Uploaded validation file ID: {validation_file_id}")
            
    if dataset_path:
        # Upload file
        print(f"Uploading dataset: {dataset_path}")
        file_response = client.files.create(
            file=open(dataset_path, "rb"),
            purpose='fine-tune'
        )
        file_id = file_response.id
        print(f"Uploaded file ID: {file_id}")

    # Create fine-tuning job
    print(f"Creating fine-tune job...\n training_file: {file_id}, validation_file: {validation_file_id}")
    fine_tune_job_response = client.fine_tuning.jobs.create(
        training_file=file_id,
        validation_file=validation_file_id if validation_file_id else None,
        model=base_model,
        suffix=suffix,
        hyperparameters={
            "n_epochs": epoch if epoch else 3
        }
    )
    fine_tune_id = fine_tune_job_response.id
    print(f"Fine-tune job created with ID: {fine_tune_id}")
    return fine_tune_id

training_file_path = "./saved_conversations/fine_tuning_conversations.jsonl"  # First dataset
validation_file_path = "./saved_conversations/fine_tuning_validation_conversations.jsonl"
dataset2_path = "./saved_conversations/fine_tuning_conversations.jsonl"  # Second dataset

# Specify base model and suffix identifiers
# base_model = "gpt-4o-2024-08-06"  # Replace with the desired base model
# base_model = "ft:gpt-4o-2024-08-06:personal:hello-fine-tune:AUOOSrHy"
# base_model = "ft:gpt-4o-2024-08-06:personal:fine-tuned-3:AUeOuOUC"
base_model = "ft:gpt-4o-2024-08-06:personal:fine-tuned-4:AUg7D0Dl"
# base_model = "ft:gpt-3.5-turbo-0125:personal:fine-tuned-5:AUhxgZ84" # gpt-3.5
# base_model = "gpt-3.5-turbo-0125"
suffix1 = "hello_fine_tune"
suffix2 = "iteration_6"

# Initialize Client
client = OpenAI()

fine_tune_id2 = fine_tune_model(client, training_file_path, base_model, suffix2, validation_path=validation_file_path, epoch=3)

However, I still get the 500 Internal Server error when trying to continue fine tuning a fine tuned model. Why is this the case?

1 Like