luopeixiang / named_entity_recognition

中文命名实体识别(包括多种模型:HMM,CRF,BiLSTM,BiLSTM+CRF的具体实现)
2.13k stars 537 forks source link

想问一下bilstm+crf做推理的时候,为什么还要加入tag呢? #44

Open 1193700079 opened 2 years ago

1193700079 commented 2 years ago
print("加载并评估bilstm+crf模型...")
crf_word2id, crf_tag2id = extend_maps(word2id, tag2id, for_crf=True)
bilstm_model = load_model(BiLSTMCRF_MODEL_PATH)
bilstm_model.model.bilstm.bilstm.flatten_parameters()  # remove warning
test_word_lists, test_tag_lists = prepocess_data_for_lstmcrf(
    test_word_lists, test_tag_lists, test=True
)
lstmcrf_pred, target_tag_list = bilstm_model.test(test_word_lists, test_tag_lists,
                                                  crf_word2id, crf_tag2id)

我只需要得到lstmcrf_pred就行了,然后为什么test参数一定要test_tag_lists