finetuning

package
v0.3.1-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 5 Imported by: 0

README

Fine-Tuning

Bindings for the fine-tuning endpoint.

Example

See Open AI's guide to fine-tunes.

See finetunes-example.go.

Documentation

Overview

Package fine-tuning provides bindings for the finetunes endpoint. Manage fine-tuning jobs to tailor a model to your specific training data. Related guide: Fine-tune models.

Index

Constants

View Source
const Endpoint = common.BaseURL + "fine_tuning/jobs"

Variables

This section is empty.

Functions

This section is empty.

Types

type CreationRequest

type CreationRequest struct {
	// The name of the model to fine-tune. You can select one of the supported [models].
	//
	// [models]: https://platform.openai.com/docs/models/overview
	Model string `json:"model,omitempty"`

	// The ID of an uploaded file that contains training data.
	//
	// See [upload file] for how to upload a file.
	//
	// Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose fine-tune.
	//
	// See the [fine-tuning guide] for more details.
	//
	// [upload file]: https://beta.openai.com/docs/api-reference/files/upload
	// [fine-tuning guide]: https://beta.openai.com/docs/guides/fine-tuning/creating-training-data
	TrainingFile string `json:"training_file,omitempty"`

	// The hyperparameters used for the fine-tuning job.
	Hyperparams HyperParameters `json:"hyperparameters"`

	// A string of up to 18 characters that will be added to your fine-tuned model name.
	//
	// For example, a suffix of "custom-model-name" would produce a model name like
	// ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel.
	Suffix *string `json:"suffix,omitempty"`

	// The ID of an uploaded file that contains validation data.
	//
	// If you provide this file, the data is used to generate validation metrics periodically
	// during fine-tuning. These metrics can be viewed in the fine-tuning results file. The
	// same data should not be present in both train and validation files.
	//
	// Your dataset must be formatted as a JSONL file. You must upload your file with the
	// purpose fine-tune.
	//
	// See the [fine-tuning guide] for more details.
	//
	// [fine-tuning results]: https://beta.openai.com/docs/guides/fine-tuning/analyzing-your-fine-tuned-model
	// [fine-tuning guide]: https://beta.openai.com/docs/guides/fine-tuning/creating-training-data
	ValidationFile *string `json:"validation_file,omitempty"`
}

Request structure for the "create" fine-tune endpoint.

type DeleteResponse

type DeleteResponse struct {
	ID      int64                 `json:"id"`
	Object  string                `json:"object"`
	Deleted bool                  `json:"deleted"`
	Error   *common.ResponseError `json:"error,omitempty"`
}

func MakeDeleteRequest

func MakeDeleteRequest(fineTuneModel string, organizationID *string) (*DeleteResponse, error)

Delete a fine-tuned model. You must have the Owner role in your organization.

type FineTune

type FineTune struct {
	ID             string                `json:"id"`
	CreatedAt      uint64                `json:"created_at"`
	Error          *common.ResponseError `json:"error,omitempty"`
	FineTunedModel string                `json:"fine_tuned_model"`
	FinishedAt     uint64                `json:"finished_at"`
	Hyperparams    HyperParameters       `json:"hyperparameters"`
	Model          string                `json:"model"`
	Object         string                `json:"object"`
	OrganizationID string                `json:"organization_id"`
	ResultFiles    []string              `json:"result_files"`
	Status         string                `json:"status"`
	TrainedTokens  uint64                `json:"trained_tokens"`
	TrainingFile   string                `json:"training_file"`
	ValidationFile string                `json:"validation_file"`
}

Response structure for the "create" fine-tune endpoint.

func MakeCancelRequest

func MakeCancelRequest(fineTuneID string, organizationID *string) (*FineTune, error)

Immediately cancel a fine-tune job.

func MakeCreationRequest

func MakeCreationRequest(request *CreationRequest, organizationID *string) (*FineTune, error)

Creates a job that fine-tunes a specified model from a given dataset.

Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.

Learn more about Fine-tuning

func MakeRetrieveRequest

func MakeRetrieveRequest(fineTuneID string, organizationID *string) (*FineTune, error)

Gets info about the fine-tune job.

type FineTuneEvent

type FineTuneEvent struct {
	ID        string `json:"id"`
	CreatedAt uint64 `json:"created_at"`
	Level     string `json:"level"`
	Message   string `json:"message"`
	Object    string `json:"object"`
	Type      string `json:"type"`
}

type HyperParameters

type HyperParameters struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize uint64 `json:"batch_size"`

	// Scaling factor for the learning rate. A smaller learning rate may be
	// useful to avoid overfitting.
	LearningRateMultiplier float64 `json:"learning_rate_multiplier"`

	// The number of epochs to train the model for. An epoch refers to one
	// full cycle through the training dataset.
	NEpochs uint64 `json:"n_epochs"`
}

type ListEventsResponse

type ListEventsResponse struct {
	Object  string                `json:"object"`
	Data    []FineTuneEvent       `json:"data"`
	Error   *common.ResponseError `json:"error,omitempty"`
	HasMore bool                  `json:"has_more"`
}

func MakeListEventsRequest

func MakeListEventsRequest(fineTuneID string, limit *uint64, after, organizationID *string) (*ListEventsResponse, error)

Get fine-grained status updates for a fine-tune job.

type ListResponse

type ListResponse struct {
	Object  string                `json:"object"`
	Data    []FineTune            `json:"data"`
	Error   *common.ResponseError `json:"error,omitempty"`
	HasMore bool                  `json:"has_more"`
}

func MakeListRequest

func MakeListRequest(limit *uint64, after, organizationID *string) (*ListResponse, error)

List your organization's fine-tuning jobs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL