How to predict if a phrase is related to a short text or an article using supervised learning?

Viewed 77

I have set of short phrases and a set of texts. I want to predict if a phrase is related to an article. A phrase that isn't appearing in the article may still be related.

Some examples of annotated data (not real) is like this:

Example 1

Phrase: Automobile

Text: Among the more affordable options in the electric-vehicle marketplace, the 2021 Tesla Model 3 is without doubt the one with the most name recognition. It borrows some styling cues from the company's Model S sedan and Model X SUV, but goes its own way with a unique interior design and an all-glass roof. Acceleration is quick, and the Model 3's chassis is playful as well—especially the Performance model's, which receives a sportier suspension and a track driving mode. But EV buyers are more likely interested in driving range than speediness or handling, and the Model 3 delivers there too. The base model offers up to 263 miles of driving range according to the EPA, and the more expensive Long Range model can go up to 353 per charge.

Label: Related (PS: For a given text, one and only one phrase is labeled 'Related' with it. All others are 'Unrelated')

Example 2

Phrase: Programming languages

Text: Python 3.9 uses a new parser, based on PEG instead of LL(1). The new parser’s performance is roughly comparable to that of the old parser, but the PEG formalism is more flexible than LL(1) when it comes to designing new language features. We’ll start using this flexibility in Python 3.10 and later.

The ast module uses the new parser and produces the same AST as the old parser.

In Python 3.10, the old parser will be deleted and so will all functionality that depends on it (primarily the parser module, which has long been deprecated). In Python 3.9 only, you can switch back to the LL(1) parser using a command line switch (-X oldparser) or an environment variable (PYTHONOLDPARSER=1).

Label: Related(i.e. all other phrases are 'Unrelated')

I think I may have to use, for example, pre-trained BERT, because this kind of prediction needs additional knowledge. But this does not seem like a standard classification problem so I can't find out-of-the-box codes. May I have some advice on how to combine existing wheels and train it?

0 Answers
Related