Skip to content

Add a ParityBpeTrainer example and list it in the trainers API docs - #2217

Open
cimeister wants to merge 1 commit into
huggingface:mainfrom
cimeister:parity-bpe-example
Open

Add a ParityBpeTrainer example and list it in the trainers API docs#2217
cimeister wants to merge 1 commit into
huggingface:mainfrom
cimeister:parity-bpe-example

Conversation

@cimeister

Copy link
Copy Markdown
Contributor

ParityBpeTrainer was added without a usage example or an API docs entry. Its docstring assumed local per-language files that users are unlikely to have, and did not document the ratio argument.

This PR:

  • adds examples/train_parity_bpe.py, which pulls per-language training text from wikimedia/wikipedia and a parallel dev set from openlanguagedata/flores_plus, then demonstrates both balancing modes
  • lists ParityBpeTrainer in docs/source-doc-builder/api/trainers.mdx
  • describes the ratio parameter in more detail: it is a relative target, the trainer selects the language with the lowest compression_rate / ratio, and compression is counted in the units the pre-tokenizer emits, which for ByteLevel means bytes. Equal ratios therefore do not give equal tokenization across scripts, since Devanagari takes about 2.5x the bytes of Latin script for the same content. The example computes its ratios from mean FLORES+ bytes per sentence for that reason.

ParityBpeTrainer shipped without a usage example or an API docs entry. Its
docstring assumed local per-language files that users are unlikely to have,
and did not document the `ratio` argument.

Add examples/train_parity_bpe.py, which pulls per-language training text from
wikimedia/wikipedia and a parallel dev set from openlanguagedata/flores_plus,
then demonstrates both balancing modes. List ParityBpeTrainer in
docs/source-doc-builder/api/trainers.mdx.

Document `ratio` in more detail: it is a relative target, the trainer selects the
language with the lowest compression_rate / ratio, and compression is counted in
the units the pre-tokenizer emits, which for ByteLevel means bytes. Equal ratios
therefore do not give equal tokenization across scripts, since Devanagari takes
about 2.5x the bytes of Latin script for the same content. The example derives
its ratios from mean FLORES+ bytes per sentence for that reason. Also note that
balancing needs either a parallel dev set or ratios, and that the dev set takes
precedence when both are passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant