1

次の 2 つの文を考えてみましょう。

"why isn't Alex's text tokenizing? The house on the left is the Smiths' house"

それでは、トークン化してデコードしましょう。

from transformers import BertTokenizer
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased', do_lower_case=True)
tokenizer.decode(tokenizer.convert_tokens_to_ids(tokenizer.tokenize("why isn't Alex's text tokenizing? The house on the left is the Smiths' house")))

我々が得る:

"why isn't alex's text tokenizing? the house on the left is the smiths'house"

私の質問は、smiths'houseのような所有格で不足しているスペースをどのように扱うかです。

私にとっては、トランスフォーマーでのトークン化のプロセスが正しく行われていないようです。の出力を考えてみましょう

tokenizer.tokenize("why isn't Alex's text tokenizing? The house on the left is the Smiths' house")

我々が得る:

['why', 'isn', "'", 't', 'alex', "'", 's', 'text', 'token', '##izing', '?', 'the', 'house', 'on', 'the', 'left', 'is', 'the', 'smith', '##s', "'", 'house']

したがって、このステップでは、最後のアポストロフィに関する重要な情報がすでに失われています。トークン化が別の方法で行われた場合は、はるかに優れています。

['why', 'isn', "##'", '##t', 'alex', "##'", '##s', 'text', 'token', '##izing', '?', 'the', 'house', 'on', 'the', 'left', 'is', 'the', 'smith', '##s', "##'", 'house']

このように、トークン化はアポストロフィに関するすべての情報を保持し、所有格の問題は発生しません。

4

0 に答える 0