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
Close
Hashes for tokenization_scorer-1.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59024038df6faa60b71d5b06fa300566e099982685f4e32a05706886db9b3467 |
|
MD5 | 4ff73f55712ea1d9e1a613989fc71110 |
|
BLAKE2b-256 | 717447579eadcd10eff91c6485ea9208f394ff9c54c55ffe197cf447b223eb8d |
Close
Hashes for tokenization_scorer-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 411e1f7190b3b3b1c5e2496f054b424af72c215ed71888694146475101c114b4 |
|
MD5 | 53029bca5c39869a879fdab829d781c9 |
|
BLAKE2b-256 | 2033a871d26a267d7bc7945ae3bd6a963d0a6c853805102bdfaa161c8d72ed28 |