Encoder/Decoder and tokens counter for GPT3
Project description
An OpenAI GPT3 helper library for encoding/decoding strings and counting tokens.
Counting tokens gives the same output as OpenAI’s tokenizer
Supported python versions: >=2.7 <3.0 OR >=3.3
Installing
pip install gpt3_tokenizer
Examples
Encoding/decoding a string
import gpt3_tokenizer
a_string = "That's my beautiful and sweet string"
encoded = gpt3_tokenizer.encode(a_string) # outputs [2504, 338, 616, 4950, 290, 6029, 4731]
decoded = gpt3_tokenizer.decode(encoded) # outputs "That's my beautiful and sweet string"
Counting tokens
import gpt3_tokenizer
a_string = "That's my beautiful and sweet string"
tokens_count = gpt3_tokenizer.count_tokens(a_string) # outputs 7
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gpt3_tokenizer-0.1.5.tar.gz
(560.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gpt3_tokenizer-0.1.5.tar.gz.
File metadata
- Download URL: gpt3_tokenizer-0.1.5.tar.gz
- Upload date:
- Size: 560.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.3 Darwin/23.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0366a9b7000b1a9066ae9257eed7f2b665b374788d38bbeac86ab9145ab1a6c9
|
|
| MD5 |
35e18abadfbb3caa9d2965b1fa788a22
|
|
| BLAKE2b-256 |
46f633582154322e1444ba6a677a4bca1d79e1221304e3607b14881c3510bf56
|
File details
Details for the file gpt3_tokenizer-0.1.5-py2.py3-none-any.whl.
File metadata
- Download URL: gpt3_tokenizer-0.1.5-py2.py3-none-any.whl
- Upload date:
- Size: 567.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.3 Darwin/23.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d0ed9c7efa907d45ce3c338ffe2ee3bc9124ee1236248989bd883fd4eb0e5b6
|
|
| MD5 |
be14a8564759115669651d1c681dd8db
|
|
| BLAKE2b-256 |
ebedaf04d6badad07846809ef832ab1ea294697961d82c2c330445bd081b1e47
|