Alibaba-NLP / KB-NER

Winner system (DAMO-NLP) of SemEval 2022 MultiCoNER shared task over 10 out of 13 tracks.
Other
178 stars 20 forks source link

TextEncodeInput must be Union #5

Closed Mint-hfut closed 2 years ago

Mint-hfut commented 2 years ago

我将下载到的数据解压到./flair/datasets/,并运行python train.py --config config/xlmr-large-first_10epoch_1batch_4accumulate_0.000005lr_10000lrrate_en_monolingual_crf_fast_norelearn_sentbatch_sentloss_nodev_finetune_twitter15_doc_joint_multiview_posterior_4temperature_captionobj_classattr_vinvl_ocr_ner24.yaml会出现下面错误。在twitter17上也会出现同样的错误。 此外在flair/embeddings.py中第723行存在未声明的方法:utils.init_embedding

Traceback (most recent call last): File "D:\代码\KB-NER-main\flair\trainers\finetune_trainer.py", line 910, in train loss, features = self.model.forward_loss(student_input, return_features=True) File "D:\代码\KB-NER-main\flair\models\sequence_tagger_model.py", line 1902, in forward_loss features = self.forward(data_points) File "D:\代码\KB-NER-main\flair\models\sequence_tagger_model.py", line 854, in forward self.embeddings.embed(sentences) File "D:\代码\KB-NER-main\flair\embeddings.py", line 194, in embed embedding.embed(sentences) File "D:\代码\KB-NER-main\flair\embeddings.py", line 99, in embed self._add_embeddings_internal(sentences) File "D:\代码\KB-NER-main\flair\embeddings.py", line 3083, in _add_embeddings_internal self._add_embeddings_to_sentences(sentences) File "D:\代码\KB-NER-main\flair\embeddings.py", line 3214, in _add_embeddings_to_sentences encoded_inputs = self.tokenizer.encode_plus(subtoken_ids_sentence, File "C:\Python\Python310\lib\site-packages\transformers\tokenization_utils_base.py", line 2570, in encode_plus return self._encode_plus( File "C:\Python\Python310\lib\site-packages\transformers\tokenization_utils_fast.py", line 498, in _encode_plus batched_output = self._batch_encode_plus( File "C:\Python\Python310\lib\site-packages\transformers\tokenization_utils_fast.py", line 425, in _batch_encode_plus encodings = self._tokenizer.encode_batch( TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]] Traceback (most recent call last): File "D:\代码\KB-NER-main\train.py", line 412, in getattr(trainer,'train')(**train_config) File "D:\代码\KB-NER-main\flair\trainers\finetune_trainer.py", line 1003, in train if loss != 0: UnboundLocalError: local variable 'loss' referenced before assignment

wangxinyu0922 commented 2 years ago

确认一下你的transformers是不是3.0.0?

Mint-hfut commented 2 years ago

已解决,非常感谢