https://github.com/romantech/openai-fine-tuning
OpenAI Fine-tuning for JSON Output
https://github.com/romantech/openai-fine-tuning
fine-tuning nodejs openai
Last synced: 3 months ago
JSON representation
OpenAI Fine-tuning for JSON Output
- Host: GitHub
- URL: https://github.com/romantech/openai-fine-tuning
- Owner: romantech
- Created: 2023-08-27T16:07:22.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-03T06:48:43.000Z (over 2 years ago)
- Last Synced: 2024-05-15T15:32:25.937Z (over 1 year ago)
- Topics: fine-tuning, nodejs, openai
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenAI Fine-tuning for JSON Output
## Introduction
This project, written in JavaScript (Node.js), fine-tunes OpenAI's primary models to produce JSON-formatted output. It aims to enhance both cost-efficiency and data consistency for applications that utilize the OpenAI API. Portions of the codebase are inspired by the Python [open-finetuning](https://github.com/horosin/open-finetuning).
## Prerequisites
- Node.js 16 LTS or later
- OpenAI Node v4
## Usage
### Step 1: Set OpenAI API Key Environment Variable
Define your OpenAI API key by setting an environment variable named `API_KEY`.
```bash
export API_KEY=your-openai-api-key
```
### Step 2: Generate Sample Training Data
- Execute `npm run prepare`.
- Use a prompt capable of generating the desired output.
- For optimal sample quality, it is recommended to use GPT-4.
- OpenAI requires a minimum of `50` samples.
- The sample data will be stored in `src/data/training-examples.json`.
### Step 3: Generate System Message Formatting Data
- Execute `npm run transform`.
- Use a more straightforward prompt than the previous step.
- The results will be saved in `src/data/training-data.jsonl`.
### Step 4: Proceed with Fine-tuning
- Execute `npm run finetune`.
- Upon completion, the fine-tuned model ID will be displayed on the console.
### Step 5: Test the Fine-tuned Model
- Execute `npm run model`.
- Test the model using a simplified version of the original prompt.