You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
encoder_output = outputs[0]
pooled_output = outputs[1]
new_mem = outputs[2]
请问ERINE-doc不是号称可以处理长文本吗 为什么在当输出文本超过512tokens时 依然出现:Token indices sequence length is longer than the specified maximum sequence length for this model (566 > 512). Running this sequence through the model will result in indexing errors
The text was updated successfully, but these errors were encountered:
在使用demo时:
import numpy as np
import paddle
from paddlenlp.transformers import ErnieDocModel
from paddlenlp.transformers import ErnieDocTokenizer
def get_related_pos(insts, seq_len, memory_len=128):
beg = seq_len + seq_len + memory_len
r_position = [list(range(beg - 1, seq_len - 1, -1)) +
list(range(0, seq_len)) for i in range(len(insts))]
return np.array(r_position).astype('int64').reshape([len(insts), beg, 1])
tokenizer = ErnieDocTokenizer.from_pretrained('ernie-doc-base-zh')
model = ErnieDocModel.from_pretrained('ernie-doc-base-zh')
inputs = tokenizer("长文本")
inputs = {k:paddle.to_tensor([v + [0] * (128-len(v))]).unsqueeze(-1) for (k, v) in inputs.items()}
memories = [paddle.zeros([1, 128, 768], dtype="float32") for _ in range(12)]
position_ids = paddle.to_tensor(get_related_pos(inputs['input_ids'], 128, 128))
attn_mask = paddle.ones([1, 128, 1])
inputs['memories'] = memories
inputs['position_ids'] = position_ids
inputs['attn_mask'] = attn_mask
outputs = model(**inputs)
encoder_output = outputs[0]
pooled_output = outputs[1]
new_mem = outputs[2]
请问ERINE-doc不是号称可以处理长文本吗 为什么在当输出文本超过512tokens时 依然出现:Token indices sequence length is longer than the specified maximum sequence length for this model (566 > 512). Running this sequence through the model will result in indexing errors
The text was updated successfully, but these errors were encountered: