FIELD

The present disclosure generally relates to machine learning and more specifically to training and validating a machine learning model for natural language processing.

BACKGROUND

Machine learning models may be trained to perform a variety of cognitive tasks. For example, a machine learning model trained to perform natural language processing may classify text by at least assigning, to the text, one or more labels indicating a sentiment, a topic, and/or an intent associated with the text. Training the machine learning model to perform natural language processing may include adjusting the machine learning model to minimize the errors present in the output of the machine learning model. For instance, training the machine learning model may include adjusting the weights applied by the machine learning model in order to minimize a quantity of incorrect labels assigned by the machine learning model.

SUMMARY

Methods, systems, and articles of manufacture, including computer program products, are provided for training a machine learning model for natural language processing. In one aspect, there is provided a system. The system may include at least one data processor and at least one memory. The at least one memory may store instructions that result in operations when executed by the at least one data processor. The operations may include: generating, based at least on a context-free grammar, a sample forming a corpus, the context-free grammar including one or more production rules for replacing a first nonterminal symbol with a second nonterminal symbol and/or a terminal symbol, the sample being generated by at least rewriting recursively a first text string to form a second text string associated with the sample, and the first text string being rewritten by at least applying the one or more production rules to replace one or more nonterminal symbols included in the first text string until no nonterminal symbols remain in the first text string; and training and validating, based at least on the corpus, a machine learning model to process a natural language.

In some variations, one or more of the features disclosed herein including the following features can optionally be included in any feasible combination. The context-free grammar may include a first production rule for replacing the first nonterminal symbol with at least the second nonterminal symbol. The context-free grammar may further include a second production rule for replacing the second nonterminal symbol with at least the terminal symbol. The first text string may be rewritten recursively by at least applying the first production rule to replace the first nonterminal symbol included in the first text string with the second nonterminal symbol before applying the second production rule to replace the second nonterminal symbol with the terminal symbol.

In some variations, the generating of the corpus may further include assigning, to the sample, a ground-truth label for the second text string associated with the sample. The ground-truth label may indicate a sentiment, a topic, and/or an intent associated with the second text string. The ground-truth label may be associated with a first value based on the terminal symbol being an entity having a semantic significance. The ground-truth label may be associated with a second value based on the terminal symbol being a nonentity having no semantic significance.

In some variations, the ground-truth label may be associated with a value corresponding to an application of the machine learning model trained to process the natural language.

In some variations, the machine learning model may be trained by at least adjusting one or more weights applied by the machine learning model to at least minimize an error in an output of the machine learning model. The error in the output of the machine learning model may correspond to a difference between the ground-truth label assigned to the sample and a label assigned to the sample by the machine learning model.

In some variations, the machine learning model may be validated based at least on the machine learning model assigning, to the sample, a label matching the ground-truth label associated with the sample.

In some variations, the context-free grammar may be defined based at least on a text associated with the natural language. The context-free grammar may be defined by at least determining a hierarchy including a first plurality of layers having a first plurality of members forming a first set of nonterminal symbols including the first nonterminal symbol and the second nonterminal symbol. The hierarchy may further include a second plurality of layers having a second plurality of members forming a second set of terminal symbols including the terminal symbol.

In some variations, the context-free grammar may be defined by at least determining, based at least on one or more directed edges interconnecting the first plurality of members and the second plurality of members, the one or more production rules.

In some variations, the context-free grammar may be defined by at least determining, based at least on the first plurality of members, the first set of nonterminal symbols. The context-free grammar may be further defined by at least determining, based at least on the second plurality of members, the second set of terminal symbols.

In some variations, the first plurality of layers may include a pattern layer including a pattern present in the text and an entity cluster layer including a cluster of a first entity and a second entity present in the subpattern. The second plurality of layers may include a padding layer including a nonentity present in the subpattern, an entity layer including the first entity and the second entity, and a synonym layer including a synonym associated with the first entity and/or the second entity.

In some variations, the machine learning model may be a neural network, a Bayesian network, a Markov chain, and/or a support vector machine.

In some variations, each of the first nonterminal symbol and the second nonterminal symbol may denote a noun phrase, a verb phrase, an adjective phrase, an adverb phrase, a Gerund phrase, an infinitive phrase, an absolute phrase, a determiner, a conjunction, a verb, a noun, a pronoun, an adjective, an adverb, a preposition, or an interjection.

In some variations, the terminal symbol may denote a word in a lexicon associated with the natural language.

In some variations, the sample may be part of a training dataset or a validation dataset forming the corpus.

In another aspect, there is provided a method for training a machine learning model for natural language processing. generating, based at least on a context-free grammar, a sample forming a corpus, the context-free grammar including one or more production rules for replacing a first nonterminal symbol with a second nonterminal symbol and/or a terminal symbol, the sample being generated by at least rewriting recursively a first text string to form a second text string associated with the sample, and the first text string being rewritten by at least applying the one or more production rules to replace one or more nonterminal symbols included in the first text string until no nonterminal symbols remain in the first text string; and training and validating, based at least on the corpus, a machine learning model to process a natural language.

In another aspect, there is provided a computer program product that includes a non-transitory computer readable storage medium. The non-transitory computer-readable storage medium may include program code that causes operations when executed by at least one data processor. The operations may include: generating, based at least on a context-free grammar, a sample forming a corpus, the context-free grammar including one or more production rules for replacing a first nonterminal symbol with a second nonterminal symbol and/or a terminal symbol, the sample being generated by at least rewriting recursively a first text string to form a second text string associated with the sample, and the first text string being rewritten by at least applying the one or more production rules to replace one or more nonterminal symbols included in the first text string until no nonterminal symbols remain in the first text string; and training and validating, based at least on the corpus, a machine learning model to process a natural language.

Implementations of the current subject matter can include methods consistent with the descriptions provided herein as well as articles that comprise a tangibly embodied machine-readable medium operable to cause one or more machines (e.g., computers, etc.) to result in operations implementing one or more of the described features. Similarly, computer systems are also described that may include one or more processors and one or more memories coupled to the one or more processors. A memory, which can include a non-transitory computer-readable or machine-readable storage medium, may include, encode, store, or the like one or more programs that cause one or more processors to perform one or more of the operations described herein. Computer implemented methods consistent with one or more implementations of the current subject matter can be implemented by one or more data processors residing in a single computing system or multiple computing systems. Such multiple computing systems can be connected and can exchange data and/or commands or other instructions or the like via one or more connections, including, for example, to a connection over a network (e.g. the Internet, a wireless wide area network, a local area network, a wide area network, a wired network, or the like), via a direct connection between one or more of the multiple computing systems, etc.

The details of one or more variations of the subject matter described herein are set forth in the accompanying drawings and the description below. Other features and advantages of the subject matter described herein will be apparent from the description and drawings, and from the claims. While certain features of the currently disclosed subject matter are described for illustrative purposes in relation to training a machine learning model for natural language processing, it should be readily understood that such features are not intended to be limiting. The claims that follow this disclosure are intended to define the scope of the protected subject matter.

