tokenization-scorer

Simple package for evaluating text tokenizations. The input is a text (list of files or stdin) and output a single number. The higher the number, the better the tokenization. The intended workflow is to try multiple tokenizations and select the one with the highest number.
It can be used from the command line:
pip3 install tokenization-scorer
tokenization-scorer -i en-de.tokenized_with_unigramlm.{en,de}
> 0.4826
tokenization-scorer -i en-de.tokenized_with_wordpiece.{en,de}
> 0.5047
or within Python:
import tokenization_scorer
text1 = "pick @@ed pick @@l @@ed pick @@les"
tokenization_scorer.score(text1, metric="renyi", power=2.5)
> 0.8031528501359657
text2 = "pick @@e @@d pick @@l @@e @@d pick @@l @@e @@s"
tokenization_scorer.score(text2, metric="renyi", power=2.5)
> 0.9105681923824472
Use tokenization-scorer -h to get an overview of supported metrics.
This package is a side-product of the paper Tokenization and the Noiseless Channel.
@inproceedings{tokenization_noiseless,
title={Tokenization and the Noiseless Channel},
author={Zouhar, Vilém and Meister, Clara and Gastaldi, Juan Luis and Sachan, Mrinmaya and Cotterell, Ryan},
booktitle={Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics},
year={2023},
url={https://aclanthology.org/2023.acl-long.284/},
}
Metadata
Release files for tokenization-scorer 1.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tokenization_scorer-1.1.8.tar.gz | 5.3 kB | Without provenance | Details for tokenization_scorer-1.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tokenization_scorer-1.1.8-py3-none-any.whl | Python 3 | none | any | Details for tokenization_scorer-1.1.8-py3-none-any.whl |
Total release size: 11.7 kB
Release files / tokenization_scorer-1.1.8.tar.gz
| Download URL | tokenization_scorer-1.1.8.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03ebaa67a11b5aa5b29515d42a263a11ee0627c8e4f6d2ebb34eb159a227fd43
|
|
BLAKE2b-256 checksum How to use checksums |
edfe3904122e2dc1fa5b2408c7b756644708d794732249a15985a7ca943a0a86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Release files / tokenization_scorer-1.1.8-py3-none-any.whl
| Download URL | tokenization_scorer-1.1.8-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
662663ed029ae165ce5968d962622fd34539c533ecb521510b6b20db82e35ad4
|
|
BLAKE2b-256 checksum How to use checksums |
afe6d2b0c5e8ee4d40c97e0eaa5973342d310059528cb4d611a3d39f44d4464f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Security for tokenization-scorer 1.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.