请问hanlp2.0 提供ner 模型的训练集是什么形式的呢?

使用 hanlp.load(hanlp.pretrained.ner.MSRA_NER_BERT_BASE_ZH) 来predict 的时候,发现以一篇“文章”切成句子使用模型识别出来的ner,与同一篇加另外半篇“文章”合起来使用模型识别出来的ner是不一样的(同一篇文章句子切成的句子完全一致)。
请问这个模型的训练集是什么样的?会导致“一篇半”的时候识别不出来“一篇”识别到的ner。可以提供训练集sample吗?

另外predict 的时候会warning:

WARNING:tensorflow:8 out of the last 16 calls to <function Model.make_predict_function.<locals>.predict_function at 0x7ff93d4c9670> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to 
(1) creating @tf.function repeatedly in a loop, 
(2) passing tensors with different shapes, 
(3) passing Python objects instead of tensors. 
For (1), please define your @tf.function outside of the loop. 
For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing.
For (3), please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for  more details.

然后会因为resource exhausted 停止 ,请问应该如何避免这个问题呢?

================================ERROR LOG BEGINS================================
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/hanlp/utils/component_util.py", line 48, in load_from_meta_file
    obj.load(save_dir, **load_kwargs)
  File "/opt/conda/lib/python3.8/site-packages/hanlp/common/component.py", line 244, in load
    self.build(**merge_dict(self.config, training=False, logger=logger, **kwargs, overwrite=True, inplace=True))
  File "/opt/conda/lib/python3.8/site-packages/hanlp/common/component.py", line 254, in build
    self.model = self.build_model(**merge_dict(self.config, training=kwargs.get('training', None),
  File "/opt/conda/lib/python3.8/site-packages/hanlp/components/taggers/transformers/transformer_tagger.py", line 36, in build_model
    model, tokenizer = build_transformer(transformer, max_seq_length, len(self.transform.tag_vocab), tagging=True)
  File "/opt/conda/lib/python3.8/site-packages/hanlp/layers/transformers/loader.py", line 62, in build_transformer
    output = l_bert([l_input_ids, l_token_type_ids], mask=l_mask_ids)
  File "/opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 925, in __call__
    return self._functional_construction_call(inputs, args, kwargs,
  File "/opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1117, in _functional_construction_call
    outputs = call_fn(cast_inputs, *args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/tensorflow/python/autograph/impl/api.py", line 258, in wrapper
    raise e.ag_error_metadata.to_exception(e)
tensorflow.python.framework.errors_impl.ResourceExhaustedError: in user code:

    /opt/conda/lib/python3.8/site-packages/bert/model.py:80 call  *
        output           = self.encoders_layer(embedding_output, mask=mask, training=training)
    /opt/conda/lib/python3.8/site-packages/bert/transformer.py:234 call  *
        layer_output = encoder_layer(layer_input, mask=mask, training=training)
    /opt/conda/lib/python3.8/site-packages/bert/transformer.py:182 call  *
        layer_output = self.output_projector([intermediate_output, attention_output], mask=mask)
    /opt/conda/lib/python3.8/site-packages/bert/transformer.py:65 call  *
        output = self.dense(output)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:925 __call__  **
        return self._functional_construction_call(inputs, args, kwargs,
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1098 _functional_construction_call
        self._maybe_build(inputs)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:2643 _maybe_build
        self.build(input_shapes)  # pylint:disable=not-callable
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/layers/core.py:1171 build
        self.kernel = self.add_weight(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:597 add_weight
        variable = self._add_variable_with_custom_getter(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py:745 _add_variable_with_custom_getter
        new_variable = getter(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer_utils.py:133 make_variable
        return tf_variables.VariableV1(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:260 __call__
        return cls._variable_v1_call(*args, **kwargs)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:206 _variable_v1_call
        return previous_getter(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:199 <lambda>
        previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/variable_scope.py:2583 default_variable_creator
        return resource_variable_ops.ResourceVariable(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:264 __call__
        return super(VariableMetaclass, cls).__call__(*args, **kwargs)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py:1507 __init__
        self._init_from_args(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py:1651 _init_from_args
        initial_value() if init_from_fn else initial_value,
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/keras/initializers/initializers_v2.py:342 __call__
        return super(TruncatedNormal, self).__call__(shape, dtype=_get_dtype(dtype))
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/init_ops_v2.py:449 __call__
        return self._random_generator.truncated_normal(shape, self.mean,
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/init_ops_v2.py:1052 truncated_normal
        return op(
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/util/dispatch.py:201 wrapper
        return target(*args, **kwargs)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/random_ops.py:198 truncated_normal
        value = math_ops.add(mul, mean_tensor, name=name)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/ops/gen_math_ops.py:339 add
        _ops.raise_from_not_ok_status(e, name)
    /opt/conda/lib/python3.8/site-packages/tensorflow/python/framework/ops.py:6843 raise_from_not_ok_status
        six.raise_from(core._status_to_exception(e.code, message), None)
    <string>:3 raise_from
        

    ResourceExhaustedError: OOM when allocating tensor with shape[3072,768] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:Add]

=================================ERROR LOG ENDS=================================
If the problem still persists, please submit an issue to https://github.com/hankcs/HanLP/issues
When reporting an issue, make sure to paste the FULL ERROR LOG above.
  2%|▏         | 92/5832 [09:01<18:30:31, 11.61s/it]

应该是Transformer输入长度有限制导致的。当输入文本的长度大于Transformer的预设长度(126字符)时,超出部分会被丢弃,同时你会收到警告。

从你的日志什么也猜不出来,你该不会在循环里面load模型吧,家里有超算 :joy: