Corpus expansion method, device, equipment and medium
By extracting and matching the feature vectors of unlabeled corpus and labeled corpus, generating disturbance vectors, and automatically expanding corpus, the problems of high cost of corpus expansion and insufficient recall in the prior art are solved, and efficient and accurate corpus expansion and generalization capabilities are achieved. .
Patent Information
- Application Number
- CN202110988897.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-26
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2041-08-26
AI Technical Summary
The prior art has problems of high labor costs and insufficient recall corpus in the process of corpus expansion in text classification, which is difficult to meet the diversity needs of different business scenarios.
By extracting the feature vectors of the unlabeled corpus and the labeled corpus, generating perturbation vectors, determining the classification of the unlabeled corpus based on the degree of matching, and achieving automatic expansion of the corpus.
It improves the efficiency and accuracy of corpus expansion, reduces labor costs, enhances generalization capabilities, and adapts to the diverse needs of different business scenarios.
Smart Images

Figure CN113656534B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the field of natural language processing technology, and specifically to a corpus expansion method, device, electronic device, computer-readable storage medium, and computer program product. Background Art
[0002] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing. Artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0003] Text classification is a common task in natural language classification. This task is widely used in text application scenarios such as content sorting, content recommendation, and content search. The effectiveness of text classification depends on the training corpus. However, since text classification training requires a large amount of training corpus and the corpus of different business scenarios is diverse, the workload of annotating the training corpus is large. Therefore, it is desirable to provide a method for expanding the training corpus of text classification by machine means.
[0004] The methods described in this section are not necessarily methods that have been previously conceived or employed. Unless otherwise indicated, it should not be assumed that any method described in this section is considered to be prior art simply because it is included in this section. Similarly, unless otherwise indicated, the issues mentioned in this section should not be considered to have been recognized in any prior art. Summary of the invention
[0005] The present disclosure provides a corpus expansion method, device, electronic device, computer-readable storage medium and computer program product.
[0006] According to one aspect of the present disclosure, a corpus expansion method is provided, comprising: extracting a first feature vector of each unlabeled corpus in at least one unlabeled corpus and a second feature vector of the labeled corpus; generating one or more perturbation vectors of the labeled corpus based on the second feature vector of the labeled corpus; determining one or more unlabeled corpora matching the labeled corpus from the at least one unlabeled corpus based on the second feature vector and the one or more perturbation vectors of the labeled corpus, wherein the first feature vector of each unlabeled corpus in the matching one or more unlabeled corpora matches at least one of the one or more perturbation vectors and the second feature vector of the labeled corpus; and saving the unlabeled corpus matching the labeled corpus to a set of categories to which the labeled corpus belongs as an expanded corpus of the labeled corpus.
[0007] According to another aspect of the present disclosure, a corpus expansion device is provided, comprising: a corpus expansion device, comprising: a vector extraction module, configured to extract a first feature vector of each unlabeled corpus in at least one unlabeled corpus and a second feature vector of the labeled corpus; a perturbation module, configured to generate one or more perturbation vectors of the labeled corpus based on the second feature vector of the labeled corpus; a search module, configured to determine one or more unlabeled corpora matching the labeled corpus from the at least one unlabeled corpus based on the second feature vector of the labeled corpus and the one or more perturbation vectors, wherein the first feature vector of each unlabeled corpus in the matching one or more unlabeled corpora matches at least one of the one or more perturbation vectors and the second feature vector of the labeled corpus; and a classification module, configured to save the unlabeled corpus matching the labeled corpus to a set of categories to which the labeled corpus belongs as an expanded corpus of the labeled corpus.
[0008] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the corpus expansion method as described in the present disclosure.
[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the corpus expansion method as described in the present disclosure.
[0010] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements the corpus expansion method as described in the present disclosure.
[0011] According to one or more embodiments of the present disclosure, corpora can be classified accurately and efficiently to expand training corpora for text classification by machine means.
[0012] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0014] Figure 1 A schematic diagram showing an exemplary system in which the various methods described herein may be implemented according to an embodiment of the present disclosure;
[0015] Figure 2 A flowchart of a corpus expansion method according to an embodiment of the present disclosure is shown;
[0016] Figure 3 The embodiment according to the present disclosure is shown in Figure 2 A flowchart of an exemplary process of extracting a first feature vector of each unlabeled corpus and a second feature vector of the labeled corpus in the method of at least one unlabeled corpus;
[0017] Figure 4 The embodiment according to the present disclosure is shown in Figure 2 A flowchart of an exemplary process of determining one or more unlabeled corpora matching a labeled corpus from at least one unlabeled corpus in the method;
[0018] Figure 5 The embodiment according to the present disclosure is shown in Figure 2 A flowchart of an exemplary process of extracting a first feature vector of each unlabeled corpus and a second feature vector of the labeled corpus in the method of at least one unlabeled corpus;
[0019] Figure 6 A structural block diagram of a corpus expansion device according to an embodiment of the present disclosure is shown;
[0020] Figure 7 shows a structural block diagram of a vector extraction module according to an embodiment of the present disclosure;
[0021] Figure 8 shows a structural block diagram of a search module according to an embodiment of the present disclosure;
[0022] Fig. 9 shows a structural block diagram of a vector extraction module according to an embodiment of the present disclosure;
[0023] Fig.10 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0024] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0025] In the present disclosure, unless otherwise specified, the use of the terms "first", "second", etc. to describe various elements is not intended to limit the positional relationship, timing relationship, or importance relationship of these elements, and such terms are only used to distinguish one element from another element. In some examples, the first element and the second element may refer to the same instance of the element, and in some cases, based on the description of the context, they may also refer to different instances.
[0026] The terms used in the description of various examples in this disclosure are only for the purpose of describing specific examples and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element can be one or more. In addition, the term "and / or" used in this disclosure covers any one of the listed items and all possible combinations.
[0027] At present, text classification is widely used in information processing systems such as search engines, question-answering systems, and conversation systems. For example, when receiving the text "She smiled like a flower", the emotion corresponding to the text is identified as "happy". The training corpus used for text classification determines the quality of text classification. At present, there are the following two methods for annotating training corpus for text classification:
[0028] 1) The corpus expansion method based on manual annotation, that is, manually annotating the unlabeled corpus. This method is costly and requires a large number of annotators in different fields. Therefore, if a large amount of corpus needs to be expanded, it will consume extremely high manpower and material resources.
[0029] 2) The corpus expansion method based on rule vocabulary, that is, first generate rules or vocabulary through manual analysis, then mine unlabeled corpus and produce its labels through rules or vocabulary. This method can produce accurate corpus, but due to the determinism of rules and vocabulary, the recall corpus is often insufficient and it is difficult to have strong generalization ability.
[0030] In order to efficiently and accurately expand the training corpus for text classification, the present disclosure provides a corpus expansion method, including: extracting a first feature vector of each unlabeled corpus in at least one unlabeled corpus and a second feature vector of the labeled corpus; generating one or more disturbance vectors of the labeled corpus based on the second feature vector of the labeled corpus; determining one or more unlabeled corpora matching the labeled corpus from the at least one unlabeled corpus based on the second feature vector of the labeled corpus and the one or more disturbance vectors, wherein the first feature vector of each unlabeled corpus in the matching one or more unlabeled corpora matches at least one of the one or more disturbance vectors and the second feature vector of the labeled corpus; and saving the unlabeled corpus matching the labeled corpus to a set of categories to which the labeled corpus belongs as an expanded corpus of the labeled corpus.
[0031] The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0032] Figure 1 FIG. 1 is a schematic diagram of an exemplary system 100 in which various methods and apparatuses described herein may be implemented according to an embodiment of the present disclosure. Figure 1 , the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
[0033] In an embodiment of the present disclosure, the server 120 may run one or more services or software applications that enable the execution of the corpus expansion method described in the present disclosure, the training of text classification, and / or the text classification.
[0034] In some embodiments, server 120 may also provide other services or software applications that may include non-virtualized environments and virtualized environments. In some embodiments, these services may be provided as web-based services or cloud services, such as provided to users of client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) model.
[0035] exist Figure 1In the configuration shown, the server 120 may include one or more components that implement the functions performed by the server 120. These components may include software components, hardware components, or a combination thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may in turn utilize one or more client applications to interact with the server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from the system 100. Therefore, Figure 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
[0036] A user may use client devices 101, 102, 103, 104, 105, and / or 106 to input text, for example, to enter a search statement (e.g., "Is apple a fruit?"). The client device may provide an interface that enables a user of the client device to interact with the client device. The client device may also output information to the user via the interface. Figure 1 Only six client devices are depicted, but one skilled in the art will appreciate that the present disclosure may support any number of client devices.
[0037] Client devices 101, 102, 103, 104, 105 and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptops), workstation computers, wearable devices, game systems, thin clients, various messaging devices, sensors or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT Windows Mobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular phones, smart phones, tablet computers, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays and other devices. Game systems may include various handheld game devices, Internet-enabled game devices, etc. Client devices are capable of executing a variety of different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.
[0038] The network 110 may be any type of network known to those skilled in the art that may support data communications using any of a variety of available protocols, including but not limited to TCP / IP, SNA, IPX, etc. By way of example only, the one or more networks 110 may be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.
[0039] Server 120 may include one or more general purpose computers, dedicated server computers (e.g., PC (personal computer) servers, UNIX servers, mid-range servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and / or combination. Server 120 may include one or more virtual machines running virtual operating systems, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain a server's virtual storage device). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
[0040] The computing units in the server 120 may run one or more operating systems including any of the above operating systems and any commercially available server operating systems. The server 120 may also run any of a variety of additional server applications and / or middle-tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
[0041] In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
[0042] In some embodiments, the server 120 may be a server of a distributed system, or a server combined with a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in a cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services.
[0043] The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as audio files and video files. The data repository 130 may reside in various locations. For example, the data repository used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. The data repository 130 may be of different types. In some embodiments, the data repository used by the server 120 may be a database, such as a relational database. One or more of these databases may store, update, and retrieve data to and from the database in response to a command.
[0044] In some embodiments, one or more of the databases 130 may also be used by applications to store application data. The databases used by the applications may be different types of databases, such as a key-value store, an object store, or a conventional store backed by a file system.
[0045] Figure 1 The system 100 may be configured and operated in various ways to enable the application of various methods and apparatuses described in the present disclosure.
[0046] Figure 2 FIG. 2 shows a flow chart of a corpus expansion method 200 according to an embodiment of the present disclosure. Figure 2 As shown, the method includes: step S201, extracting the first feature vector of each unlabeled corpus in at least one unlabeled corpus and the second feature vector of the labeled corpus; step S203, generating one or more disturbance vectors of the labeled corpus based on the second feature vector of the labeled corpus; step S205, determining one or more unlabeled corpora matching the labeled corpus from the at least one unlabeled corpus based on the second feature vector of the labeled corpus and the one or more disturbance vectors, wherein the first feature vector of each unlabeled corpus in the matching one or more unlabeled corpora matches at least one of the one or more disturbance vectors and the second feature vector of the labeled corpus; and step S207, saving the unlabeled corpus matching the labeled corpus to the set of categories to which the labeled corpus belongs as an extended corpus of the labeled corpus.
[0047] In the corpus expansion method as described in the embodiment of the present disclosure, the unlabeled corpus matching the labeled corpus is recalled by the second feature vector and the disturbance vector of the labeled corpus, so as to classify the unlabeled corpus by machine means, improve the efficiency of corpus expansion, save manpower and time, and ensure the accuracy of corpus expansion. In addition, since the unlabeled corpus is recalled based on the disturbance vector of the labeled corpus in addition to the second feature vector of the labeled corpus, the generalization ability of the corpus expansion is improved.
[0048] In step S201 , a first feature vector of each unlabeled corpus and a second feature vector of the labeled corpus in at least one unlabeled corpus are extracted.
[0049] According to some embodiments, the same feature extraction network is used to extract feature vectors from at least one unlabeled corpus and a labeled corpus. According to some embodiments, the feature vector may be a word vector of a keyword in the corpus (for example, for the corpus "what kind of fruit is watermelon", the keywords "watermelon" and "fruit" are extracted respectively, and then the word vectors of the keywords "watermelon" and "fruit" are extracted respectively). According to some embodiments, the feature vector may be a sentence vector of the corpus (for example, for the corpus "what kind of fruit is watermelon", the sentence vector of the sentence is directly extracted).
[0050] In step S203, one or more disturbance vectors of the annotated corpus are generated based on the second feature vector of the annotated corpus.
[0051] According to some embodiments, each of the one or more disturbance vectors has one or more disturbance dimensions, and wherein, for each disturbance dimension of each disturbance vector, the corresponding dimension value of the disturbance vector is the sum of the corresponding dimension value of the second eigenvector and the disturbance value corresponding to the disturbance dimension, wherein the disturbance value is the product of the corresponding dimension value of the second eigenvector and a preset disturbance ratio.
[0052] According to some other embodiments, each of the one or more perturbation vectors has one or more non-perturbation dimensions, and wherein, for each non-perturbation dimension of each perturbation vector, the corresponding dimension value of the perturbation vector is the corresponding dimension value of the second eigenvector.
[0053] For example, when the second eigenvector is A0=(x0, y0, z0), the first perturbation vector is A1=(x0+Δ x ,y0,z0), where the perturbation dimension of the first perturbation vector is the first dimension, the non-perturbation dimensions are the second and third dimensions, and the perturbation value corresponding to the first dimension is Δ x ; The second perturbation vector is A2=(x0,y0+Δ y ,z0+Δ z), where the perturbation dimensions of the second perturbation vector are the second and third dimensions, the non-perturbation dimension is the first dimension, and the perturbation value corresponding to the second dimension is Δ y , the perturbation value corresponding to the third dimension is Δ z .
[0054] According to some embodiments, the dimension value of the disturbance vector may be a positive value or a negative value to achieve disturbances in different directions.
[0055] By setting the disturbance value corresponding to the disturbance dimension to the product of the dimension value on the disturbance dimension and the disturbance ratio, it is possible to avoid the disturbance value being too small to reduce the richness of the recalled corpus, and it is also possible to avoid the disturbance value being too large to reduce the accuracy of the recalled corpus.
[0056] According to some embodiments, each perturbation vector in the one or more perturbation vectors has only one perturbation dimension, and different perturbation vectors have different perturbation dimensions. By perturbing each dimension of the second feature vector respectively, matching corpora on each dimension are recalled to ensure the richness and accuracy of the recalled corpora.
[0057] For example, when the second eigenvector is A0=(x0, y0, z0), three perturbation vectors are generated. Among them, the first perturbation vector is A1=(x0+Δ x ,y0,z0), the perturbation dimension of the first perturbation vector is the first dimension; the second perturbation vector is A2=(x0,y0+Δ y ,z0), the perturbation dimension of the second perturbation vector is the second dimension; the third perturbation vector is A3=(x0,y0,z0+Δ z ), the perturbation dimension of the third perturbation vector is the third dimension.
[0058] At step S205, based on the second feature vector of the annotated corpus and the one or more disturbance vectors, one or more unlabeled corpora that match the annotated corpus are determined from at least one unlabeled corpus, wherein the first feature vector of each unlabeled corpus in the one or more matching unlabeled corpora matches at least one of the one or more disturbance vectors and the second feature vector of the annotated corpus.
[0059] According to some embodiments, the first feature vector of each unlabeled corpus of the matching one or more unlabeled corpora matches the second feature vector of the labeled corpus or any one of the one or more disturbance vectors, or matches the second feature vector of the labeled corpus and multiple vectors of the one or more disturbance vectors.
[0060] According to some embodiments, the distance between vectors (e.g., vector cosine distance) can be calculated to determine whether two vectors (e.g., the first feature vector of an unlabeled corpus and the second feature vector of an labeled corpus, or the first feature vector of an unlabeled corpus and the perturbation vector of an labeled corpus) match each other, wherein if the distance between the vectors is less than a predetermined distance threshold, the two vectors are determined to match each other.
[0061] In step S207 , the unannotated corpus matching the annotated corpus is saved to the set of categories to which the annotated corpus belongs as the expanded corpus of the annotated corpus.
[0062] For example, when the annotated corpus is "Nutritional ingredients of apples" and is labeled as "fruit", the unlabeled corpus "When will watermelons be on the market" that matches the annotated corpus is also saved in the category set to which "fruit" belongs, that is, it is equivalent to being labeled as "fruit".
[0063] According to some embodiments, extracting the first feature vector of each unlabeled corpus in at least one unlabeled corpus and the second feature vector of the labeled corpus includes: extracting keywords of each unlabeled corpus in at least one unlabeled corpus and keywords of the labeled corpus; for each unlabeled corpus in at least one unlabeled corpus, extracting the first feature vector of the keywords of the unlabeled corpus as the first feature vector of the unlabeled corpus; and extracting the second feature vector of the keywords of the labeled corpus as the second feature vector of the labeled corpus.
[0064] Figure 3 The embodiment according to the present disclosure is shown in Figure 2 A flowchart of an exemplary process of extracting a first feature vector of each unlabeled corpus and a second feature vector of a labeled corpus in at least one unlabeled corpus in the method (step S201).
[0065] In step S301, keywords of each unlabeled corpus and keywords of the labeled corpus in at least one unlabeled corpus are extracted.
[0066] According to some embodiments, when multiple keywords are extracted from a corpus, a primary keyword is selected from these keywords (for example, the primary keyword is selected based on the frequency or part of speech of the keyword); when only one keyword is extracted from the corpus, the keyword is the primary keyword of the corpus.
[0067] In step S303, for each unlabeled corpus in the at least one unlabeled corpus, a first feature vector of a keyword of the unlabeled corpus is extracted as the first feature vector of the unlabeled corpus.
[0068] According to some embodiments, the first feature vector of each keyword of the unlabeled corpus is extracted as the first feature vector of the unlabeled corpus. According to other embodiments, the first feature vector of the primary keyword of the unlabeled corpus is extracted.
[0069] In step S305, the second feature vector of the keyword of the annotated corpus is extracted as the second feature vector of the annotated corpus.
[0070] According to some embodiments, one or more keywords of the annotated corpus are extracted, and a second feature vector of each of the one or more keywords is extracted.
[0071] According to some embodiments, determining one or more unlabeled corpora that match an annotated corpus from at least one unlabeled corpus includes: searching for a target vector in a first feature vector of the at least one unlabeled corpus that matches at least one of the one or more disturbance vectors and a second feature vector of the annotated corpus; and selecting a corpus in the at least one unlabeled corpus that has a keyword corresponding to the target vector as the unlabeled corpus in the at least one unlabeled corpus that matches the annotated corpus.
[0072] Figure 4 The embodiment according to the present disclosure is shown in Figure 2 Flow chart of an exemplary process of determining one or more unlabeled corpora matching a labeled corpus from at least one unlabeled corpus (step S205) in the method of FIG.
[0073] In step S401, a target vector is searched in a first feature vector of at least one unlabeled corpus for matching at least one of the one or more disturbance vectors and a second feature vector of the labeled corpus.
[0074] According to some embodiments, as described above, the distance between the vectors may be calculated to determine whether the two vectors match, wherein if the distance between the vectors is less than a predetermined distance threshold.
[0075] In step S403, a corpus having a keyword corresponding to a target vector in at least one unlabeled corpus is selected as the unlabeled corpus that matches the labeled corpus in the at least one unlabeled corpus.
[0076] According to some embodiments, after determining the target vector, the keyword corresponding to the target vector is obtained, and, based on the keyword corresponding to the target vector, the unlabeled corpus is queried to determine the corpus having the keyword corresponding to the target vector. For example, when the keyword corresponding to the target vector is "apple", the corpus having the keyword "apple" is queried.
[0077] According to some embodiments, extracting a first feature vector of each unlabeled corpus in at least one unlabeled corpus and a second feature vector of a labeled corpus includes: for each unlabeled corpus in at least one unlabeled corpus, extracting a sentence vector of the unlabeled corpus as the first feature vector of the unlabeled corpus; and extracting a sentence vector of the labeled corpus as the second feature vector of the labeled corpus.
[0078] Figure 5 The embodiment according to the present disclosure is shown in Figure 2 A flowchart of an exemplary process of extracting a first feature vector of each unlabeled corpus and a second feature vector of a labeled corpus in at least one unlabeled corpus in the method (step S201).
[0079] At step S501, for each unlabeled corpus in the at least one unlabeled corpus, a sentence vector of the unlabeled corpus is extracted as a first feature vector of the unlabeled corpus. For example, a token-level sentence vector is generated using a BERT model.
[0080] At step 503, the sentence vector of the annotated corpus is extracted as the second feature vector of the annotated corpus. For example, the token-level sentence vector is generated using the BERT model.
[0081] In reference Figure 5 In the described method for extracting sentence vectors of a corpus as feature vectors, a target vector is searched in a first feature vector of at least one unlabeled corpus for a match with a second feature vector of a labeled corpus and at least one of one or more disturbance vectors, and a corpus corresponding to the target vector in at least one unlabeled corpus is selected as the unlabeled corpus that matches the labeled corpus in the at least one unlabeled corpus.
[0082] According to some embodiments, stratified sampling may be performed on all annotated corpora to divide the annotated corpora into an original training set and a test set.
[0083] According to some embodiments, the corpus expansion method as described in the present disclosure is used to expand the corpus in the original training set to obtain an expanded training set, wherein the expanded training set includes the corpus in the original training set and the expanded corpus of the corpus in the original training set.
[0084] According to some embodiments, the corpus in the original training set is used as Figure 2 The annotated corpus described above, and the expanded corpus of the corpus in the original training set is as follows Figure 2 The unlabeled corpus matches the corpus in the original training set.
[0085] According to some embodiments, the category distribution in the test set is calculated, and, through sampling, the category distribution in the augmented training set is adjusted to be the same as the category distribution in the test set.
[0086] According to some embodiments, the category distribution in the test set may be calculated based on the labeled categories of the corpus in the test set. According to some embodiments, the category distribution in the training set is calculated based on the labeled categories of the corpus in the training set (e.g., manually labeled or machine labeled as described above). According to some embodiments, if the category distribution in the training set is different from the category distribution in the test set, the categories that have too high a proportion in the training set are sampled to adjust the category distribution in the training set to be the same as the category distribution in the test set.
[0087] According to some embodiments, keywords of the corpus in the test set may be extracted, and the category distribution in the test set may be calculated based on the keywords of the corpus. According to some embodiments, keywords of the corpus in the training set may be extracted, and the category distribution in the training set may be calculated based on the keywords of the corpus. According to some embodiments, for keywords present in the test set, the category distribution corresponding to these keywords in the training set is adjusted to be the same as the category distribution corresponding to the keywords in the test set. For example, if the keywords in the test set are "fruit", "car", and "animal", and the category distribution corresponding to these three keywords is 6:3:1, the category distribution corresponding to "fruit", "car", and "animal" in the training set is also adjusted to 6:3:1. According to some embodiments, for keywords that do not exist in the test set (for example, due to the perturbation vector-based recall corpus, the corpus in the training set has keywords that do not exist in the test set), the mean of the category proportions corresponding to the keywords present in the test set is calculated to sample the keywords that do not exist in the test set. For example, if the keywords in the test set are "fruit", "car", and "animal", and the category distribution corresponding to these three keywords is 6:3:1, and the training set includes the keywords "fruit", "car", "animal", and "vegetable", then the category distribution corresponding to "fruit", "car", "animal", and "vegetable" in the training set will be adjusted to 6:3:1:3.33.
[0088] In the corpus expansion method as described in the embodiment of the present disclosure, since the category distribution in the expanded training set is adjusted to be the same as the category distribution in the test set, the training and test performance when the expanded training set is used for text classification is ensured.
[0089] Figure 6 FIG. 6 shows a structural block diagram of a corpus expansion device 600 according to an embodiment of the present disclosure.
[0090] like Figure 6As shown, the corpus expansion device 600 includes: a vector extraction module 601, configured to extract the first feature vector of each unlabeled corpus in at least one unlabeled corpus and the second feature vector of the labeled corpus; a perturbation module 602, configured to generate one or more perturbation vectors of the labeled corpus based on the second feature vector of the labeled corpus; a search module 603, configured to determine one or more unlabeled corpora matching the labeled corpus from the at least one unlabeled corpus based on the second feature vector of the labeled corpus and the one or more perturbation vectors, wherein the first feature vector of each unlabeled corpus in the matching one or more unlabeled corpora matches the second feature vector of the labeled corpus or at least one perturbation vector of the one or more perturbation vectors; and a classification module 604, configured to save the unlabeled corpus matching the labeled corpus to the set of categories to which the labeled corpus belongs.
[0091] According to some embodiments, each of the one or more disturbance vectors has one or more disturbance dimensions, and wherein, for each disturbance dimension of each disturbance vector, the corresponding dimension value of the disturbance vector is the sum of the corresponding dimension value of the second eigenvector and the disturbance value corresponding to the disturbance dimension, wherein the disturbance value is the product of the corresponding dimension value of the second eigenvector and a preset disturbance ratio.
[0092] According to some embodiments, each perturbation vector of the one or more perturbation vectors has one or more non-perturbation dimensions, and wherein, for each non-perturbation dimension of each perturbation vector, the corresponding dimension value of the perturbation vector is the corresponding dimension value of the second eigenvector.
[0093] According to some embodiments, each perturbation vector of the one or more perturbation vectors has only one perturbation dimension, and the perturbation dimensions of different perturbation vectors are different.
[0094] Figure 7 FIG. 6 is a structural block diagram of a vector extraction module 601 according to an embodiment of the present disclosure.
[0095] According to some embodiments, Figure 7 As shown, the vector extraction module 601 includes: a keyword extraction module 7011, which is configured to extract keywords of each unlabeled corpus in at least one unlabeled corpus and keywords of the labeled corpus; a first word vector extraction module 7012, which is configured to extract a first feature vector of the keywords of each unlabeled corpus in at least one unlabeled corpus as the first feature vector of the unlabeled corpus; and a second word vector extraction module 7013, which is configured to extract a second feature vector of the keywords of the labeled corpus as the second feature vector of the labeled corpus.
[0096] Figure 8A structural block diagram of the search module 603 according to an embodiment of the present disclosure is shown.
[0097] According to some embodiments, Figure 8 As shown, the search module 603 includes: a target vector matching module 8031, configured to: search for a target vector in a first feature vector of at least one unlabeled corpus that matches at least one of the one or more disturbance vectors and the second feature vector of the labeled corpus; and a corpus selection module 8032, configured to: select a corpus having a keyword corresponding to the target vector in at least one unlabeled corpus as the unlabeled corpus that matches the labeled corpus in the at least one unlabeled corpus.
[0098] Fig. 9 FIG. 6 is a structural block diagram of a vector extraction module 601 according to an embodiment of the present disclosure.
[0099] According to some embodiments, Fig. 9 As shown, the vector extraction module 601 includes: a first sentence vector extraction module 9011, which is configured to: for each unlabeled corpus in the at least one unlabeled corpus, extract the sentence vector of the unlabeled corpus as the first feature vector of the unlabeled corpus; and a second sentence vector extraction module 9012, which is configured to: extract the sentence vector of the labeled corpus as the second feature vector of the labeled corpus. In the technical solution of the present disclosure, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0100] According to an embodiment of the present disclosure, an electronic device, a readable storage medium and a computer program product are also provided.
[0101] According to an embodiment of the present disclosure, an electronic device is also provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the corpus expansion method as described in the present disclosure.
[0102] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is further provided, wherein the computer instructions are used to enable a computer to execute the corpus expansion method according to the present disclosure.
[0103] According to an embodiment of the present disclosure, a computer program product is further provided, including a computer program, wherein the computer program implements the corpus expansion method described in the present disclosure when executed by a processor.
[0104] refer to Fig.10, a block diagram of an electronic device 1000 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0105] like Fig.10 As shown, the device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0106] Multiple components in the device 1000 are connected to the I / O interface 1005, including: an input unit 1006, an output unit 1007, a storage unit 1008, and a communication unit 1009. The input unit 1006 can be any type of device that can input information to the device 1000. The input unit 1006 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device, and can include but is not limited to a mouse, a keyboard, a touch screen, a track pad, a track ball, a joystick, a microphone, and / or a remote controller. The output unit 1007 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 1008 can include but is not limited to a disk and an optical disk. The communication unit 1009 allows the device 1000 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and may include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver and / or a chipset, such as a Bluetooth™ device, a 1302.11 device, a WiFi device, a WiMax device, a cellular communication device and / or the like.
[0107] The computing unit 1001 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1001 performs the various methods and processes described above, such as method 200. For example, in some embodiments, the method 200 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded into the RAM 1003 and executed by the computing unit 1001, one or more steps of the method 200 described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute the method 200 in any other appropriate manner (eg, by means of firmware).
[0108] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0109] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0110] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0111] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0112] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0113] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0114] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0115] Although the embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above-mentioned methods, systems and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples, but only by the claims after authorization and their equivalent scope. Various elements in the embodiments or examples can be omitted or replaced by their equivalent elements. In addition, each step can be performed in an order different from that described in the present disclosure. Further, the various elements in the embodiments or examples can be combined in various ways. It is important that with the evolution of technology, many elements described herein can be replaced by equivalent elements that appear after the present disclosure.
Claims
1. A corpus expansion method, include: Extracting a first feature vector of each unlabeled corpus in at least one unlabeled corpus and a second feature vector of the labeled corpus, wherein the extracting the first feature vector of each unlabeled corpus in at least one unlabeled corpus and the second feature vector of the labeled corpus comprises: Extracting keywords of each unlabeled corpus in the at least one unlabeled corpus and keywords of the labeled corpus; For each unlabeled corpus in the at least one unlabeled corpus, extracting a first feature vector of a keyword of the unlabeled corpus as the first feature vector of the unlabeled corpus; and Extracting a second feature vector of the keyword of the annotated corpus as the second feature vector of the annotated corpus; generating one or more perturbation vectors of the annotated corpus based on the second feature vector of the annotated corpus; Based on the second feature vector of the annotated corpus and the one or more disturbance vectors, determining one or more unannotated corpora matching the annotated corpus from the at least one unannotated corpus, wherein the first feature vector of each of the one or more matching unannotated corpora matches at least one of the one or more disturbance vectors and the second feature vector of the annotated corpus, and wherein determining one or more unannotated corpora matching the annotated corpus from the at least one unannotated corpus comprises: Searching the first feature vector of the at least one unlabeled corpus for a target vector that matches at least one of the one or more disturbance vectors and the second feature vector of the labeled corpus; and Selecting a corpus having the keyword corresponding to the target vector in the at least one unlabeled corpus as the unlabeled corpus in the at least one unlabeled corpus that matches the labeled corpus; and The unannotated corpus matching the annotated corpus is saved in the set of categories to which the annotated corpus belongs as an expanded corpus of the annotated corpus.
2. The method according to claim 1, in, Each perturbation vector of the one or more perturbation vectors has one or more perturbation dimensions, and wherein, For each disturbance dimension of each disturbance vector, the corresponding dimension value of the disturbance vector is the sum of the corresponding dimension value of the second eigenvector and the disturbance value corresponding to the disturbance dimension, wherein the disturbance value is the product of the corresponding dimension value of the second eigenvector and a preset disturbance ratio.
3. The method according to claim 2, in, Each perturbation vector of the one or more perturbation vectors has one or more non-perturbation dimensions, and wherein, For each non-perturbation dimension of each perturbation vector, the corresponding dimension value of the perturbation vector is the corresponding dimension value of the second feature vector.
4. The method according to claim 2 or 3, in, Each perturbation vector of the one or more perturbation vectors has only one perturbation dimension, and the perturbation dimensions of different perturbation vectors are different.
5. The method according to any one of claims 1 to 4, in, The step of extracting the first feature vector of each unlabeled corpus and the second feature vector of the labeled corpus from at least one unlabeled corpus comprises: For each unlabeled corpus in the at least one unlabeled corpus, extracting a sentence vector of the unlabeled corpus as a first feature vector of the unlabeled corpus; and A sentence vector of the annotated corpus is extracted as a second feature vector of the annotated corpus.
6. A corpus expansion device, include: The vector extraction module is configured to extract a first feature vector of each unlabeled corpus and a second feature vector of the labeled corpus in at least one unlabeled corpus, wherein the vector extraction module includes: A keyword extraction module is configured to: extract keywords of each unlabeled corpus in the at least one unlabeled corpus and keywords of the labeled corpus; The first word vector extraction module is configured to: for each unlabeled corpus in the at least one unlabeled corpus, extract a first feature vector of a keyword of the unlabeled corpus as the first feature vector of the unlabeled corpus; and The second word vector extraction module is configured to: extract a second feature vector of a keyword of the annotated corpus as a second feature vector of the annotated corpus; A perturbation module is configured to: generate one or more perturbation vectors of the annotated corpus based on the second feature vector of the annotated corpus; A search module is configured to: determine one or more unlabeled corpora matching the labeled corpus from the at least one unlabeled corpus based on the second feature vector of the labeled corpus and the one or more disturbance vectors, wherein the first feature vector of each of the one or more matching unlabeled corpora matches at least one of the one or more disturbance vectors and the second feature vector of the labeled corpus, and wherein the search module comprises: a target vector matching module, configured to: search the first feature vector of the at least one unlabeled corpus for a target vector that matches at least one of the one or more disturbance vectors and the second feature vector of the labeled corpus; and A corpus selection module is configured to: select a corpus having a keyword corresponding to the target vector from the at least one unlabeled corpus as the unlabeled corpus in the at least one unlabeled corpus that matches the labeled corpus; and The classification module is configured to: save the unannotated corpus matching the annotated corpus into a set of categories to which the annotated corpus belongs as an expanded corpus of the annotated corpus.
7. The device according to claim 6, in, Each perturbation vector of the one or more perturbation vectors has one or more perturbation dimensions, and wherein, For each disturbance dimension of each disturbance vector, the corresponding dimension value of the disturbance vector is the sum of the corresponding dimension value of the second eigenvector and the disturbance value corresponding to the disturbance dimension, wherein the disturbance value is the product of the corresponding dimension value of the second eigenvector and a preset disturbance ratio.
8. The device according to claim 7, in, Each perturbation vector of the one or more perturbation vectors has one or more non-perturbation dimensions, and wherein, For each non-perturbation dimension of each perturbation vector, the corresponding dimension value of the perturbation vector is the corresponding dimension value of the second feature vector.
9. The device according to claim 7 or 8, in, Each perturbation vector of the one or more perturbation vectors has only one perturbation dimension, and the perturbation dimensions of different perturbation vectors are different.
10. The device according to any one of claims 6 to 9, in, The vector extraction module comprises: The first sentence vector extraction module is configured to: for each unlabeled corpus in the at least one unlabeled corpus, extract the sentence vector of the unlabeled corpus as the first feature vector of the unlabeled corpus; and The second sentence vector extraction module is configured to extract the sentence vector of the annotated corpus as the second feature vector of the annotated corpus.
11. An electronic device, include: at least one processor; as well as a memory communicatively coupled to the at least one processor; in The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
12. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-5.
13. A computer program product comprising a computer program, in, When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
