IP Library › Granted Patent US 10,783,331
Granted Patent B2
US 10,783,331 · App. 16/116,710 · Granted Sep 22, 2020

Method and apparatus for building text classification model, and text classification method and apparatus

Inventors: Yuan Xia (Beijing, CN); Jingbo Zhou (Beijing, CN); Weishan Dong (Beijing, CN); Wei Fan (Beijing, CN)
Assignee: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
G06F40/44G06F40/216G06F40/30G06F40/53G06K9/627G06K9/6264G06K9/6271G06K9/723G06N7/005
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 10,783,331
App. No.
16/116,710
Granted
Sep 22, 2020
Kind
B2
Abstract

The present disclosure provides a method and apparatus for building a text classification model, and a text classification method and apparatus. The method of building a text classification model comprises: obtaining a training sample; obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary; using the vector matrix corresponding to the text and a class of the text to train a first classification model and a second classification model respectively; during the training process, using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model, and using the loss function of the text classification model to adjust parameters for the first classification model and the second classification model, to obtain the text classification model formed by the first classification model and the second classification model. The text classification method comprises: obtaining a to-be-classified text; obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary; inputting the vector matrix into a text classification model, and obtaining a classification result of the text according to output of the text classification model. The text classification effect can be improved through the technical solutions of the present disclosure.

Claims (65)

1. A method of building a text classification model, wherein the method comprises:

obtaining a training sample, wherein the training sample includes a text and a corresponding class;

obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary;

using the vector matrix corresponding to the text and a class of the text to train a first classification model and a second classification model respectively; and

during the training, using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model, and using the loss function of the text classification model to adjust parameters for the first classification model and the second classification model, to obtain the text classification model formed by the first classification model and the second classification model.

2. The method according to claim 1 , wherein the text classification model is used to classify a medical text.

3. The method according to claim 1 , wherein a training target of the first classification model and the second classification model is to minimize the loss function of the text classification model.

4. The method according to claim 1 , wherein the first classification model is a probability-based classification model.

5. The method according to claim 4 , wherein the first classification model comprises a classification model combined based on a bidirectional length memory unit and a convolutional neural network.

6. The method according to claim 4 , wherein the training the first classification model comprises:

training the first classification model by regarding the text as input, and regarding the class of the text as output.

7. The method according to claim 1 , wherein the second classification model is a similarity-based classification model.

8. The method according to claim 7 , wherein the second classification model comprises a classification model based on a deep neural network.

9. The method according to claim 7 , wherein the training the second classification model comprises: training the second classification model by regarding the text and expert's data corresponding to the class of the text as input, and regarding a similarity between the text and the expert's data as output.

10. The method according to claim 1 , wherein the using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model comprises:

using a preset combination form to integrate the loss function of the first classification model and the loss function of the second classification model, to obtain the loss function of the text classification model.

11. A text classification method, wherein the method comprises:

obtaining a to-be-classified text;

obtaining a vector matrix corresponding to the to-be-classified text, after performing word segmentation for the to-be-classified text based on an entity dictionary; and

inputting the vector matrix into a text classification model, and obtaining a classification result of the to-be-classified text according to output of the text classification model,

wherein the text classification model is pre-built according to a method of building the text classification model, wherein the method of building the text classification model comprises:

obtaining a training sample, wherein the training sample includes a text and a corresponding class;

obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary;

using the vector matrix corresponding to the text and a class of the text to train a first classification model and a second classification model respectively; and

during the training, using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model, and using the loss function of the text classification model to adjust parameters for the first classification model and the second classification model, to obtain the text classification model formed by the first classification model and the second classification model.

12. A device, wherein the device comprises:

one or more processors; and

a storage for storing one or more programs, wherein

the one or more programs, when executed by said one or more processors, enable said one or more processors to implement a method of building a text classification model, wherein the method comprises:

obtaining a training sample, wherein the training sample includes a text and a corresponding class;

obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary;

using the vector matrix corresponding to the text and a class of the text to train a first classification model and a second classification model respectively; and

during the training, using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model, and using the loss function of the text classification model to adjust parameters for the first classification model and the second classification model, to obtain the text classification model formed by the first classification model and the second classification model.

13. The device according to claim 12 , wherein the text classification model is used to classify a medical text.

14. The device according to claim 12 , wherein a training target of the first classification model and the second classification model is to minimize the loss function of the text classification model.

15. The device according to claim 12 , wherein the first classification model is a probability-based classification model.

16. The device according to claim 15 , wherein the first classification model comprises a classification model combined based on a bidirectional length memory unit and a convolutional neural network.

17. The device according to claim 15 , wherein the training the first classification model comprises:

training the first classification model by regarding the text as input, and regarding the class of the text as output.

18. A device, wherein the device comprises:

one or more processors; and

a storage for storing one or more programs, wherein

the one or more programs, when executed by said one or more processors, enable said one or more processors to implement a text classification method, wherein the method comprises:

obtaining a to-be-classified text;

obtaining a vector matrix corresponding to the to-be-classified text, after performing word segmentation for the to-be-classified text based on an entity dictionary; and

inputting the vector matrix into a text classification model, and obtaining a classification result of the to-be-classified text according to output of the text classification model,

wherein the text classification model is pre-built according to a method of building the text classification model, wherein the method of building the text classification model comprises:

obtaining a training sample, wherein the training sample includes a text and a corresponding class;

obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary;

using the vector matrix corresponding to the text and a class of the text to train a first classification model and a second classification model respectively; and

during the training, using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model, and using the loss function of the text classification model to adjust parameters for the first classification model and the second classification model, to obtain the text classification model formed by the first classification model and the second classification model.

19. A non-transitory computer-readable storage medium including computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, implement a method of building a text classification model, wherein the method comprises:

obtaining a training sample, wherein the training sample includes a text and a corresponding class;

obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary;

using the vector matrix corresponding to the text and a class of the text to train a first classification model and a second classification model respectively; and

during the training, using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model, and using the loss function of the text classification model to adjust parameters for the first classification model and the second classification model, to obtain the text classification model formed by the first classification model and the second classification model.

20. A non-transitory computer-readable storage medium including computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, implement a text classification method, wherein the method comprises:

obtaining a to-be-classified text;

obtaining a vector matrix corresponding to the to-be-classified text, after performing word segmentation for the to-be-classified text based on an entity dictionary; and

inputting the vector matrix into a text classification model, and obtaining a classification result of the to-be-classified text according to output of the text classification model,

wherein the text classification model is pre-built according to a method of building the text classification model, wherein the method of building the text classification model comprises:

obtaining a training sample, wherein the training sample includes a text and a corresponding class;

obtaining a vector matrix corresponding to the text, after performing word segmentation for the text based on an entity dictionary;

using the vector matrix corresponding to the text and a class of the text to train a first classification model and a second classification model respectively; and

during the training, using a loss function of the first classification model and a loss function of the second classification model to obtain a loss function of the text classification model, and using the loss function of the text classification model to adjust parameters for the first classification model and the second classification model, to obtain the text classification model formed by the first classification model and the second classification model.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Oct 1, 2018
From: XIA, YUAN; ZHOU, JINGBO; DONG, WEISHAN; FAN, WEI
To: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
Reel/Frame 047172/0584 →
Priority Claims (1)
CN 2017 1 08826850 · Sep 26, 2017 · national
Continuity (1)
Related Publication 20190095432A1 · Mar 28, 2019