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.3.1.tar.gz (65.4 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.3.1-py3-none-any.whl (70.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bpe_knockout-2024.3.1.tar.gz
  • Upload date:
  • Size: 65.4 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.3.1.tar.gz
Algorithm Hash digest
SHA256 65cd4885d1743f5b7080122cd7ee425193ef1d4ab71557e106b8afa76b895abe
MD5 6320df0bc5952c3cedd790870ff87fc9
BLAKE2b-256 ee4007a72a8b48dab4b73f97f405c1671bc31a2319b84299a4eeda6e1f786584

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bpe_knockout-2024.3.1-py3-none-any.whl
  • Upload date:
  • Size: 70.6 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7596502fe1fcb0e81d7e101f98c972a859cdd66497bfb5638f81619333621f7e
MD5 b327c818eb7c7d1e23cc6153757fc921
BLAKE2b-256 b70614740773116f7cd8c8863d64376317fbae67ef91e0079a192b70a0ac6de1

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