Skip to main content

coverage

test coverage

tests

test results

Byte Pair Encoding for Natural Language Processing.

Installation

Install with pip:

pip install bpelib

Uninstalling

Uninstall with pip:

pip uninstall bpelib

Usage

Import the BPE class.

from bpelib import bpe

Learn encoding on construct or at a later time:

bpe = BPE(['start', 'learning', 'now'])
# or ...
bpe.learn_encoding(['start', 'learning', 'now'])

To encode or decode a word, simply call the BPE object.

encoded = bpe('encode')  # '<w/> e n c o d e </w>'
decoded = bpe(encoded)  # 'encode'
assert 'encode' == decoded

You can call encode or decode explicitly, too.

encoded = bpe.encode('encode')  # '<w/> e n c o d e </w>'
decoded = bpe.decode(encoded)  # 'encode'
assert 'encode' == decoded

You can also specify maximum vocabulary size and the used encoding.

bpe = BPE(max_vocab_size=1024, encoding='ascii')

Metadata

Release files for bpelib 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bpelib 0.1.3
File Size Uploaded
bpelib-v0.1.3.tar.gz 1.6 MB Details

Release files / bpelib-v0.1.3.tar.gz

Download URL bpelib-v0.1.3.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
751d1ff98fa76b3beb7524425d33065c1eda1102cb127669c2b81b600df95aac
BLAKE2b-256 checksum
How to use checksums
1d7d2304ee53cb4005420f5a328fc111d3749b034b130b70e3abcea9029ab164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

v0.1.2

1 release file

v0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page