Transformer_Temporal_Tagger icon indicating copy to clipboard operation
Transformer_Temporal_Tagger copied to clipboard

How to tag dates using the model temporal_tagger_DATEBERT_tokenclassifier

Open pratikchhapolika opened this issue 2 years ago • 2 comments

I am using this code to load the model and the tokenizer:

tokenizer = AutoTokenizer.from_pretrained("satyaalmasian/temporal_tagger_DATEBERT_tokenclassifier", use_fast=False)
model = tr.BertForTokenClassification.from_pretrained("satyaalmasian/temporal_tagger_DATEBERT_tokenclassifier")

I have a list of text:

examples=['Texas DRIVER LICENSE Class AM 04/10/2014', 'N. Joy Driving DOB 09/21/1990']

How do I now pass this into the model to get proper tagging of dates? Sorry little confused.

@dennlinger

pratikchhapolika avatar Aug 18 '22 06:08 pratikchhapolika

Hi @dennlinger , any help please?

pratikchhapolika avatar Aug 22 '22 05:08 pratikchhapolika

Hi @pratikchhapolika, sorry for the late answer! For the DateBERT classifier, you need to take some additional steps to obtain predictions, namely, embedding the date itself.

An example is given in the Huggingface model card, or alternatively in our script for tagging inference.

Personally, we found that the fine-tuned "base" BERT model already achieves very comparable performance (i.e., the temporal_tagger_BERT_tokenclassifier model), which you can simply load with a TokenClassificationPipeline like this:

from transformers import pipeline

pipe = pipeline("token-classification", model="satyaalmasian/temporal_tagger_BERT_tokenclassifier")
# And then simply pass strings as inputs:
pipe("Tomorrow will be a beautiful day")

dennlinger avatar Aug 22 '22 08:08 dennlinger