"Object" Detection in Textual Data I have a task where the input is a parsed document (i.e., full text in 1 string or tokens) and I need to classify parts of the text into say 5 classes (i.e., 5 tokens from the entire text are labeled into 5 different classes).
Example:
Document #1: &quot;... cat ...&quot; (the token &quot;cat&quot; belongs to class &quot;0&quot; which is animals)
Document #2: &quot;... fish ...&quot; (the token &quot;fish&quot; belongs to class &quot;0&quot; which is animals)
It is important to note that at inference time, I have the entire document (in text), and so most of the tokens from it do not belong to any of the classes.
What would be a good approach to this task? I thought about a simple classification problem where I take the labeled tokens from each document and input it into an RNN classifier, but that ignores the rest of the document and at test time irrelevant tokens can have larger probabilities than the labeled tokens.
I also had an idea inspired by YOLO, and maybe apply a 1D CNN object detector (with the respective number of classes) on the entire text. Is this reasonable?
Thanks.
This looks quite similar to Named Entity Recognition (NER), which is traditionally done with a sequence labeling model such as Conditional Random Fields. Normally NER is used when:

The list of possible entities is not predefined: the training data might contain &quot;Mr James Smith&quot; but the test data could contain &quot;Mr John Doe&quot;. In other words, the classes are open.
It is assumed that the context of the text can help the model predict an entity. For example in a sentence like &quot;Today X said that ...&quot;, the word &quot;said&quot; after X should help the model predict that X is either a person or an organization, but it cannot be a location.