Package for evaluating text tokenizations.
Project description
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/},
}
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
Built Distribution
File details
Details for the file tokenization_scorer-1.1.4.tar.gz
.
File metadata
- Download URL: tokenization_scorer-1.1.4.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0be80c91fad54741b578911a16c92675d328c9b560f7d366395495c71972c77 |
|
MD5 | 40ae43bdd3e40cc2b37b967bffb714bc |
|
BLAKE2b-256 | a9c54b3a239ed05f7494c763fcd48622a7a023197780fe405d89f45ff4fff097 |
File details
Details for the file tokenization_scorer-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: tokenization_scorer-1.1.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 834f4978d2bcba461ac2a6e5118bc5cb64b7d30a1664c3ec3bbb5ee6ddbe0ac7 |
|
MD5 | bd2dd1170008de67ac7d0e30a0be578d |
|
BLAKE2b-256 | b5187ff95533708c617b481d69f1c77553943b006ecd0445d83f53d662105f9b |