bowang-lab / joint-ner-and-re

This repository contains the corpora and supplementary data, along with instructions for recreating the experiments, for our paper: "End-to-end Named Entity Recognition and Relation Extraction using Pre-trained Language Models".
https://arxiv.org/abs/1912.13415
GNU General Public License v3.0
90 stars 14 forks source link

Inference for NER/RE model #7

Open isaacmg opened 4 years ago

isaacmg commented 4 years ago

Hi just wondering if your actual joint NER/RE model can be used for inference at this point? The model that seems to be loaded in the notebook is a vanilla BertModel so wouldn't I want to actually do BertForEntityAndRelationExtraction.from_pretrained() or am I missing something? I also attempted to use your BertForNERAndRE model

from saber.models.bert_for_ner_and_re import BertForNERAndRE
model = BertForNERAndRE("CoNLL2004/config.json", [], "CoNLL2004")
tokenizer = BertTokenizer.from_pretrained("CoNLL2004", do_lower_case=False)
out = tokenizer.tokenize("Google News is a news aggregator app developed by Google. It presents a continuous, customizable flow of articles organized from thousands of publishers and magazines. Google News is available as an app on ")
model.predict(out)

But this resulted in KeyError: 15

    231             ent_idxs = \
    232                 [tok_idx.item() for tok_idx in tok_map if tok_idx != TOK_MAP_PAD and
--> 233                  idx_to_ent[ner_pred[tok_idx].item()].startswith(tuple(CHUNK_END_TAGS))]
    234 
    235             # Permutate these predicted entities to get all candidate entities

Finally just wondering do you have the weights from the other datasets you trained on too?

Thank you.

teresha09 commented 4 years ago

Hi. Are you succeeded fixing this issue?

isaacmg commented 4 years ago

No I haven't looked at it too much recently. Would be interested if anyone is able to use it though.

JohnGiorgi commented 4 years ago

Hi both,

Thanks for the interest in our work. Unfortunately our paper wasn’t accepted to either of the venues we tried to publish in, and as such we have moved on to other projects. This code is basically “research-grade” and lots of stuff is wonky (or just doesn’t work)