Downloads · 30 days
0
geniacllm/ja-en-tokenizer-unigram-v5
ja-en-tokenizer-unigram-v5 is a machine learning model from geniacllm. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Downloads · 30 days
0
Access
Public
Updated Aug 15, 2024
Repo size
972 KB
Likes
2
Public
Click a slice to open those files.
.model972 KB · 99%
From the Hugging Face model README
数字を全て一桁区切りに。
wikipedia, mbpp, grade-school-mathで学習したトークナイザー。
以下を参考に日本語の語彙を追加。
概算ですが、アルファベットが約6割、日本語(ひらがな・カタカナ・漢字)が約4割となっています。(その他記号や数字は1~2%程度)
vocab_size=56,320(語彙サイズ)<br> character_coverage=0.9995(文字のカバー率99.95%)<br> model_type="unigram"(アルゴリズム)<br> normalization="identity"(正規化なし)<br> byte_fallback=True(バイト変換あり)<br> split_digits=True(数字分割あり)<br> allow_whitespace_only_pieces=True(空白のトークンを許可する)<br> remove_extra_whitespaces=True(余分な空白の削除あり)<br>
LlamaTokenizer<br> ※encode時に文頭にbos_tokenである"<s>"トークンが付きます。
!pip install transformers>=4.34.0
from transformers import AutoTokenizer
test_tokenizer = AutoTokenizer.from_pretrained("geniacllm/ja-en-tokenizer-unigram-v5", use_fast=False)
# text
text = "This is tokenizer test."
# tokenize
tokenized = test_tokenizer.tokenize(text)
print(tokenized)
# encode
encoded = test_tokenizer.encode(text)
print(encoded)
# decode
decoded = test_tokenizer.decode(encoded)
print(decoded)
# special_token
print(test_tokenizer.special_tokens_map)
# vocab size
print(len(test_tokenizer))
# all subwords in vocab
print(test_tokenizer.get_vocab())