Text classification method, apparatus, device, and computer readable medium

By transforming the text discrimination function from Euclidean space to angular space and constructing a ternary loss function, the problem of low accuracy in existing medical text classification methods is solved, and higher accuracy in text semantic classification is achieved.

CN116541764BActive Publication Date: 2025-11-04PING AN TECH (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310700884.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-13
Publication Date
2025-11-04
Estimated Expiration
2043-06-13

AI Technical Summary

Technical Problem

Existing medical text classification methods, which rely on Euclidean space-based text discrimination functions, are susceptible to noise and thus suffer from low classification accuracy.

Method used

The text discrimination function is transformed from Euclidean space representation to angular space representation, and the robustness and discrimination ability of the discrimination function are enhanced by constructing ternary sentence groups and ternary loss functions, thus building a text classification model.

Benefits of technology

It improves the accuracy of medical text classification, enhances robustness to noise, and enables more accurate semantic text classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116541764B_ABST
    Figure CN116541764B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of natural language, and discloses a text classification method, which comprises the following steps: obtaining a pre-trained initial text classification model, and obtaining a text discriminant function from the initial text classification model; converting the text discriminant function from a Euclidean space representation into an angle space representation to obtain an updated text discriminant function; obtaining a preset training sentence set, and constructing a three-element sentence group according to training sentences in the training sentence set; performing function modeling based on the three-element sentence group to obtain a three-element loss function; constructing a model objective function according to the updated text discriminant function and the three-element loss function, and constructing a text classification model according to the model objective function; and obtaining a text to be classified, and performing semantic classification on the text to be classified through the text classification model. The application also discloses a text classification device, equipment and a storage medium. The application can improve the accuracy of medical text classification.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of natural language, in particular to a text classification method, device, equipment and medium. BACKGROUND

[0002] With the explosive growth of information, manual annotation data has become time-consuming, low-quality, and easily affected by the subjective consciousness of the annotator, especially in the medical industry, professional doctors often have limited time and a large number of patients to serve, and cannot spend time on complex medical text classification, and professional data annotation classification personnel often make mistakes when processing medical text classification due to the strong professionalism of medical vocabulary, therefore, it is of practical significance to use machine automation to realize the annotation of text, and the repeated and boring text annotation task of medical text can be effectively overcome by computers.

[0003] Medical text classification refers to using a computer to automatically classify and mark medical text according to a certain classification system or standard, which is often performed by a text classification model based on a text discriminant function, and the existing text discriminant function is generally based on a Euclidean space, which is very susceptible to noise data, thereby resulting in low accuracy of medical text classification. SUMMARY

[0004] The present application provides a text classification method, device, equipment and medium, which mainly aims to convert the text discriminant function of the model from a Euclidean space representation to an angle space representation when classifying medical text, thereby improving the accuracy of medical text classification.

[0005] To achieve the above purpose, the present application provides a text classification method, comprising:

[0006] obtaining a pre-trained initial text classification model, and obtaining a text discriminant function from the initial text classification model;

[0007] converting the text discriminant function from a Euclidean space representation to an angle space representation to obtain an updated text discriminant function;

[0008] obtaining a pre-set training sentence set, and constructing a triple sentence group according to the training sentences in the training sentence set;

[0009] function modeling based on the triple sentence group to obtain a triple loss function;

[0010] constructing a model objective function according to the updated text discriminant function and the triple loss function, and constructing a text classification model through the model objective function;

[0011] Obtaining a text to be classified, and performing semantic classification on the text to be classified by using the text classification model.

[0012] Optionally, the obtaining of the text discriminant function from the initial text classification model comprises:

[0013] Optionally, the obtaining of the text discriminant function from the initial text classification model comprises:

[0014] Optionally, the obtaining of the text discriminant function from the initial text classification model comprises:

[0015] Optionally, the obtaining of the text discriminant function from the initial text classification model comprises:

[0016] Optionally, the obtaining of the text discriminant function from the initial text classification model comprises:

[0017] Optionally, the converting of the text discriminant function from the Euclidean space representation into the angle space representation to obtain an updated text discriminant function comprises:

[0018] Optionally, the converting of the text discriminant function from the Euclidean space representation into the angle space representation to obtain an updated text discriminant function comprises:

[0019] Optionally, the converting of the text discriminant function from the Euclidean space representation into the angle space representation to obtain an updated text discriminant function comprises:

[0020] Optionally, the constructing of the triple sentence group according to the training sentence in the training sentence set comprises:

[0021] Optionally, the constructing of the triple sentence group according to the training sentence in the training sentence set comprises:

[0022] Optionally, the constructing of the triple sentence group according to the training sentence in the training sentence set comprises:

[0023] Optionally, the text discriminant function is:

[0024]

[0025] wherein, sim is a similarity calculation function, τ is a temperature hyperparameter, hi as a feature sample, as a feature positive sample, h j as a feature negative sample, n is the number of selected feature negative samples.

[0026] Optionally, the ternary loss function is:

[0027]

[0028] wherein, n i as a sample sentence, n' i as a first mask sentence, n" i as a second mask sentence, sim is a similarity calculation function, and m is an offset between the first mask sentence and the second mask sentence.

[0029] To solve the above problems, the application further provides a text classification device, which comprises:

[0030] a discriminant function updating module, configured to obtain a pre-trained initial text classification model, and obtain a text discriminant function from the initial text classification model, convert the text discriminant function from a Euclidean space representation to an angle space representation, and obtain an updated text discriminant function;

[0031] a loss function construction module, configured to obtain a pre-set training sentence set, and construct a ternary sentence group according to training sentences in the training sentence set, perform function modeling based on the ternary sentence group, and obtain a ternary loss function;

[0032] a classification model construction module, configured to construct a model objective function according to the updated text discriminant function and the ternary loss function, and construct a text classification model through the model objective function;

[0033] a text semantic classification module, configured to obtain a text to be classified, and perform semantic classification on the text to be classified through the text classification model.

[0034] Optionally, the conversion of the text discriminant function from the Euclidean space representation to the angle space representation to obtain the updated text discriminant function comprises:

[0035] obtaining a feature formula in the text discriminant function, and representing the feature formula through the angle of cosine similarity to obtain an angle feature formula;

[0036] replacing the feature formula in the text discriminant function with the angle feature formula to obtain the updated text discriminant function.

[0037] To solve the above problems, the application further provides an electronic device, which comprises:

[0038] at least one processor; and

[0039] a memory in communication with the at least one processor; wherein

[0040] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the text classification method as described above.

[0041] To solve the above problems, the application further provides a computer readable storage medium, comprising a storage data area and a storage program area, the storage data area stores created data, and the storage program area stores a computer program; wherein the computer program is executed by a processor to implement the text classification method as described above.

[0042] In the embodiment of the application, first, a pre-trained initial text classification model is acquired, and a text discriminant function is acquired from the initial text classification model, then the text discriminant function is converted from a Euclidean space representation to an angle space representation to obtain an updated text discriminant function, then a preset training sentence set is acquired, and a triple sentence group is constructed according to the sentences in the training sentence set, based on the triple sentence group, function modeling is performed to obtain a triple loss function, finally, a model objective function is constructed according to the updated text discriminant function and the triple loss function, and a text classification model is constructed through the model objective function, and the preset text to be classified is classified by the text classification model. Since the representation of the text discriminant function in the initial text discriminant model is converted in the application, the discriminant ability of the discriminant function and the robustness to noise are enhanced, and the triple loss function is constructed according to the training sentences in the training sentence group, so that the loss function can learn the order relationship of the semantic similarity between medical texts, and thus the purpose of improving the classification accuracy of the text classification model in medical text classification based on text semantics is achieved. BRIEF DESCRIPTION OF DRAWINGS

[0043] Figure 1 A flowchart of a text classification method provided by an embodiment of the application;

[0044] Figure 2 A detailed flowchart of a step in a text classification method provided by an embodiment of the application;

[0045] Figure 3 A detailed flowchart of a step in a text classification method provided by an embodiment of the application;

[0046] Figure 4 A module diagram of a text classification device provided by an embodiment of the application;

[0047] Figure 5An internal structure schematic diagram of an electronic device for implementing a text classification method is provided in an embodiment of the present application.

[0048] The implementation, functional features and advantages of the present application will be further illustrated in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0049] It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.

[0050] Embodiments of the present application provide a text classification method. The execution subject of the text classification method includes, but is not limited to, at least one of a server, a terminal and other electronic devices that can be configured to execute the method provided by the embodiments of the present application. The server can be an independent server, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. In other words, the text classification method can be executed by software or hardware installed in a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to, a single server, a server cluster, a cloud server or a cloud server cluster, etc.

[0051] Reference Figure 1 As shown in the figure, a flowchart of a text classification method is provided in an embodiment of the present application. In the embodiment, the text classification method includes the following steps S1-S6:

[0052] S1, obtaining a pre-trained initial text classification model, and obtaining a text discrimination function from the initial text classification model.

[0053] In the embodiment of the present application, the initial text classification model is a Bert (Bidirectional Encoder Representation from Transformers) model, which can also be referred to as a sentence representation model. The initial text classification model is based on the Encoder in the Transformer and adds a bidirectional structure. In addition to being used for text classification tasks, it can also be used for named entity recognition tasks, text similarity judgment tasks, regression tasks, etc.

[0054] The initial text classification model is a Bert model, and therefore, a self-encoding (AE) pre-training mode is adopted, in addition to a GPT (Generative Pre-Training) model adopting an auto-regressive (AR) pre-training mode, which can also be referred to as a generative pre-training model. In the application type, the GPT model is more suitable for a text generation task, and the Bert model is more suitable for a text understanding task and related tasks derived from the text understanding task, such as the text classification task applied in the scheme.

[0055] Further, the initial text classification model is a deep learning model, which can be applied to various different fields, such as speech recognition, medical diagnosis, application degree test, and the like.

[0056] When applied to the medical diagnosis field, various types of medical events (such as surgery, outpatient service, and the like) can be classified to help a hospital optimize and manage a work flow, and a comprehensive analysis of a patient condition can be made based on a patient clinical record or an examination report to give a doctor auxiliary decision support.

[0057] In the embodiment of the application, the text discrimination function is a function for classifying a sentence text in the initial text classification model.

[0058] Reference Figure 2 Further, the text discrimination function is obtained from the initial text classification model, and includes:

[0059] S101, a preset text set is obtained, and data enhancement is performed on initial texts in the text set to obtain enhanced texts;

[0060] S102, the initial texts in the text set are divided into batches according to a preset batch division mode, and then input into the initial text classification model to obtain a plurality of initial text classification feature sets;

[0061] S103, the enhanced texts corresponding to the initial texts are divided into batches according to the batch division mode, and then input into the initial text classification model to obtain a plurality of enhanced text classification feature sets;

[0062] S104, initial text classification features in the initial text classification feature set are taken as feature samples, enhanced text classification features in the enhanced text classification feature set corresponding to the initial text classification feature set are taken as feature positive samples, and the remaining initial text classification features in the initial text classification feature set are taken as feature negative samples, and the text discrimination function is constructed.

[0063] The data augmentation is a method of modifying existing data or newly creating synthetic data from the existing data to increase the amount of data, each feature in the initial text classification feature set is a feature in the same division batch, and each feature in the enhanced text classification feature set is also a feature in the same division batch.

[0064] As an embodiment of the application, the data augmentation method is a dropout data augmentation method, and the enhanced text corresponding to the initial text is obtained by reducing the features of the initial text.

[0065] For example, x, y, and z are initial texts in the same division batch, A, B, and C are initial text features obtained after the initial text is input into an initial text classification model, a, b, and c are enhanced text classification features obtained after the initial text is input into the initial text classification model after data augmentation, when x is used as a feature sample, a is used as a feature positive sample, and B and C are used as feature negative samples.

[0066] Specifically, the method of obtaining a text discrimination function by constructing feature positive and negative samples in the present scheme belongs to a contrast learning mode.

[0067] In the embodiment of the application, the text discrimination function can also be referred to as an NT-Xen objective function.

[0068]

[0069] Wherein, sim is a similarity calculation function, tau is a temperature hyperparameter, h i is a feature sample, is a feature positive sample, h j is a feature negative sample, and n is the number of selected feature negative samples.

[0070] S2, converting the text discrimination function from a Euclidean space representation to an angle space representation to obtain an updated text discrimination function.

[0071] In the embodiment of the application, the Euclidean space is the Euclidean space, which is a rule abstraction and generalization of the real space, and the angle space is a two-dimensional plane space represented by an angle by converting a three-dimensional Euclidean space.

[0072] In the embodiment of the application, the updated text discrimination function is the text discrimination function represented in the angle space.

[0073] Since in the Euclidean space, the text discriminant function is very susceptible to noise data, and a slight disturbance can cause the text discriminant function to make an erroneous judgment, thereby reducing the accuracy of the initial text classification model based on the text discriminant function for text classification. The Euclidean space is converted into an angle space to obtain an updated text discriminant function, thereby improving the model robustness of the updated text discriminant function.

[0074] Reference Figure 3 As shown, further, the conversion of the text discriminant function from a Euclidean space representation to an angle space representation to obtain an updated text discriminant function comprises:

[0075] S201, obtaining a feature formula in the text discriminant function, and representing the feature formula by the angle of cosine similarity to obtain an angle feature formula;

[0076] S202, replacing the feature formula in the text discriminant function by the angle feature formula to obtain the updated text discriminant function.

[0077] In the embodiment of the application, the angle feature formula is:

[0078]

[0079] wherein, h i is the feature sample, h j is the feature negative sample, is the transpose of the feature sample.

[0080] In the embodiment of the application, the updated text discriminant function is:

[0081]

[0082] wherein, τ is a temperature hyperparameter, and k is the offset of θ i,j .

[0083] S3, obtaining a preset training sentence set, and constructing a triple sentence group according to the training sentences in the training sentence set.

[0084] In the embodiment of the application, the training sentence set is used to construct a triple sentence group, and the training sentence is a sentence in the medical field.

[0085] In the embodiment of the application, the triple sentence group is a sentence obtained by masking the sentences in the training sentence set, for example, optionally taking one sentence as a sample sentence, and masking 20% and 40% respectively to obtain two sentences, and the two sentences and the sample sentence constitute a triple sentence group.

[0086] Further, the constructing the triple sentence group according to the training sentences in the training sentence set comprises:

[0087] Any training sentence in the training sentence set is acquired as a sample sentence, and the sample sentence is masked to obtain a first masked sentence and a second masked sentence;

[0088] The triple sentence group is constructed according to the sample sentence, the first masked sentence and the second masked sentence.

[0089] In the embodiment of the application, the slight semantic difference between different sentences can be distinguished by constructing the triple sentence group, and the semantic order between sentences is clear.

[0090] S4, function modeling is performed based on the triple sentence group to obtain a triple loss function.

[0091] In the embodiment of the application, the triple loss function is:

[0092]

[0093] Wherein, n i is the sample sentence, n′ i is the first masked sentence, n″ i is the second masked sentence, sim is a similarity calculation function, and m is an offset between the first masked sentence and the second masked sentence.

[0094] S5, a model objective function is constructed according to the updated text discrimination function and the triple loss function, and a text classification model is constructed through the model objective function.

[0095] In the embodiment of the application, the model objective function is:

[0096]

[0097] Wherein, is the model objective function, is the updated text discrimination function, and λ is a correlation coefficient

[0098] In the embodiment of the application, the text classification model enhances the text discrimination ability compared with the initial text classification model, and can determine the semantic order of the preset text to be classified.

[0099] S6, a text to be classified is acquired, and the text to be classified is subjected to semantic classification through the text classification model.

[0100] In the embodiment of the application, the text to be classified is a text that needs to be subjected to semantic classification, and the text format of the text to be classified is not limited, which can be a Chinese text, an English text or a text in other formats.

[0101] The text to be classified can be medical literature, case records, drug instructions and the like in the medical field, and when classifying these texts, highly rigorous, professional language knowledge and mathematical statistical analysis ability are required.

[0102] In a possible implementation, the accuracy of the text classification model in processing a text classification task can be tested by using the text to be classified.

[0103] In the embodiment of the application, a pre-trained initial text classification model is first acquired, and a text discriminant function is acquired from the initial text classification model. Then, the text discriminant function is converted from a Euclidean space representation to an angle space representation to obtain an updated text discriminant function. A preset training sentence set is then acquired, and a triple sentence group is constructed according to the sentences in the training sentence set. Based on the triple sentence group, function modeling is performed to obtain a triple loss function. Finally, a model objective function is constructed according to the updated text discriminant function and the triple loss function, and a text classification model is constructed through the model objective function. The preset text to be classified is subjected to semantic classification through the text classification model. Since the representation of the text discriminant function in the initial text discriminant model is converted in the application, the discriminant ability of the discriminant function and the robustness to noise are enhanced. Moreover, the triple loss function is constructed according to the training sentences in the training sentence group, so that the loss function can learn the order relationship of the semantic similarity between medical texts, thereby achieving the purpose of improving the classification accuracy of the text classification model in classifying medical texts based on text semantics.

[0104] As shown in FIG. 1, it is a module schematic diagram of the text classification device. Figure 4

[0105] The text classification device 100 can be installed in an electronic device. According to the functions implemented, the text classification device can include a discriminant function updating module 101, a loss function constructing module 102, a classification model constructing module 103 and a text semantic classification module 104. The modules of the application can also be referred to as units, which refer to a series of computer program segments that can be executed by an electronic device processor and can complete a fixed function, and are stored in the memory of the electronic device.

[0106] In this embodiment, the functions of each module / unit are as follows:

[0107] The discriminant function updating module 101 is configured to acquire a pre-trained initial text classification model, acquire a text discriminant function from the initial text classification model, convert the text discriminant function from a Euclidean space representation to an angle space representation, and obtain an updated text discriminant function.

[0108] ​The loss function construction module 102 is configured to acquire a preset training sentence set, construct a triple sentence group according to a training sentence in the training sentence set, perform function modeling based on the triple sentence group, and obtain a triple loss function.

[0109] The classification model construction module 103 is configured to construct a model target function according to the updated text discrimination function and the triple loss function, and construct a text classification model through the model target function.

[0110] The text semantic classification module 104 is configured to acquire a text to be classified, and perform semantic classification on the text to be classified through the text classification model.

[0111] In detail, each module in the text classification device 100 in the embodiment of the present application adopts the same technical means as the above-described text classification method when in use, and can produce the same technical effects, which will not be described herein again. Figures 1 to 3

[0112] As shown in the figure, it is a structural schematic diagram of an electronic device for implementing the text classification method of the present application. Figure 5

[0113] The electronic device can include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and can further include a computer program (such as a text classification program) stored in the memory 11 and executable on the processor 10.

[0114] In some embodiments, the processor 10 can be composed of an integrated circuit, for example, can be composed of a single packaged integrated circuit, or can be composed of multiple packaged integrated circuits with the same function or different functions, including one or more combinations of central processing units (CPU), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control core (Control Unit) of the electronic device, which connects all components of the electronic device through various interfaces and lines, executes or runs programs or modules stored in the memory 11 (such as executing a text classification program), and calls data stored in the memory 11 to perform various functions of the electronic device and process data.

[0115] ​​The memory 11 includes at least one type of readable storage medium, such as a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 can also be an external storage device of the electronic device, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 11 can include both an internal storage unit and an external storage device of the electronic device. The memory 11 can be used not only to store application software and various data installed in the electronic device, such as the code of a text classification program, etc., but also to temporarily store data that has been output or will be output.

[0116] The communication bus 12 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable connection and communication between the memory 11 and at least one processor 10, etc.

[0117] The communication interface 13 is used for communication between the electronic device and other devices, including a network interface and a user interface. Optionally, the network interface can include a wired interface and / or a wireless interface (e.g., a WI-FI interface, a Bluetooth interface, etc.), which is typically used to establish a communication connection between the electronic device and other electronic devices. The user interface can be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface can also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch, etc. The display can also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visualized user interface.

[0118] Figure 5 Only an electronic device with components is shown, and those skilled in the art can understand that, Figure 5The illustrated structure does not constitute a limitation on the electronic device, which can include fewer or more components than those shown, or combine certain components, or arrange the components differently.

[0119] For example, although not shown, the electronic device can further include a power supply (such as a battery) for powering the various components, preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charge management, discharge management, and power consumption management. The power supply can also include one or more direct current or alternating current power supplies, recharging devices, power supply fault detection circuits, power supply converters or inverters, power supply status indicators, and any other components. The electronic device can also include various sensors, Bluetooth modules, Wi-Fi modules, and the like, which are not described here.

[0120] It should be understood that the embodiments are only for illustration and are not limited in the scope of the patent application by the structure.

[0121] The text classification program stored in the memory 11 of the electronic device is a combination of multiple computer programs, which, when running in the processor 10, can realize:

[0122] Obtaining a pre-trained initial text classification model, and obtaining a text discriminant function from the initial text classification model;

[0123] Converting the text discriminant function from a Euclidean space representation to an angle space representation to obtain an updated text discriminant function;

[0124] Obtaining a pre-set training sentence set, and constructing a triple sentence group according to the training sentences in the training sentence set;

[0125] Function modeling based on the triple sentence group to obtain a triple loss function;

[0126] Constructing a model objective function according to the updated text discriminant function and the triple loss function, and constructing a text classification model through the model objective function;

[0127] Obtaining a text to be classified, and performing semantic classification on the text to be classified through the text classification model.

[0128] Specifically, the specific implementation method of the processor 10 for the above computer programs can refer to Figure 1 The descriptions of the related steps in the corresponding embodiments are not repeated here.

[0129] Further, the modules / units integrated in the electronic device, if realized in the form of software function units and sold or used as independent products, can be stored in a nonvolatile computer readable storage medium. The computer readable storage medium can be volatile or nonvolatile. For example, the computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).

[0130] The application further provides a computer readable storage medium, which stores a computer program, and the computer program can realize the following when executed by a processor of an electronic device:

[0131] obtaining a pre-trained initial text classification model, and obtaining a text discriminant function from the initial text classification model;

[0132] converting the text discriminant function from a Euclidean space representation to an angle space representation to obtain an updated text discriminant function;

[0133] obtaining a preset training sentence set, and constructing a triple sentence group according to training sentences in the training sentence set;

[0134] function modeling based on the triple sentence group to obtain a triple loss function;

[0135] constructing a model objective function according to the updated text discriminant function and the triple loss function, and constructing a text classification model through the model objective function;

[0136] obtaining a text to be classified, and performing semantic classification on the text to be classified through the text classification model.

[0137] In several embodiments provided in the application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the apparatus embodiment described above is merely illustrative. For example, the division of the modules is only a logical function division, and another division mode can be used in actual implementation.

[0138] The modules described as separate components can or can not be physically separated, and the components displayed as modules can or can not be physical units, i.e., they can be located in one place or distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0139] In addition, each function module in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software function modules.

[0140] It is obvious for those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and the present application can be realized in other specific forms without departing from the spirit or essential characteristics of the present application.

[0141] Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting, the scope of the present application is defined by the appended claims rather than the above description, and therefore all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the present application. Any additional reference signs in the claims should not be considered as limiting the claims involved.

[0142] The blockchain referred to in the present application is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. Blockchain, in essence, is a decentralized database, which is a series of data blocks associated using cryptography. Each data block contains information about a batch of network transactions, which is used to verify the validity (anti-fake) of the information and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.

[0143] The embodiments of the present application can acquire and process related data based on artificial intelligence technology. Among them, artificial intelligence (Artificial Intelligence, AI) is to use digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Theory, method, technology and application system.

[0144] In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices stated in the system claims can also be realized by one unit or device through software or hardware. The second word is used to indicate the name, and does not mean any specific order.

[0145] Finally, it should be pointed out that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. A text classification method, characterized in that, The method includes: Obtain a pre-trained initial text classification model, and obtain a text discrimination function from the initial text classification model, wherein the text discrimination function is a function in the initial text classification model that classifies sentence text; The text discrimination function is converted from Euclidean space representation to angular space representation to obtain the updated text discrimination function; Obtain a preset set of training statements, and construct a triple statement group based on the training statements in the set of training statements; Based on the aforementioned ternary statement group, function modeling is performed to obtain the ternary loss function; A model objective function is constructed based on the updated text discrimination function and the ternary loss function, and a text classification model is constructed using the model objective function. Obtain the text to be classified, and perform semantic classification on the text to be classified using the text classification model.

2. The text classification method as described in claim 1, characterized in that, The step of obtaining the text discrimination function from the initial text classification model includes: Obtain a preset text set, and perform data augmentation on the initial text in the text set to obtain augmented text; The initial texts in the text set are divided into batches according to a preset batching method and then input into the initial text classification model to obtain multiple initial text classification feature sets. After dividing the enhanced texts corresponding to each initial text into batches according to the batch division method, they are input into the initial text classification model to obtain multiple sets of enhanced text classification features. The text discrimination function is constructed by using the initial text classification features in the initial text classification feature set as feature samples, the enhanced text classification features in the enhanced text classification feature set corresponding to the initial text classification feature set as positive feature samples, and the remaining initial text classification features in the initial text classification feature set as negative feature samples.

3. The text classification method as described in claim 1, characterized in that, The step of converting the text discrimination function from Euclidean space representation to angular space representation to obtain the updated text discrimination function includes: Obtain the feature expression in the text discrimination function, and represent the feature expression using the angle of cosine similarity to obtain the angle feature expression; The updated text discrimination function is obtained by replacing the feature expression in the text discrimination function with the angular feature expression.

4. The text classification method as described in claim 1, characterized in that, The step of constructing triplet statement groups based on training statements in the training statement set includes: Obtain any training statement from the training statement set as a sample statement, and mask the sample statement to obtain a first masked statement and a second masked statement. The ternary statement group is constructed based on the sample statement, the first mask statement, and the second mask statement.

5. The text classification method as described in claim 1, characterized in that, The text discrimination function is: in, For similarity calculation function, For temperature overparameter, For feature samples, As a positive sample with features, For feature negative samples, This represents the number of negative samples selected for the feature.

6. The text classification method as described in claim 1, characterized in that, The ternary loss function is: in, This is a sample statement. This is the first mask statement. This is the second mask statement. For similarity calculation function, This is the offset between the distance between the first mask statement and the second mask statement.

7. A text classification device, characterized in that, The device includes: The discriminant function update module is used to obtain a pre-trained initial text classification model and obtain a text discriminant function from the initial text classification model. The text discriminant function is a function in the initial text classification model that classifies sentence text. The text discriminant function is converted from Euclidean space representation to angular space representation to obtain an updated text discriminant function. The loss function construction module is used to obtain a preset training statement set, construct a ternary statement group based on the training statements in the training statement set, perform function modeling based on the ternary statement group, and obtain a ternary loss function. The classification model building module is used to construct a model objective function based on the updated text discrimination function and the ternary loss function, and to construct a text classification model through the model objective function. The text semantic classification module is used to obtain the text to be classified and to perform semantic classification on the text to be classified using the text classification model.

8. The text classification device as described in claim 7, characterized in that, The step of converting the text discrimination function from Euclidean space representation to angular space representation to obtain the updated text discrimination function includes: Obtain the feature expression in the text discrimination function, and represent the feature expression using the angle of cosine similarity to obtain the angle feature expression; The updated text discrimination function is obtained by replacing the feature expression in the text discrimination function with the angular feature expression.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the text classification method as described in any one of claims 1 to 6.

10. A computer-readable storage medium, comprising a data storage area and a program storage area, wherein the data storage area stores created data and the program storage area stores a computer program; wherein, When the computer program is executed by a processor, it implements the text classification method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Text classification method and device

    CN114048290A