AnswerDotAI / AnswerDotAI/ModernBERT
How to use a custom tokenizer for pre-training BERT from scratch
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
I want to use `main.py yamls/main/mosaic-bert-base-uncased.yaml` to pre-train MosaicBERT from scratch on my custom (obscure language) dataset. I have converted the dataset to .mds format, and the training goes well with the mentioned yaml file. Based on my understanding, I also need to train my own tokenizer as well because of the nature of the language. I have trained a custom tokenizer on my dataset using `base_bert_uncased` as the tokenizer format.
I saw this line in the `yaml` file:
```
tokenizer_name: bert-base-uncased
```
I wanted to ask how can I tell the `yaml` file to use my own tokenizer that I haven't yet uploaded to huggingface. I tried specifying the tokenizer's local directory path but the backend is perhaps coded to find the tokenizer on `huggingface.com` because it throws this message with my custom tokenizer path:
```
OSError: ./ does not appear to have a file named config.json. Checkout 'https://huggingface.co/.//tree/main' for available files.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with main.py and yamls/main/mosaic-bert-base-uncased.yaml, then trace how tokenizer_name is loaded when given a local directory. Reproduce the reported config.json error with the custom tokenizer path and determine what local tokenizer layout is accepted. Done means the YAML can use the custom tokenizer without uploading it to Hugging Face and pre-training starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100