Given a list of sentences like this:

  • 4 to 5 hours over a period of 16 weeks
  • 1st session: 2.0-2.5 hours & 2nd session: 1.5-2.0 hours
  • Approximately 5-6 visits over the course of 5 months. Visit 1, 3, 5: about 1.5 hours. Visit 2, 4: short
  • 15 visits over a period of approximately 74 weeks.
  • You will come to the organization about 12 times, over a period of a little more than three years. Each visit will take from 3-6 hours.

What tools/strategy should I use if I want to let the model spit out the following data for the above sentences:

Number of sessions Total duration(h) Total timespan(w)
Unknown 4-5 16
2 3.5-4.5 Unknown
5-6 4.5 20
15 Unknown 74
12 36-72 156

I'm a ML beginner and wondered if this is achievable with Tensorflow or GPT? For further learning on my own: what is the specific terminology I should google for? Is this NER, text extraction or more like text classification?


The task is a specific case of NER (technically NER is a sequence labeling task, a special case of classification).

I think you would have two main options:

  • Apply a pre-trained NER model: most deal with time entities but not always very accurately, and it wouldn't be specifically adapted to your data so you wouldn't obtain the distinction between the three types of values. Advantage: no need for training data.
  • Train your own NER model: that's the ideal scenario in terms of performance, assuming you have (or can have) a good amount of annotated data for training.
  • $\begingroup$ Thanks for your input. Now how would I accomplish the mathematical operations that need to be incorporated in the result? (e.g. the total duration is the sum of the session time). Or would that be some post-processing operation? $\endgroup$
    – Daan
    Feb 22 at 17:52
  • 1
    $\begingroup$ @Daan that would be a post-processing indeed: first the NER tags the elements that it detects with their type e.g. "total_duration", then you collect the elements and do the calculation. Don't forget to account for the fact that sometimes the NER model will make mistakes: miss an element or label the wrong part. $\endgroup$
    – Erwan
    Feb 22 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.