A data time sequence representation method and device based on contrast learning and a medium
By explicitly modeling the correlation between different periods of the data source through a self-attention mechanism and a time decay module, reasonable positive and negative samples are constructed. The time-aware data representation is trained using time-series contrast loss, which solves the problem of insufficient cross-period contrast capability in existing technologies and achieves more accurate data evaluation.
Patent Information
- Application Number
- CN202611663821.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-27
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies lack cross-period comparison capabilities in data time-series representation learning, have unreasonable negative sample construction, insufficient utilization of time-series information, and insufficient representational discriminability, resulting in inaccurate evaluation results.
By explicitly modeling the correlation between different periods of the same data source through a self-attention mechanism and a time decay module, positive samples, hard negative samples and excluded samples are constructed. Time-aware data representation is trained using time-series contrastive loss, and weighted fusion is performed by combining differential decay rate and quality weight to generate time-aware data representation.
It enhances cross-period modeling capabilities, improves the discriminative and generalizable nature of representations, and enhances the accuracy and comparability of data evaluation, enabling it to capture the development trajectory and business logic of data sources.
Smart Images

Figure CN123179092A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of time series data modeling and deep representation learning, and in particular to a data time series representation method, device and medium based on contrastive learning. Background Technology
[0002] In data evaluation, effectively learning the temporal representation of data is a key issue. Current technologies for learning temporal representations of data mainly include the following solutions:
[0003] Time series modeling based on RNN / LSTM: Input the historical sequence of data into a recurrent neural network to extract the time series representation;
[0004] Transformer-based temporal modeling: using a self-attention mechanism to model the temporal dependencies of data;
[0005] Representation learning based on simple contrast: Using contrastive learning methods, positive and negative sample pairs are constructed through data augmentation;
[0006] Graph Neural Network-Based Structural Representation: Node representations are learned by aggregating neighbor information through a graph neural network.
[0007] When the aforementioned existing technologies are applied to efficient data evaluation, the following technical shortcomings exist:
[0008] Lack of cross-period comparison capability: Existing methods treat the representation of the data source at different times as independent learning, failing to explicitly model the correlation and differences of the same data source at different times;
[0009] Inappropriate negative sample construction: Traditional contrastive learning methods do not consider the time factor when constructing negative samples, resulting in different data sources from the same period being incorrectly distanced;
[0010] Insufficient utilization of temporal information: Although methods such as RNN / Transformer model temporal dependencies, they fail to explicitly utilize the time decay property;
[0011] Insufficient distinguishability: The lack of specific contrast signals tailored to the characteristics of the data source results in low distinguishability of the learned representation. Summary of the Invention
[0012] To address the shortcomings of existing technologies, this invention discloses a data time-series representation method based on contrastive learning, comprising:
[0013] Step S1: Standardize the dataset according to data identifier, data type, data occurrence time, and data quality indicators to obtain dataset A;
[0014] Step S2: Divide dataset A into time steps based on several time periods, and arrange them in order into a time step sequence. ;
[0015] Step S3: Normalize the data features in the time step, embed and encode the category features, and generate a missing mask and behavior type identifier to obtain a time step input vector with a unified dimension.
[0016] Step S4: Input the time step input vector into the time series data encoder, and obtain the contextual representation of the data at each time step through the self-attention mechanism. ;
[0017] Step S5: The time decay module combines the data occurrence time, data type, and preset data weights to perform weighted fusion of the context representations at different time steps, generating a time-aware data representation. ;
[0018] Step S6: Construct positive samples, hard negative samples, and excluded samples, and train time-aware data representation using time-series contrastive loss;
[0019] Step S7: Input the trained time-aware data representation into the multi-task output layer, and output the comprehensive evaluation result corresponding to the data identifier, data type, data occurrence time and data quality index.
[0020] In step S5, the workflow of the time decay module includes:
[0021] Time difference calculation: for the current evaluation time and the time of occurrence of historical data Calculate the time difference The time unit can be month, quarter, or year; Differentiated decay rate: Set the learnable decay rate according to the data type. ;
[0022] If the data pertains to teachers, their short-term behaviors, such as teaching feedback and classroom interaction, are analyzed using a larger scale. This gives higher weight to recent performance; long-term achievements such as papers, projects, and awards are given less weight. This ensures that its long-term contributions are not rapidly diminished; social services, student mentoring, and other activities are subject to a moderate decay rate; quality weight fusion: a quality weight is introduced for each historical data item. ;
[0023] If the data is teacher-related, quality weighting Factors such as course difficulty, class size, paper level, project role, and student mentoring outcomes can be used to ensure that high-quality historical actions contribute more effectively within the same time frame; Correction phase: A phase system is introduced based on data type and data occurrence time. ;
[0024] If the data is teacher-related, it can reasonably reflect both the recent growth signals of young teachers and the long-term achievements of senior teachers; Normalization fusion: The weight of historical time step i to the current representation is:
[0025]
[0026] in The encoder attention score;
[0027] For behavior type;
[0028] The final time-aware data is represented as .
[0029] This solution uses a time decay module to combine the time of behavior occurrence, behavior type, and evaluation business weights to weight and fuse the contextual representations at different time steps, generating a time-aware data representation, namely, a time-aware teacher representation. ;
[0030] In step S6, the samples for time-series contrast loss and the sample construction method include:
[0031] Positive samples across stages from the same data source: construct positive sample pairs for the representations of the same data source before and after adjacent time periods; enable the model to learn the continuous development trajectory of teachers' abilities; the time interval k can be set to 1 to 3 time slices according to the evaluation cycle.
[0032] Enhanced positive samples from the same data source: Sequences from the same data source within the same time window are subjected to temporal masking, slight feature perturbations, or time window clipping to obtain an enhanced view. and As positive samples are brought closer together, this ensures that data augmentation views are explicitly included in the positive sample set.
[0033] Stratified difficult negative samples: Prioritize data sources of the same type and time period as negative samples to form more comparable difficult negative samples; avoid the over-simplification of random negative samples, which may lead to insufficient representation discrimination.
[0034] Samples excluded based on cooperative relationships: If two data sources have a strong cooperative relationship in the same physical space or system, they will not be directly used as negative samples; this prevents the model from mistakenly distancing itself from truly relevant data sources.
[0035] Hierarchical sampling based on behavior type: positive and negative samples are sampled separately in different data types, and the loss is synthesized according to the data type weights; this enables the model to learn differentiated representations of different evaluation dimensions.
[0036] There is also an overall loss function, which is expressed as the sum of the products of the cross-stage positive sample loss from the same data source, the enhanced positive sample loss from the same data source, the stratified difficult negative sample loss, the sample loss excluded by cooperation relationship, and the multi-task evaluation supervision loss with their respective preset weights.
[0037] Its expression is:
[0038]
[0039] The temporal contrastive loss training described above uses cosine similarity to quantify the similarity of temporal representation vectors in the data. The cosine similarity is:
[0040] .
[0041] The smoothness of the distribution of the cosine similarity It is controlled by the temperature parameter τ.
[0042]
[0043] in, For the candidate sample set; The smaller the value, the more concentrated the similarity distribution. The larger the value, the smoother the similarity distribution.
[0044] In step S4, the workflow of the time-series data encoder includes:
[0045] Input features: A sequence of behavioral features of the data over T time steps. Each Includes numerical features and categorical features;
[0046] Preprocessing: Numerical features are scaled by quantiles or normalized by Z-score, and categorical features are encoded by embedding. The preprocessed numerical feature vector and categorical feature vector are used as feature encodings.
[0047] Information encoding: Mark the behavior category at each time step as the behavior type encoding;
[0048] Record the absolute position of each time step on the time axis as the absolute position code;
[0049] Record the time interval between adjacent time steps as the adjacent time slice interval encoding;
[0050] Generate a missing mask m_i for the missing data and concatenate it with the input vector; this enables the model to distinguish between "no behavior" and "missing data";
[0051] Encoding feature fusion: The feature encoding, behavior type encoding, absolute time position encoding and adjacent time slice interval encoding are added or concatenated, and then linearly mapped to obtain a d-dimensional input representation, which is used as the input of the Transformer encoder;
[0052] d is preferably 128-dimensional or 256-dimensional;
[0053] The Transformer encoder is preferably 2 to 4 layers, each layer containing 4 to 8 attention heads, feedforward network layers, residual connections and LayerNorm normalization, and the hidden dimension of the feedforward network is preferably 2 to 4 times the input dimension;
[0054] Transformer encoder attention calculation: The self-attention layer calculates weights based on the correlation between different time steps, enabling the model to simultaneously capture recent data performance, long-term data accumulation, and phased data development and changes;
[0055] Output: The encoder outputs the context representation of each time step. And obtain the data-level temporal representation through weighted pooling, last time step representation or attention pooling.
[0056] The present invention also provides an electronic device, comprising:
[0057] One or more processors;
[0058] Memory, used to store one or more programs;
[0059] When the one or more programs are executed by the one or more processors, the one or more processors implement the data timing representation method as described above.
[0060] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data timing representation method as described above.
[0061] The beneficial effects of this invention are:
[0062] Enhanced cross-period modeling capabilities: Through a step-by-step temporal representation process and cross-stage positive sample construction, the correlation between representations of the same data source at different periods is explicitly modeled, enabling the representation to capture the development trajectory of the data source.
[0063] Enhanced time perception: By incorporating differentiated decay rates, quality weights, and phase corrections, business logic such as teaching, research, and social services into the time decay module, avoiding simply weighting based on time proximity;
[0064] Improved discriminative power: By using difficult negative samples and cooperation exclusion rules, the model learns a more comparable boundary that better fits the data evaluation scenario;
[0065] Enhanced generalization ability: Through enhancement methods such as temporal masking, feature perturbation, and time window sampling, the model's adaptability to data in different physical locations and at different stages is improved;
[0066] Improved evaluation accuracy: The results of temporal representation learning can directly serve the data source quality, data source capabilities, data source service capabilities, and comprehensive evaluation tasks, making the final evaluation results both current, long-term, and discriminative. Attached Figure Description
[0067] Figure 1 This is a diagram illustrating the overall architecture of the timing comparison framework in the embodiments of this application.
[0068] Figure 2 This is a schematic diagram of the service-aware time decay module in the embodiments of this application;
[0069] Figure 3 This is a schematic diagram of multi-level contrast loss in the embodiments of this application. Detailed Implementation
[0070] To enable those skilled in the art to better understand the present invention, the technical solutions in the specific embodiments of the present invention will be clearly and completely described below.
[0071] Example 1
[0072] like Figure 1 As shown, a data time-series representation method based on contrastive learning includes:
[0073] Step S1: Standardize the dataset according to data identifier, data type, data occurrence time, and data quality indicators to obtain dataset A;
[0074] Step S2: Divide dataset A into time steps based on several time periods, and arrange them in order into a time step sequence. ;
[0075] Step S3: Normalize the data features in the time step, embed and encode the category features, and generate a missing mask and behavior type identifier to obtain a time step input vector with a unified dimension.
[0076] Step S4: Input the time step input vector into the time series data encoder, and obtain the contextual representation of the data at each time step through the self-attention mechanism. ;
[0077] Step S5: The time decay module combines the data occurrence time, data type, and preset data weights to perform weighted fusion of the context representations at different time steps, generating a time-aware data representation. ;
[0078] Step S6: Construct positive samples, hard negative samples, and excluded samples, and train time-aware data representation using time-series contrastive loss;
[0079] Step S7: Input the trained time-aware data representation into the multi-task output layer, and output the comprehensive evaluation result corresponding to the data identifier, data type, data occurrence time and data quality index.
[0080] like Figure 2 As shown, in step S5, the workflow of the time decay module includes:
[0081] Time difference calculation: for the current evaluation time and the time of occurrence of historical data Calculate the time difference The time unit can be month, quarter, or year; Differentiated decay rate: Set the learnable decay rate according to the data type. ;
[0082] If the data pertains to teachers, their short-term behaviors, such as teaching feedback and classroom interaction, are analyzed using a larger scale. This gives higher weight to recent performance; long-term achievements such as papers, projects, and awards are given less weight. This ensures that its long-term contributions are not rapidly diminished; social services, student mentoring, and other activities are subject to a moderate decay rate; quality weight fusion: a quality weight is introduced for each historical data item. ;
[0083] If the data is teacher-related, quality weighting Factors such as course difficulty, class size, paper level, project role, and student mentoring outcomes can be used to ensure that high-quality historical actions contribute more effectively within the same time frame; Correction phase: A phase system is introduced based on data type and data occurrence time. ;
[0084] If the data is teacher-related, it can reasonably reflect both the recent growth signals of young teachers and the long-term achievements of senior teachers; Normalization fusion: The weight of historical time step i to the current representation is:
[0085]
[0086] in The encoder attention score;
[0087] For behavior type;
[0088] The final time-aware data is represented as .
[0089] In step S6, the samples for time-series contrast loss and the sample construction method include:
[0090] Positive samples across stages from the same data source: construct positive sample pairs for the representations of the same data source before and after adjacent time periods;
[0091] Enhanced positive samples from the same data source: Sequences from the same data source within the same time window are subjected to temporal masking, slight feature perturbations, or time window clipping to obtain an enhanced view. and ;
[0092] Stratified difficult negative samples: Prioritize data sources of the same type and time period as negative samples to form more comparable difficult negative samples; avoid the over-simplification of random negative samples, which may lead to insufficient representation discrimination.
[0093] Samples excluded based on cooperative relationships: If two data sources have a strong cooperative relationship in the same physical space or system, they will not be directly used as negative samples; this prevents the model from mistakenly distancing itself from truly relevant data sources.
[0094] Hierarchical sampling based on behavior type: positive and negative samples are sampled separately in different data types, and the loss is synthesized according to the data type weights; this enables the model to learn differentiated representations of different evaluation dimensions.
[0095] There is also an overall loss function, which is expressed as the sum of the products of the cross-stage positive sample loss from the same data source, the augmented positive sample loss from the same data source, the stratified hard negative sample loss, and the multi-task evaluation supervision loss with their respective preset weights.
[0096] Its expression is:
[0097]
[0098] in, This indicates the positive sample loss across different stages for teachers;
[0099] This indicates that the positive sample loss is enhanced by the teacher's input.
[0100] This indicates the negative sample loss due to stratification difficulties.
[0101] Indicating a cooperative relationship excludes sample loss;
[0102] Indicates the loss of multi-task evaluation and supervision;
[0103] to Weights can be learned or preset.
[0104] The temporal contrastive loss training uses cosine similarity to measure the similarity of temporal representation vectors. The cosine similarity is:
[0105] .
[0106] The smoothness of the cosine similarity distribution is controlled by the temperature parameter τ.
[0107] In step S4, the workflow of the time-series data encoder includes:
[0108] Input features: A sequence of behavioral features of the data over T time steps. each Includes numerical features and categorical features;
[0109] Preprocessing: Numerical features are scaled by quantiles or normalized by Z-score, and categorical features are encoded by embedding. The preprocessed numerical feature vector and categorical feature vector are used as feature encodings.
[0110] Information encoding: Mark the behavior category at each time step as the behavior type encoding;
[0111] Record the absolute position of each time step on the time axis as the absolute position code;
[0112] Record the time interval between adjacent time steps as the adjacent time slice interval encoding;
[0113] Generate a missing mask m_i for the missing data and concatenate it with the input vector; this enables the model to distinguish between "no behavior" and "missing data";
[0114] Encoding feature fusion: The feature encoding, behavior type encoding, absolute time position encoding and adjacent time slice interval encoding are added or concatenated, and then linearly mapped to obtain a d-dimensional input representation, which is used as the input of the Transformer encoder;
[0115] d is preferably 128-dimensional or 256-dimensional;
[0116] The Transformer encoder is preferably 2 to 4 layers, each layer containing 4 to 8 attention heads, feedforward network layers, residual connections and LayerNorm normalization, and the hidden dimension of the feedforward network is preferably 2 to 4 times the input dimension;
[0117] Transformer encoder attention calculation: The self-attention layer calculates weights based on the correlation between different time steps, enabling the model to simultaneously capture recent data performance, long-term data accumulation, and phased data development and changes;
[0118] Output: The encoder outputs the context representation of each time step. And obtain the data-level temporal representation through weighted pooling, last time step representation or attention pooling.
[0119] When the data in this embodiment specifically refers to university teacher data, the specific method is as follows:
[0120] Step S1: Collect data on teachers' teaching, research, social service and teacher-student interaction during the continuous evaluation period, and standardize the data according to teacher identification, behavior type, occurrence time and quality indicators.
[0121] Step S2 involves dividing the continuous time into time slices such as semesters, academic years, or calendar months, and creating a time step sequence for each teacher. Each time step includes features such as course evaluations, teaching workload, thesis projects, student mentoring, and social services within that period.
[0122] Step S3: Normalize the numerical features of each time step, embed and encode the category features, and generate a missing mask and behavior type identifier to obtain a time step input vector with a unified dimension.
[0123] Step S4: Input the time step input vector into the temporal data encoder, and obtain the teacher's contextual representation at each time step through a self-attention mechanism. ;
[0124] Step S5: By combining the behavior occurrence time, behavior type, and evaluation business weights through the time decay module, the representations from different periods are weighted and fused to generate a time-aware teacher representation. ;
[0125] Step S6: Construct positive samples, difficult negative samples, and excluded samples based on teacher development stage, discipline, professional title, college, and cooperation relationship; and train the representation space using temporal contrastive loss.
[0126] Step S7: Input the trained teacher temporal representation into the multi-task output layer to obtain results such as teaching quality, research ability, social service and comprehensive evaluation, and use this representation as the basic feature for subsequent teacher evaluation, trend analysis or similar teacher retrieval.
[0127] The core components of the above process include a time series data encoder, a time decay module, a time series contrast loss function, and a multi-task output layer. These components are sequentially connected and jointly trained to obtain a stable teacher time series representation.
[0128] The specific working principle of its time-series data encoder is as follows:
[0129] The time-series data encoder is responsible for converting the teacher's historical behavior sequence into a vector representation, preferably using a Transformer encoder structure with time interval encoding.
[0130] Input features: The sequence of teacher's behavioral features over T time steps. each Numerical characteristics include teaching workload, student evaluation, course difficulty, number and quality of papers, project funding, student guidance, and social service, as well as categorical characteristics such as discipline, professional title, college, and course type.
[0131] Preprocessing methods: Numerical features are scaled by quantiles or normalized by Z-score, categorical features are encoded by Embedding, and missing data is generated by generating a missing mask m_i and concatenating it with the input vector, so that the model can distinguish between "no behavior" and "missing data".
[0132] Encoding format: The feature encoding, behavior type encoding, absolute time position encoding and adjacent time slice interval encoding are added or concatenated, and then linearly mapped to obtain a d-dimensional input representation, where d is preferably 128-dimensional or 256-dimensional.
[0133] Network structure: The Transformer encoder is preferably 2 to 4 layers, each layer containing 4 to 8 attention heads, feedforward network layers, residual connections and LayerNorm normalization. The hidden dimension of the feedforward network is preferably 2 to 4 times the input dimension.
[0134] Attention calculation: The self-attention layer calculates weights based on the correlation between different time steps, enabling the model to simultaneously capture recent teaching performance, long-term scientific research accumulation, and phased development changes;
[0135] Output method: The encoder outputs the context representation of each time step. Teacher-level temporal representations are obtained through weighted pooling, last time step representation, or attention pooling, which can then be used by the time decay module and the contrastive learning module.
[0136] The time decay module is used to combine ordinary time decay with the business logic of university teacher evaluation, avoiding simple weighting based solely on "high recent weight":
[0137] Time difference calculation: for the current evaluation time t and the time of occurrence of historical behavior Calculate the time difference The time unit can be a month, semester, or academic year;
[0138] Differentiated decay rate: Set a learnable decay rate based on behavior type. Among them, short-cycle behaviors such as teaching feedback and classroom interaction adopt a larger proportion. This gives higher weight to recent performance; long-term achievements such as papers, projects, and awards are given less weight. This ensures that its long-term contributions are not rapidly diminished; social services, student mentoring, and other activities are subject to a moderate decay rate.
[0139] Quality weight fusion: Introducing quality weights to each historical behavior. Factors such as course difficulty, class size, paper level, project role, and student guidance outcomes can enable high-quality historical activities to make a greater contribution within the same time interval.
[0140] Career stage adjustment: Introduce stage coefficients based on teacher's professional title, years of teaching experience, or development stage. This ensures that both the recent growth signals of young teachers and the long-term achievements of senior teachers can be reasonably reflected.
[0141] Normalized fusion: The weight of historical time step i to the current representation is:
[0142]
[0143] in For encoder attention score, For behavior type; ultimately, time perception is represented as ;
[0144] Business impact: This module can distinguish between the immediacy of teaching evaluation, the continuity of scientific research results, and the phased nature of social services, so that teacher evaluation results can reflect the current state while retaining the ability to identify long-term contributions.
[0145] Its time-series contrast loss function is as follows:
[0146] The time-series contrastive loss function incorporates sample construction strategies specific to teacher data, avoiding the direct application of random positive and negative samples in general contrastive learning. Cosine similarity can be used as a similarity metric.
[0147]
[0148] And through temperature parameters Control the smoothness of the distribution.
[0149] Smoothness of cosine similarity distribution From temperature parameters control.
[0150]
[0151] in, For the candidate sample set; The smaller the value, the more concentrated the similarity distribution. The larger the value, the smoother the similarity distribution.
[0152] The sample / loss hierarchy, its corresponding construction method, and its function are as follows:
[0153] Positive samples across stages for the same teacher: construct positive sample pairs for the representations of the same teacher in adjacent semesters, adjacent academic years, or before and after promotion, so that the model can learn the continuous development trajectory of the teacher's ability; the time interval k can be set to 1 to 3 time slices according to the evaluation cycle.
[0154] Enhanced positive samples from the same teacher: Sequences from the same teacher within the same time window are subjected to temporal masking, slight feature perturbation, or time window pruning to obtain enhanced views. and As positive samples are brought closer together, this ensures that the enhanced view of the same teacher is clearly included in the positive sample set.
[0155] Stratified difficult negative samples: Prioritize selecting negative samples from teachers of the same subject, title, college, or similar teaching experience to form more comparable difficult negative samples, avoiding the possibility of insufficient discrimination caused by overly easy random negative samples.
[0156] Collaboration relationship exclusion samples: If two teachers have a strong collaborative relationship in the same paper, the same project, or the same course team, they will not be directly used as negative samples to prevent the model from mistakenly distancing itself from the real relevant teachers.
[0157] Hierarchical sampling by behavior type: Positive and negative samples are sampled separately in behavior types such as teaching, scientific research, and social service, and the loss is synthesized according to the weight of behavior type, so that the model learns the differentiated representation of different evaluation dimensions.
[0158] The overall loss function is a weighted combination of various contrastive losses and evaluation task losses:
[0159]
[0160] in, This indicates the positive sample loss across different stages for teachers;
[0161] This indicates that the positive sample loss is enhanced by the teacher's input.
[0162] This indicates the negative sample loss due to stratification difficulties.
[0163] Indicating a cooperative relationship excludes sample loss;
[0164] Indicates the loss of multi-task evaluation and supervision;
[0165] w1 to w5 are learnable or preset weights.
[0166] Through this loss design, the continuous development trajectories of the same teacher are brought closer together, and different teachers with comparable characteristics are reasonably distinguished. Teacher samples with cooperative or strong correlation relationships are not mistakenly and simply pulled apart.
[0167] To enhance the effectiveness of contrastive learning, this invention also designs a specific data augmentation strategy:
[0168] Temporal masking enhancement: Randomly mask the input sequence for several time steps, forcing the model to learn the complete temporal representation;
[0169] Feature perturbation enhancement: Add small random noise to the input features to generate positive samples for contrastive learning;
[0170] Enhanced time sampling: Randomly sample time windows of different lengths from teacher history to increase the diversity of training samples.
[0171] Example 2
[0172] When the method described in this invention is applied to process data from factory equipment, it includes the following steps:
[0173] Step S1: Standardize the data according to equipment identification, operating condition type, data acquisition time, and sensor quality indicators to obtain dataset B;
[0174] Step S2: Divide dataset B into time steps based on several time periods, and arrange them in order into a time step sequence;
[0175] Step S3: Normalize the sensor data in the time step, embed and encode the working condition category features, and generate a missing mask and working condition type identifier to obtain a time step input vector with a unified dimension.
[0176] Step S4: Input the time step input vector into the time series data encoder and obtain the machine's context representation at each time step through the self-attention mechanism;
[0177] Step S5: By combining the data acquisition time, operating condition type and preset equipment weights through the state decay module, the context representations of different time steps are weighted and fused to generate the state-aware machine representation zt.
[0178] Step S6: Construct positive samples, difficult negative samples, and excluded samples, and train the state-aware machine representation using temporal contrastive loss;
[0179] Step S7: Input the trained state-aware machine representation into the multi-task output layer, and output the comprehensive evaluation result of device health corresponding to device identification, operating conditions, data acquisition time, and sensor quality indicators.
[0180] In step S5, the workflow of the state decay module includes:
[0181] Time difference calculation: Calculate the time difference between the current evaluation time and the historical data collection time. The time unit can be hour, shift, or day.
[0182] Differentiated attenuation rate: Set a learnable attenuation rate based on the operating condition type;
[0183] If the data is related to machine operation, short-cycle transient signals such as vibration frequency and instantaneous temperature are given a larger attenuation rate to give higher weight to recent sudden abnormal performance; long-term degradation trends such as bearing wear and material fatigue are given a smaller attenuation rate to prevent long-term hidden dangers from being quickly weakened; and lubrication maintenance and regular inspections are given a medium attenuation rate.
[0184] Quality weight fusion: Introducing quality weights to each piece of historical data;
[0185] If the data is related to machine operation, quality weights can include, for example, load rate, ambient temperature and humidity, alarm level, maintenance record completeness, and sensor confidence, so that high-quality, high-load operation history can make a greater contribution under the same time difference.
[0186] Correction phase: Introduce phase coefficients based on operating condition type and equipment life cycle;
[0187] If the data is machine operation data, it can reasonably reflect the dynamic fluctuations during the break-in period of new equipment and the cumulative damage during the decline period of old equipment.
[0188] Normalization fusion: The weight of historical time step i to the current representation is consistent with the weight calculation method in Example 1.
[0189] The samples and sample construction methods for order-contrast loss include:
[0190] Positive samples across stages for the same equipment: construct positive sample pairs from the representations of the same equipment before and after adjacent shifts or adjacent production cycles;
[0191] Enhanced positive samples from the same device: Sequences from the same device within the same time window are subjected to temporal masking, slight feature perturbation, or time window clipping to obtain enhanced views;
[0192] Stratified difficult negative samples: Prioritize equipment of the same model, operating conditions, and production line as negative samples to form more comparable difficult negative samples; avoid the possibility of too many random negative samples leading to insufficient discrimination.
[0193] Related system exclusion samples: If two machines have a strong upstream and downstream linkage relationship in the same production line or the same control system (such as a serial production line), they will not be directly used as negative samples; to prevent the model from mistakenly distancing the equipment that is actually working together.
[0194] Hierarchical sampling based on operating condition type: positive and negative samples are sampled separately in different operating condition types, and the loss is synthesized according to the weight of the operating condition type; so that the model learns the differentiated representation of different operating dimensions.
[0195] There is also an overall loss function, which is expressed as the sum of the products of the positive sample loss across stages of the same device, the enhanced positive sample loss of the same device, the stratified difficult negative sample loss, and the multi-task evaluation and supervision loss with their respective preset weights.
[0196] Its expression is consistent with the corresponding expression in Example 1.
[0197] The workflow of a time-series data encoder includes:
[0198] Input features: The sequence of machine's operational features over T time steps each Includes numerical features and categorical features;
[0199] Preprocessing: Numerical features are scaled by quantiles or normalized by Z-score, and categorical features are encoded by embedding. The preprocessed numerical feature vector and categorical feature vector are used as feature encodings.
[0200] Information encoding: Mark the working condition category of each time step as the working condition type encoding;
[0201] Record the absolute position of each time step on the time axis as the absolute position code;
[0202] Record the time interval between adjacent time steps as the adjacent time slice interval encoding;
[0203] Generate a missing mask m_i for the missing data and concatenate it with the input vector; this enables the model to distinguish between "no data due to shutdown" and "missing data due to sensor failure";
[0204] Encoding feature fusion: The feature encoding, working condition type encoding, absolute time position encoding and adjacent time slice interval encoding are added or concatenated, and then linearly mapped to obtain a d-dimensional input representation, which is used as the input of the Transformer encoder;
[0205] d is preferably 128-dimensional or 256-dimensional;
[0206] The Transformer encoder is preferably 2 to 4 layers, each layer containing 4 to 8 attention heads, feedforward network layers, residual connections and LayerNorm normalization, and the hidden dimension of the feedforward network is preferably 2 to 4 times the input dimension;
[0207] Transformer encoder attention calculation: The self-attention layer calculates weights based on the correlation between different time steps, enabling the model to simultaneously capture recent transient anomalies, long-term performance degradation, and phased changes in operating conditions;
[0208] Output: The encoder outputs the context representation of each time step. Machine-level temporal representations are obtained through weighted pooling, last time step representation, or attention pooling.
[0209] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A data time-series representation method based on contrastive learning, characterized in that, include: Step S1: Standardize the dataset according to data identifier, data type, data occurrence time, and data quality indicators to obtain dataset A; Step S2: Divide dataset A into time steps based on several time periods, and arrange them in order into a time step sequence. ; Step S3: Normalize the data features in the time step, embed and encode the category features, and generate a missing mask and behavior type identifier to obtain a time step input vector with a unified dimension. Step S4: Input the time step input vector into the time series data encoder, and obtain the contextual representation of the data at each time step through the self-attention mechanism. ; Step S5: The time decay module combines the data occurrence time, data type, and preset data weights to perform weighted fusion of the context representations at different time steps, generating a time-aware data representation. ; Step S6: Construct positive samples, hard negative samples, and excluded samples, and train time-aware data representation using time-series contrastive loss; Step S7: Input the trained time-aware data representation into the multi-task output layer, and output the comprehensive evaluation result corresponding to the data identifier, data type, data occurrence time and data quality index.
2. The data time-series representation method based on contrastive learning according to claim 1, characterized in that, In step S5, the workflow of the time decay module includes: Time difference calculation: for the current evaluation time t and the historical data occurrence time Calculate the time difference Differentiated decay rate: Set the learnable decay rate based on the data type. Quality weight fusion: Introducing quality weights to each historical data item. Correction Phase: Introducing a phase system based on data type and data occurrence time. Normalized fusion: The weight of historical time step i on the current representation is: ; in The encoder attention score; For behavior type; The final time-aware data is represented as .
3. The data time-series representation method based on contrastive learning according to claim 1, characterized in that, In step S6, the samples for time-series contrast loss and the sample construction method include: Positive samples across stages from the same data source: construct positive sample pairs for the representations of the same data source before and after adjacent time periods; Enhanced positive samples from the same data source: Sequences from the same data source within the same time window are subjected to temporal masking, slight feature perturbations, or time window clipping to obtain an enhanced view. and ; Stratified difficult negative samples: Data sources of the same type and time period are used as negative samples to form more comparable difficult negative samples; Samples excluded based on cooperative relationship: If two data sources have a strong cooperative relationship in the same physical space or system, they will not be directly used as negative samples; Hierarchical sampling based on behavior type: positive and negative samples are sampled separately in different data types, and the loss is synthesized according to the data type weights.
4. The data time-series representation method based on contrastive learning according to claim 3, characterized in that, There is also an overall loss function, which is expressed as the sum of the products of the cross-stage positive sample loss from the same data source, the enhanced positive sample loss from the same data source, the stratified difficult negative sample loss, the sample loss excluded by cooperation relationship, and the multi-task evaluation supervision loss with their respective preset weights.
5. The data time-series representation method based on contrastive learning according to claim 3, characterized in that, The temporal contrastive loss training described above uses cosine similarity to quantify the similarity of temporal representation vectors in the data. The cosine similarity is: 。 6. The data time-series representation method based on contrastive learning according to claim 5, characterized in that, The smoothness of the distribution of the cosine similarity From temperature parameters control: ; in, For the candidate sample set; The smaller the value, the more concentrated the similarity distribution. The larger the value, the smoother the similarity distribution.
7. The data time-series representation method based on contrastive learning according to claim 1, characterized in that, In step S4, the workflow of the time-series data encoder includes: Input features: A sequence of behavioral features of the data over T time steps. Each Includes numerical features and categorical features; Preprocessing: Numerical features are scaled by quantiles or normalized by Z-score, and categorical features are encoded by embedding. The preprocessed numerical feature vector and categorical feature vector are used as feature encodings. Information encoding: Mark the behavior category at each time step as the behavior type encoding; Record the absolute position of each time step on the time axis as the absolute position code; Record the time interval between adjacent time steps as the adjacent time slice interval encoding; Encoding feature fusion: The feature encoding, behavior type encoding, absolute time position encoding and adjacent time slice interval encoding are added or concatenated, and then linearly mapped to obtain a d-dimensional input representation, which is used as the input of the Transformer encoder; Transformer encoder attention calculation: The self-attention layer calculates weights based on the correlation between different time steps, enabling the model to simultaneously capture recent data performance, long-term data accumulation, and phased data development and changes; Output: The encoder outputs the context representation of each time step. Data-level temporal representations are obtained through weighted pooling, last time step representation, or attention pooling.
8. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data timing representation method as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the data timing representation method as described in any one of claims 1-7.
