Skip to main content

Package for evaluating text tokenizations.

Project description

tokenization-scorer PyPI Version

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

tokenization_scorer-1.1.6.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenization_scorer-1.1.6-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file tokenization_scorer-1.1.6.tar.gz.

File metadata

  • Download URL: tokenization_scorer-1.1.6.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for tokenization_scorer-1.1.6.tar.gz
Algorithm Hash digest
SHA256 86ff9dc659d3108b3922a1fcfecbf3e4221c8a32bc4e0b2cca68e69d2929e24d
MD5 76ac080777e5ce1f7aa153069cdfabb4
BLAKE2b-256 70f23553284dddc2ae72e628e2bab986479d55b3c55af6b5119ef6c08e5b70d6

See more details on using hashes here.

File details

Details for the file tokenization_scorer-1.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for tokenization_scorer-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 aa6174abc4a9b80b3ef3cfd235b906a9727561d69c99fa5b432a19fd415f28c8
MD5 495f14e1acaf1264c8f59c6ee9905c4d
BLAKE2b-256 c3ee52b92e856777c896249b0a7a6a1676d5d7546efb0f630364f869be244b41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page