Early overflow intelligent identification method and system based on knowledge guidance and residual enhancement
By introducing knowledge bias terms from drilling expert rules into the self-attention mechanism and constructing a prototype of normal operating conditions, the problems of poor threshold adaptability and feature overlap in early overflow identification are solved, achieving higher identification accuracy and earlier warning effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNIV OF PETROLEUM (EAST CHINA)
- Filing Date
- 2026-06-04
- Publication Date
- 2026-08-04
AI Technical Summary
Existing early overflow identification technologies suffer from poor threshold adaptability, insufficient capture of weak early-stage anomaly features, and severe overlap between normal operating conditions and early overflow sample features, resulting in low identification accuracy and insufficient early warning timeliness.
An intelligent recognition method based on knowledge guidance and residual enhancement is adopted. By introducing knowledge bias terms from drilling expert rules into the self-attention mechanism, the method focuses on the local trends and inflection point information of the monitoring parameters, constructs a normal operating condition feature prototype, and uses a residual enhancement module to reduce feature overlap interference and improve recognition accuracy.
It improves the accuracy and timeliness of early overflow identification, enabling earlier identification and warning of overflow events, reducing false alarm rates, and enhancing sensitivity to subtle anomalies.
Smart Images

Figure CN122333112B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of oil drilling risk monitoring, well control safety early warning and artificial intelligence recognition technology, and in particular to an early overflow intelligent recognition method and system based on knowledge guidance and residual enhancement. Background Technology
[0002] During drilling, when the formation pressure exceeds the bottom hole pressure, formation fluids may invade the wellbore and push drilling fluid outwards; this phenomenon is called a blowout. If a blowout is not identified and controlled in its early stages, it can quickly escalate into a blowout, causing significant economic losses, environmental pollution, and even casualties.
[0003] Existing early overflow identification technologies are mainly divided into two categories: the first category is the identification method based on expert rules, which usually triggers an alarm by checking whether monitoring parameters such as outlet flow, pool volume, vertical pressure, and drilling pressure exceed preset thresholds; the second category is the intelligent identification method based on data-driven methods, which uses artificial neural networks, long short-term memory networks, autoencoders, convolutional neural networks and their combined models to learn the nonlinear relationship between monitoring parameters and overflow.
[0004] Among these methods, expert rule-based methods have the advantage of strong interpretability, but the baselines and fluctuation ranges of monitoring parameters vary significantly across different blocks, well types, and operating conditions, making it difficult to apply fixed thresholds universally and resulting in a trade-off between false alarm and false negative rates. Data-driven methods can automatically learn complex relationships, but their identification results are highly dependent on the quality of the training data, and the models themselves lack an explicit understanding of drilling mechanisms and anomaly evolution patterns, making them prone to performance degradation under conditions of data scarcity, noise interference, and distribution shifts.
[0005] There are two inherent challenges in early overflow identification: First, the abnormal changes in monitoring parameters at the initial stage of overflow are extremely weak and very similar to normal drilling fluctuations, making it difficult for traditional models to capture them; Second, early overflow samples often span the time of overflow occurrence, and the same data window contains both normal operating data and early overflow data, resulting in feature overlap and further interfering with classification. Summary of the Invention
[0006] To address the problems of poor threshold adaptability, insufficient capture of weak early-stage anomaly features, and severe overlap between normal operating conditions and early-stage overflow sample features in existing early overflow identification methods, this invention provides an intelligent early overflow identification method based on knowledge guidance and residual enhancement. An intelligent early overflow identification model based on knowledge guidance and residual enhancement is constructed. This model can focus on weak but mechanistic abnormal periods and reduce the overlap interference between normal operating conditions and early overflow, thereby improving identification accuracy and early warning timeliness.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: On the one hand, an early overflow intelligent identification method based on knowledge guidance and residual enhancement is provided, including: Raw drilling monitoring data is acquired and preprocessed to obtain preprocessed data. The preprocessed data is augmented using a knowledge-guided self-attention module to obtain an augmented feature matrix; The enhanced feature matrix is processed using the prototype learning residual enhancement module to obtain the residual feature matrix; by constructing one or more normal working condition feature prototypes, the most similar feature prototype is matched based on the feature similarity between the enhanced feature matrix and each prototype, and the residual feature matrix is obtained based on the feature difference between the enhanced feature matrix and the most similar feature prototype. The residual feature matrix is input into the classification layer to obtain the predicted probability of early overflow.
[0008] Preferably, the step of using a knowledge-guided self-attention module to enhance the preprocessed data to obtain an enhanced feature matrix specifically includes: calculating the local slope of each monitoring parameter in the preprocessed data to obtain a local slope matrix; constructing a trend consistency index, a pool volume correction factor, and an inflection point index based on the local slope matrix; multiplying the trend consistency index by the correction factor and adding the inflection point index to obtain a knowledge bias term; superimposing the knowledge bias term into the standard self-attention score to obtain a knowledge-guided attention score; and weighting the knowledge-guided attention score to obtain the enhanced feature matrix.
[0009] Preferably, based on drilling expert rules, the structural trend consistency index is constructed using the local slope increase of outlet flow, the local slope increase of drilling speed, the local slope decrease of standpipe pressure, and the local slope decrease of drilling pressure.
[0010] Preferably, the process of constructing the pool volume correction factor is as follows: taking a local time window centered at time s, the slope of the change of the pool volume parameter at that time is obtained by fitting and solving the least squares method to obtain the local slope; based on the non-negative part of the local slope of the pool volume, the pool volume correction factor is constructed by inverse proportional decay mapping; the inverse proportional decay mapping maps the non-negative part of the local slope of the pool volume into a weighting factor in the form of the reciprocal.
[0011] Preferably, the inflection point index is constructed as follows: the inflection point index is constructed based on the increase of the difference in outlet flow rate, the increase of the difference in drilling speed, the decrease of the difference in stand pressure, and the decrease of the difference in drilling pressure.
[0012] Preferably, the step of matching the most similar feature prototype based on the feature similarity between the enhanced feature matrix and each prototype, and obtaining the residual feature matrix based on the feature difference between the enhanced feature matrix and the most similar feature prototype, specifically involves: constructing one or more normal operating condition feature prototypes, calculating the distance between the enhanced feature matrix and each prototype, assigning the enhanced feature matrix to the prototype with the smallest distance, calculating the difference between the enhanced feature matrix and the prototype with the smallest distance, and obtaining the residual feature matrix.
[0013] Preferably, the construction of one or more normal working condition feature prototypes is as follows: if only a single normal working condition is considered, the mean of the enhanced feature matrix of all normal samples is used as the normal prototype; if different normal sub-working conditions such as drilling, pump start-up, and pump stop-up are considered, multiple normal prototypes are constructed respectively.
[0014] On the other hand, an early overflow intelligent identification system based on knowledge guidance and residual enhancement is provided, including: a preprocessing module, which acquires raw drilling monitoring data and performs preprocessing to obtain preprocessed data; The knowledge-guided self-attention module is used to enhance the preprocessed data, resulting in an enhanced feature matrix. The residual enhancement module of prototype learning processes the enhanced feature matrix to obtain the residual feature matrix. By constructing one or more normal working condition feature prototypes, the most similar feature prototype is matched based on the feature similarity between the enhanced feature matrix and each prototype. The residual feature matrix is obtained based on the feature difference between the enhanced feature matrix and the most similar feature prototype. The prediction module inputs the residual feature matrix into the classification layer to obtain the predicted probability of early overflow.
[0015] Furthermore, an electronic device is also provided, including: Memory, used for non-transitory storage of computer-readable instructions; and Processor, for executing the computer-readable instructions, When the computer-readable instructions are executed by the processor, they perform the method described in the first aspect above.
[0016] In another aspect, a storage medium is also provided for non-transitory storage of computer-readable instructions, wherein when the non-transitory computer-readable instructions are executed by a computer, the method described in the first aspect is performed.
[0017] The above technical solution has the following advantages or beneficial effects: This invention introduces a knowledge bias term into the standard self-attention score through a knowledge-guided self-attention module; it also corrects the attention allocation based on local window slope, trend consistency, pool volume correction factor, and inflection point index, so that the model prioritizes time periods that conform to the early overflow anomaly evolution pattern, thereby enhancing weak anomaly features.
[0018] This invention constructs one or more normal operating condition feature prototypes through a prototype residual enhancement module. The residual feature matrix is obtained by subtracting the sample to be identified from the most similar prototype, so as to weaken the interference of overlapping features in normal operating conditions and amplify the difference between early overflow and normal operating conditions. Attached Figure Description
[0019] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0020] Figure 1 This is an overall flowchart of the early overflow intelligent identification method based on knowledge guidance and residual enhancement in Example 1; Figure 2 The flowchart shows the knowledge-guided self-attention module in Implementation Example 1. Figure 3 Here is a flowchart of the residual enhancement and classification module based on prototype learning in Example 1; Figure 4 This is a comparison chart of the recognition results of test case 1 of the knowledge-guided and residual-enhanced early overflow intelligent recognition method in Example 1 and the baseline method. Figure 5 This is a comparison chart of the recognition results of test case 2 of the knowledge-guided and residual-enhanced early overflow intelligent recognition method in Example 1 and the baseline method. Detailed Implementation
[0021] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0022] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments of the invention. The terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0023] In this embodiment of the invention, "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of this invention, "multiple" refers to two or more.
[0024] Furthermore, to facilitate a clear description of the technical solutions of the embodiments of the present invention, the terms "first" and "second" are used in the embodiments of the present invention to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.
[0025] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0026] Example 1 To address the problems of poor threshold adaptability, insufficient capture of weak early-stage anomaly features, and severe overlap between normal operating conditions and early-stage overflow sample features in existing early-stage overflow identification methods, this invention provides an intelligent early-stage overflow identification method and system based on knowledge guidance and residual enhancement. By directly embedding prior knowledge from drilling experts regarding how early-stage overflow parameters change into the decision-making process of the intelligent early-stage overflow identification model based on knowledge guidance and residual enhancement, the model focuses on weak but mechanistically consistent anomaly periods. Through feature enhancement and difference amplification mechanisms, the overlap interference between normal operating conditions and early-stage overflow is reduced, thereby improving identification accuracy and early warning timeliness.
[0027] The method proposed in this invention introduces a knowledge bias term during the self-attention score calculation process, guiding the model to prioritize time segments that conform to the early overflow mechanism. This knowledge bias term is constructed based on the local trends of monitoring parameters, the cooperative change patterns between parameters, and inflection point information. Specifically, the local trends of monitoring parameters and the cooperative change patterns between parameters are used together to construct a trend consistency index to determine whether the change direction of key parameters such as outlet flow rate, drilling speed, standpipe pressure, and drilling pressure matches the early overflow mechanism; the local change trend of pool volume parameters is used to construct a pool volume correction factor; and the slope difference before and after the parameter changes from stable fluctuation to abnormal change is used to construct an inflection point index. Simultaneously, a normal operating condition feature prototype is constructed through prototype learning, and the residual between the sample and the prototype is used for classification, thereby amplifying the difference between early overflow and normal operating conditions, improving identification accuracy, and providing early warning.
[0028] Figure 1 This paper presents the overall framework of the early overflow intelligent recognition model based on knowledge guidance and residual enhancement constructed in this invention, which includes a knowledge-guided feature enhancement module and a prototype learning residual enhancement module. Figure 2A flowchart illustrating the workflow of the knowledge-guided self-attention module is presented. Figure 3 The flowchart of the residual enhancement and classification module based on prototype learning is shown. Figure 4 and Figure 5 The diagrams show a comparison of the recognition results of the method of this invention and the baseline method in test cases 1 and 2, respectively.
[0029] In one or more of the technical solutions disclosed in the embodiments, such as Figures 1 to 3 As shown, the early overflow intelligent identification method based on knowledge guidance and residual enhancement includes: S1: Acquire raw drilling monitoring data and preprocess it to obtain preprocessed data.
[0030] A set of monitoring parameters for identifying early overflows is determined, and the raw drilling monitoring data in the set of monitoring parameters is preprocessed; the preprocessing includes normalization and sliding window sample generation.
[0031] The monitoring parameter set includes: outflow rate (FOR), standpipe pressure (SPP), wobble weight (WOB), rate of penetration (ROP), and pool volume (SUM). These raw drilling monitoring data in the monitoring parameter set were all acquired using integrated logging tools in the oilfield. These parameters are considered because they include both pressure and flow rate parameters that respond rapidly to overflows, as well as pool volume parameters that indicate the degree of anomaly development, collectively characterizing the early overflow trend.
[0032] This embodiment uses overflow case data from 20 wells in an oilfield as a basis to screen and construct samples of drilling monitoring parameters. Based on historical research and field experience in the oilfield, outlet flow rate, standpipe pressure, drilling pressure, drilling speed, and pool volume were selected as model inputs. Among these, outlet flow rate and standpipe pressure respond relatively quickly to overflow occurrences, drilling pressure and drilling speed characterize load and mechanical changes during drilling, and pool volume provides supplementary indication of the degree of anomaly development.
[0033] The raw drilling monitoring data in the above monitoring parameter set are subjected to Min-Max normalization. The normalization formula is as follows: (1) in, This is raw drilling monitoring data. This refers to the normalized raw drilling monitoring data. In subsequent reports, the raw drilling monitoring data is also referred to as the raw data point, and the normalized raw drilling monitoring data is also referred to as the normalized data point.
[0034] Then, a sliding window is used to process the normalized data points. Sampling is performed to generate samples, with each window containing T consecutive time steps to cover the entire process from normal drilling to early overflow evolution and then to the gradual enhancement of the anomaly.
[0035] This invention performs Min-Max normalization on the raw drilling monitoring data and then generates samples using a sliding window method. Preferably, the window length T is 100, corresponding to a time span of approximately 800 seconds, to cover the entire process from normal drilling to the appearance of anomalies and their gradual intensification. This generates a total of 10,540 samples, which are then divided into training, validation, and test sets.
[0036] S2: Use the knowledge-guided self-attention module to enhance the preprocessed data and obtain the enhanced feature matrix.
[0037] The method of using a knowledge-guided self-attention module to enhance the preprocessed data and obtain an enhanced feature matrix includes: calculating the local slope of each monitoring parameter in the preprocessed data to obtain a local slope matrix; constructing a trend consistency index, a pool volume correction factor, and an inflection point index based on the local slope matrix; multiplying the trend consistency index by the correction factor and adding the inflection point index to obtain a knowledge bias term; superimposing the knowledge bias term into the standard self-attention score to obtain a knowledge-guided attention score; and weighting the knowledge-guided attention score to obtain the enhanced feature matrix.
[0038] In this first embodiment (see...) Figure 2 First, the input sample sequence X is linearly mapped and positionally encoded to obtain the feature matrix Z. Then, a local window is constructed around each time point of interest, s. The local slopes of outlet flow rate, stand pressure, drilling pressure, drilling speed and pool volume were calculated respectively, and a trend consistency index was constructed based on the early overflow change pattern summarized by drilling experts.
[0039] Input data sequence X, perform linear mapping and positional encoding on input data sequence X to obtain feature matrix Z; feature matrix Z is then processed by a self-attention mechanism to obtain standard self-attention score (i.e., ... Figure 1 , 2 (Based on the self-attention score matrix); simultaneously, a local window is constructed around each attention time s. The local slope of each monitoring parameter is calculated to obtain the local slope matrix G. Based on the local slope matrix G, a trend consistency index, a pool volume correction factor, and an inflection point index are constructed and fused to obtain the knowledge bias term. This refers to the knowledge-guided attention score matrix. The standard self-attention score and the knowledge-guided attention score matrix are weighted and summed to obtain a new attention score matrix. This new matrix is then used to weight the feature matrix Z, which has undergone linear mapping and positional encoding, to obtain the attention-weighted feature matrix, i.e., the enhanced feature matrix. Specifically: Standard self-attention mechanism for input data sequences Features are obtained by performing linear mapping The formula is: (2) To preserve temporal location information, a location code E is introduced, resulting in: (3) The position coding preferably adopts a sine or cosine form.
[0040] Next, the feature matrix at time t is... Projection as query vector Key vector Sum value vector : (4) Without the introduction of knowledge guidance, the standard self-attention score is: (5) Where t represents the current time and s represents the time being observed. The dimension of the key vector.
[0041] The core improvement of this invention lies in the fact that it no longer relies solely on data for automatic learning of attention allocation, but instead embeds drilling experts' prior knowledge of early overflow variation patterns into the attention score calculation process. The early overflow variation patterns are as follows: when the outlet flow rate and drilling speed show an upward trend, while the standpipe pressure and drilling pressure show a downward trend, the current position is considered consistent with early overflow characteristics; when the pool volume has not yet shown a significant increase, the current position is considered closer to the initial stage of overflow; when the parameters around the current position show a sudden change in slope from stable fluctuations to abnormal changes, this position is considered to correspond to a possible inflection point of overflow.
[0042] The above judgment results are constructed into knowledge bias terms. This score is then superimposed on the standard self-attention score to obtain a knowledge-guided attention score, enabling the allocation of more attention to time periods that conform to the early overflow mechanism. The attention-weighted feature matrix can better highlight early weak anomalies, thereby improving subsequent classification and recognition capabilities.
[0043] The knowledge-guided process involves constructing a local window around each time point s to be considered. Calculate the local slope using the least squares method : (6) (7) Where s is the time point for calculating the trend, which is the time point that is being monitored; and x is the time point used to represent the local window. τ is the trend value at time s; τ is the index of the data point within the local window; x(τ) is the original monitoring parameter value corresponding to time τ.
[0044] Based on drilling expert rules, early-stage blowouts typically manifest as increased outlet flow, increased drilling speed, decreased standpipe pressure, and decreased drilling pressure. This forms the basis for constructing trend consistency indicators. : (8) in, , , , The local slopes of the outlet flow rate, drilling speed, stand pressure, and drilling pressure were all calculated using the least squares method.
[0045] This invention is based on expert rules in the drilling field and utilizes structural trend consistency indicators such as local slope increase of outlet flow, local slope increase of drilling speed, local slope decrease of standpipe pressure, and local slope decrease of drilling pressure.
[0046] This is because in the early overflow identification task, the abnormal change trend of the monitoring parameters in the early stage of overflow is very weak, and traditional data-driven models often have difficulty capturing these subtle signals. Therefore, by introducing the trend consistency index, the model can give higher attention weight to the monitoring parameter data sequence that conforms to the characteristics of early overflow, thereby significantly enhancing the sensitivity to key abnormal changes.
[0047] Considering the relatively delayed response of the pool volume to overflow, this invention further utilizes the local slope of the pool volume. Construction of the repair pool volume correction factor This allows the moment closer to the initial stage of the overflow to receive a higher weight.
[0048] The process of constructing the pool volume correction factor is as follows: using a local time window centered at time s, the slope of the change of the pool volume parameter at that time is obtained by fitting the solution using the least squares method, i.e., the local slope of the pool volume; based on the non-negative part of the local slope of the pool volume, the pool volume correction factor is constructed by inverse proportional decay mapping.
[0049] Considering the inherent characteristic of the pool volume parameters in drilling engineering exhibiting a delayed response to overflow events, the upward trend of pool volume parameters is weak in the early stages of an overflow, but gradually strengthens significantly as the overflow progresses. To effectively differentiate between the early and mid-to-late stages of an overflow based on the degree of change in pool volume parameters and to dynamically adjust the strength of the trend consistency index, this invention constructs a pool volume correction factor. Using a local time window centered on time s, the slope of the pool volume parameter change at that time is obtained by least squares fitting, i.e., the local slope of the pool volume. Based on the non-negative part of the local slope, the pool volume correction factor is constructed through an inverse proportional decay mapping. The inverse proportional decay mapping maps the non-negative part of the local slope of the pool volume into a weighting factor using its reciprocal form.
[0050] This allows the upward trend of the pool volume parameters to be as weak as possible, and to be closer to the early stage of overflow. The closer the value is to 1, the more it can maximize the preservation and enhancement of the guiding role of the trend consistency indicator; however, when the upward trend of the pool volume parameter becomes more significant and it enters the middle and late stages of overflow development, The values gradually decrease, automatically weakening the attention-guided weights at corresponding moments. This allows for adaptive focusing and feature enhancement during the critical early stages of overflow, based on the hysteresis response of the pool volume parameters. The aim of this design is to enhance the model's attention to subtle anomaly trends.
[0051] Pool volume correction factor The construction process is as follows: (9) (10) In the knowledge-guided self-attention mechanism, b(s) is an additional attention weight used to enhance the model's focus on early overflow features, and its core relies on the local variation trend of the pool volume parameter and the trend consistency index. First, This represents the slope of the trend of the pool volume parameter at time s within a local time window, that is, the degree to which the pool volume increases or remains stable over time. Since the pool volume response is relatively lagging in the initial stage of overflow, its local trend can be used to determine whether the current moment is close to the start of overflow: when the pool volume has not yet increased significantly... Approaching 0 A value close to 1 indicates that the overflow is more likely in its early stages, and strong guidance should be maintained; when the pool volume shows a clear upward trend... Increase A decrease indicates that the overflow may have entered the middle or late stage of development, and the emphasis on early characteristics should be reduced. Based on The constructed enhancement factor is used to adjust attention allocation. When the local trend of pool volume is not obvious, that is... When approaching zero, A larger value significantly enhances attention during that time period, causing the model to focus more on potential early anomalous signals; conversely, when the pool volume has already increased significantly, A smaller value reduces the amplification effect on attention. In this way, the hysteresis characteristics of the pool volume are transformed into guiding information that the model focuses on, enabling the model to more accurately capture the key features of early overflow.
[0052] final, Indicators of Consistency with Trends This is combined to form b(s), which is the additional attention weight.
[0053] The trend consistency index is used to determine whether key parameters such as outlet flow rate, standpipe pressure, drill pressure, and drill speed simultaneously show abnormal trends consistent with early overflows. Only when the trends of these key parameters match the characteristics of early overflows... This effectively enhances the attention weights, ensuring that the model's focus on early anomalies is appropriately amplified throughout the data sequence. This design not only fully utilizes the hysteresis response characteristics of the pool volume but also incorporates multi-parameter trend information, achieving precise enhancement of early overflow characteristics and improving recognition accuracy and early warning capabilities.
[0054] To further identify the inflection point where monitoring parameters shift from stable fluctuations to abnormal changes, this invention constructs an inflection point index based on the increase in the difference in outlet flow rate, the increase in the difference in drilling speed, the decrease in the difference in standpipe pressure, and the decrease in the difference in drilling pressure. Specifically, the local window is divided into a first half and a second half, and the slope of the monitoring parameters in the first half is calculated using the least squares method. and the slope of the monitoring parameters in the second half window And calculate the difference between the slope of the second half window and the slope of the first half window: (11) Then construct inflection point indicators : (12) in, , , , These are the differences between the slope of the second half of the window and the slope of the first half of the window for the outlet flow rate, vertical pressure, drilling pressure, and drilling speed, respectively.
[0055] Finally, the trend consistency index is multiplied by the pool volume correction factor, and the inflection point index is added to obtain the knowledge bias term. The formula is: (13) in, This is the inflection point enhancement coefficient, which controls the intensity of extra attention the model allocates when it detects a critical point in time when a monitored parameter changes from a stable state to an abnormal trend. In the trend consistency enhancement mechanism, when an early overflow occurs, the monitored parameter often experiences a transition from stable fluctuations to obvious abnormal changes. This transition point usually reflects the timing of the overflow more directly than the overall trend of the parameter. The introduction of this feature enables the model to more sensitively capture early abnormal signals at these turning points, thereby improving early identification capabilities.
[0056] The knowledge bias term constructed in this invention comprehensively considers two factors: first, whether the trend of key parameters within the current time window is consistent with early overflow characteristics; and second, whether the monitored parameters are at an inflection point from stability to anomaly at the current moment. Combining these two parts to form r(s) provides a gradual attention gradient in the self-attention mechanism, allowing the model to gradually increase its attention to relevant time points as abnormal evidence accumulates. This design achieves the following: first, it enables the model to simultaneously focus on trend consistency and anomaly inflection points, comprehensively capturing early abnormal features; second, through the joint enhancement of trends and inflection points, the model can effectively distinguish between early overflow and normal fluctuations in monitored parameters, reducing false alarms; and finally, this gradient-based attention allocation method guides the model to learn key features more efficiently during training, improving recognition accuracy and early warning time.
[0057] The enhanced feature matrix generation process is as follows: The knowledge bias term is superimposed with the standard attention score to obtain the knowledge-guided attention score. This knowledge-guided attention score is then normalized to generate global attention. Finally, the global attention sequence is element-wise weighted with the linearly transformed feature sequence to obtain the enhanced feature matrix. Specifically: Standard self-attention scores were obtained respectively. and knowledge bias Then, the bias term is superimposed on the standard self-attention score to obtain the knowledge-guided attention score, as shown in the formula: (14) Wherein, λ is the knowledge guidance intensity coefficient.
[0058] Softmax normalization is applied to the attention score after knowledge guidance to obtain local attention. With global attention : (15) (16) Then the global attention sequence The enhanced feature matrix is obtained by element-wise weighting the linearly transformed feature sequence Z. : (17) Where Z is the original data sequence after linear mapping and positional encoding, and Z is weighted element-wise by the attention score matrix A to obtain... .
[0059] In the early overflow identification process, the enhanced feature matrix Attention weights at each time step This reflects the importance of this time point in identifying early anomalies within the entire sequence. Through weighting, the importance of key data sequences related to early overflow in the feature matrix is amplified, making it easier for the model to capture weak but crucial anomalous signals. Furthermore, by amplifying key features and suppressing non-key features, the enhanced feature matrix makes the differences between early overflow samples and normal samples more pronounced in the feature space, thereby improving the classifier's discrimination accuracy and early warning timeliness.
[0060] In other words, the enhanced feature matrix not only strengthens early anomalous signals, but also filters out interfering information through the attention mechanism, enabling subsequent classifiers to identify early overflow events more efficiently and accurately.
[0061] In this way, the model can allocate more attention to time segments that conform to the early overflow evolution pattern, thereby enhancing weak anomalous features.
[0062] The knowledge-guided process of this invention involves performing linear regression (least squares method) on the data of each monitoring parameter within a local sliding window centered at the current time point s, based on the input sequence X. For each parameter sequence, the slope of the linear fit of the data points within that window is calculated, yielding the local slope matrix G for the corresponding time point. This matrix records the local change trend of all monitoring parameters over the entire time series, used to determine whether the trend is consistent with the early overflow. After obtaining the local slope matrix G, a trend consistency index, a pool volume correction factor, and an inflection point index are constructed. The trend consistency index is multiplied by the pool volume correction factor, and the inflection point index is added to obtain the knowledge bias term. .
[0063] The trend consistency index, also known as the slope index, is used to measure whether the changing trends of various monitoring parameters in the area (within a local window) near the current point of interest are consistent with the early overflow characterization.
[0064] Inflection point indicators are indicators of change points, used to capture information about the turning point of parameters from stability to anomaly, which is equivalent to enhancing key change points.
[0065] The pool volume correction factor is a rate of change indicator used to adjust attention allocation. It takes advantage of the lag in pool volume response to give higher attention to moments closer to the time of the event.
[0066] The inflection point indicator, pool volume correction factor, and trend consistency indicator are combined to form the final knowledge bias term.
[0067] Knowledge bias, i.e., the attention score matrix after knowledge guidance. This method integrates trend consistency indicators (slope and direction consistency), pool volume correction factors, and inflection point indicators to provide knowledge bias for the self-attention mechanism. By using knowledge bias terms... The scores are added to the standard self-attention score to form the final knowledge-guided attention score matrix, which guides the model to focus on key time periods.
[0068] This invention introduces a knowledge bias term into the standard attention score, enabling the model to directly utilize the mechanistic changes of monitoring parameters during recognition, focusing on learning the characteristics of weak early overflow but consistent trends.
[0069] S3: The enhanced feature matrix is processed using the residual enhancement module of prototype learning to obtain the residual feature matrix; by constructing one or more normal working condition feature prototypes, the most similar feature prototype is matched based on the feature similarity between the enhanced feature matrix and each prototype, and the residual feature matrix is obtained based on the feature difference between the enhanced feature matrix and the most similar feature prototype.
[0070] The most similar prototype is matched based on the feature similarity between the enhanced feature matrix and each prototype. The residual feature matrix is obtained based on the feature difference between the enhanced feature matrix and the optimal prototype. Specifically, one or more normal working condition feature prototypes are constructed, the distance between the enhanced feature matrix and each prototype is calculated, and the enhanced feature matrix is assigned to the prototype with the smallest distance. The difference between the enhanced feature matrix and the prototype with the smallest distance is calculated to obtain the residual feature matrix.
[0071] In this step, to eliminate the feature overlap problem caused by the sample window spanning the overflow occurrence time, the present invention introduces a residual enhancement module based on prototype learning.
[0072] This embodiment constructs a normal operating condition prototype on a normal sample set (see...). Figure 3 If only a single normal working condition is considered, the mean of the enhanced feature matrix of all normal samples is used as the normal prototype; if different normal sub-working conditions such as drilling, pump start-up, and pump stop-up are considered, multiple normal prototypes are constructed respectively.
[0073] For any sample to be identified, first calculate its Frobenius distance with each normal prototype, and assign it to the nearest prototype. Then, subtract the nearest prototype features from the sample feature matrix to obtain the residual feature matrix. Since the early overflow samples have been reinforced with knowledge-guided attention, their residuals with normal prototypes are significantly larger than those of normal samples. Therefore, this residual feature can effectively amplify the feature differences between different operating conditions, which is more conducive to subsequent classification and identification.
[0074] Specifically, this module first constructs a normal operating condition feature prototype on normal samples in the training set. Let the enhanced feature matrix of the i-th normal sample be... Then the Frobenius distance between the two characteristic matrices is: (18) If only a single normal prototype P is considered, the prototype is obtained by minimizing the sum of the squared Frobenius distances from all normal samples to that prototype: (19) (20) In actual drilling, normal operating conditions can be further subdivided into multiple sub-operating conditions such as drilling, pump start-up, and pump stop-up. Therefore, this invention preferably constructs multiple normal prototypes. For any sample to be identified, first calculate its distance to each prototype, and assign it to the prototype with the smallest distance: (twenty one) Then, calculate the residual feature matrix between the sample and the prototype with the smallest distance: (twenty two) in, This represents the index of the prototype with the smallest distance when calculating the distance between a given sample and multiple normal prototypes; in other words, each sample will have its feature differences calculated with all normal prototypes, and It is an identifier that indicates which prototype the sample is closest to.
[0075] For a sample in training or testing, it may belong to a sub-state of normal drilling, such as the state under different operating conditions like pump on or pump off. The model calculates the difference between the feature matrix of the sample and the prototype of each normal sub-state, and then finds the prototype with the smallest distance. This refers to the number or index of the prototype with the smallest distance in the prototype set. This metric maps a sample to the best-matching normal state prototype, allowing for further calculation of feature residuals for early overflow identification and classification. In this way, the model can more accurately measure the deviation of a sample from the normal pattern, thereby enhancing anomaly detection capabilities.
[0076] Since the characteristics of the early overflow samples guided by knowledge have been enhanced during the critical time period, the residuals between them and the normal prototypes are significantly larger than those of the normal samples, thus making the residual features a more discriminative classification basis.
[0077] By using prototype learning and residual enhancement modules, the overlapping interference caused by normal operating condition segments in early overflow samples is reduced, and the difference between normal operating conditions and early overflow is amplified.
[0078] S4: Input the residual feature matrix into the classification layer to obtain the predicted probability of early overflow.
[0079] In this step, the residual characteristic matrix obtained in S3 is... The predicted probability of this sample belonging to the early overflow is obtained from the input classification layer: (twenty three) in, The classification layer, which can consist of one or more fully connected layers, is used to map the residual feature matrix into a classification output; the Sigmoid function is used to obtain the predicted probability that a sample belongs to the early overflow.
[0080] After obtaining the predicted probability of early overflow, the trained model is used to identify the continuous drilling data window in online monitoring or offline analysis scenarios. When the sample output exceeds the preset discrimination threshold, an early overflow alarm is issued.
[0081] Furthermore, this invention employs a joint loss function to train the entire model. This loss function consists of classification loss. Prototype constraint loss and residual separation loss The composition ensures that classification accuracy, prototype representativeness, and inter-class separability are maintained simultaneously.
[0082] Classification loss Used to ensure the accuracy of the recognition results; prototype constraint loss Used to ensure that the normal prototype is representative of the normal sample set; residual separation loss This is used to further reduce the residuals of normal samples and increase the residuals of early overflow samples.
[0083] The classification loss uses cross-entropy loss: (twenty four) Prototype constraint loss is used to constrain normal samples to be as close as possible to their respective prototypes, in order to ensure the representativeness of the prototypes. (25) The residual separation loss is used to minimize the residuals of normal samples and ensure that the residuals of early overflow samples are not less than a preset interval m. (26) (27) The total loss is obtained by weighting the three factors together: (28) in, and These are the weighting coefficients for prototype constraint loss and residual separation loss, respectively. The residual separation interval parameter is used. Through the above joint loss function, the model can not only improve classification accuracy, but also maintain the representativeness of the normal prototype and enhance the separation between normal samples and early overflow samples in the residual space.
[0084] By training the entire network end-to-end, the knowledge-guided attention module, the prototype learning residual enhancement module, and the classification layer can be co-optimized. Under a set of optimized parameters, such as the number of training epochs... 100 indicates dimension 64, key vector dimension With a value of 32, a local window radius of L of 5, an inflection point reinforcement coefficient of γ of 0.1, a knowledge guidance intensity of λ of 0.1, an interval parameter of m of 5, and loss weights μ and ν both of 0.01, the model achieved better results.
[0085] Furthermore, the detailed workflow of this invention is as follows: Step 1: Collect drilling monitoring parameter data, normalize the monitoring parameters, and construct a sample sequence using a sliding window; Step 2: Input the sample sequence into the linear mapping layer and the position encoding layer to obtain a feature representation containing temporal position information; Step 3: Calculate the query vector, key vector, and value vector based on the feature representation to obtain the standard self-attention score; Step 4: Construct a local window around each time point of interest, calculate the slope of change of each monitoring parameter within the local window, and construct a trend consistency index based on the changing trends of FOR, ROP, SPP, and WOB. Step 5: Construct a correction factor based on the local variation trend of the pool volume SUM parameter, and construct an inflection point index based on the slope difference between the preceding and following sub-windows. Step 6: Combine the trend consistency index, correction factor and inflection point index to form a knowledge bias item, and superimpose it on the standard self-attention score to obtain the knowledge-guided attention score; Step 7: Normalize the knowledge-guided attention score to obtain global attention weights, and use the global attention weights to weight the original features to obtain the enhanced feature matrix; Step 8: Construct one or more normal operating condition prototypes based on the enhanced feature matrix of normal samples in the training set; Step 9: Calculate the residual feature matrix between the enhanced feature matrix of the sample to be identified and the most recent normal operating condition prototype; Step 10: Input the residual feature matrix into the classification layer and output the predicted probability that the sample belongs to the early overflow. Step 11: Construct a joint loss function that includes classification loss, prototype constraint loss and residual separation loss, and iteratively optimize the model parameters until the preset training termination condition is met.
[0086] To illustrate the effectiveness of the method in this embodiment, simulation experiments were conducted in two difficult-to-identify test cases (see...). Figure 4 , 5 In all tests, the method of this invention outperforms the traditional SAM method. In test case 1, the method of this invention achieved an accuracy of 95.29%, a recall rate of 93.88%, and an AUC of 98.33%, issuing an alarm 50 seconds earlier than the baseline model and 74 seconds earlier than on-site manual identification.
[0087] In test case 2, the method of this invention achieved an accuracy of 94.17%, a recall of 92.11%, and an AUC of 96.69%, issuing an alarm 34 seconds earlier than the baseline model; on-site manual identification based on changes in pool volume resulted in an alarm time that lagged behind the model by approximately 6 minutes.
[0088] Ablation experiments on the model show that: adding only the residual enhancement module can improve accuracy, but there is a risk of false positives in some scenarios; adding only the knowledge guidance module can maintain high accuracy and improve recall; the performance is best when both the knowledge guidance module and the residual enhancement module are introduced, indicating that the two have significant synergistic gains.
[0089] The experimental results show that, on a dataset consisting of 20 wells and 10,540 samples, the residual-enhanced knowledge-guided self-attention model KGSAM-R proposed in this invention improves the average recognition accuracy by 5.35% and the average alarm time by 42 seconds compared to the traditional self-attention model SAM. Furthermore, it demonstrates better early warning timeliness and higher recall in both difficult-to-identify test cases.
[0090] Example 2 This embodiment provides an early overflow intelligent identification system based on knowledge guidance and residual enhancement, including: The preprocessing module acquires and preprocesses the raw drilling monitoring data to obtain the preprocessed data. The knowledge-guided self-attention module is used to enhance the preprocessed data, resulting in an enhanced feature matrix. The residual enhancement module of prototype learning processes the enhanced feature matrix to obtain the residual feature matrix; one or more normal working condition feature prototypes are constructed, and the most similar prototype is matched based on the feature similarity between the enhanced feature matrix and each prototype. The residual feature matrix is obtained based on the feature difference between the enhanced feature matrix and the optimal prototype. The prediction module inputs the residual feature matrix into the classification layer to obtain the predicted probability of early overflow.
[0091] Example 3 This embodiment also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein, the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in Embodiment 1.
[0092] Example 4 This embodiment also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the method described in Embodiment 1.
[0093] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An early overflow intelligent identification method based on knowledge guidance and residual enhancement, characterized in that, include: Raw drilling monitoring data is acquired and preprocessed to obtain preprocessed data. The preprocessed data is enhanced using a knowledge-guided self-attention module to obtain an enhanced feature matrix. Specifically, this includes: calculating the local slope of each monitoring parameter in the preprocessed data to obtain a local slope matrix; constructing a trend consistency index, a pool volume correction factor, and an inflection point index based on the local slope matrix; multiplying the trend consistency index by the correction factor and adding the inflection point index to obtain a knowledge bias term; superimposing the knowledge bias term onto the standard self-attention score to obtain a knowledge-guided attention score; and weighting the knowledge-guided attention score to obtain the enhanced feature matrix. The process of constructing the pool volume correction factor is as follows: taking a local time window centered at time s, the slope of the change of the pool volume parameter at that time is obtained by fitting and solving the least squares method to obtain the local slope; based on the non-negative part of the local slope of the pool volume, the pool volume correction factor is constructed by inverse proportional decay mapping; the inverse proportional decay mapping maps the non-negative part of the local slope of the pool volume into a weighting factor in the form of the inverse. The enhanced feature matrix is processed using the prototype learning residual enhancement module to obtain the residual feature matrix; by constructing one or more normal working condition feature prototypes, the most similar feature prototype is matched based on the feature similarity between the enhanced feature matrix and each prototype, and the residual feature matrix is obtained based on the feature difference between the enhanced feature matrix and the most similar feature prototype. The residual feature matrix is input into the classification layer to obtain the predicted probability of early overflow.
2. The early overflow intelligent identification method based on knowledge guidance and residual enhancement as described in claim 1, characterized in that: Based on drilling expert rules, a consistency index of structural trends is constructed using the local slope increase of outlet flow, the local slope increase of drilling speed, the local slope decrease of standpipe pressure, and the local slope decrease of drilling pressure.
3. The early overflow intelligent identification method based on knowledge guidance and residual enhancement as described in claim 1, characterized in that: The inflection point index is constructed as follows: the inflection point index is constructed based on the increase of the difference in outlet flow rate, the increase of the difference in drilling speed, the decrease of the difference in stand pressure, and the decrease of the difference in drilling pressure.
4. The early overflow intelligent identification method based on knowledge guidance and residual enhancement as described in claim 1, characterized in that: The process of matching the most similar feature prototype based on the feature similarity between the enhanced feature matrix and each prototype, and obtaining the residual feature matrix based on the feature difference between the enhanced feature matrix and the most similar feature prototype, specifically involves: constructing one or more normal operating condition feature prototypes, calculating the distance between the enhanced feature matrix and each prototype, assigning the enhanced feature matrix to the prototype with the smallest distance, calculating the difference between the enhanced feature matrix and the prototype with the smallest distance, and obtaining the residual feature matrix.
5. The early overflow intelligent identification method based on knowledge guidance and residual enhancement as described in claim 4, characterized in that: The construction of one or more normal working condition feature prototypes is as follows: if only a single normal working condition is considered, the mean of the enhanced feature matrix of all normal samples is used as the normal prototype; if different normal sub-working conditions such as drilling, pump start-up, and pump stop-up are considered, multiple normal prototypes are constructed respectively.
6. An early overflow intelligent identification system based on knowledge guidance and residual enhancement, characterized in that, include: The preprocessing module acquires and preprocesses the raw drilling monitoring data to obtain the preprocessed data. The knowledge-guided self-attention module enhances the preprocessed data to obtain an enhanced feature matrix. Specifically, this includes: calculating the local slope of each monitoring parameter in the preprocessed data to obtain a local slope matrix; constructing a trend consistency index, a pool volume correction factor, and an inflection point index based on the local slope matrix; multiplying the trend consistency index by the correction factor and adding the inflection point index to obtain a knowledge bias term; superimposing the knowledge bias term onto the standard self-attention score to obtain a knowledge-guided attention score; and weighting the knowledge-guided attention score to obtain the enhanced feature matrix. The process of constructing the pool volume correction factor is as follows: taking a local time window centered at time s, the slope of the change of the pool volume parameter at that time is obtained by fitting and solving the least squares method to obtain the local slope; based on the non-negative part of the local slope of the pool volume, the pool volume correction factor is constructed by inverse proportional decay mapping; the inverse proportional decay mapping maps the non-negative part of the local slope of the pool volume into a weighting factor in the form of the inverse. The residual enhancement module of prototype learning processes the enhanced feature matrix to obtain the residual feature matrix. By constructing one or more normal working condition feature prototypes, the most similar feature prototype is matched based on the feature similarity between the enhanced feature matrix and each prototype. The residual feature matrix is obtained based on the feature difference between the enhanced feature matrix and the most similar feature prototype. The prediction module inputs the residual feature matrix into the classification layer to obtain the predicted probability of early overflow.
7. An electronic device, characterized in that, Includes a memory and a processor, as well as computer instructions stored in the memory and running on the processor, which, when executed by the processor, perform the functions of claim 1. The steps in the early overflow intelligent identification method based on knowledge guidance and residual enhancement as described in any one of the 5 claims.
8. A computer-readable storage medium, characterized in that, Used to store computer instructions, which, when executed by a processor, complete claim 1. The steps in the early overflow intelligent identification method based on knowledge guidance and residual enhancement as described in any one of the 5 claims.