Text data drift detection method, electronic device and computer program product
By performing feature extraction and enhancement in text data drift detection and converting it into a matching problem for quantitative calculation, the problem of low sensitivity to subtle changes and high computational complexity of existing methods is solved, and efficient text data drift detection is achieved.
Patent Information
- Application Number
- CN202410251899.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-05
- Publication Date
- 2024-10-18
AI Technical Summary
Existing text data drift detection methods have low sensitivity to subtle changes, high computational complexity, cannot effectively capture feature interactions, and are difficult to adapt to complex and diverse data changes.
By determining the text features, using the drift detection model for local and global feature extraction, combining the external parameter matrix for feature enhancement, and converting it into a matching problem for quantitative calculation, the detection accuracy is improved.
It improves the accuracy of text data drift detection and the ability to adapt to complex data, reduces the computational complexity, and is suitable for large-scale data processing.
Smart Images

Figure CN118797400A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a text data drift detection method, electronic device and computer program product. Background Art
[0002] The significance of data drift detection is to timely discover changes in data distribution and predict signs of model failure in advance. At present, the commonly used data drift detection methods in related technologies include statistical feature analysis, statistical distribution similarity measurement, topic modeling and domain knowledge-based methods. Among them, the statistical feature analysis method is less sensitive to changes in text data and cannot capture subtle changes. The similarity measurement method is more sensitive to the representation of text data, and different results may be obtained for different representation methods. In addition, drift detection through univariate measurement implies the assumption of feature independence and cannot mine complex interactions between features. This method also has high computational complexity when facing large-scale data. The topic modeling method relies on the predefined number of topics and model parameters. In addition, it is relatively difficult to process long texts, which may cause information loss or distortion. The method based on domain knowledge relies on the experience and knowledge of experts, which is difficult to adapt to complex and diverse data drift, and the domain knowledge may become outdated over time and needs to be continuously updated and maintained. Summary of the invention
[0003] In view of this, embodiments of the present application provide a text data drift detection method, electronic device, storage medium, and computer product.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application provides a method for detecting text data drift, the method comprising:
[0006] Determine text features of all texts in the first to-be-matched text set and the first original text set;
[0007] Inputting text features of all texts in the first to-be-matched text set and the first original text set into a drift detection model to obtain a matching degree output by the drift detection model; the drift detection model is used to form matching pairs of text features in the first to-be-matched text set and text features in the first original text set, and determining a matching degree between the first to-be-matched text set and the first original text set based on a matching relationship between each matching pair;
[0008] Based on the matching degree, it is determined whether data drift occurs in the first to-be-matched text set.
[0009] In the above solution, determining the text features of all texts in the first to-be-matched text set and the first original text set includes:
[0010] Perform word segmentation processing on all texts in the first to-be-matched text set and the first original text set;
[0011] The word segmentation results are mapped to word vectors to obtain text features of each text in the first to-be-matched text set and the first original text set.
[0012] In the above solution, the step of inputting the text features of all texts in the first to-be-matched text set and the first original text set into the drift detection model to obtain the matching degree output by the drift detection model includes:
[0013] Performing local feature extraction on all texts in the first to-be-matched text set and the first original text set based on the drift detection model;
[0014] Performing global feature extraction based on local features of all texts in the first to-be-matched text set and the first original text set;
[0015] The matching degree between the first to-be-matched text set and the first original text set is determined based on the global feature.
[0016] In the above solution, extracting local features from all texts in the first to-be-matched text set and the first original text set based on the drift detection model includes:
[0017] Performing feature enhancement processing on text features in the first to-be-matched text set and the first original text set based on a first external parameter matrix to obtain a first enhanced feature of each text feature;
[0018] Performing feature enhancement processing on the text features in the first to-be-matched text set and the first original text set based on a second external parameter matrix to obtain a second enhanced feature of each text feature; wherein the dimensions of the first external parameter matrix and the second external parameter matrix are different;
[0019] The first enhanced feature and the second enhanced feature are respectively fused with the original text feature to obtain a third enhanced feature and a fourth enhanced feature of each text feature;
[0020] The third enhanced feature, the fourth enhanced feature and the original text feature of each text feature are concatenated to obtain the fifth enhanced feature of each text feature, and the fifth enhanced feature is characterized as a local feature of the text.
[0021] In the above solution, the determining whether data drift occurs in the first to-be-matched text set based on the matching degree includes:
[0022] If the matching degree is greater than or equal to a set value, it is determined that no data drift occurs in the first to-be-matched text set;
[0023] If the matching degree is less than the set value, it is determined that data drift occurs in the first text to be matched.
[0024] On the other hand, the embodiment of the present application also provides a model training method, including:
[0025] Determine a training data set; the training data in the training data set includes a second text set to be matched and a second original text set, and the label of the training data indicates whether data drift occurs in the second text set to be matched;
[0026] The drift detection model is trained based on the training data set.
[0027] On the other hand, an embodiment of the present application further provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor is used to execute the steps in the above method when running the computer program.
[0028] On the other hand, an embodiment of the present application further provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method are implemented.
[0029] On the other hand, an embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned text data drift detection method.
[0030] On the other hand, an embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned model training method.
[0031] The embodiment of the present application determines the text features of all texts in the first text set to be matched and the first original text set, inputs the text features of all texts in the first text set to be matched and the first original text set into a drift detection model, and obtains the matching degree output by the drift detection model. Among them, the drift detection model is used to form matching pairs of text features in the first text set to be matched and text features in the first original text set, determine the matching degree of the first text set to be matched and the first original text set based on the matching relationship of each matching pair, and determine whether data drift occurs in the first text set to be matched based on the matching degree. The embodiment of the present application converts the text data drift detection problem into a matching problem, forms matching pairs of text features in the first text set to be matched and the first original text set, and performs quantitative calculation on the matching degree, with low computational complexity, thereby improving the detection accuracy of text drift. In addition, the embodiment of the present application takes into account the correlation features between the various text features, and is suitable for complex data drift detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a schematic diagram of an implementation flow of a text data drift detection method provided by an embodiment of the present invention;
[0033] Figure 2 is a schematic diagram of a drift detection process provided by an embodiment of the present invention;
[0034] Figure 3 is a schematic diagram of another drift detection process provided by an embodiment of the present invention;
[0035] Figure 4 It is a schematic diagram of an implementation flow of a model training method provided by an embodiment of the present invention;
[0036] Figure 5 is a schematic diagram of an electronic device provided by an embodiment of the present invention; DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Drift in machine learning refers to the statistical characteristics of data or context changing over time, which leads to a decrease in model performance. Monitoring the continued success of machine learning models requires monitoring the data entering the model. Data drift detection is a key component of the machine learning monitoring system. The significance of data drift detection is to timely discover changes in data distribution and predict signs of model failure in advance. It is of great significance for the timely adjustment of AI models.
[0039] There are several related technologies for detecting text data drift:
[0040] 1. Statistical feature analysis: Data drift is detected by analyzing the statistical features of text data, such as word frequency, part-of-speech distribution, sentence length, etc. When the data distribution changes, the statistical features will also change accordingly. Drift detection can be performed by comparing the statistical features of different time periods or different data sources.
[0041] 2. Statistical distribution similarity measure: This is the most common method currently. It looks at each input variable of the model separately and detects data drift by calculating similarity measures between data, such as cosine similarity, edit distance, etc. When the data distribution changes, the similarity between the data will also change. You can determine whether there is drift by comparing similarity measures.
[0042] 3. Topic modeling: Topic modeling techniques, such as Latent Dirichlet Allocation (LDA) and Word2Vec, are used to mine the topic distribution of text data. When the data distribution changes, the topic distribution will also change accordingly. Drift detection can be performed by comparing the topic distribution of different time periods or different data sources.
[0043] 4. Domain knowledge-based method: Use the prior knowledge of domain experts or domain knowledge base to analyze text data and determine whether there is drift. This method relies on the experience and knowledge of domain experts and requires continuous updating and maintenance of the domain knowledge base.
[0044] Although these data drift detection methods have certain effects, they also have some technical disadvantages, as follows:
[0045] 1. Statistical feature analysis: The statistical feature analysis method is less sensitive to changes in text data and cannot capture subtle changes.
[0046] 2. Statistical distribution similarity measurement: Text is unstructured data, and common divergence measurement cannot be applied to the original data. Similarity measurement methods are sensitive to the representation of text data, and different representation methods may produce different results. In addition, drift detection through single variable measurement implies the assumption of feature independence and cannot mine complex interactions between features. This method also has high computational complexity when facing large-scale data.
[0047] 3. Topic modeling: Topic modeling methods rely on the predefined number of topics and model parameters. In addition, it is relatively difficult to process long texts, which may lead to information loss or distortion.
[0048] 4. Methods based on domain knowledge: Methods based on domain knowledge rely on the experience and knowledge of experts and are difficult to adapt to complex and diverse data drift. In addition, domain knowledge may become outdated over time and needs to be constantly updated and maintained.
[0049] In view of the shortcomings of the above-mentioned related technologies, an embodiment of the present invention provides a text data drift detection method, which can lock the coordinate position by determining the distance and azimuth according to the idea of polar coordinates, taking the reader as the pole, the distance as the polar diameter and the azimuth as the polar angle, and finally obtain the position of the tag. In order to illustrate the technical solution of the present invention, a specific embodiment is used for description below.
[0050] Figure 1 1 is a schematic diagram of an implementation flow of a text data drift detection method provided by an embodiment of the present invention, wherein the execution subject of the text data drift detection method is an electronic device. Figure 1 ,Text data drift detection methods include:
[0051] S101, determining text features of all texts in a first to-be-matched text set and a first original text set.
[0052] The first original text set is a text set without data drift, and may be historical text data of a certain historical period of time.
[0053] The first to-be-matched text set and the first original text set both include multiple texts. Each text is segmented, and then word vector mapping is performed after the segmentation. The text is then expressed as a whole segment vector to obtain a text feature representation of each text.
[0054] For example, assuming there are n texts in the text set to be matched, mapping them to the text vector space can be expressed as follows:
[0055] S=(w1,w2,...,w n )
[0056] Among them, w i is a d-dimensional vector representing the i-th paragraph of text. The original text set is expressed as A in the same way.
[0057] S102, inputting text features of all texts in the first to-be-matched text set and the first original text set into a drift detection model to obtain a matching degree output by the drift detection model; the drift detection model is used to form matching pairs of text features in the first to-be-matched text set and text features in the first original text set, and determining the matching degree of the first to-be-matched text set and the first original text set based on the matching relationship of each matching pair.
[0058] The embodiment of the present application adopts a supervised learning method, uses labeled drift samples for training, builds a drift detection model, and then classifies new text data (such as the first set of texts to be matched) to determine whether there is drift.
[0059] By inputting all text features into the drift detection model through text vector conversion, the sensitivity of the drift detection model can be improved.
[0060] The drift detection model groups text features in the first to-be-matched text set and text features in the first original text set into matching pairs, captures the mutual matching relationship, and comprehensively determines the matching degree between the first to-be-matched text set and the first original text set based on the matching relationship of each matching pair.
[0061] For example, a common attention calculation method can be used to capture the matching degree information between the first original text set and the first text set to be matched, and a nonlinear function can be used to encode the text features in the first original text set and the first text set to be matched. Then, the two encoding results can be calculated through common attention to obtain an attention parameter matrix, and the weight of the original text feature representation is redistributed using this attention parameter matrix to obtain a new sentence vector representation. The new sentence vector obtained by each text feature pair is used to calculate the matching degree of the first original text set and the first text set to be matched.
[0062] Here, the matching relationship of each matching pair may also be calculated by similarity, and then the matching degree of the text set may be determined based on the matching relationship of each matching pair.
[0063] S103: Determine whether data drift occurs in the first to-be-matched text set based on the matching degree.
[0064] For example, a threshold is set for the matching degree. If the threshold is exceeded, it is considered that the two text sets have a high matching degree and no data drift has occurred; otherwise, it is considered that the matching degree is low and data drift has occurred.
[0065] The embodiment of the present application determines the text features of all texts in the first text set to be matched and the first original text set, inputs the text features of all texts in the first text set to be matched and the first original text set into a drift detection model, and obtains the matching degree output by the drift detection model. Among them, the drift detection model is used to form matching pairs of text features in the first text set to be matched and text features in the first original text set, determine the matching degree of the first text set to be matched and the first original text set based on the matching relationship of each matching pair, and determine whether data drift occurs in the first text set to be matched based on the matching degree. The embodiment of the present application converts the text data drift detection problem into a matching problem, forms matching pairs of text features in the first text set to be matched and the first original text set, and performs quantitative calculation on the matching degree, with low computational complexity, thereby improving the detection accuracy of text drift. In addition, the embodiment of the present application takes into account the correlation features between the various text features, and is suitable for complex data drift detection.
[0066] In one embodiment, determining the text features of all texts in the first to-be-matched text set and the first original text set includes:
[0067] Perform word segmentation processing on all texts in the first to-be-matched text set and the first original text set;
[0068] The word segmentation results are mapped to word vectors to obtain text features of each text in the first to-be-matched text set and the first original text set.
[0069] For example, you can rely on dictionaries for word segmentation. In machine learning, features are transmitted in the form of numerical values. Similarly, in natural language processing (NLP), text features also need to be mapped into numerical vectors.
[0070] This embodiment uses the mapping process of "word-vector space 1-vector space 2" to realize the vectorization of text words, and converts a word into a vector (numerical vector). For example, "word-vector space 1" can use One-Hot encoding to convert text words into One-Hot vectors. "Vector space 1-vector space 2" can use Singular Value Decomposition (SVD).
[0071] In one embodiment, inputting text features of all texts in the first to-be-matched text set and the first original text set into a drift detection model to obtain a matching degree output by the drift detection model includes:
[0072] Performing local feature extraction on all texts in the first to-be-matched text set and the first original text set based on the drift detection model;
[0073] Performing global feature extraction based on local features of all texts in the first to-be-matched text set and the first original text set;
[0074] The matching degree between the first to-be-matched text set and the first original text set is determined based on the global feature.
[0075] The accuracy of semantic extraction of a single paragraph of text has a significant impact on the final result, so the semantic features of a single paragraph of text are enhanced and extracted before calculating the relationship between texts. For example, the semantic features of a single paragraph of text can be enhanced and extracted to obtain local semantic features. An external parameter matrix can be introduced to help the model learn and extract more information. The matrix can map the intermediate calculation results to the specified dimension.
[0076] The common attention calculation method can be used to capture the matching degree information between text sets. After the common attention calculation, an attention parameter matrix can be obtained. This attention parameter matrix is used to redistribute the weights of the original text feature representation to obtain the global features.
[0077] In one embodiment, extracting local semantic features from all texts in the first to-be-matched text set and the first original text set based on the drift detection model includes:
[0078] Performing feature enhancement processing on text features in the first to-be-matched text set and the first original text set based on a first external parameter matrix to obtain a first enhanced feature of each text feature;
[0079] Performing feature enhancement processing on the text features in the first to-be-matched text set and the first original text set based on a second external parameter matrix to obtain a second enhanced feature of each text feature; wherein the dimensions of the first external parameter matrix and the second external parameter matrix are different;
[0080] The first enhanced feature and the second enhanced feature are respectively fused with the original text feature to obtain a third enhanced feature and a fourth enhanced feature of each text feature;
[0081] The third enhanced feature, the fourth enhanced feature and the original text feature of each text feature are concatenated to obtain the fifth enhanced feature of each text feature, and the fifth enhanced feature is characterized as a local feature of the text.
[0082] First, the local features of the text are enhanced. The accuracy of semantic extraction of a single paragraph of text has a significant impact on the final result, so the semantic features of a single paragraph of text are enhanced and extracted before calculating the relationship between texts.
[0083] Taking the text set S to be matched as an example, the first feature enhancement method introduces an external parameter matrix to help the model learn. The matrix directly maps the intermediate calculation results to the specified dimension. Among them, W1 is the parameter matrix to be learned. Each text embedded in the text set S will be multiplied with different column parameters in the parameter matrix. diag means taking diagonal elements. The operation of taking diagonal elements can help the model retain the text self-action information and filter out other influences. · represents matrix multiplication.
[0084]
[0085] The second feature enhancement method introduces an external parameter matrix W2 to help the model learn and extract more information. Finally, the diagonal operation is also performed to obtain the calculation result of the specified dimension.
[0086]
[0087] The feature enhancement operation in this step has a smaller and more focused calculation scope, capturing more unique features of the text itself, and extracting information comprehensively and calculating concisely. This eliminates the need for complex models to perform operations such as statistical information extraction after text vector embedding.
[0088] Above Corresponding to the first enhanced feature, Corresponding to the second enhanced feature. and It is an enhanced feature of the text features in the text set to be matched, and the above calculation also needs to be performed on the text features in the original text set.
[0089] Then the softmax function is used to requantize the weight distribution value, and the attention weight matrix O is obtained. S It integrates single-text-level information from all aspects and dimensions, and deeply explores various inherent characteristics of a single paragraph of text.
[0090] O S =softmax(O S )
[0091] The next calculation is to compare and fuse the result of the feature enhancement calculation with the original embedding vector of the text itself to embed the new text features of the corresponding dimension.
[0092]
[0093] The above calculation can be The multiplication result is transformed to the corresponding dimension. Represents element-wise multiplication. The results obtained by the two feature enhancement calculation methods are represented as V1 and V2, respectively, where V1 corresponds to the third enhanced feature and V2 corresponds to the fourth enhanced feature.
[0094] In order to obtain the new text enhancement vector and the original text vector expression, we can choose to concatenate them in the first dimension or the second dimension respectively, thus obtaining N S The text embedding expression of , which is the expression vector enhanced by text features.
[0095]
[0096] The text features in the original text set are processed in the same way to obtain N A , use N S and N A They respectively represent the expression vectors of the text to be matched and the original text after local feature enhancement (the fifth enhanced feature).
[0097] Then, global feature extraction is performed. Traditional encoding methods such as LSTM will multiply the amount of calculation as the amount of text increases, which will seriously affect the calculation speed and practicality. In order to control the amount of calculation and improve the calculation performance, nonlinear functions can be used for encoding. Among them, is the Sigmoid function and is the Tanh function.
[0098] H S =σ(N S )·Δ(N S )
[0099] H A =σ(N A )·Δ(N A )
[0100] The common attention calculation method is used to capture the matching degree information between the text sets to be matched. After the common attention calculation, an attention parameter matrix C can be obtained S , and use this matrix to redistribute the weights of the original embedding vector representation to obtain a new sentence vector representation.
[0101]
[0102] R S =softmax(C S )·H Q
[0103] In order to avoid information loss to the greatest extent, a contrast layer is added to fuse the original information with the enhanced information again so that the original information is retained after fusion.
[0104] M S =H S ·RS
[0105] Finally, the global feature M S Input compression layer (Convolutional Neural Networks (CNN) + Multi-Layer Perceptron (MLP)) to get Z S , Z S Represents the vector expression of global semantic information contained in the text set level. Next, multiple pooling operations are used to compress the local semantic information expression and calculate the final matching score. f Represents the parameters to be learned.
[0106]
[0107]
[0108] Score = concat[V S ,V T ,Z S ,Z T ]·W f
[0109] In one embodiment, determining whether data drift occurs in the first to-be-matched text set based on the matching degree includes:
[0110] If the matching degree is greater than or equal to a set value, it is determined that no data drift occurs in the first to-be-matched text set;
[0111] If the matching degree is less than the set value, it is determined that data drift occurs in the first text to be matched.
[0112] A threshold is set for the matching result Score. If the threshold is exceeded, it is considered that the two text sets have a high degree of match and no data drift has occurred. Otherwise, it is considered that the match is low and data drift has occurred.
[0113] like Figure 2 As shown, Figure 2 It is a schematic diagram of a drift detection process provided by an embodiment of the present invention, wherein S1, S2...Sn are original texts in the text set to be matched, T1, T2, T3...Tn are original texts in the original text set, each text in the text set to be matched and the original text set is vectorized, and then local feature enhancement is performed on each text feature, and then global feature extraction is performed based on the local feature enhancement results, and the extracted global features are input into the compression layer to obtain the output matching result Score.
[0114] Figure 3is a schematic diagram of another drift detection process provided by an embodiment of the present invention, including:
[0115] S301, respectively perform word segmentation and word vector mapping on each text expression in the original text set and the text set to be matched.
[0116] S302 , feature enhancement and whole-segment vector expression are performed on each text expression in the original text set and the text set to be matched.
[0117] S303, pairing the original text set and the texts in the to-be-matched text set into matching pairs, capturing the mutual matching relationship.
[0118] S304, calculating the matching relationship results of each matching pair.
[0119] S305, determining the degree of matching between the original text set and the to-be-matched text set. If the matching is successful, it is considered that no drift has occurred; if the matching fails, it is considered that drift has occurred.
[0120] Figure 4 1 is a schematic diagram of an implementation flow of a model training method provided by an embodiment of the present invention, wherein the execution subject of the model training method is an electronic device. Figure 4 , model training methods include:
[0121] S401, determining a training data set; the training data in the training data set includes a second text set to be matched and a second original text set, and the label of the training data indicates whether data drift occurs in the second text set to be matched.
[0122] S402: Train the drift detection model based on the training data set.
[0123] The embodiment of the present application adopts a supervised learning method, uses labeled drift samples for training, builds a drift detection model, and then classifies new text data to determine whether there is drift. All text features are input into the model through text vector conversion to improve the model sensitivity; the correlation features between each feature are considered, which is suitable for complex data drift detection. The model reduces the dimension through pooling operations to reduce the computational complexity. There is no need to predefine the topic, no input length limit, and no reliance on expert knowledge and experience.
[0124] The embodiment of the present application converts the text data drift detection problem into a matching problem, performs quantitative calculations, and reduces the amount of calculations. The semantic features of the text itself and the associated features between text pairs are fused and extracted through the local feature extraction layer and the global feature extraction layer, respectively, which is suitable for complex data drift detection. The nonlinear function encoding and compression layer are used to perform multiple dimensionality reduction and complexity reduction operations, which greatly reduces the amount of calculations and improves performance efficiency. The feature extraction is complete, the embodiment of the present application is less sensitive to data changes, has strong robustness, and does not rely on external knowledge bases, etc., and is easy to implement.
[0125] The embodiments of the present application can be used in monitoring model effects and application effects, and can provide early warning of performance degradation through data drift, thereby improving product stability, improving product reputation, and further enhancing commercial influence and value.
[0126] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0127] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0128] It should be noted that the technical solutions described in the embodiments of the present invention can be arbitrarily combined without conflict.
[0129] In addition, in the embodiments of the present invention, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0130] An embodiment of the present invention provides a text data drift detection device, the device comprising:
[0131] A first determination module, used to determine text features of all texts in the first to-be-matched text set and the first original text set;
[0132] A matching module, used for inputting text features of all texts in the first to-be-matched text set and the first original text set into a drift detection model to obtain a matching degree output by the drift detection model; the drift detection model is used for forming matching pairs of text features in the first to-be-matched text set and text features in the first original text set, and determining a matching degree between the first to-be-matched text set and the first original text set based on a matching relationship between each matching pair;
[0133] The second determination module is used to determine whether data drift occurs in the first to-be-matched text set based on the matching degree.
[0134] In one embodiment, the first determining module is specifically configured to:
[0135] Perform word segmentation processing on all texts in the first to-be-matched text set and the first original text set;
[0136] The word segmentation results are mapped to word vectors to obtain text features of each text in the first to-be-matched text set and the first original text set.
[0137] In one embodiment, the matching module is specifically used for:
[0138] Performing local feature extraction on all texts in the first to-be-matched text set and the first original text set based on the drift detection model;
[0139] Performing global feature extraction based on local features of all texts in the first to-be-matched text set and the first original text set;
[0140] The matching degree between the first to-be-matched text set and the first original text set is determined based on the global feature.
[0141] In one embodiment, the matching module is specifically used for:
[0142] Performing feature enhancement processing on text features in the first to-be-matched text set and the first original text set based on a first external parameter matrix to obtain a first enhanced feature of each text feature;
[0143] Performing feature enhancement processing on the text features in the first to-be-matched text set and the first original text set based on a second external parameter matrix to obtain a second enhanced feature of each text feature; wherein the dimensions of the first external parameter matrix and the second external parameter matrix are different;
[0144] The first enhanced feature and the second enhanced feature are respectively fused with the original text feature to obtain a third enhanced feature and a fourth enhanced feature of each text feature;
[0145] The third enhanced feature, the fourth enhanced feature and the original text feature of each text feature are concatenated to obtain the fifth enhanced feature of each text feature, and the fifth enhanced feature is characterized as a local feature of the text.
[0146] The second determination module is specifically used for:
[0147] If the matching degree is greater than or equal to a set value, it is determined that no data drift occurs in the first to-be-matched text set;
[0148] If the matching degree is less than the set value, it is determined that data drift occurs in the first text to be matched.
[0149] An embodiment of the present invention provides a model training device, the device comprising:
[0150] A third determination module is used to determine a training data set; the training data in the training data set includes a second text set to be matched and a second original text set, and the label of the training data indicates whether data drift occurs in the second text set to be matched;
[0151] A training module is used to train the drift detection model based on the training data set.
[0152] In actual application, the first determination module, the matching module and the second determination module can be implemented by a processor in an electronic device, such as a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU) or a programmable gate array (FPGA).
[0153] It should be noted that: the text data drift detection device provided in the above embodiment only uses the division of the above modules as an example when performing text data drift detection. In actual applications, the above processing can be assigned to different modules as needed, that is, the internal structure of the device is divided into different modules to complete all or part of the processing described above. In addition, the text data drift detection device provided in the above embodiment and the text data drift detection method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0154] The above-mentioned text data drift detection device can be in the form of an image file. After the image file is executed, it can be run in the form of a container or a virtual machine to implement the text data drift detection method described in this application. Of course, it is not limited to the image file form. As long as some software forms that can implement the text data drift detection method described in this application are within the protection scope of this application.
[0155] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the embodiment of the present application further provides an electronic device, and the above text data drift detection method is implemented by a processor of the electronic device. Figure 5 Schematic diagram of the hardware structure of the electronic device of the present application embodiment. Figure 5 As shown, the electronic equipment includes:
[0156] Communication interface 501, capable of exchanging information with other devices such as network devices;
[0157] The processor 502 is connected to the communication interface 501 to implement information exchange with other devices and is used to execute the method provided by one or more technical solutions of the electronic device side when running the computer program. The computer program is stored in the memory 503.
[0158] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 504. It can be understood that the bus system 504 is used to realize the connection and communication between these components. In addition to the data bus, the bus system also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 504 .
[0159] The memory 503 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0160] In this application, the electronic device can be a single hardware device or a cluster of multiple hardware devices, such as a cloud computing platform. The so-called cloud computing platform is a cluster device that organizes multiple independent electronic device physical hardware resources into pooled resources, which provides the required virtual resources and services to the outside world.
[0161] The memory 503 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0162] It can be understood that the memory 503 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), direct memory bus random access memory (DRRAM). The memory described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memory.
[0163] The method disclosed in the above embodiment of the present application can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the program in the memory and completes the steps of the above method in combination with its hardware.
[0164] In an exemplary embodiment, the present application also provides a computer program product, including a computer program, which can be executed by the processor 502 of the electronic device to complete the steps described in the text data drift detection method of the embodiment of the present application.
[0165] In an exemplary embodiment, the embodiment of the present application also provides a computer program product, including a computer program, which can be executed by the processor 502 of the electronic device to complete the steps described in the model training method of the embodiment of the present application.
[0166] Optionally, when the processor executes the program, the corresponding processes implemented by the electronic device in each method of the embodiments of the present application are implemented, which will not be described in detail here for the sake of brevity.
[0167] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, including a first memory storing a computer program, and the computer program can be executed by a processor of an electronic device to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0168] In the several embodiments provided in the present application, it should be understood that the disclosed devices, electronic devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0169] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0170] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
Claims
1. A text data drift detection method, characterized in that: The method comprises: Determine text features of all texts in the first to-be-matched text set and the first original text set; Inputting text features of all texts in the first to-be-matched text set and the first original text set into a drift detection model to obtain a matching degree output by the drift detection model; the drift detection model is used to form matching pairs of text features in the first to-be-matched text set and text features in the first original text set, and determining a matching degree between the first to-be-matched text set and the first original text set based on a matching relationship between each matching pair; Based on the matching degree, it is determined whether data drift occurs in the first to-be-matched text set.
2. The method according to claim 1, characterized in that: The step of determining text features of all texts in the first to-be-matched text set and the first original text set includes: Perform word segmentation processing on all texts in the first to-be-matched text set and the first original text set; The word segmentation results are mapped to word vectors to obtain text features of each text in the first to-be-matched text set and the first original text set.
3. The method according to claim 1, characterized in that The step of inputting text features of all texts in the first to-be-matched text set and the first original text set into a drift detection model to obtain a matching degree output by the drift detection model includes: Performing local feature extraction on all texts in the first to-be-matched text set and the first original text set based on the drift detection model; Performing global feature extraction based on local features of all texts in the first to-be-matched text set and the first original text set; The matching degree between the first to-be-matched text set and the first original text set is determined based on the global feature.
4. The method according to claim 3, characterized in that: The extracting local features of all texts in the first to-be-matched text set and the first original text set based on the drift detection model includes: Performing feature enhancement processing on text features in the first to-be-matched text set and the first original text set based on a first external parameter matrix to obtain a first enhanced feature of each text feature; Performing feature enhancement processing on the text features in the first to-be-matched text set and the first original text set based on a second external parameter matrix to obtain a second enhanced feature of each text feature; wherein the dimensions of the first external parameter matrix and the second external parameter matrix are different; The first enhanced feature and the second enhanced feature are respectively fused with the original text feature to obtain a third enhanced feature and a fourth enhanced feature of each text feature; The third enhanced feature, the fourth enhanced feature and the original text feature of each text feature are concatenated to obtain the fifth enhanced feature of each text feature, and the fifth enhanced feature is characterized as a local feature of the text.
5. The method according to claim 1, characterized in that: The determining whether data drift occurs in the first to-be-matched text set based on the matching degree includes: If the matching degree is greater than or equal to a set value, it is determined that no data drift occurs in the first to-be-matched text set; If the matching degree is less than the set value, it is determined that data drift occurs in the first text to be matched.
6. A model training method for training the drift detection model according to any one of claims 1 to 5, characterized in that: The method comprises: Determine a training data set; the training data in the training data set includes a second text set to be matched and a second original text set, and the label of the training data indicates whether data drift occurs in the second text set to be matched; The drift detection model is trained based on the training data set.
7. An electronic device, characterized in that: include: A processor and a memory for storing a computer program that can be executed on the processor, wherein: The processor is used to execute the steps of the method described in claims 1 to 5 or claim 6 when running a computer program.
8. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to claims 1 to 5 or claim 6 are implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to claim 6 are implemented.
Citation Information
Patent Citations
Text matching method, device, storage medium and processor
CN113283497A
Marketing knowledge text matching method based on multiple data sources
CN114443811A
Semantic drift detection method and device, electronic equipment and storage medium
CN116502646A
