US 12,271,701 B2
Method and apparatus for training text classification model
Yao Qiu, Guangdong (CN); Jinchao Zhang, Guangdong (CN); Jie Zhou, Guangdong (CN); and Cheng Niu, Guangdong (CN)
Assigned to TENCENT TECHNOLOGY (SHENZHEN) COMPANY LIMITED, Shenzhen (CN)
Filed by TENCENT TECHNOLOGY (SHENZHEN) COMPANY LIMITED, Guangdong (CN)
Filed on Sep. 20, 2022, as Appl. No. 17/948,348.
Application 17/948,348 is a continuation of application No. PCT/CN2021/101372, filed on Jun. 22, 2021.
Claims priority of application No. 202010753159.6 (CN), filed on Jul. 30, 2020.
Prior Publication US 2023/0016365 A1, Jan. 19, 2023
Int. Cl. G06F 40/30 (2020.01); G06F 40/40 (2020.01)
CPC G06F 40/30 (2020.01) [G06F 40/40 (2020.01)] 20 Claims
OG exemplary drawing
 
1. A method for training a text classification model, executed by a computer device, the method comprising:
obtaining a training sample of the text classification model, the training sample being a text;
determining a semantic representation of the training sample using the text classification model, wherein the semantic representation of the training sample represents a semantic of the training sample;
determining a predicted classification result of the training sample based on the semantic representation;
generating an adversarial sample corresponding to the training sample based on the training sample and perturbation information for the training sample;
determining a semantic representation of the adversarial sample corresponding to the training sample using the text classification model, wherein the semantic representation of the adversarial sample represents a semantic of the adversarial sample, the semantic of the adversarial sample is consistent with the semantic of the training sample;
determining a classification loss of the text classification model based on the predicted classification result of the training sample;
determining a contrastive loss of the text classification model based on the semantic representation of the training sample and the semantic representation of the adversarial sample corresponding to the training sample; and
training the text classification model based on the classification loss and the contrastive loss.