Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@beskar-labs/gpt-encoder

beskar-co134MITdeprecated1.0.7TypeScript support: included

This package has been deprecated in favor of https://www.npmjs.com/package/gpt-tokenizer

Browser-based implementation of BPE Encoder / Decoder for GPT-2 / GPT-3.

readme

gpt-encoder

GPT-2 and GPT-3 use byte pair encoding to turn text into a series of integers to feed into the model. latitudegames implemented this in Node.js. This is an implementation of their encoder for use in the browser, re-written in Typescript.

Installation

npm install @beskar-labs/gpt-encoder

Usage

import { encode } from '@beskar-labs/gpt-encoder';

const tokens = encode(
  'This is an example sentence to try encoding out on!'
).length;