|
# 説明 |
|
ごく少量の日本語テキストで作った、テスト用のトークナイザーです。 |
|
## 学習に使ったデータサイズ |
|
日本語:545KB |
|
## 設定 |
|
vocab_size=32,000(語彙サイズ)<br> |
|
character_coverage=0.9995(文字のカバー率99.95%)<br> |
|
model_type="BPE"(アルゴリズム)<br> |
|
normalization="identity"(正規化なし)<br> |
|
byte_fallback=True(バイト変換あり)<br> |
|
split_digits=True(数字分割あり)<br> |
|
allow_whitespace_only_pieces=True(空白のトークンを許可する)<br> |
|
remove_extra_whitespaces=True(余分な空白の削除あり)<br> |
|
<br> |
|
# 使い方 |
|
```python |
|
!pip install transformers>=4.34.0 |
|
|
|
from transformers import T5Tokenizer |
|
test_tokenizer = T5Tokenizer.from_pretrained("geniacllm/ucllm-test-tokenizer-bpe") |
|
``` |
|
```python |
|
# text |
|
text = "今日はいい天気ですね。" |
|
|
|
# tokenize |
|
tokenized = test_tokenizer.tokenize(text) |
|
print(tokenized) |
|
# 出力:['今日は', 'いい', '天', '気', 'ですね', '。'] |
|
|
|
# encode |
|
encoded = test_tokenizer.encode(text) |
|
print(encoded) |
|
# 出力:[5130, 448, 30475, 30024, 1650, 29966, 2] |
|
|
|
# decode |
|
decoded = test_tokenizer.decode(encoded) |
|
print(decoded) |
|
# 出力:今日はいい天気ですね。</s> |
|
|
|
# special_token |
|
print(test_tokenizer.special_tokens_map) |
|
# 出力:{'bos_token': '<s>', 'eos_token': '</s>', 'unk_token': '<unk>', 'sep_token': '<SEP>', 'pad_token': '<pad>', 'cls_token': '<CLS>', 'mask_token': '<MASK>', 'additional_special_tokens': ['<EOD>']} |
|
|
|
# vocab size |
|
print(len(test_tokenizer)) |
|
# 出力:32000 |
|
|
|
# all subwords in vocab |
|
print(test_tokenizer.get_vocab()) |
|
# 出力:{'<unk>': 0, '<s>': 1, '</s>': 2, '<pad>': 3, '<CLS>': 4, '<SEP>': 5, …(以下略) |
|
``` |
|
|