我正试图通过变压器使用XLNET。但是,我一直遇到"AttributeError:'NoneType‘对象没有属性'tokenize'“的问题。我不知道该怎么做。如果有人能为我指明正确的方向,我们将不胜感激。
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased', do_lower_case=True)
print(' Original: ', X_train[1])
# Print the tweet split into tokens.
print('Tokenized: ', tokenizer.tokenize(X_train[1]))
# Print the tweet mapped to token ids.
print('Token IDs: ', tokenizer.convert_tokens_to_ids(tokenizer.tokenize(X_train[1])))
Original: hey angel duh sexy really thanks haha
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-67-2b1b432b3e15> in <module>()
2
3 # Print the tweet split into tokens.
----> 4 print('Tokenized: ', tokenizer.tokenize(X_train[2]))
5
6 # Print the tweet mapped to token ids.
AttributeError: 'NoneType' object has no attribute 'tokenize'
发布于 2021-06-01 11:20:55
我假定:
from transformers import XLNetTokenizerFast
tokenizer = XLNetTokenizerFast.from_pretrained('xlnet-base-cased', do_lower_case=True)
有用吗?在本例中,您只是缺少了句式包:
pip install sentencepiece
发布于 2021-10-22 14:16:30
如果安装了SenencePience,并且仍然存在错误
当然,@cronoik的答案是正确的。毫无疑问。但是如果您已经安装了SenencePience软件包,并且仍然存在错误,那么只需使用SenencePience。
https://stackoverflow.com/questions/67785438
复制相似问题