# gpt-3-encoder

> Javascript BPE Encoder Decoder for GPT-2 / GPT-3

Latest version **1.1.4** (published 2023-01-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install gpt-3-encoder
pnpm add gpt-3-encoder
yarn add gpt-3-encoder
bun add gpt-3-encoder
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2023-01-18 |
| First published | 2020-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 720 |
| Maintainers | nickwalton00 |

## Links

- npm: https://www.npmjs.com/package/gpt-3-encoder
- Repository: https://github.com/AIDungeon/GPT-3-Encoder
- Homepage: https://github.com/AIDungeon/GPT-3-Encoder#readme
- Issues: https://github.com/AIDungeon/GPT-3-Encoder/issues
- npm.io page: https://npm.io/package/gpt-3-encoder

## Recent versions

- 1.1.4 (latest) — 2023-01-18
- 1.1.3 — 2020-09-15
- 1.1.2 — 2020-09-15
- 1.1.1 — 2020-09-08
- 1.1.0 — 2020-09-08
- 1.0.5 — 2020-09-04
- 1.0.4 — 2020-09-04
- 1.0.3 — 2020-09-04
- 1.0.2 — 2020-09-04
- 1.0.1 — 2020-09-04
- 1.0.0 — 2020-09-04

## README

# GPT-3-Encoder
Javascript BPE Encoder Decoder for GPT-2 / GPT-3

## About
GPT-2 and GPT-3 use byte pair encoding to turn text into a series of integers to feed into the model. This is a javascript implementation of OpenAI's original python encoder/decoder which can be found [here](https://github.com/openai/gpt-2)

## Install with npm

```
npm install gpt-3-encoder
```

## Usage

Compatible with Node >= 12

```js
const {encode, decode} = require('gpt-3-encoder')

const str = 'This is an example sentence to try encoding out on!'
const encoded = encode(str)
console.log('Encoded this string looks like: ', encoded)

console.log('We can look at each token and what it represents')
for(let token of encoded){
  console.log({token, string: decode([token])})
}

const decoded = decode(encoded)
console.log('We can decode it back into:\n', decoded)

```

---
_Source: https://npm.io/package/gpt-3-encoder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
