1# TikToken clone for PHP - PHP GPT3 tokenizer
2
3PHP Text Tokenizer for GPT models
4
5## About
6
7A PHP toolkit to tokenize text like GPT family of models process it.
8
9Forked from [semji/gpt3-tokenizer-php](https://github.com/semji/gpt3-tokenizer-php) to bug fixes and improvement.
10
11## Requirements
12* PHP 8.1
13* mbstring extension [details here on how to install mbstring](https://www.php.net/manual/en/mbstring.installation.php)
14## Usage
15
16```php
17use TikToken\Encoder;
18$prompt = "Ai is cool";
19$encoder = new Encoder();
20
21$tokens = $encoder->encode($prompt); // [32, 72, 318, 3608]
22
23// Get tokens count:
24echo count($tokens); // 4
25```
26