bert-as-service 最大序列长度

数据挖掘 nlp 顺序 伯特
2022-02-26 21:57:29

我安装了 bert-as-service(bert-as-service github repomulti_cased_L-12_H-768_A-12 )并尝试在模型上用日语编码一些句子。它似乎有效,因为我得到了每个单词长度为 768 的向量,但np.shape()每个句子都显示了这一点:

np.shape(vec_j[0]): (25, 768)
np.shape(vec_j[1]): (25, 768)
np.shape(vec_j[2]): (25, 768)
np.shape(vec_j[3]): (25, 768)
np.shape(vec_j[4]): (25, 768)
type: <class 'numpy.ndarray'>

我的句子很短,所以有相当多的 0 填充。不过,我不确定为什么这个模型的最大序列长度似乎是 25 而不是这里提到的 512: Bert documentation section on tokenization

“截断到最大序列长度。(您最多可以使用 512,但出于内存和速度原因,您可能希望使用更短的长度。)”

1个回答

的默认设置为max_seq_len25,如下所示标题服务器 API: bert-as-service 自述文件

这里的 Github repo 上有一个未解决的问题,创建者似乎正在实现一个功能: bert-as-service issues