T5 for Named Entity Recognition
The task is as follows: need to write the code for NamedEntityRecognition(Token classification), using the T5 model. Who knows how to do this, please write explicitly on the example.This should work as for example:from transformers import AutoModelForTokenClassification, AutoTokenizer
import torch
model = AutoModelForTokenClassification.from_pretrained("dbmdz/bert-large-cased-finetuned-conll03-english", return_dict=True)
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
label_list = [
    "O",       # Outside of a named entity
    "B-MISC",  # Beginning of a miscellaneous entity right after another miscellaneous entity
    "I-MISC",  # Miscellaneous entity
    "B-PER",   # Beginning of a person's name right after another person's name
    "I-PER",   # Person's name
    "B-ORG",   # Beginning of an organisation right after another organisation
    "I-ORG",   # Organisation
    "B-LOC",   # Beginning of a location right after another location
    "I-LOC"    # Location
]
sequence = "Hugging Face Inc. is a company based in New York City. Its headquarters are in DUMBO, therefore very" \
           "close to the Manhattan Bridge."
# Bit of a hack to get the tokens with the special tokens
tokens = tokenizer.tokenize(tokenizer.decode(tokenizer.encode(sequence)))
inputs = tokenizer.encode(sequence, return_tensors="pt")
outputs = model(inputs).logits
predictions = torch.argmax(outputs, dim=2)
print([(token, label_list[prediction]) for token, prediction in zip(tokens, predictions[0].numpy())])
[('[CLS]', 'O'), ('Hu', 'I-ORG'), ('##gging', 'I-ORG'), ('Face', 'I-ORG'), ('Inc', 'I-ORG'), ('.', 'O'), ......]Please, write a concrete example with using T5Model and T5Tokenizer
2020-11-23T16:19:42Z
github.com/google-research/text-to-text-transfer-transformerDoes T5 support sequence labeling (like NER) tasks?opened04:52AM - 26 Dec 19 UTCclosed04:44PM - 26 Dec 19 UTCMorizeyaoHi there, just as the title says. I wonder, does T5 support sequence labeling (l…ike NER) tasks?

I don't see report of such tasks in the paper. (correct me If I am wrong).

Thank you very much!
2020-11-24T12:23:48Z
Yes, I exactly know that T5 support NER Tasks. It’s difficult to build, but need.