PHPackages                             rahul900day/gpt-3-encoder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. rahul900day/gpt-3-encoder

Abandoned → [rahul900day/tiktoken-php](/?search=rahul900day%2Ftiktoken-php)Library[Parsing &amp; Serialization](/categories/parsing)

rahul900day/gpt-3-encoder
=========================

GPT-3-Encoder is a PHP implementation of OpenAI's original python encoder/decoder.

1.1.0(3y ago)232.0k↓39%[2 PRs](https://github.com/RahulDey12/gpt-3-encoder/pulls)MITPHPPHP ^7.4 || ^8.0

Since Mar 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/RahulDey12/gpt-3-encoder)[ Packagist](https://packagist.org/packages/rahul900day/gpt-3-encoder)[ Fund](https://ko-fi.com/rahul900day)[ RSS](/packages/rahul900day-gpt-3-encoder/feed)WikiDiscussions 1.x Synced 3w ago

READMEChangelog (3)Dependencies (4)Versions (6)Used By (0)

GPT-3-Encoder for PHP
=====================

[](#gpt-3-encoder-for-php)

[![StyleCI Status](https://camo.githubusercontent.com/70a475a560e507c66f4bca83a9db0d21a394103600e1413e6f30d7cf6a06e820/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3631303932343130392f736869656c64)](https://styleci.io/repos/610924109)[![Build Status](https://github.com/RahulDey12/gpt-3-encoder/workflows/CI/badge.svg)](https://github.com/rahuldey12/gpt-3-encoder/actions)[![Version](https://camo.githubusercontent.com/31cbeca2bd121ba3d22b51248a87eb77c67a5f0c646e54215c9b1d6c651da5b8/68747470733a2f2f706f7365722e707567782e6f72672f726168756c3930306461792f6770742d332d656e636f6465722f76657273696f6e)](https://packagist.org/packages/rahul900day/gpt-3-encoder)[![PHP Version Require](https://camo.githubusercontent.com/b397aabd75c7b2582295b478840d995961d3d75673625985b15e299f358365ed/687474703a2f2f706f7365722e707567782e6f72672f726168756c3930306461792f6770742d332d656e636f6465722f726571756972652f706870)](https://packagist.org/packages/rahul900day/gpt-3-encoder)

PHP BPE Encoder Decoder for GPT-2/GPT-3

About
-----

[](#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 PHP implementation of OpenAI's original python encoder/decoder which can be found [here](https://github.com/openai/gpt-2).

Get Started
-----------

[](#get-started)

> Requires [PHP 7.4+](https://php.net/releases/)

Install GPT-3-Encoder via the [Composer](https://getcomposer.org/) package manager

```
composer require rahul900day/gpt-3-encoder
```

Usage
-----

[](#usage)

Encoding a text to tokens

```
use Rahul900day\Gpt3Encoder\Encoder;

Encoder::encode("Your prompt.");
```

Decoding to text from tokens

```
use Rahul900day\Gpt3Encoder\Encoder;

Encoder::decode([8582, 242, 98]);
```

Credits
-------

[](#credits)

- [Rahul Dey](https://github.com/RahulDey12)
- [All Contributors](https://github.com/RahulDey12/gpt-3-encoder/graphs/contributors)

This packages has some codes and test inspiration from node's [gpt-3-encoder](https://github.com/latitudegames/GPT-3-Encoder)

License
-------

[](#license)

This package is released under the [MIT License](https://github.com/RahulDey12/gpt-3-encoder/blob/main/LICENSE.md).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~228 days

Total

4

Last Release

515d ago

PHP version history (2 changes)1.0.0PHP ^8.0

1.1.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/67074314?v=4)[Rahul Dey](/maintainers/rahul900day)[@rahul900day](https://github.com/rahul900day)

---

Top Contributors

[![RahulDey12](https://avatars.githubusercontent.com/u/26340814?v=4)](https://github.com/RahulDey12 "RahulDey12 (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

decoderencodergpt-2gpt-2-tokenizergpt-3gpt-3-tokenizerphptokenizerphpGPT-3tokenizerencoderdecodergpt-2GPT-3-TokenizerGPT-2-TokenizerGPT-3-EncoderGPT-2-Encoder

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rahul900day-gpt-3-encoder/health.svg)

```
[![Health](https://phpackages.com/badges/rahul900day-gpt-3-encoder/health.svg)](https://phpackages.com/packages/rahul900day-gpt-3-encoder)
```

###  Alternatives

[gioni06/gpt3-tokenizer

PHP package for Byte Pair Encoding (BPE) used by GPT-3.

84572.5k10](/packages/gioni06-gpt3-tokenizer)[rajentrivedi/tokenizer-x

TokenizerX calculates required tokens for given prompt

91242.5k3](/packages/rajentrivedi-tokenizer-x)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6442.4k](/packages/sbsaga-toon)[shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

2545.7k](/packages/shaarli-netscape-bookmark-parser)[suin/json

A Simple wrapper of json\_decode() and json\_encode(). This provides object-oriented interface and exception-based error handing.

1027.6k3](/packages/suin-json)[mathematicator-core/tokenizer

Math Tokenizer

104.9k6](/packages/mathematicator-core-tokenizer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
