npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chatgpt-fine-tuning

v1.0.0

Published

Easily tune your models.

Downloads

9

Readme

Easily tune your models.

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

| Method | Parameters | Return Type | Description | |--------|------------|-------------|-------------| | approve | - | Promise<void> | Approves the current row for fine-tuning. | | reject | - | Promise<void> | Rejects the current row for fine-tuning. | | fix | userText: string, assistantText: string, log?: boolean | Promise<void> | Submits a correction for the current row, including the user and assistant text. Option to log details to file after each row. | | log | message: string | void | Logs a message to the output file. This operation is synchronous. |

| Property | Type | Description | |-----------------|-----------------|-------------| | response | ChatMessage | Holds 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

| Name | Type | Description | |------|------|-------------| | id | string | Unique identifier for the chat message. | | text | string | The text content of the chat message. | | role | Role | The role of the message sender (e.g., user, assistant). | | name | string | The name of the sender. Optional. | | delta | string | Optional string that may contain additional information or changes made to the message. | | detail | openai.CreateChatCompletionResponse | CreateChatCompletionStreamResponse | Optional detailed response from OpenAI or a streaming response, providing further context or metadata about the chat message. | | parentMessageId | string | The ID of the parent message if this message is a reply or related to another message in the conversation. Optional. | | conversationId | string | The 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.