Skip to main content

Implementation of BPE-knockout, a morphologically informed post-processing step for BPE tokenisers.

Project description

BPE-knockout

Repo hosting all the code used for the BPE-knockout paper. Below are the instructions for reproducing and extending the intrinsic evaluations. Extrinsic evaluations are done with RobBERT's framework.

Data

All data is included in the repo, because it is obtainable for free elsewhere and free of license too.

Installing

Because this repo ships with data (word lists and tokenisers) that take quite a while to compute, we currently only guarantee that an editable install works. That is: you tell Python to use the folder into which you cloned the repo, rather than copying the code to your global or virtual site-packages directory.

git clone https://github.com/GitMew/BPE-knockout.git
cd BPE-knockout
pip install -r requirements.txt
pip install -e .

If you're using conda or venv, don't forget to activate those before running any calls to pip install.

Running

  1. Unzip the .rar file under data/compressed/.
  2. Run py main.py or python main.py in a terminal.

Using your own data

It is possible to use other datasets (even other languages) than the ones used for the paper. Here is how you would do that:

  1. Make sure you have the following files:
    1. A word count file from a sufficiently large corpus;
    2. A file with morphological decompositions (not necessarily of the same words);
    3. Optional: if you don't want to generate a new BPE tokeniser from your word counts, the file(s) that specify your existing BPE tokeniser.
  2. If your morphological decompositions are not in CELEX format, you still need to write your own parser for the morphology file. Do this in src/datahandlers/morphology.py by creating a subclass of the abstract LemmaMorphology class.
  3. In src/auxiliary/config.py, create a new function that creates a ProjectConfig object declaring the paths to all the relevant files, as well as the name of the relevant LemmaMorphology subclass. Use the setup() functions as examples.
  4. In main.py, specify this new config.

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

bpe_knockout-2024.4.1.tar.gz (69.5 kB view details)

Uploaded Source

Built Distribution

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

bpe_knockout-2024.4.1-py3-none-any.whl (75.1 kB view details)

Uploaded Python 3

File details

Details for the file bpe_knockout-2024.4.1.tar.gz.

File metadata

  • Download URL: bpe_knockout-2024.4.1.tar.gz
  • Upload date:
  • Size: 69.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

File hashes

Hashes for bpe_knockout-2024.4.1.tar.gz
Algorithm Hash digest
SHA256 0ff8860a4f7033b3cf21cea7ae135fce4577f0e85c8e6b17f369b00306104d0d
MD5 35e2a41ad0c75807b65312a502936eb5
BLAKE2b-256 509b5d71bb200cf288e913fe29d0fb43b2ea4deda9a896bc52d69e636d998d3f

See more details on using hashes here.

File details

Details for the file bpe_knockout-2024.4.1-py3-none-any.whl.

File metadata

  • Download URL: bpe_knockout-2024.4.1-py3-none-any.whl
  • Upload date:
  • Size: 75.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

File hashes

Hashes for bpe_knockout-2024.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9aaf1ee5f5edc61d97ebee892f21c646994671da1a1576518318aaf8b6f5b8b5
MD5 e62ddf30203d4de5e1b9b6ce44032713
BLAKE2b-256 3c1ad3e7f96dd31f6efe62aafb7fd9678901755c220631c7c731be1770ca60d7

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