LoginSignup
1
0

kotomamba-2.8B-v1.0は『雪国』の冒頭をどうトークナイズするのか

Posted at

Kotoba Technologiesからkotomanbaがリリースされたので、とりあえずトークナイザを試してみることにした。ただ、kotomamba-2.8B-v1.0のトークナイザは、Megatron-LMのかなり古いバージョンをベースにしていて、今となっては動かしにくいシロモノだった。Google Colaboratoryだとこんな感じ。

!pip install transformers sentencepiece
!test -d kotomamba || git clone --depth=1 https://github.com/kotoba-tech/kotomamba
from kotomamba.megatron_lm.megatron.tokenizer import build_tokenizer
from transformers.utils import cached_file
arg=type("",(object,),{})
arg.tokenizer_type="SentencePieceTokenizer"
arg.tokenizer_model=cached_file("kotoba-tech/kotomamba-2.8B-v1.0","tokenizer.model")
arg.vocab_extra_ids=0
arg.make_vocab_size_divisible_by=128
tkz=build_tokenizer(arg)
print([tkz.inv_vocab[t] for t in tkz.tokenize("国境の長いトンネルを抜けると雪国であった。夜の底が白くなった。")])

私(安岡孝一)の手元では、以下の結果となった。

['▁', '国境', 'の', '長', 'い', 'トンネル', 'を', '抜け', 'る', 'と', '雪国', 'で', 'あっ', 'た', '。', '夜', 'の', '底', 'が', '白く', 'な', 'った', '。']

非常に残念だが「雪国であった」を「雪国」「で」「あっ」「た」とトークナイズしておきながら、その一方「白くなった」を「白く」「な」「った」とトークナイズするようなトークナイザは、あまりに使い勝手が悪い。さて、何とかならないかなぁ。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0