This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This api supports fine tuning chat models
- Loading branch information
1 parent
2a9abd0
commit 253aff4
Showing
14 changed files
with
356 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
api/src/main/java/com/theokanning/openai/fine_tuning/FineTuningEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.theokanning.openai.fine_tuning; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
|
||
/** | ||
* An object representing an event in the lifecycle of a fine-tuning job | ||
* | ||
* https://platform.openai.com/docs/api-reference/fine-tuning/list-events | ||
*/ | ||
@Data | ||
public class FineTuningEvent { | ||
/** | ||
* The type of object returned, should be "fine-tuneing.job.event". | ||
*/ | ||
String object; | ||
|
||
/** | ||
* The creation time in epoch seconds. | ||
*/ | ||
@JsonProperty("created_at") | ||
Long createdAt; | ||
|
||
/** | ||
* The log level of this message. | ||
*/ | ||
String level; | ||
|
||
/** | ||
* The event message. | ||
*/ | ||
String message; | ||
|
||
/** | ||
* The type of event, i.e. "message" | ||
*/ | ||
String type; | ||
} |
90 changes: 90 additions & 0 deletions
90
api/src/main/java/com/theokanning/openai/fine_tuning/FineTuningJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.theokanning.openai.fine_tuning; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Fine-tuning job | ||
* https://platform.openai.com/docs/api-reference/fine-tuning/object | ||
*/ | ||
@Data | ||
public class FineTuningJob { | ||
/** | ||
* The object identifier, which can be referenced in the API endpoints. | ||
*/ | ||
String id; | ||
|
||
/** | ||
* The object type, which is always "fine_tuning.job". | ||
*/ | ||
String object; | ||
|
||
/** | ||
* The unix timestamp for when the fine-tuning job was created. | ||
*/ | ||
@JsonProperty("created_at") | ||
Long createdAt; | ||
|
||
/** | ||
* The unix timestamp for when the fine-tuning job was finished. | ||
*/ | ||
@JsonProperty("finished_at") | ||
Long finishedAt; | ||
|
||
/** | ||
* The base model that is being fine-tuned. | ||
*/ | ||
String model; | ||
|
||
/** | ||
* The name of the fine-tuned model that is being created. | ||
* Can be null if no fine-tuned model is created yet. | ||
*/ | ||
@JsonProperty("fine_tuned_model") | ||
String fineTunedModel; | ||
|
||
/** | ||
* The organization that owns the fine-tuning job. | ||
*/ | ||
@JsonProperty("organization_id") | ||
String organizationId; | ||
|
||
/** | ||
* The current status of the fine-tuning job. | ||
* Can be either created, pending, running, succeeded, failed, or cancelled. | ||
*/ | ||
String status; | ||
|
||
/** | ||
* The hyperparameters used for the fine-tuning job. | ||
* See the fine-tuning guide for more details. | ||
*/ | ||
Hyperparameters hyperparameters; | ||
|
||
/** | ||
* The file ID used for training. | ||
*/ | ||
@JsonProperty("training_file") | ||
String trainingFile; | ||
|
||
/** | ||
* The file ID used for validation. | ||
* Can be null if validation is not used. | ||
*/ | ||
@JsonProperty("validation_file") | ||
String validationFile; | ||
|
||
/** | ||
* The compiled results files for the fine-tuning job. | ||
*/ | ||
@JsonProperty("result_files") | ||
List<String> resultFiles; | ||
|
||
/** | ||
* The total number of billable tokens processed by this fine-tuning job. | ||
*/ | ||
@JsonProperty("trained_tokens") | ||
Integer trainedTokens; | ||
} |
46 changes: 46 additions & 0 deletions
46
api/src/main/java/com/theokanning/openai/fine_tuning/FineTuningJobRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.theokanning.openai.fine_tuning; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
|
||
/** | ||
* Request to create a fine tuning job | ||
* https://platform.openai.com/docs/api-reference/fine-tuning/create | ||
*/ | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Data | ||
public class FineTuningJobRequest { | ||
|
||
/** | ||
* The ID of an uploaded file that contains training data. | ||
*/ | ||
@NonNull | ||
@JsonProperty("training_file") | ||
String trainingFile; | ||
|
||
/** | ||
* The ID of an uploaded file that contains validation data. | ||
* Optional. | ||
*/ | ||
@JsonProperty("validation_file") | ||
String validationFile; | ||
|
||
/** | ||
* The name of the model to fine-tune. | ||
*/ | ||
@NonNull | ||
String model; | ||
|
||
/** | ||
* The hyperparameters used for the fine-tuning job. | ||
*/ | ||
Hyperparameters hyperparameters; | ||
|
||
/** | ||
* A string of up to 40 characters that will be added to your fine-tuned model name. | ||
*/ | ||
String suffix; | ||
} |
28 changes: 28 additions & 0 deletions
28
api/src/main/java/com/theokanning/openai/fine_tuning/Hyperparameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.theokanning.openai.fine_tuning; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
/** | ||
* Hyperparameters for a fine-tuning job | ||
* https://platform.openai.com/docs/api-reference/fine-tuning/object#hyperparameters | ||
*/ | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Data | ||
public class Hyperparameters { | ||
|
||
/** | ||
* The number of epochs to train the model for. | ||
* An epoch refers to one full cycle through the training dataset. | ||
* "Auto" decides the optimal number of epochs based on the size of the dataset. | ||
* If setting the number manually, we support any number between 1 and 50 epochs. | ||
*/ | ||
@JsonProperty("n_epochs") | ||
Integer nEpochs; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
253aff4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code is really easy and good documentation easy to understand for any java developer Theo kannig