Skip to content

ernie-1.0 支持padding 吗?我试验了padding, 结果不对呢 #10788

@lzg188

Description

@lzg188

Feature request

tokenizer = AutoTokenizer.from_pretrained('ernie-1.0')
#text = tokenizer('自然语言处理', padding=True, return_attention_mask=True)

text = tokenizer(
'自然语言处理',
padding='max_length', # Pad to the specified max_length
max_length=128, # Set the fixed length to 128
truncation=True, # Truncate if longer than max_length
return_attention_mask=True
)

model = AutoModelForSequenceClassification.from_pretrained('ernie-1.0',num_classes=2)
#sequence_output = model(input_ids=paddle.to_tensor([text['input_ids']]))
sequence_output = model(input_ids=paddle.to_tensor([text['input_ids']]), attention_mask=paddle.to_tensor([text['attention_mask']]))

print(sequence_output)

Motivation

rt

Your contribution

rt

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions