Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ByteLevelBPE training error after adding normalizers.Replace #1348

Closed
Byshev333 opened this issue Sep 27, 2023 · 3 comments
Closed

ByteLevelBPE training error after adding normalizers.Replace #1348

Byshev333 opened this issue Sep 27, 2023 · 3 comments
Labels

Comments

@Byshev333
Copy link

Byshev333 commented Sep 27, 2023

Recently I used ByteLevelBPETokenizer for tokenize training and set add_prefix_space to True during the training process. Later I found that it is reasonable to add prefix_space for English, but there is actually no need to add prefix_space for Chinese, Japanese and Korean. So, I use tokenizer.normalizer = normalizers.Replace(pattern=tokenizers.Regex(r"^(?=\p{Latin})"), content=' ') and set add_prefix_space=False to achieve the above function. But during the training process, an error was reported:

Traceback (most recent call last):
  File "trainer_bbpe_kwai.py", line 119, in <module>
    tokenizer.train(
  File "/share/miniconda3/envs/hf_tokenizers/lib/python3.8/site-packages/tokenizers/implementations/byte_level_bpe.py", line 98, in train
    self._tokenizer.train(files, trainer=trainer)
pyo3_runtime.PanicException: index out of bounds: the len is 39 but the index is 39
thread '<unnamed>' panicked at 'index out of bounds: the len is 35 but the index is 35', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bounds: the len is 115 but the index is 115', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bounds: the len is 16 but the index is 16', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bouThanks for your attention to this matter.nds: the len is 4 but the index is 4', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bounds: the len is 4 but the index is 4', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bounds: the len is 32 but the index is 32', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bounds: the len is 13 but the index is 13', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bounds: the len is 7 but the index is 7', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21
thread '<unnamed>' panicked at 'index out of bounds: the len is 2 but the index is 2', /home/runner/work/tokenizers/tokenizers/tokenizers/src/tokenizer/normalizer.rs:382:21

How can we solve this problem?
training code
Thanks for your attention to this issue.

Copy link

github-actions bot commented Dec 9, 2023

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Dec 9, 2023
@ArthurZucker
Copy link
Collaborator

Sorry I did not have a look but the normalizer if of course in cause here. Not sure I'll have the time to debug this, @Narsil if anything comes to your mind!

@github-actions github-actions bot removed the Stale label Dec 10, 2023
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jan 10, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants