New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chatgpt-fine-tuning

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chatgpt-fine-tuning

Easily tune your models.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to ChatGpt Fine Tuning SDK 👋

Version Documentation Maintenance

Easily tune your models.

  • 🖤 npm

Overview

This package helps you programmatically generate your fine-tuning dataset in JSONL format. It is a wrapper of the chatgpt npm package so you can use it the same way.

As documented in OpenAI's official documentation, training data is expected to follow the format:

{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What's the capital of France?"}, {"role": "assistant", "content": "Paris, as if everyone doesn't know that already."}]}
{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who wrote 'Romeo and Juliet'?"}, {"role": "assistant", "content": "Oh, just some guy named William Shakespeare. Ever heard of him?"}]}
{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "How far is the Moon from Earth?"}, {"role": "assistant", "content": "Around 384,400 kilometers. Give or take a few, like that really matters."}]}

The way the package works is by using "tuners". Each sendMessage call returns a tuner object which you either approve or reject and fix.

Based on these actions, you will have a training file that reflects these decisions.

Install

# npm
npm install chatgpt-fine-tuning

# yarn
yarn add chatgpt-fine-tuning

Configuration

To use the SDK, you need to configure it with your API key. Here's a simple setup:

import ChatGptFineTuning from 'chatgpt-fine-tuning';

const outFile = 'fine-tuning-output.jsonl'; // required
const systemMessage = 'Marv is a factual chatbot that is also sarcastic.'; // required

const gpt4Api = new ChatGptFineTuning({
    apiKey: process.env.GPT4_API_KEY || '', // required
    systemMessage,
  }, outFile)

Usage

tuner

MethodParametersReturn TypeDescription
approve-Promise<void>Approves the current row for fine-tuning.
reject-Promise<void>Rejects the current row for fine-tuning.
fixuserText: string, assistantText: string, log?: booleanPromise<void>Submits a correction for the current row, including the user and assistant text. Option to log details to file after each row.
logmessage: stringvoidLogs a message to the output file. This operation is synchronous.
PropertyTypeDescription
responseChatMessageHolds the current chat message that the tuner will operate on.
const tuner = await gpt4Api.sendMessage("What is the capital of France?");

// programmatic verification
if (tuner.response.text.includes("Paris")) {
  tuner.approve();
} else {
  // marks assistant response with a weight of 0
  tuner.reject();
  // inserts the user response and a correct assistant response with a weight of 1
  tuner.fix("You did not provide the correct answer", "Paris");
}
tuner.log("Finished run")

ChatMessage

NameTypeDescription
idstringUnique identifier for the chat message.
textstringThe text content of the chat message.
roleRoleThe role of the message sender (e.g., user, assistant).
namestringThe name of the sender. Optional.
deltastringOptional string that may contain additional information or changes made to the message.
detailopenai.CreateChatCompletionResponse | CreateChatCompletionStreamResponseOptional detailed response from OpenAI or a streaming response, providing further context or metadata about the chat message.
parentMessageIdstringThe ID of the parent message if this message is a reply or related to another message in the conversation. Optional.
conversationIdstringThe ID of the conversation this message belongs to. Optional.

API

The API is the same as the chatgpt package (reference).

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Donate

Bitcoin: bc1qhp9havdzfzqr9mzdc3257txmegrpryhx3kdpyz

Strike: rodrigo

📝 License

This project is MIT licensed.

Keywords

FAQs

Package last updated on 27 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc