<jupyter_start><jupyter_text>how to train a tokenizer<jupyter_code>import sys
sys.path.append('..')
from jpn_bpe_tokenizer import MecabBPETrainTokenizer<jupyter_output><empty_output><jupyter_text>Specify the text to use for training<jupyter_code>files = 'data/very_small_sample.txt'<jupyter_output><empty_output><jupyter_text>Instntiate an tokenizer object<jupyter_code>tokenizer = MecabBPETrainTokenizer()<jupyter_output><empty_output><jupyter_text>Train<jupyter_code>tokenizer.train(files,
                vocab_size=52000,
                special_tokens=["<pad>", "<unk>", "<s>", "</s>", "<mask>"])<jupyter_output><empty_output><jupyter_text>Create a folder to save the trained config files<jupyter_code>import os
DIR = 'config_files'
os.makedirs(DIR,exist_ok=True)<jupyter_output><empty_output><jupyter_text>Save<jupyter_code>tokenizer.save_model(DIR)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12542372881355932, 'fraction_numerical': 0.005649717514124294, 'mean_word_length': 9.423529411764706, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '105013', 'license': 'MIT', 'n_tokens_mistral': 340, 'n_tokens_neox': 330, 'n_words': 40, 'path': 'examples/train_tokenizer.ipynb', 'repo_name': 'stsuchi/Japanese-BPE-Tokenizer', 'size': '885'}