我正在处理文本分类问题,在此我想使用BERT模型作为基础,接着再加上密集层。我想知道3个参数如何工作?例如,如果我有3个句子:
'My name is slim shade and I am an aspiring AI Engineer',
'I am an aspiring AI Engineer',
'My name is Slim'
那么这三个参数会做什么呢?我认为如下:
max_length=5
严格保留所有句子的长度为5padding=max_length
将第三个句子添加1个填充位truncate=True
截断第一个和第二个句子,使它们的长度严格为5。
如果我错了,请纠正我。
以下是我使用的代码。
! pip install transformers==3.5.1
from transformers import BertTokenizerFast
tokenizer = BertTokenizerFast.from_pretrained('bert-base-uncased')
tokens = tokenizer.batch_encode_plus(text,max_length=5,padding='max_length', truncation=True)
text_seq = torch.tensor(tokens['input_ids'])
text_mask = torch.tensor(tokens['attention_mask'])
Lemmatization
和/或Stemming
会更好吗?它能够处理sin,cos,theta,gamma
等吗?我认为这些也是300B个文本的一部分,因为它仅基于这些内容预测正确的标签。 - DeshwalcurrentI
是否会被更改为current I
,因为单独的current
一词可能会被分解。您无需执行词形还原,我在此问题上有一个答案:https://dev59.com/27Xna4cB1Zd3GeqPFh88#57072351 - Ashwin Geet D'Sa