# US 2022/0277141 A1 · Neural network based representation learning for natural language processing

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0277141 A1
- Document ID: US20220277141A1
- Status: Published application
- Kind: A1
- Application number: 17/187,608
- Filed: 2021-02-26
- Published: 2022-09-01
- Earliest claimed: 2021-02-26
- Assignees: salesforce.com, inc.
- Applicants: salesforce.com, inc.
- Inventors: Erik Lennart Nijkamp; Caiming Xiong
- Web page: https://patentgrep.com/patent/US20220277141A1

## CPC

- G06F 40/279: Recognition of textual entities
- G06F 40/35: Discourse or dialogue representation
- G06F 40/194: Calculation of difference between files
- G06F 40/295: Named entity recognition
- G06F 40/58: Use of machine translation, e.g. for multi-lingual retrieval, for server-side translation for client devices or for real-time translation
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A machine learning based model generates a feature representation of a text sequence, for example, a natural language sentence or phrase. The system trains the machine learning based model by receiving an input text sequence and perturbing the input text sequence by masking a subset of tokens. The machine learning based model is used to predict the masked tokens. A predicted text sequence is generated based on the predictions of the masked tokens. The system processes the predicted text sequence using the machine learning based model to determine whether a token was predicted or an original token. The parameters of the machine learning based model are adjusted to minimize an aggregate loss based on prediction of the correct word for a masked token and a classification of a word as original or replaced.

## Claims

### Claim 1

A computer implemented method for training a machine learning based model, the method comprising:
initializing the machine learning based model comprising a set of parameters;
training the machine learning based model by repeatedly performing:
generating a masked text sequence by replacing a token of an input text sequence with a masked token, for one or more tokens of the input text sequence;
predicting one or more masked tokens of the masked text sequence using the machine learning based model;
generating a predicted text sequence by replacing masked tokens of the masked text sequence with tokens predicted by the machine learning based model;
using the machine learning based model as a classifier to discriminate between replaced tokens of the predicted text sequence and original tokens of the input text sequence; and
adjusting the set of parameters of the machine learning based model based on an accuracy of prediction of masked tokens and an accuracy of classification of tokens using the machine learning based model; and
storing the trained machine learning based model.

### Claim 2 (depends on 1)

The method of claim 1, wherein the machine learning based model is a transformer encoder model.

### Claim 3 (depends on 1)

The method of claim 1, wherein adjusting the set of parameters is based on an aggregate loss obtained by combining:
(1) a generator loss indicative of accuracy of prediction of masked tokens by the machine learning based model, and
(2) a discriminator loss indicative of an accuracy of classification of tokens using the machine learning based model.

### Claim 4 (depends on 3)

The method of claim 3, wherein the generator loss is determined based on a comparison of tokens predicted by the machine learning based model with corresponding tokens of the input text sequence.

### Claim 5 (depends on 3)

The method of claim 3, wherein the discriminator loss is determined by verifying the result of classification performed using the machine learning based model by comparing tokens of the predicted text sequence with the input text sequence.

### Claim 6 (depends on 1)

The method of claim 1, wherein the training is pretraining using a first training dataset, the method further comprising:
further training the pretrained machine learning based model using a second training dataset for one or more text processing tasks.

### Claim 7 (depends on 6)

The method of claim 6, wherein the one or more text processing tasks comprise:
sentiment analysis of natural language sentences;
given a question, determining an answer for the question;
performing named entity recognition in a text; or
determining whether two sentences are similar.

### Claim 8 (depends on 1)

The method of claim 1, wherein the text sequence is based on a vocabulary, wherein obtaining the predicted text sequence by replacing masked tokens of the masked text sequence with tokens predicted by the machine learning based model comprises:
predicting a plurality of predicted text sequences based on candidate tokens predicted for each masked token; and
sampling the predicted text sequence from the plurality of predicted text sequences.

### Claim 9

A non-transitory computer readable storage medium storing instructions that when executed by a computer processor, cause the computer processor to perform steps comprising:
initializing the machine learning based model comprising a set of parameters;
training the machine learning based model by repeatedly performing:
generating a masked text sequence by replacing a token of an input text sequence with a masked token, for one or more tokens of the input text sequence;
predicting one or more masked tokens of the masked text sequence using the machine learning based model;
generating a predicted text sequence by replacing masked tokens of the masked text sequence with tokens predicted by the machine learning based model;
using the machine learning based model as a classifier to discriminate between replaced tokens of the predicted text sequence and original tokens of the input text sequence; and
adjusting the set of parameters of the machine learning based model based on an accuracy of prediction of masked tokens and an accuracy of classification of tokens using the machine learning based model; and
storing the trained machine learning based model.

### Claim 10 (depends on 9)

The non-transitory computer readable storage medium of claim 9, wherein the machine learning based model is a transformer encoder model.

### Claim 11 (depends on 9)

The non-transitory computer readable storage medium of claim 9, wherein adjusting the set of parameters is based on an aggregate loss obtained by combining:
(1) a generator loss indicative of accuracy of prediction of masked tokens by the machine learning based model, and
(2) a discriminator loss indicative of an accuracy of classification of tokens using the machine learning based model.

### Claim 12 (depends on 11)

The non-transitory computer readable storage medium of claim 11, wherein the generator loss is determined based on a comparison of tokens predicted by the machine learning based model with corresponding tokens of the input text sequence.

### Claim 13 (depends on 11)

The non-transitory computer readable storage medium of claim 11, wherein the discriminator loss is determined by verifying the result of classification performed using the machine learning based model by comparing tokens of the predicted text sequence with the input text sequence.

### Claim 14 (depends on 9)

The non-transitory computer readable storage medium of claim 9, wherein the training is pretraining using a first training dataset, wherein the instructions further cause the computer processor to perform steps comprising:
further training the pretrained machine learning based model using a second training dataset for one or more text processing tasks.

### Claim 15 (depends on 14)

The non-transitory computer readable storage medium of claim 14, wherein the one or more text processing tasks comprise:
sentiment analysis of natural language sentences;
given a question, determining an answer for the question;
performing named entity recognition in a text; or
determining whether two sentences are similar.

### Claim 16 (depends on 9)

The non-transitory computer readable storage medium of claim 9, wherein the text sequence is based on a vocabulary, wherein obtaining the predicted text sequence by replacing masked tokens of the masked text sequence with tokens predicted by the machine learning based model comprises:
predicting a plurality of predicted text sequences based on candidate tokens predicted for each masked token; and
sampling the predicted text sequence from the plurality of predicted text sequences.

### Claim 17

A computer system comprising:
a computer processor; and
a non-transitory computer readable storage medium storing instructions that when executed by the computer processor cause the computer processor to perform steps comprising:
initializing the machine learning based model comprising a set of parameters;
training the machine learning based model by repeatedly performing:
generating a masked text sequence by replacing a token of an input text sequence with a masked token, for one or more tokens of the input text sequence;
predicting one or more masked tokens of the masked text sequence using the machine learning based model;
generating a predicted text sequence by replacing masked tokens of the masked text sequence with tokens predicted by the machine learning based model;
using the machine learning based model as a classifier to discriminate between replaced tokens of the predicted text sequence and original tokens of the input text sequence; and
adjusting the set of parameters of the machine learning based model based on an accuracy of prediction of masked tokens and an accuracy of classification of tokens using the machine learning based model; and
storing the trained machine learning based model.

### Claim 18 (depends on 17)

The computer system of claim 17, wherein the training is pretraining using a first training dataset, wherein the instructions further cause the computer processor to perform steps comprising:
further training the pretrained machine learning based model using a second training dataset for one or more text processing tasks.

### Claim 19 (depends on 18)

The computer system of claim 18, wherein the one or more text processing tasks comprise:
sentiment analysis of natural language sentences;
given a question, determining an answer for the question;
performing named entity recognition in a text; or
determining whether two sentences are similar.

### Claim 20 (depends on 17)

The computer system of claim 17, wherein the text sequence is based on a vocabulary, wherein obtaining the predicted text sequence by replacing masked tokens of the masked text sequence with tokens predicted by the machine learning based model comprises:
predicting a plurality of predicted text sequences based on candidate tokens predicted for each masked token; and
sampling the predicted text sequence from the plurality of predicted text sequences.
