Data set generation method and device, equipment, storage medium and program product
By obtaining seed words related to the topic, filtering and augmenting the data sets, and iteratively screening using clustering and classification methods, the problem of low accuracy of search results in the existing technology is solved, and higher retrieval accuracy and data samples are achieved.
Patent Information
- Application Number
- CN202411815043.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-03-18
AI Technical Summary
In the prior art, the accuracy of the text retrieval results based on keyword matching is low, mainly due to the inconsistent quality of the tags marked by manual labels, resulting in a decrease in the accuracy and reliability of the matching algorithm.
By obtaining seed words related to the topic, filtering out the initial data set, using clustering method for sample expansion, and then using classification method for filtering, iterating until the preset number of iterations is reached to generate the target data set.
The accuracy of the search results is improved, and the accuracy and correlation of data samples are ensured through dynamic adaptation to the clustering method of data distribution and classification screening based on statistical language models.
Smart Images

Figure CN119646225A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a method, apparatus, device, storage medium and program product for generating a data set. Background Art
[0002] In the field of information retrieval, keyword-based text retrieval is a widely used technical means. According to conventional practice, after receiving the search keywords provided by the user, the system will try to match these keywords with pre-set text tags to locate and return documents or content fragments associated with the search keywords. In this process, the preset text tags play a key role. They are usually used to describe the subject, category or other characteristic information of the text.
[0003] However, a significant problem in the prior art is that these preset tags are mostly completed by manual annotation. Due to subjective differences between different people and inconsistencies in understanding the same text, the quality of the generated tags varies. The inconsistency of the tagging standards caused by human factors directly reduces the accuracy and reliability of the keyword matching algorithm, making the search results presented to users often inaccurate or even misjudged.
[0004] Therefore, how to improve the accuracy of search results is a technical problem that needs to be solved urgently by those skilled in the art. Summary of the invention
[0005] The present application provides a method, device, equipment, storage medium and program product for generating a data set, so as to solve the technical problem of low accuracy of retrieval results.
[0006] In a first aspect, the present application provides a method for generating a data set, comprising:
[0007] Get seed words related to the topic;
[0008] According to the seed word, screening is performed in a preset unlabeled data set to obtain a first data set, wherein the first data set includes a plurality of first data samples related to the seed word;
[0009] Using a clustering method, performing sample expansion processing on the first data set to obtain a second data set, wherein the second data set includes a plurality of second data samples related to the seed word, and the number of the second data samples is greater than the number of the first data samples;
[0010] The second data set is subjected to classification and screening processing by a classification method, and the clustering and classification and screening processing steps are iterated until a preset number of iterations are reached to obtain a target data set, wherein the target data set includes target data samples for multiple topics.
[0011] Optionally, in the method described above, the step of performing sample expansion processing on the first data set in a clustering manner to obtain a second data set includes:
[0012] Generate a data set to be expanded according to the screened unlabeled data set and the first data set;
[0013] Obtaining an embedded representation of the data set to be expanded;
[0014] A k-means clustering algorithm is used to perform cluster analysis on the embedded representation of the data set to be expanded, and a second data set is generated according to the cluster analysis result.
[0015] Optionally, in the method as described above, the adopting a classification method to perform classification screening processing on the second data set includes:
[0016] Generate a to-be-screened data set according to the screened unlabeled data set and the second data set;
[0017] Performing feature extraction based on a statistical language model on data samples in the to-be-screened data set to obtain a plurality of word segmentation features;
[0018] Using a word frequency-inverse document frequency statistical method, the word segmentation features are subjected to feature vectorization processing to obtain a word segmentation feature matrix;
[0019] According to the word segmentation feature matrix, a binary classification model for prediction is obtained by training;
[0020] The second data set is subjected to classification and screening processing using the binary classification model for prediction.
[0021] Optionally, in the above method, generating the to-be-screened data set according to the screened unlabeled data set and the second data set includes:
[0022] The filtered unlabeled data set and the second data set are combined to form a data set to be filtered.
[0023] Optionally, in the above method, the step of obtaining seed words related to the topic includes:
[0024] In response to the user's data set generation operation, a seed word input interface is displayed, and a seed word related to the topic input by the user on the seed word input interface is obtained; or,
[0025] Receive the seed words related to the topic sent by the user's terminal device.
[0026] Optionally, in the above method, the step of obtaining seed words related to the topic includes:
[0027] Get sample sentences related to the topic;
[0028] Keyword extraction is performed on the sentence samples to obtain seed words related to the topic.
[0029] Optionally, the method as described above, after the step of performing classification and screening processing on the second data set in a classification manner and iterating the classification and screening processing steps until a preset number of iterations is reached to obtain the target data set, further comprises:
[0030] The target data set is outputted to perform natural language processing using the target data set.
[0031] In a second aspect, the present application provides a device for generating a data set, comprising:
[0032] An acquisition module is used to acquire seed words related to the topic;
[0033] A first processing module, configured to screen a preset unlabeled data set according to the seed word to obtain a first data set, wherein the first data set includes a plurality of first data samples related to the seed word;
[0034] A second processing module is used to perform sample expansion processing on the first data set in a clustering manner to obtain a second data set, wherein the second data set includes a plurality of second data samples related to the seed word, and the number of the second data samples is greater than the number of the first data samples;
[0035] The third processing module is used to classify and filter the second data set in a classified manner, and iterate the clustering and classification and filtering steps until a preset number of iterations to obtain a target data set, wherein the target data set includes target data samples for multiple topics.
[0036] Optionally, the second processing module, when performing sample expansion processing on the first data set in a clustering manner to obtain a second data set, is used to:
[0037] Generate a data set to be expanded according to the screened unlabeled data set and the first data set;
[0038] Obtaining an embedded representation of the data set to be expanded;
[0039] A k-means clustering algorithm is used to perform cluster analysis on the embedded representation of the data set to be expanded, and a second data set is generated according to the cluster analysis result.
[0040] Optionally, the third processing module, when performing classification and screening processing on the second data set in a classification manner, is used to:
[0041] Generate a to-be-screened data set according to the screened unlabeled data set and the second data set;
[0042] Performing feature extraction based on a statistical language model on data samples in the to-be-screened data set to obtain a plurality of word segmentation features;
[0043] Using a word frequency-inverse document frequency statistical method, the word segmentation features are subjected to feature vectorization processing to obtain a word segmentation feature matrix;
[0044] According to the word segmentation feature matrix, a binary classification model for prediction is obtained by training;
[0045] The second data set is subjected to classification and screening processing using the binary classification model for prediction.
[0046] Optionally, the third processing module, when generating the to-be-screened data set according to the screened unlabeled data set and the second data set, is used to:
[0047] The filtered unlabeled data set and the second data set are combined to form a data set to be filtered.
[0048] Optionally, the acquisition module, when acquiring seed words related to the topic, is used to:
[0049] In response to the user's data set generation operation, a seed word input interface is displayed, and a seed word related to the topic input by the user on the seed word input interface is obtained; or,
[0050] Receive the seed words related to the topic sent by the user's terminal device.
[0051] Optionally, the acquisition module, when acquiring seed words related to the topic, is used to:
[0052] Get sample sentences related to the topic;
[0053] Keyword extraction is performed on the sentence samples to obtain seed words related to the topic.
[0054] Optionally, the above device further includes:
[0055] The fourth processing module is used for:
[0056] The target data set is outputted to perform natural language processing using the target data set.
[0057] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0058] The memory stores computer-executable instructions;
[0059] The processor executes the computer-executable instructions stored in the memory to implement the method for generating a data set as described in any one of the first aspects.
[0060] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method for generating a data set as described in any one of the first aspects.
[0061] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method for generating a data set as described in any one of the first aspects.
[0062] The data set generation method provided in the present application determines a vocabulary set related to the current topic by obtaining seed words related to the topic; screens a preset unlabeled data set according to the seed words to obtain a first data set, thereby determining multiple first data samples related to the seed words, thereby achieving the first expansion of the sample data; adopts a clustering method to perform sample expansion processing on the first data set to obtain a second data set with a sample number greater than the first data sample, thereby achieving a secondary expansion of the sample data, and the clustering method can dynamically adapt to the data distribution, and the distribution of data samples processed by the clustering method is more compact, thereby initially improving the accuracy of the data samples; adopts a classification method to perform classification and screening processing on the second data set to filter out data samples that are not related to the current topic, thereby achieving the beneficial effect of accurately determining the data set. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0064] Figure 1 A schematic diagram of a system architecture for generating a data set provided in an embodiment of the present application;
[0065] Figure 2 A schematic diagram of an application scenario of a method for generating a data set provided in an embodiment of the present application;
[0066] Figure 3A flowchart of a method for generating a data set provided in an embodiment of the present application;
[0067] Figure 4 Another schematic diagram of a flow chart of a method for generating a data set provided in an embodiment of the present application;
[0068] Figure 5 A schematic diagram of a brief flow chart of a method for generating a data set provided in an embodiment of the present application;
[0069] Figure 6 A schematic diagram of the structure of a data set generation device provided in an embodiment of the present application;
[0070] Figure 7 A schematic diagram of the structure of an electronic device provided in this application.
[0071] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0072] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0073] First, the terms involved in this application are explained:
[0074] K-means clustering algorithm: (K-means clustering) is a widely used unsupervised learning algorithm for partitioning a dataset into K clusters, where each data point belongs to the cluster center closest to it.
[0075] Statistical language model: A mathematical model used to predict the probability of the next word or character in a text sequence. It is based on statistical methods, which learns the laws of language by analyzing large amounts of text data and estimates the probability of a specific word appearing in a given context.
[0076] Term Frequency-Inverse Document Frequency (TF-IDF) is a commonly used statistical method to determine the importance of a term in a document set or corpus. The larger the TF-IDF value, the more useful the term is in distinguishing different documents. This method is widely used in fields such as information retrieval, text mining, and natural language processing.
[0077] Binary classification model: A machine learning model used to solve classification problems with only two possible outcomes. The goal of this type of model is to classify input data into one of two mutually exclusive categories. For example, determining whether an email is spam (spam / not spam) or predicting whether a patient has a certain disease (illness / not illness) are typical binary classification problems.
[0078] The method for generating the data set provided in this application can be applied to Figure 1 The schematic diagram of the system architecture for generating the dataset shown in FIG. Figure 1 As shown, the data set generation system includes: a user end and a server end. The user end is used to provide a human-computer interaction interface between the generation system and the user, and the server end is used to process the data sent by the user end.
[0079] The above-mentioned user terminal can be a wireless terminal or a wired terminal. The wireless terminal can be a device that provides voice and / or other business data connectivity to the user, a handheld device with a wireless connection function, or other processing equipment connected to a wireless modem. The wireless terminal can communicate with one or more core network devices via a radio access network (Radio Access Network, referred to as RAN). The wireless terminal can be a mobile terminal, such as a mobile phone (or "cellular" phone) and a computer with a mobile terminal. For example, it can be a portable, pocket-sized, handheld, computer-built-in or vehicle-mounted mobile device that exchanges language and / or data with the radio access network. For another example, the wireless terminal can also be a personal communication service (Personal Communication Service, referred to as PCS) phone, a cordless phone, a Session Initiation Protocol (Session Initiation Protocol, referred to as SIP) phone, a wireless local loop (Wireless Local Loop, referred to as WLL) station, a personal digital assistant (Personal Digital Assistant, referred to as PDA) and other devices. The wireless terminal may also be referred to as a system, a subscriber unit (SubscriberUnit), a subscriber station (Subscriber Station), a mobile station (MobileStation), a mobile station (Mobile), a remote station (Remote Station), a remote terminal (Remote Terminal), an access terminal (AccessTerminal), a user terminal (User Terminal), a user agent (User Agent), a user device (User Device or User Equipment), and is not limited here. Optionally, the above-mentioned terminal device may also be a smart watch, a tablet computer, and other devices.
[0080] With the rapid development of the Internet and information technology, text data has shown an explosive growth. However, due to the diversity and complexity of text data, although large-scale text data sets are available, these data sets still require linguists or domain experts to perform annotation work to assist in improving the performance of the model. The above annotation work is time-consuming and labor-intensive, and due to individual differences, different people may have different annotations on the same data, making it difficult to ensure the consistency and accuracy of the annotation quality, which brings great challenges to data processing and analysis. Therefore, using a small number of annotated samples to train a high-performance text classification model and annotate massive unlabeled data is not only of great significance for improving data processing efficiency, but also has a far-reaching impact on promoting the in-depth development of big data technology.
[0081] At present, the methods for text annotation based on a small amount of annotated data mainly include semi-supervised learning, active learning, and Prompt engineering based on large models. In the related technology, an excitation network is used for pre-training and a target network is used for training. Among them, the excitation network uses consistency regularization and data enhancement technology to mine information and features from unsupervised data and supervised data, and provides multi-level regularization constraints for the subsequent training of the target network. This technology uses an excitation network to guide the two-stage training method of the target network. The final target network is a lightweight convolutional neural network. Therefore, the number of parameters is smaller, fewer resources are required during operation, and the speed is faster. However, this method still relies on supervised data, cannot automatically obtain supervised data from keywords, cannot identify and correct noise data in supervised data, and cannot cope with the situation where there is less effective information in the supervised data.
[0082] Figure 2 A schematic diagram of the application scenario for generating the data set provided in this application, such as Figure 2 As shown, one application scenario of the prior art is: S101, the user end obtains the user question, and sends the user question to the server; S102, the server calls the data to be processed in the database according to the user question, S103, processes the above-mentioned data to be processed, obtains a data set about the reply content, and sends the data set about the reply content to the user end; the user end displays the data set about the reply content on the human-computer interaction interface to complete the data set generation.
[0083] In combination with the above scenarios, it can be seen that in the above-mentioned related technologies, the two-stage training method of guiding the target network by the excitation network has the technical problem of being unable to accurately label the data because it relies on supervised data.
[0084] The method for generating a data set provided in the present application solves the technical problem of low accuracy of the data set corresponding to the search results by means of expanding and then screening the data set.
[0085] A method for generating a data set provided in an embodiment of the present application is intended to solve the above technical problems in the prior art and is executed by a server or a user end in the above data set generation system, hereinafter collectively referred to as an electronic device.
[0086] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0087] like Figure 3 As shown, Figure 3A flowchart of a method for generating a data set provided in an embodiment of the present application is provided. A method for generating a data set may specifically include steps S201 to S204, wherein:
[0088] S201. Obtain seed words related to the topic.
[0089] Specifically, collect text data related to the target topic, and then use natural language processing tools for preprocessing, such as word segmentation and stop word removal; apply keyword extraction algorithms (such as RAKE or TextRank) or topic modeling techniques (such as LDA) to identify important words in the text; word vector models (such as Word2Vec) can be used to calculate the similarity of words to expand and verify the initially extracted seed word set.
[0090] S202: Screening a preset unlabeled data set according to the seed word to obtain a first data set, wherein the first data set includes a plurality of first data samples related to the seed word.
[0091] Specifically, natural language processing technology is used to preprocess the unlabeled data set, including word segmentation, stop word removal and normalization; for each data sample, its relevance to the seed word is calculated, which can be achieved through methods such as keyword matching, word vector similarity calculation or TF-IDF; data samples with high relevance to the seed word are screened out to construct the first data set; the screening criteria are verified and adjusted to ensure that the samples in the first data set accurately reflect the relevance to the seed word.
[0092] S203, using a clustering method to perform sample expansion processing on the first data set to obtain a second data set, wherein the second data set includes a plurality of second data samples related to the seed word, and the number of the second data samples is greater than the number of the first data samples.
[0093] Specifically, feature extraction is performed on samples in the first data set, and TF-IDF, word vectors or other text representation methods may be used; a clustering algorithm (such as K-means, DBSCAN or hierarchical clustering) is applied to group the samples to identify potential structures and patterns in the data; based on the clustering results, clusters related to the seed words are identified, and additional samples similar to these cluster centers are searched in the unlabeled data set to expand the data set; these new samples are added to the first data set to form a second data set, ensuring that its sample size is larger than the initial data set, and verifying its relevance to the seed words.
[0094] It is understandable that clustering can adapt to the dynamic distribution of data and can identify previously unknown, naturally occurring groups or categories from big data.
[0095] In this embodiment, clustering is used. On the one hand, it can adapt to the real-time update of the unlabeled data set. Among all clusters, the cluster most relevant to the topic is used as the second data set, which can improve the similarity between the second data set and the target topic. On the other hand, data that is different from the target topic but related can be identified from the unlabeled data set, which can improve the richness and breadth of the data contained in the second data set.
[0096] S204, adopting a classification method to perform classification and screening processing on the second data set, and iterating the clustering and classification and screening processing steps until a preset number of iterations to obtain a target data set, wherein the target data set includes target data samples for multiple topics.
[0097] Specifically, a classification model is trained using the second data set, and a support vector machine, random forest or deep learning model may be selected; the second data set is classified using the model to screen out samples that are highly correlated with the seed words; the data set is updated and the model is retrained, and this process is iterated to improve the classification accuracy until a preset number of iterations is reached or the classification effect is no longer significantly improved; after multiple iterative screenings, the target data set is obtained to ensure that the samples therein are highly correlated with the seed words and meet the expected quality standards.
[0098] It can be understood that, in this embodiment, by classifying the second data set multiple times and filtering out data samples in the second data set that are not related to the subject, the second data set can be optimized in terms of accuracy to obtain a more accurate target data set.
[0099] It should be noted that the text feature extraction methods used in the above clustering and classification processes are different, so that S204 can ensure that irrelevant data that is not "noticed" in the clustering process S203 can be screened out.
[0100] Furthermore, before S203, it also includes: determining a text feature extraction method, wherein the feature extraction method includes extracting embedded features from a semantic perspective, extracting n-gram features from a statistical perspective, etc.; according to the target focus angle, in the preset extraction method group, determining a target screening method group corresponding to the target feature extraction method, wherein the target screening method group includes a target clustering method and a target classification method. Accordingly, when executing step S203, the first data set is processed by the target clustering method to obtain the second data set, and when executing step S204, the second data set is processed by the target classification method to obtain the target data set.
[0101] The data set generation method provided in the embodiment of the present application determines the vocabulary set related to the current topic by obtaining seed words related to the topic; based on the seed words, a preset unlabeled data set is screened to obtain a first data set, thereby determining multiple first data samples related to the seed words, and realizing the first expansion of the sample data; a clustering method is used to perform sample expansion processing on the first data set to obtain a second data set with a sample number greater than the first data sample, thereby realizing the secondary expansion of the sample data, and the clustering method can dynamically adapt to the data distribution, and the distribution of data samples processed by the clustering method is more compact, thereby initially improving the accuracy of the data samples; a classification method is used to perform classification and screening processing on the second data set to filter out data samples that are not related to the current topic, thereby achieving the beneficial effect of accurately determining the data set.
[0102] In an implementable manner, the above S203 uses a clustering method to perform sample expansion processing on the first data set to obtain the second data set, which may specifically include S203-1 to S203-3, wherein:
[0103] S203 - 1 . Generate a data set to be expanded according to the filtered unlabeled data set and the first data set.
[0104] Specifically, the filtered unlabeled data set is sampled to obtain data samples to be expanded; and the selected samples are merged with the first data set to form the data set to be expanded.
[0105] S203-2. Obtain an embedded representation of the data set to be expanded.
[0106] Specifically, select an appropriate embedding model, such as Word2Vec, GloVe, FastText or BERT, according to the characteristics of the dataset and task requirements; preprocess the dataset to be expanded, including steps such as text cleaning, word segmentation and stop word removal; input the preprocessed text into the selected embedding model to generate an embedding representation for each data sample, which is usually a vector of fixed dimension that captures the semantic information of the text; further, verify and store the generated embedding representation.
[0107] S203-3. Perform cluster analysis on the embedded representation of the data set to be expanded using a k-means clustering algorithm, and generate a second data set according to the cluster analysis result.
[0108] Specifically, the embedding representation of the data set to be expanded is obtained, and the K-means clustering algorithm is applied to perform cluster analysis on it. First, K data points are randomly selected as the initial cluster centers. Then, the distance from each data point to each cluster center is calculated and assigned to the cluster with the closest distance. Subsequently, the position of the cluster center is updated according to the mean of the data points in the cluster, and the above process is repeated until the cluster center no longer changes significantly or the preset number of iterations is reached. Finally, the similarity of data points in the same cluster is high, while the similarity of data points between different clusters is low.
[0109] The data set generation method provided in the embodiment of the present application generates a data set to be expanded by using the screened unlabeled data set and the first data set, thereby realizing the first expansion of data samples; obtaining an embedded representation of the data set to be expanded, and completing the pre-processing of the k-means clustering algorithm; using the embedded representation of the data set to be expanded that can be obtained by the k-means clustering algorithm, and utilizing the characteristics of the k-means clustering algorithm that can dynamically adapt to the data distribution, obtaining a clustering analysis result with a more compact distribution between data samples; and more accurately generating a second data set based on the clustering analysis result with a more compact distribution between data samples.
[0110] In an implementable manner, the above S204 adopts a classification method to perform classification and screening processing on the second data set, which may specifically include S204-1 to S204-5, wherein:
[0111] S204-1. Generate a dataset to be screened based on the screened unlabeled dataset and the second dataset.
[0112] Specifically, the filtered unlabeled data set is sampled as a negative sample set; the second data set is used as a positive sample set; and these selected samples are merged to form a data set to be filtered with a binary classification label.
[0113] S204-2. Perform feature extraction based on a statistical language model on the data samples in the to-be-screened data set to obtain a plurality of word segmentation features.
[0114] Specifically, the data samples are preprocessed, including cleaning, word segmentation, and stop word removal; an appropriate statistical language model, such as the n-gram model, is selected to capture the word order and co-occurrence relationship in the text; the model is used to analyze each sample and extract n-gram features, which can be word frequency, co-occurrence frequency, or conditional probability, etc.; the extracted n-gram features are converted into vector representations that can be used for subsequent analysis, ensuring that these word segmentation features can effectively reflect the statistical characteristics and semantic information of the text.
[0115] S204-3. Use the word frequency-inverse document frequency statistical method to perform feature vectorization processing on the word segmentation features to obtain a word segmentation feature matrix.
[0116] Specifically, the word segmentation features of all samples in the data set to be screened are collected to build a vocabulary; the word frequency (TF) of each word in each sample, that is, the ratio of the number of times a word appears in a document to the total number of words in the document; the inverse document frequency (IDF) is calculated, that is, the logarithm of the ratio of the total number of documents to the number of documents containing the word, to measure the word's distinguishing ability; TF and IDF are multiplied to obtain the TF-IDF value of each word, and a feature vector for each sample is generated; the feature vectors of all samples are combined into a word feature matrix.
[0117] S204-4. According to the word segmentation feature matrix, a binary classification model for prediction is trained.
[0118] Specifically, pair the word segmentation feature matrix with the corresponding label data (such as positive and negative classes) to form a training data set; select a suitable binary classification algorithm, such as logistic regression, support vector machine (SVM), random forest or neural network, according to task requirements and data characteristics; input the training data set into the selected classification algorithm, perform model training, and adjust model parameters to optimize classification performance; evaluate the accuracy and generalization ability of the model through cross-validation or validation set, and adjust hyperparameters to improve model performance; obtain an optimized binary classification model and prepare it for predicting the category of new data samples.
[0119] S204-5. Use the binary classification model for prediction to perform classification and screening processing on the second data set.
[0120] Specifically, the samples in the second data set are converted into the same feature representation as that used when training the model, ensuring that the feature vector is consistent with the model input format; these feature vectors are input into the trained binary classification model for prediction, and the model will output a category label or probability score for each sample, indicating the possibility that it belongs to the positive class or the negative class; according to the set threshold or decision rule, the samples predicted by the model as positive are screened out, and it is considered that these samples have a high correlation with the seed word; the accuracy of the screening results is verified, and the model or threshold is adjusted as needed.
[0121] The data set generation method provided in the embodiment of the present application generates a data set to be screened based on a screened unlabeled data set and a second data set; performs feature extraction based on a statistical language model on data samples in the data set to be screened to obtain multiple word segmentation features; uses a word frequency-inverse document frequency statistical method to perform feature vectorization processing on the word segmentation features, and quantizes the word segmentation features into a matrix form to obtain a word segmentation feature matrix; trains a binary classification model for prediction based on the word segmentation feature matrix; uses the binary classification model to perform classification and screening processing on the second data set, and eliminates irrelevant sample data in the second data set, thereby improving the accuracy of the sample data.
[0122] In an implementable manner, the above S204-1, generating a to-be-screened data set according to the screened unlabeled data set and the second data set, may specifically include:
[0123] The filtered unlabeled data set is merged with the second data set to obtain the data set to be filtered.
[0124] Specifically, a preset stop word list containing common stop words is obtained, which usually have little contribution to the semantics of text analysis; each text sample in the filtered unlabeled data set and the second data set is segmented to split the text into independent words or tags; the word segmentation results of each sample are traversed to filter out the words that appear in the stop word list and only retain the words that are meaningful for semantic analysis; the filtered words are recombined into a new text sample to form a data set to be filtered, ensuring that its content is more concise and rich in information.
[0125] In an achievable manner, the above S201, obtaining seed words related to the topic, may specifically include S201-1 or S201-2, wherein:
[0126] S201 - 1 . In response to a data set generation operation by a user, a seed word input interface is displayed, and seed words related to the topic input by the user on the seed word input interface are obtained.
[0127] Specifically, monitor the user's operation to determine when to trigger the data set generation process, and start the seed word input interface at a preset time; design and present a human-computer interaction interface, wherein the interface allows the user to input seed words related to the topic, and the interface should provide clear instructions and input boxes to facilitate user operation; pay attention to the user's interaction on the input interface in real time, capture the seed words input by the user, and perform preliminary format verification and cleaning to ensure the validity and relevance of the input; store or pass the obtained seed words to subsequent data processing modules.
[0128] S201-2. Receive seed words related to the topic sent by the user's terminal device.
[0129] In one possible implementation, the above S201, obtaining seed words related to the topic, may specifically include S201-00 and S201-01, wherein:
[0130] S201-00, obtain sentence samples related to the topic.
[0131] S201-01. Perform keyword extraction on sentence samples to obtain seed words related to the topic.
[0132] Specifically, the implementation process refers to the specific implementation method of S201, which will not be repeated in this embodiment.
[0133] In one possible implementation, in the above S204, after the second data set is subjected to classification and screening processing by classification, and the steps of classification and screening processing are iterated until a preset number of iterations are reached to obtain the target data set, the method further includes:
[0134] Output the target dataset to perform natural language processing using the target dataset.
[0135] Specifically, integrate and organize the text data that has been processed and screened in the early stage to ensure that its format and structure meet the requirements of natural language processing tasks; perform necessary encoding and serialization on the data to support different storage formats and transmission protocols, such as JSON, CSV or database format; verify the integrity and consistency of the data set, check whether there is missing or abnormal data, and perform necessary cleaning and correction; output the target data set to the preset storage location on the user side.
[0136] The method for generating a data set provided in the above embodiment is described below with reference to a specific example. Figure 4 As shown, the following steps are included:
[0137] S301, obtaining sentence samples related to the topic, and performing keyword extraction on the sentence samples to obtain seed words related to the topic.
[0138] This can be achieved in two ways: by responding to the user's data set generation operation, displaying a seed word input interface, and obtaining the seed words related to the topic input by the user on the seed word input interface; or by receiving the seed words related to the topic sent by the user's terminal device.
[0139] For the specific implementation method, please refer to the relevant implementation process of S201, which will not be repeated in this embodiment.
[0140] S302: Screening a preset unlabeled data set according to the seed word to obtain a first data set, wherein the first data set includes a plurality of first data samples related to the seed word.
[0141] Specifically, the sample data containing any seed words is taken as the labeled sample set D1, and the sample data not containing the seed words is taken as the unlabeled data set.
[0142] The database includes text data such as unlabeled data, labeled sample set D1 and unlabeled data set.
[0143] S303: Generate a data set to be expanded according to the filtered unlabeled data set and the first data set.
[0144] The dataset to be expanded D1' is a combination of the labeled sample set D1 and the screened unlabeled dataset.
[0145] S304: Obtain an embedded representation of the data set to be expanded, perform cluster analysis on the embedded representation of the data set to be expanded using a k-means clustering algorithm, and generate a second data set according to the cluster analysis result.
[0146] Specifically, the K-means algorithm is used to embed the text data of the expanded data set D1' into several clusters, and the clusters with more intersections with the labeled sample set D1 are regarded as sample sets highly relevant to the current topic, so as to obtain the second data set D2 and complete the expansion of relevant samples of the current topic.
[0147] S305: Generate a to-be-screened data set based on the screened unlabeled data set and the second data set.
[0148] Specifically, the to-be-screened data set D2' is obtained according to the screened unlabeled data set and the second data set D2.
[0149] S306: Perform feature extraction based on a statistical language model on the data samples in the to-be-screened data set to obtain a plurality of word segmentation features, and use a word frequency-inverse document frequency statistical method to perform feature vectorization processing on the word segmentation features to obtain a word segmentation feature matrix.
[0150] The sample data in the to-be-screened dataset D2' is processed by the N-Gram model for word segmentation, and the word frequency-inverse document frequency (TF-IDF) weight vector of each word segmentation unit is calculated to obtain the word segmentation feature matrix P. The specific process is as follows:
[0151] First, the N-Gram model is used to perform word segmentation on each sample data in the to-be-screened data set D2' to generate a word sequence containing n consecutive vocabulary units.
[0152] Then, for each vocabulary unit, the inverse document frequency (IDF) is calculated, that is, the ratio of the total number of documents in the corpus to the number of documents containing this specific unit, IDF(k), as follows:
[0153]
[0154] The K units with the highest frequency of occurrence are regarded as the key unit set of the current topic. Next, the term frequency (TF) of each key unit in each text sample is counted, that is, the number of times it appears in a single document m:
[0155]
[0156] Generate a set of frequency vectors P∈R 1×K, as the feature vector of the text sample, we get a set of data feature matrices P∈R M×K , which is equivalent to the word segmentation feature matrix.
[0157] S307: According to the word segmentation feature matrix, a binary classification model for prediction is obtained by training.
[0158] Specifically, an initial TF-IDF binary classification module is trained using the data feature matrix P and labels to obtain a TF-IDF binary classification model for prediction.
[0159] S308, using the binary classification model for prediction to perform classification and screening processing on the second data set; and iterating the classification and screening processing steps until a preset number of iterations is reached to obtain a target data set.
[0160] Specifically, the TF-IDF binary classification model will be used to filter out sample data with low relevance to the current topic in the second data set D2, and improve the accuracy of the target data set D3 until the number of iterations is reached, and the latest target data set D3 is used as the final result, so as to accurately obtain sample data related to the current topic.
[0161] Taking the topic "learning text" as an example, when the user searches for text with the topic "learning text", the server initially gives the seed words: "topic", "class hour", "chapter". Then, based on the given seed words, search for data in the data to be labeled, and filter all text data containing the above keywords as the labeled sample set D1. Based on the K-means clustering module, the embedding representation of all text data containing the above keywords is obtained, and the embedded representation is clustered. If it is found that the embedding of texts such as "website" in the labeled sample set D1 is usually included, the labeled sample set D1 has a high degree of correlation with the representation of "website", and these texts such as "website" will be clustered together. Then the cluster with the highest proportion of samples containing the labeled sample set D1 is regarded as the topic-related text, and is marked as the second data set D2. Based on the TF-IDF binary classification module, the frequency of occurrence of different words in all text data containing the above keywords is counted, and different words can be obtained based on the N-Gram model. It is found that in the second data set D2, the frequency of "recommendation" is low, which means that it has a weak relationship with learning. Therefore, in the TF-IDF binary classification module, "recommendation" will not be the core feature based on classification. However, "contact information" will appear more frequently, and the TF-IDF binary classification module will regard "contact information" as a new core feature, and comprehensively consider the information of the above keywords, predict the relevant samples as positive samples, and mark them as the target sample set D3. Finally, iterate the above process, continuously optimize and expand the relevant keywords, and finally complete the text annotation task of the "learning text" theme.
[0162] Furthermore, after S308, the process may also include: outputting a target data set, and performing natural language processing using the target data set to obtain reply content corresponding to the seed word corresponding to the current topic, wherein the reply content is expressed in natural language.
[0163] If the method for generating the data set provided in this embodiment is summarized, it can be summarized as follows: Figure 5 As shown, after taking the vocabulary set related to the current topic input by the user as seed words and matching the seed words to the relevant first data set D1; using the K-means algorithm to perform multi-dimensional expansion on the first data set D1 to obtain the second data set D2, thereby achieving the expansion of a small number of samples; then using the TF-IDF binary classification module, remove the text data in the second data set D2 that is not related to the seed words to obtain the sample set D3, so as to increase the accuracy of the annotation; then repeat the iteration until the text annotation is completed (reaching the number of iterations), and obtain the target sample set, thereby achieving the beneficial effect of accurate labeling of text data.
[0164] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0165] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0166] Figure 6 A schematic diagram of the structure of a data set generation device 40 provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the data set generation device 40 provided in the embodiment of the present application includes:
[0167] An acquisition module 401 is used to acquire seed words related to the topic;
[0168] A first processing module 402 is used to screen a preset unlabeled data set according to the seed word to obtain a first data set, wherein the first data set includes a plurality of first data samples related to the seed word;
[0169] The second processing module 403 is used to perform sample expansion processing on the first data set by clustering to obtain a second data set, wherein the second data set includes a plurality of second data samples related to the seed word, and the number of the second data samples is greater than the number of the first data samples;
[0170] The third processing module 404 is used to classify and filter the second data set in a classification manner, and iterate the classification and filtering steps until a preset number of iterations is reached to obtain a target data set, wherein the target data set includes target data samples for multiple seed words.
[0171] Optionally, the second processing module 403, when performing sample expansion processing on the first data set in a clustering manner to obtain the second data set, is used to:
[0172] Generate a data set to be expanded according to the screened unlabeled data set and the first data set;
[0173] Obtain the embedding representation of the dataset to be expanded;
[0174] The k-means clustering algorithm is used to perform cluster analysis on the embedded representation of the data set to be expanded, and a second data set is generated according to the cluster analysis results.
[0175] Optionally, the third processing module 404, when performing classification and screening processing on the second data set in a classification manner, is used to:
[0176] Generate a data set to be screened based on the screened unlabeled data set and the second data set;
[0177] Perform feature extraction based on a statistical language model on the data samples in the to-be-screened data set to obtain multiple word segmentation features;
[0178] The word frequency-inverse document frequency statistical method is used to perform feature vectorization on the word segmentation features to obtain the word segmentation feature matrix;
[0179] According to the word segmentation feature matrix, a binary classification model for prediction is trained;
[0180] The second data set is subjected to classification and screening processing using a binary classification model for prediction.
[0181] Optionally, the third processing module 404, when generating a to-be-screened data set based on the screened unlabeled data set and the second data set, is used to:
[0182] The filtered unlabeled dataset and the second dataset are merged as the dataset to be filtered.
[0183] Optionally, the acquisition module 401, when acquiring seed words related to the topic, is used to:
[0184] In response to the user's data set generation operation, a seed word input interface is displayed, and a seed word related to the topic input by the user on the seed word input interface is obtained; or,
[0185] Receive the seed words related to the topic sent by the user's terminal device.
[0186] Optionally, the acquisition module 401, when acquiring seed words related to the topic, is used to:
[0187] Get sample sentences related to the topic;
[0188] Perform keyword extraction on sentence samples to obtain seed words related to the topic.
[0189] Optionally, the above device 40 further includes:
[0190] The fourth processing module is used for:
[0191] Output the target dataset to perform natural language processing using the target dataset.
[0192] The data set generation device 40 provided in this embodiment can execute the method provided in the above method embodiment, and its implementation principle and technical effect are similar, which will not be described in detail in this embodiment.
[0193] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0194] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0195] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to a transistor, a memristor, etc.
[0196] Figure 7 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 7 As shown, the electronic device 50 provided in this embodiment includes: at least one processor 501 and a memory 502. Optionally, the electronic device 50 also includes a communication component 503. The processor 501, the memory 502 and the communication component 503 are connected via a bus 504.
[0197] In a specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502, so that at least one processor 501 executes the above method.
[0198] The specific implementation process of the processor 501 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0199] If not otherwise specified, the processor 501 may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not otherwise specified, the memory 502 may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0200] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0201] An embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above redundant field updating method for a distributed system is implemented.
[0202] An embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the above redundant field updating method for a distributed system.
[0203] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0204] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0205] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for generating a data set, characterized in that: include: Get seed words related to the topic; According to the seed word, screening is performed in a preset unlabeled data set to obtain a first data set, wherein the first data set includes a plurality of first data samples related to the seed word; Using a clustering method, performing sample expansion processing on the first data set to obtain a second data set, wherein the second data set includes a plurality of second data samples related to the seed word, and the number of the second data samples is greater than the number of the first data samples; The second data set is subjected to classification and screening processing by a classification method, and the clustering and classification and screening processing steps are iterated until a preset number of iterations are reached to obtain a target data set, wherein the target data set includes target data samples for multiple topics.
2. The method according to claim 1, characterized in that The method of performing sample expansion processing on the first data set by clustering to obtain a second data set includes: Generate a data set to be expanded according to the screened unlabeled data set and the first data set; Obtaining an embedded representation of the data set to be expanded; A k-means clustering algorithm is used to perform cluster analysis on the embedded representation of the data set to be expanded, and a second data set is generated according to the cluster analysis result.
3. The method according to claim 1, characterized in that: The adopting a classification method to perform classification and screening processing on the second data set includes: Generate a to-be-screened data set according to the screened unlabeled data set and the second data set; Performing feature extraction based on a statistical language model on data samples in the to-be-screened data set to obtain a plurality of word segmentation features; Using a word frequency-inverse document frequency statistical method, the word segmentation features are subjected to feature vectorization processing to obtain a word segmentation feature matrix; According to the word segmentation feature matrix, a binary classification model for prediction is obtained by training; The second data set is subjected to classification and screening processing using the binary classification model for prediction.
4. The method according to claim 3, characterized in that The step of generating a to-be-screened data set according to the screened unlabeled data set and the second data set includes: The filtered unlabeled data set and the second data set are combined to form a data set to be filtered.
5. The method according to any one of claims 1 to 4, characterized in that: The step of obtaining seed words related to the topic includes: In response to the user's data set generation operation, a seed word input interface is displayed, and a seed word related to the topic input by the user on the seed word input interface is obtained; or, Receive the seed words related to the topic sent by the user's terminal device.
6. The method according to any one of claims 1 to 4, characterized in that: The step of obtaining seed words related to the topic includes: Get sample sentences related to the topic; Keyword extraction is performed on the sentence samples to obtain seed words related to the topic.
7. The method according to any one of claims 1 to 4, characterized in that: After the second data set is subjected to classification and screening processing by the classification method, and the steps of classification and screening processing are iterated until a preset number of iterations are performed to obtain the target data set, the method further includes: The target data set is outputted to perform natural language processing using the target data set.
8. A device for generating a data set, characterized in that: include: An acquisition module, used to acquire seed words related to the topic; A first processing module, configured to screen a preset unlabeled data set according to the seed word to obtain a first data set, wherein the first data set includes a plurality of first data samples related to the seed word; A second processing module is used to perform sample expansion processing on the first data set in a clustering manner to obtain a second data set, wherein the second data set includes a plurality of second data samples related to the seed word, and the number of the second data samples is greater than the number of the first data samples; The third processing module is used to classify and filter the second data set in a classified manner, and iterate the clustering and classification and filtering steps until a preset number of iterations to obtain a target data set, wherein the target data set includes target data samples for multiple topics.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, 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 for generating a data set according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method for generating a data set according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for generating a data set according to any one of claims 1 to 7 is implemented.