danny50610/bpe-tokeniser
最新稳定版本:0.3.0
Composer 安装命令:
composer require danny50610/bpe-tokeniser
包简介
PHP port for openai/tiktoken (most)
README 文档
README
PHP port for openai/tiktoken (most)
Supported encodings
- gpt-3.5-turbo
- gpt-4
- gpt-4o
- gpt-oss
- gpt-5
- more ...
For available encodings, see src/EncodingFactory.php
Installation
composer require danny50610/bpe-tokeniser
Example
GPT-5 (o200k_base)
use Danny50610\BpeTokeniser\EncodingFactory; $enc = EncodingFactory::createByModelName('gpt-5-2025-08-07'); var_dump($enc->encode("hello world")); /** * output: * array(2) { * [0]=> * int(24912) * [1]=> * int(2375) * } */ var_dump($enc->decode($enc->encode("hello world"))); // output: string(11) "hello world"
GPT-4 / GPT-3.5-Turbo (cl100k_base)
use Danny50610\BpeTokeniser\EncodingFactory; $enc = EncodingFactory::createByEncodingName('cl100k_base'); var_dump($enc->encode("hello world")); /** * output: * array(2) { * [0]=> * int(15339) * [1]=> * int(1917) * } */ var_dump($enc->decode($enc->encode("hello world"))); // output: string(11) "hello world"
use Danny50610\BpeTokeniser\EncodingFactory; $enc = EncodingFactory::createByModelName('gpt-3.5-turbo'); var_dump($enc->decode($enc->encode("hello world"))); // output: string(11) "hello world"
统计信息
- 总下载量: 369.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-19