Oil and gas well production abnormity diagnosis method fused with large language model
By employing Transformer model and large language model diagnostic technology with multimodal data fusion and cross-modal semantic alignment, the problems of shallow data fusion, single diagnostic dimensions, and poor stability in the diagnosis of anomalies in oil and gas well production have been solved, enabling efficient, interpretable composite fault diagnosis and rapid handling.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NORTHEAST GASOLINEEUM UNIV
- Filing Date
- 2026-04-11
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies for diagnosing production anomalies in oil and gas wells suffer from shallow data fusion, limited diagnostic dimensions, insufficient generalization ability, and poor long-term model stability. They are unable to achieve deep fusion of multimodal data and cross-modal semantic alignment, resulting in low accuracy and a lack of interpretability in diagnosing composite faults.
By employing multimodal data acquisition and preprocessing, a multimodal embedding and fusion model based on the Transformer architecture is constructed to achieve cross-modal semantic alignment. Fault analysis is performed by combining a two-stage diagnostic architecture with a large language model, and a closed-loop iterative optimization mechanism is constructed to generate interpretable diagnostic results.
It achieves deep fusion and cross-modal semantic alignment of multi-dimensional and multi-modal data of oil and gas wells, improves the early identification rate of faults, diagnostic accuracy and interpretability, adapts to the full-scenario diagnostic needs of different well types and operating conditions, and reduces the downtime and maintenance costs of faults.
Smart Images

Figure CN122065128A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent development technology of oil and gas fields, specifically a method for diagnosing production anomalies in oil and gas wells that integrates a large language model. Background Technology
[0002] Oil and gas wells are the core production units in oil and gas exploration and development. The stability of their production conditions directly determines oil and gas recovery rates, production safety, and operation and maintenance costs. During long-term production, oil and gas wells are prone to various abnormal conditions such as sand production, wax deposition, tubing leakage, pump and valve failure, insufficient formation fluid supply, water channeling, and abnormal equipment noise. If these conditions are not diagnosed and addressed in a timely and accurate manner, they can lead to reduced production, production stoppages, or even major safety accidents such as equipment damage, wellhead loss of control, and personnel casualties.
[0003] Current technologies for diagnosing abnormal production in oil and gas wells are mainly divided into three categories, all of which have significant technical bottlenecks and shortcomings: 1. Traditional diagnostic techniques based on human experience: These rely on the professional experience of on-site maintenance engineers and technical experts, and rely on manual verification of production data and on-site inspections to judge abnormal operating conditions. They suffer from low diagnostic efficiency, high subjectivity, and high labor costs. They are also extremely poor at identifying early and hidden faults and cannot meet the real-time monitoring and full-coverage diagnostic needs of oil and gas fields with a scale of tens of thousands of fields.
[0004] 2. Diagnostic techniques based on traditional machine learning: These techniques, with algorithms such as support vector machines, backpropagation neural networks, and random forests as their core, build diagnostic models based on structured production data such as oil pressure, casing pressure, and production volume, which improves diagnostic efficiency to some extent. However, these techniques can only utilize single structured time-series data and cannot integrate the massive amounts of unstructured data from the oilfield (work logs, fault cases, monitoring images, equipment operation audio, etc.). The data utilization rate is less than 20%, and the diagnostic dimensions are limited. At the same time, the model has extremely poor generalization ability, and can only identify fault types that have appeared in the training set. The accuracy rate for diagnosing rare faults and complex faults with multiple coupled factors is less than 30%, which easily leads to serious missed diagnoses and false diagnoses. Furthermore, the model is a black box structure and cannot output clear diagnostic criteria, making it difficult for field personnel to accept and implement.
[0005] 3. Existing improved technologies based on deep learning and large language models: With deep learning models such as CNN, LSTM, and Transformer as the core, the feature extraction capabilities of time series data and image data have been improved, and some existing technologies attempt to introduce large language models to optimize the diagnostic process. However, existing technologies suffer from three major flaws: First, the fusion of multimodal data is extremely shallow. Most of them involve simple feature splicing after modeling different modal data separately, without achieving cross-modal semantic alignment and deep fusion. They cannot uncover the associated fault features between different modal data, such as the inability to associate the string leakage coupling features between "visual features of wellhead seepage, audio features of pipeline fluid scouring, and temporal features of oil pressure drop". Second, the application of large language models is superficial. Most existing technologies only use large language models as "text generators" or "translators" for diagnostic results, without deeply integrating the domain knowledge reasoning, causal analysis, and context learning capabilities of large language models into the core diagnostic link. They cannot use industry standards and historical cases to achieve reasoning diagnosis of unknown and complex faults, and have failed to break through the generalization bottleneck of traditional models that "can only be diagnosed after seeing". Third, there is a lack of a complete closed-loop iteration mechanism. The model cannot be continuously optimized based on field handling feedback data. With changes in formation conditions and production conditions, the diagnostic accuracy of the model decreases by more than 35% after long-term operation (more than 12 months), and it cannot stably adapt to field needs in the long term.
[0006] Meanwhile, existing technologies only utilize production time-series data and fault text examples, without involving the fusion of multimodal data such as visual and audio, severely limiting diagnostic dimensions. Furthermore, existing technologies only perform simple feature fusion on multimodal data, failing to achieve cross-modal semantic alignment and lacking the reasoning capabilities of large language models, resulting in insufficient diagnostic capabilities for complex faults. Additionally, existing technologies do not construct a two-stage diagnostic architecture, failing to balance real-time performance and accuracy, and lack a closed-loop iteration mechanism, leading to poor long-term operational stability. In summary, existing patented technologies cannot simultaneously solve the core technical problems of deep multimodal data fusion, deep coupling of large language models and diagnostic links, and balancing the generalization and interpretability of fault diagnosis, indicating a significant technological gap. Summary of the Invention
[0007] To address the aforementioned deficiencies in existing technologies, the present invention aims to provide a method for diagnosing oil and gas well production anomalies by integrating a large language model. This method achieves deep fusion and cross-modal semantic alignment of multi-dimensional and multi-modal data from oil and gas wells, deeply integrates the domain knowledge reasoning capabilities of the large language model into the entire diagnostic process, and constructs a complete diagnostic system of "real-time initial screening - deep diagnosis - scheme generation - closed-loop iteration". This significantly improves the accuracy, generalization, and interpretability of oil and gas well production anomaly diagnosis, while adapting to the full-scenario oil and gas well diagnostic needs of different well types, operating conditions, and monitoring configurations.
[0008] To achieve the above objectives, the present invention provides the following technical solution: a method for diagnosing oil and gas well production anomalies by integrating a large language model, comprising the following steps: S1 Multimodal Data Acquisition and Preprocessing: Acquire multi-source heterogeneous data from target oil and gas wells, including four categories: structured production time series data, unstructured domain text data, visual monitoring data, and audio operation data. Perform preprocessing operations such as cleaning and feature extraction on each type of data to obtain the initial features of the corresponding modality. S2 Multimodal Data Unified Representation and Cross-Modal Alignment: Construct a multimodal embedding and fusion model based on the Transformer architecture, perform dimensional unified mapping and intramodal context encoding on the initial features of each modality, mine the implicit correlation between features of different modalities through a multi-head cross-attention mechanism, complete cross-modal semantic alignment, and finally generate a unified multimodal fusion representation vector that contains both full-modal features and cross-modal correlation information. S3 Two-Stage Anomaly Diagnosis: The first stage is a lightweight anomaly screening, which uses a pre-trained TCN-Transformer lightweight anomaly detection model to perform millisecond-level real-time anomaly identification on the multimodal fusion representation vector and label the anomaly samples with the corresponding anomaly modal dimensions; The second stage is a deep diagnosis using a large language model, which inputs the fusion representation of the anomaly samples, the corresponding original multimodal data, and a pre-built oil and gas well domain knowledge base into a fine-tuned oil and gas well domain large language model through retrieval enhancement, and outputs anomaly root cause analysis, fault type determination, fault classification, and diagnostic confidence. S4 treatment plan generation and visualization output: Based on the diagnostic results and linked with the knowledge base of oil and gas wells, a standardized treatment plan matching the actual working conditions and fault classification of the target well is generated. The interpretable text and multimodal supporting data of the diagnostic basis are output simultaneously. The unified display is completed through the visualization platform, and graded alarm push is completed according to the fault classification. S5 Model Closed-Loop Iterative Optimization: Collect feedback data from on-site fault handling, actual fault verification data, and newly added fault case data; update the training dataset and domain knowledge base; and use incremental learning to incrementally fine-tune the multimodal embedding fusion model, anomaly screening model, and domain large language model to complete the continuous self-optimization and closed-loop iteration of the diagnostic system.
[0009] Further, in step S1, the structured production time-series data includes the target well's real-time oil pressure, casing pressure, back pressure, wellhead temperature, bottom hole flowing pressure, daily fluid production, daily oil production, daily water production, water cut, pumping unit stroke, stroke frequency, motor current, motor voltage, active power, dynamometer data, formation static parameters, historical production data, and well workover operation history data; the unstructured domain text data includes the target well operation log, well workover records, historical fault diagnosis reports, on-site handling records, a database of fault cases of similar wells in the same block, SY / T series standards for oil and gas well production, oil production equipment operation and maintenance manuals, and technical and patent documents in the field of oil and gas field development; the visual monitoring data includes high-definition real-time monitoring videos of wellhead equipment, downhole television imaging images, dynamometer imaging images, and logging curve images; and the audio operation data includes real-time operating audio data of the pumping unit gearbox, drive motor, wellhead Christmas tree, and downhole pump set.
[0010] Further, in step S1, the specific preprocessing process is as follows: for structured production time-series data, outliers are removed using the 3σ criterion, missing values are filled using linear interpolation, the data is mapped to the [0,1] interval using Min-Max normalization, time-series segmentation is performed using the sliding window method, and time-series data is processed using Time-Series... The Transformer extracts initial temporal features; for unstructured domain text data, it performs text cleaning, removes garbled and redundant information, and performs Chinese word segmentation and stop word removal. It extracts core entities such as fault type, well number, and handling measures using named entity recognition technology, mines relationships between entities using relation extraction technology, constructs a structured oil and gas well domain knowledge base, and extracts initial text features using a BERT-wwm pre-trained model; for visual monitoring data, it performs denoising, deblurring, and contrast enhancement, extracts video keyframes using frame difference method, identifies and locates abnormal targets using a YOLOv8 target detection model, and extracts initial visual features using a ResNet50 pre-trained model; for audio running data, it removes environmental noise using spectral subtraction, removes silent segments using endpoint detection technology, extracts acoustic features such as MFCC and Mel spectrum, and extracts initial audio features using an AST audio pre-trained model.
[0011] Further, in step S2, the multimodal embedding fusion model includes a temporal feature branch, a text feature branch, a visual feature branch, an audio feature branch, an intramodal Transformer encoder, and a cross-modal attention fusion module. The specific implementation process is as follows: the initial features of the four branches are uniformly mapped to a 768-dimensional vector space through a linear mapping layer to eliminate the dimensional differences between modalities; through four independent intramodal Transformer encoders, the contextual correlation features within each modality are mined to obtain intramodal encoded features; the four sets of intramodal encoded features are input into the cross-modal attention fusion module, and a multi-head cross-attention mechanism is adopted, using the single-modal feature as the Query and the features of the other three modalities as the Key and Value, to calculate the attention weights between different modal features, mine cross-modal latent fault correlation features, and complete semantic alignment; the aligned four sets of modal features are concatenated, and feature fusion is completed through a fully connected layer to generate the final multimodal fusion representation vector.
[0012] Furthermore, in the first stage of step S3, the lightweight anomaly detection model is pre-trained based on the multimodal fusion representation vector of the oilfield's historical normal and abnormal operating conditions. The model outputs the anomaly confidence score in the 0-1 interval. The anomaly confidence score threshold is set to 0.6. When the anomaly confidence score of a sample is ≥0.6, it is determined to be an abnormal sample. At the same time, the modal dimension, occurrence time, and parameter change magnitude corresponding to the anomaly are marked. Samples determined to be normal are directly stored in the production database and do not enter the second stage of the diagnostic process. While ensuring the real-time nature of the diagnosis, the system's computing power consumption is significantly reduced.
[0013] Furthermore, in the second stage of step S3, the construction process of the large language model for the oil and gas well domain is as follows: The Llama3-70B or Tongyi Qianwen 2-72B open-source general-purpose large language model is selected as the base. Continuous pre-training is performed based on text data from the oil and gas well domain, injecting professional knowledge from fields such as oil and gas well development, fault diagnosis, and equipment maintenance to enhance the model's understanding of domain terminology. Based on a paired dataset of historical multimodal fault data and expert diagnostic results, LoRA low-rank adaptation technology is used for fine-tuning, allowing the model to learn the mapping relationship between multimodal fusion representations and fault root causes, as well as the causal reasoning logic of fault diagnosis, resulting in a dedicated large language model for the oil and gas well domain. Simultaneously, a retrieval enhancement RAG system based on the Milvus vector database is constructed. Based on the fusion representation and anomaly dimension labeling of abnormal samples, the top 10 relevant fault cases, industry standards, and handling specifications with the highest matching degree are retrieved from the domain knowledge base, providing accurate knowledge support for model reasoning and fundamentally preventing model illusions.
[0014] Furthermore, in the second stage of step S3, the fault classification adopts a four-level classification rule, specifically: Level 1 fault (urgent): anomalies that may lead to major safety accidents such as wellhead loss of control, equipment damage, and personnel casualties, such as wellhead leakage, tubing breakage, pump jamming, etc., requiring immediate shutdown and handling; Level 2 fault (serious): anomalies that may lead to well production stoppage and a significant drop in production, such as severe insufficient formation fluid supply, severe pump and valve damage, severe water channeling, etc., requiring handling within 24 hours; Level 3 fault (general): anomalies that have some impact on production but will not lead to production stoppage, such as slight wax deposition, sand production, parameter fluctuations, etc., requiring handling within 72 hours; Level 4 fault (minor): early anomalies that have basically no impact on production, such as slight abnormal noise from equipment, small parameter fluctuations, etc., requiring key attention during daily inspections.
[0015] Furthermore, in step S4, the handling plan is generated based on fault classification differentiation, including handling priority, step-by-step operation process, required equipment and materials, safety precautions, handling effect verification standards, and experience reference for handling similar faults in adjacent wells; interpretable text includes a complete diagnostic logic chain, anomaly feature evidence, historical case matching, corresponding industry standard clauses, and root cause reasoning process; multimodal supporting data includes anomaly time series curves, fault image fragments, audio waveform diagrams, and relevant case text fragments; the visualization platform displays real-time operating condition dashboards, anomaly alarm pop-ups, fault root cause analysis graphs, handling plan flowcharts, and multimodal supporting data panels, while simultaneously pushing graded alarm information and handling plans to corresponding operation and maintenance personnel and management personnel via SMS and the oilfield production management system.
[0016] Further, in step S5, the specific process of incremental fine-tuning is as follows: collect on-site handling feedback data, consistency data between actual faults and diagnostic results, newly added fault cases and handling records, and correction opinions from on-site experts; after preprocessing, update the training dataset, domain knowledge base, and vector database; adopt an incremental learning approach, combined with Elastic Weight Consolidation (EWC) catastrophic forgetting suppression technology, to incrementally fine-tune the multimodal embedding fusion model, anomaly screening model, and domain large language model, while retaining the original diagnostic capabilities of the model, and learning newly added fault features and diagnostic knowledge; conduct accuracy, recall, and generalization performance tests on the fine-tuned model; when the test indicators are better than the current online model, update the online model version to complete the closed-loop iteration of the diagnostic system.
[0017] Compared with the prior art, the beneficial effects of the present invention are: This invention achieves deep fusion and cross-modal semantic alignment of multi-dimensional and multi-modal data from oil and gas wells, breaking through the core bottleneck of existing technologies' single data dimension and shallow fusion. It simultaneously collects and fuses four core data categories: structured time-series data, unstructured text data, visual monitoring data, and audio operation data. Through a cross-modal attention mechanism, it achieves semantic alignment and deep fusion of different modal data, fully exploring the implicit correlation fault characteristics between different modal data, and completely solving the problems of "one-sided single-modal diagnosis and ineffective multi-modal splicing and fusion" in existing technologies. Compared with existing single-modal diagnostic technologies, this invention improves the early fault identification rate by more than 42% and the data utilization rate by more than 85%, accurately capturing early hidden faults that traditional technologies cannot identify. This invention constructs a two-stage diagnostic architecture, deeply integrating a large language model into the core diagnostic process, overcoming the shortcomings of existing technologies such as poor generalization and insufficient ability to diagnose complex and rare faults. In the first stage, a lightweight model is used to achieve millisecond-level anomaly screening, ensuring real-time performance for large-scale oil and gas field diagnosis. In the second stage, the domain knowledge reasoning, causal analysis, and contextual learning capabilities of the large language model are used as the core of diagnosis, rather than simply as a result output tool. Combined with a retrieval-enhanced domain knowledge base, it can not only accurately identify common faults but also perform reasoning diagnosis on rare faults not found in the training set and complex faults involving multiple factors, completely breaking down the generalization barrier of traditional models that require "seeing before diagnosis." Compared with existing technologies, this invention improves the accuracy of complex fault diagnosis by over 58%, the rare fault identification rate by over 72%, and the overall diagnostic accuracy by over 96%. This invention achieves end-to-end interpretability of diagnostic results, overcoming the industry pain points of existing technologies' black-box models and poor interpretability. Through a domain-specific large language model, it simultaneously outputs a complete diagnostic logic chain, supporting evidence of abnormal features, historical case matching, and corresponding industry standard clauses along with the diagnostic results. It also displays multimodal supporting data, enabling on-site maintenance personnel to clearly grasp the complete causal logic of the diagnosis, significantly improving the credibility of diagnostic results and the efficiency of handling execution. Compared with existing technologies, the accuracy of the handling solution of this invention is improved by more than 65%, the average fault handling cycle is shortened by more than 52%, and the downtime due to faults is significantly reduced. This invention establishes a complete closed-loop iterative mechanism for the diagnostic system, ensuring the stability and accuracy of the model during long-term operation. By collecting on-site handling feedback data and new fault case data, the invention continuously optimizes the entire-link model using incremental learning technology. Simultaneously, through catastrophic forgetting suppression technology, it prevents the model from losing its original diagnostic capabilities during iteration, completely solving the problem of accuracy decay caused by changes in working conditions and geological conditions after long-term operation of traditional models. Compared with existing technologies, the diagnostic accuracy decay rate of the model in this invention during long-term operation (more than 12 months) is reduced from more than 35% to less than 4%, and it can stably adapt to on-site production needs for a long time. It possesses strong scenario adaptability and compatibility, and can adapt to the full-scenario diagnostic needs of all types of oil and gas wells. The multimodal fusion architecture of this invention adopts a modular design, which can flexibly adapt to the monitoring equipment configuration of different oil and gas wells: for wells with complete monitoring equipment, full multimodal data can be accessed to achieve high-precision diagnosis; for remote wells and low-production wells with simple monitoring equipment, only core time series data and text data can be accessed to achieve basic diagnosis, without the need to rebuild the model, which greatly reduces the cost and cycle of field deployment; compared with the existing technology, the field deployment cycle of this invention is shortened by more than 75%, and the coverage of adaptable well types is increased by more than 90%, which can fully cover all types of oil and gas wells such as rod pump wells, electric submersible pump wells, screw pump wells, gas wells, and horizontal wells. Attached Figure Description
[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.
[0019] In the attached diagram: Figure 1 This is an overall flowchart of the oil and gas well production anomaly diagnosis method integrating a large language model as described in this invention; Figure 2 This is a schematic diagram of the architecture of the multimodal data unified representation and cross-modal alignment module described in this invention; Figure 3 This is a schematic diagram of the architecture of the two-stage anomaly diagnosis module described in this invention; Figure 4 This is a flowchart illustrating the closed-loop iterative optimization module of the model described in this invention. Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0021] The target well in this embodiment is well X-1 in block X of an oilfield, with a depth of 2350m and a total drilled depth of 2420m. It is produced using a rod pump and has been in production for 3 years. Historically, its production has been stable, with a daily fluid production of 25m³. 3 / d, daily oil production 8.2m 3 / d, water cut 67.2%, wellhead oil pressure 3.2MPa, casing pressure 5.8MPa. The specific implementation steps of this embodiment are as follows: Step S1: Multimodal Data Acquisition and Preprocessing Multimodal data acquisition (1) Structured production time series data acquisition: Real-time production data of the well is acquired through the RTU terminal, pressure sensor, temperature sensor, flow sensor, motor monitoring module deployed at the wellhead, as well as the oilfield SCADA production management system. The acquisition frequency is 1 time / minute, including: oil pressure, casing pressure, back pressure, wellhead temperature, daily fluid production, daily oil production, daily water production, water cut, pumping unit stroke, stroke frequency, motor three-phase current, motor voltage, active power, and dynamometer data. At the same time, historical production data, well workover operation history data, formation porosity, permeability, oil saturation and other static parameters of the well are acquired to form a structured time series dataset.
[0022] (2) Unstructured text data collection: Through the oilfield production management system and knowledge base system, collect the well's operation log, well repair record, historical fault diagnosis report and on-site handling record; collect 1200+ sets of historical fault case library of similar wells in Block X; collect SY / T series industry standards for oil and gas well production, pumping unit equipment operation and maintenance manual, development plan of the block, and technical literature in the field of oil and gas well fault diagnosis to form an unstructured text dataset.
[0023] (3) Visual monitoring data acquisition: Real-time monitoring videos of the wellhead tree and pumping unit equipment are acquired through a 4-megapixel high-definition AI camera deployed at the wellhead, with a frame rate of 25fps; real-time imaging images of the well's dynamometer and historical logging curve images are also acquired to form a visual dataset. (4) Audio operation data acquisition: Real-time operation audio data of the pumping unit gearbox, drive motor, and wellhead tree are acquired through a high-precision audio pickup device deployed at the wellhead, with a sampling frequency of 44.1kHz, a collection duration of 10 seconds / time, and a collection interval of 1 minute to form an audio dataset.
[0024] Multimodal data preprocessing (1) Structured production time series data preprocessing: The 3σ criterion is used to remove outliers from the original time series data, and linear interpolation is used to fill in the missing values caused by sensor interruption; Min-Max normalization is used to map all time series data to the [0,1] interval to eliminate the difference in the dimensions of different parameters; the sliding window method is used to segment the time series data with a window size of 60 minutes and a step size of 10 minutes to generate continuous time series data segments; the time series segments are feature extracted by the pre-trained Time-SeriesTransformer model to generate a 768-dimensional initial time series feature vector.
[0025] (2) Preprocessing of unstructured domain text data: Unified text extraction is performed on PDF, Word and Excel documents to remove invalid information such as garbled characters, special symbols and redundant spaces; Jieba Chinese word segmentation tool is used to segment the text and remove stop words; BERT-base named entity recognition model is used to extract core entities such as fault type, well number, fault time, disposal measures and fault cause in the text, and causal relationship between entities is extracted by relation extraction model to build a structured knowledge base for oil and gas well domain; the text data is embedded by pre-trained BERT-wwm model to generate 768-dimensional initial text feature vector, and the processed text data is converted into vectors and stored in Milvus vector database to build a retrieval enhancement RAG system.
[0026] (3) Visual monitoring data preprocessing: Gaussian denoising and contrast enhancement are performed on the original video and image data. The motion change key frames in the video are extracted by the frame difference method, and redundant frames without change are removed. The abnormal targets such as wellhead leakage, equipment deformation, and loose fasteners in the key frame images are identified and located by the pre-trained YOLOv8 target detection model, and the abnormal areas and abnormal types are marked. The key frame images are feature extracted by the pre-trained ResNet50 model to generate a 768-dimensional visual initial feature vector.
[0027] (4) Audio running data preprocessing: Spectral subtraction is used to remove environmental noise from the original audio data, and silent segments are removed by dual threshold endpoint detection technology; core acoustic features such as MFCC, Mel spectrum, zero crossing rate, and spectral centroid of the audio data are extracted; acoustic features are embedded by a pre-trained AST audio model to generate a 768-dimensional initial audio feature vector, and abnormal audio segments are marked by an anomaly detection model.
[0028] Step S2: Unified representation and cross-modal alignment of multimodal data This embodiment constructs a multimodal embedding and fusion model based on the Transformer architecture. The model includes a temporal feature branch, a text feature branch, a visual feature branch, an audio feature branch, four intramodal Transformer encoders, and a cross-modal attention fusion module. The specific implementation process is as follows: 1. Dimensional Unification Mapping: Input the initial temporal features, initial text features, initial visual features, and initial audio features obtained in step S1 into the corresponding linear mapping layer. Map the feature vectors of the four branches to a 768-dimensional vector space to eliminate the dimensional differences between different modalities and obtain four sets of feature vectors with unified dimensions.
[0029] 2. Intramodal context encoding: The four sets of feature vectors with unified dimensions are input into four independent intramodal Transformer encoders. Each encoder contains six Transformer encoding layers. The contextual features within each modality are mined through a self-attention mechanism. For example, the temporal branch mines the temporal variation correlation between production parameters, and the text branch mines the causal correlation between fault entities. Finally, four sets of intramodal encoded features are obtained.
[0030] 3. Cross-modal attention alignment and fusion: The four sets of intramodal encoded features are input into the cross-modal attention fusion module. An 8-head cross-attention mechanism is adopted, with the single-modal feature as the query and the features of the other three modalities as the key and value. The attention weights between different modal features are calculated to mine the implicit fault association features across modalities, such as the coupling association between "the temporal features of oil pressure drop, the visual features of wellhead seepage, and the audio features of pipeline scouring", and to complete the cross-modal semantic alignment. The aligned four sets of modal features are concatenated and feature dimensionality reduction and fusion are performed through two fully connected layers. Finally, a 768-dimensional unified multimodal fusion representation vector is generated, which contains the core fault features of the four modalities and cross-modal association information.
[0031] 4. Fusion Representation Verification: The similarity between the fusion representation and the original features of each modality is calculated by cosine similarity to ensure that the similarity is ≥0.85, thus fully preserving the core features of each modality; the K-means clustering algorithm is used to verify the distinguishability of the fusion representation between normal and abnormal operating conditions, ensuring that the clustering profile coefficient is ≥0.7, thus possessing good fault differentiation ability.
[0032] Step S3 Two-stage abnormality diagnosis This embodiment adopts a two-stage architecture of "lightweight real-time initial screening + deep diagnosis using a large language model", and the specific implementation process is as follows: Phase 1: Initial Screening for Lightweight Anomalies 1. Model pre-training: The TCN-Transformer lightweight anomaly detection model was adopted. The model was pre-trained based on the multimodal fusion representation vector of the historical normal and abnormal operating conditions of 1,000 wells in the oilfield. The input of the model is the multimodal fusion representation vector, and the output is the anomaly confidence score in the range of 0-1. The anomaly confidence score threshold was set to 0.6. When the confidence score is ≥0.6, it is judged as an abnormal sample.
[0033] 2. Real-time Anomaly Identification: At 8:00 AM on [Date], the system inputs the real-time multimodal fusion representation vector of well X-1 generated in step S2 into the pre-trained anomaly screening model. The calculated anomaly confidence score is 0.92, far exceeding the threshold of 0.6, thus identifying it as an anomaly sample. Simultaneously, the anomaly dimensions are labeled as temporal anomaly, visual anomaly, and audio anomaly. The anomaly occurred between 7:00 AM and 8:00 AM that day, and the abnormal parameter changes were: oil pressure decreased from 3.2 MPa to 1.1 MPa, and daily fluid production decreased from 25 m³ / h. 3 / d decreased to 8m 3 / d, the motor current fluctuation amplitude increases by 35%.
[0034] 3. Result Triage: If the sample is determined to be an abnormal sample, its multimodal fusion representation vector, the corresponding original multimodal data, and the abnormal dimension label are input together into the second-stage large language model deep diagnosis module; samples from other normal periods are directly stored in the production database and do not enter the subsequent process.
[0035] Phase Two: In-depth Diagnosis of Large Language Models 1. Construction of a large language model for the oil and gas well domain: This embodiment selects the Tongyi Qianwen 2-72B open-source large language model as the base. First, it performs continuous pre-training based on more than 1 million words of text data (industry standards, failure cases, equipment manuals, and technical documents) in the oilfield, injecting domain-specific professional knowledge. Then, based on a dataset of more than 5,000 sets of historical multimodal failure data and expert diagnosis results from the oilfield, it uses LoRA low-rank adaptation technology for fine-tuning. The LoRA rank is set to 8, the training rounds are 10, and the learning rate is 2e-4, resulting in a large language model specifically for the oil and gas well domain. At the same time, a RAG retrieval enhancement system based on the Milvus vector database is constructed.
[0036] 2. Enhanced Knowledge Matching: Based on the fusion representation and anomaly dimension labeling of the X-1 well anomaly sample, the top 10 matching related fault cases, industry standards, and handling specifications were retrieved from the vector database. The retrieval results showed that the anomaly feature matched the "tubing corrosion and leakage" fault cases of 3 wells in Block X with a 92% match rate. At the same time, it matched the relevant diagnostic standards for tubing leakage in SY / T6120-2019 "Technical Specification for Downhole Operations in Oil Wells".
[0037] 3. Deep diagnostic reasoning: The multimodal fusion representation vector of the abnormal sample, the original multimodal data, the abnormal dimension label, and the retrieved domain knowledge are input into the fine-tuned domain language model according to the preset Prompt template. The Prompt template explicitly requires the model to output the abnormal root cause analysis, fault type, fault classification, diagnostic confidence, diagnostic basis and reasoning logic chain.
[0038] 4. Diagnostic Result Output: After the large language model completes the reasoning, it outputs the final diagnostic result: Anomaly root cause analysis: Tubing corrosion caused tubing leakage. The leakage location was a historical corrosion point 1200m below the wellhead. Tubing corrosion perforation caused formation produced fluid to leak out of the tubing, resulting in decreased oil pressure and reduced production. At the same time, there was abnormal noise from wellhead seepage and pipeline fluid scouring. Fault type: Abnormal tubing integrity - tubing corrosion and leakage; Fault classification: Level 2 fault (severe); Diagnostic confidence level: 0.94; Diagnostic criteria: ① A significant drop in oil pressure, a decrease in production, and no significant change in water cut are consistent with the temporal characteristics of tubing leakage; ② The visual characteristics of fluid seepage at the wellhead flange and the audio characteristics of abnormal fluid scouring noise in the pipeline are highly consistent with the multimodal characteristics of tubing leakage; ③ The well workover record from 6 months ago shows that there is a tubing corrosion point 1200m below the wellhead, which provides the basic conditions for leakage; ④ The feature matching rate of similar failure cases in 3 wells in the same block reaches 92%, verifying the accuracy of the diagnostic conclusion. Reasoning logic chain: abnormal timing parameters lock the direction of tubing leakage → visual and audio anomalies verify wellhead fluid leakage → historical operation data lock corrosion risk points → matching similar cases to verify diagnostic conclusions.
[0039] 5. Verification of diagnostic results: Compare the fault type in the diagnostic results with the multimodal feature matching degree of the abnormal samples. The overall matching degree is calculated to be 93%, and the diagnostic confidence is 0.94≥0.8. The result is determined to be a valid diagnostic result and proceeds to the subsequent treatment plan generation stage.
[0040] Step S4: Generation and Visualization of the Treatment Plan 1. Generation of Tiered Disposal Plans: Based on the diagnostic results of the Level 2 fault, and in conjunction with operational specifications and disposal cases in the domain knowledge base, a standardized disposal plan matching the X-1 well condition is generated through a large language model. Specific content includes: Priority: Level 2, to be completed within 24 hours; Step-by-step operation procedure: ① Shut down the wellhead production gate valve, complete the wellhead pressure relief, and implement safety protection measures; ② Conduct wellhead pressure testing to verify tubing leakage; ③ Pull out the downhole tubing, complete tubing inspection, and locate the leakage point; ④ Replace the corroded and leaking section of tubing and replace tubing seals; ⑤ Run the tubing into the well, complete the wellhead pressure test, and start production after the pressure test is passed; ⑥ After starting production, continuously monitor production data for 3 days to verify the treatment effect. Required equipment and materials: working machine, oil pipes, seals, pressure testing equipment, positive pressure breathing apparatus, explosion-proof tools; Safety Precautions: Strictly implement SY / T5225-2019 "Technical Regulations for Fire Prevention and Explosion Protection in Oil and Gas Drilling, Development, Storage and Transportation", complete wellhead gas detection before operation, implement blowout prevention and fire prevention measures, and ensure that operators are certified to work. Verification criteria for treatment effectiveness: After well opening, oil pressure recovers to above 3.0 MPa, and daily fluid production recovers to 24 m³ / day. 3 The water cut is above / d, the water content is stable, and there is no seepage or abnormal noise at the wellhead; Experience in handling similar failures: After handling similar failures in wells X-2 and X-5 in the same block, the production recovery rate reached 100%, with an average handling cycle of 18 hours.
[0041] 2. Generation of Explanatory Content and Supporting Data: Simultaneously generate an interpretable explanatory document for the diagnostic results, fully presenting the diagnostic logic chain, supporting evidence of abnormal features, historical case matching, and corresponding industry standard clauses; at the same time, it is equipped with multimodal supporting data, including time series curves of abnormal oil pressure and production from 7:00 to 8:00, monitoring screenshots of wellhead seepage, abnormal audio waveforms, and text fragments of similar fault cases in the same block.
[0042] 3. Visualized Output and Alarm Push: Diagnostic results, fault classification, root cause analysis, handling plans, interpretable content, and multimodal supporting data are uniformly displayed through the oilfield intelligent production visualization platform. This includes a real-time operating condition dashboard, a red abnormal alarm pop-up, a fault root cause analysis graph, a handling plan flowchart, and a multimodal supporting data panel. At the same time, secondary alarm information and complete handling plans are pushed to the well area maintenance team and work area management personnel through the oilfield production management system and SMS, ensuring that relevant personnel receive alarm information as soon as possible.
[0043] Step S5: Closed-loop iterative optimization of the model 1. Feedback Data Acquisition: After receiving the alarm, the on-site work team completed the operation and handling at 18:00 on the same day. After pulling out the tubing, it was confirmed that the actual fault was a corrosion perforation and leakage of the tubing 1200m below the wellhead, which was completely consistent with the diagnosis. After replacing the tubing, the well was started for production, and the oil pressure recovered to 3.3MPa, and the daily fluid production recovered to 25.2m³. 3 / d, production conditions returned to normal. The system collects feedback data from this handling, including the actual fault type, consistency with the diagnostic results, the effectiveness of the handling plan, production recovery data after handling, and optimization suggestions from on-site engineers. At the same time, this fault case is added to the fault case library.
[0044] 2. Dataset Update: After preprocessing, the collected feedback data and newly added fault cases are updated to the multimodal training dataset, domain knowledge base, and Milvus vector database. At the same time, negative sample data in the diagnosis process are labeled and added to the negative sample dataset.
[0045] 3. Incremental Fine-tuning Optimization: An incremental learning approach is adopted, combined with Elastic Weight Consolidation (EWC) catastrophic forgetting suppression technology. Based on the updated dataset, the multimodal embedding fusion model, anomaly screening model, and domain-specific large language model are incrementally fine-tuned. The training rounds are 3, and the learning rate is 1e-5. While retaining the original diagnostic capabilities of the model, it learns the newly added fault features and diagnostic knowledge, thus avoiding catastrophic forgetting in the model.
[0046] 4. Model Testing and Version Update: Performance testing was conducted on the fine-tuned model. The test results showed that the overall diagnostic accuracy of the model improved from 96.2% to 96.5%, and the identification rate of tubing leakage faults improved from 92% to 95%. The test indicators were better than the current online model, and the online model version update was completed, realizing a complete closed-loop iteration of the diagnostic system.
[0047] Example Effect Verification This embodiment accurately identified the early-stage tubing corrosion and leakage fault in well X-1 using the method of the present invention. The diagnostic results were completely consistent with the actual fault, with a diagnostic accuracy of 100%. The diagnosis was completed in just 8 minutes from the occurrence of the anomaly, achieving real-time diagnosis. The generated treatment plan was fully adapted to the on-site conditions, with an on-site treatment cycle of only 10 hours, which is more than 60% shorter than the traditional treatment cycle. Production was fully restored after the fault was treated, without causing a long-term shutdown or production loss, verifying the excellent effect of the present invention.
Claims
1. A method for diagnosing production anomalies in oil and gas wells by integrating a large language model, characterized in that, Includes the following steps: S1 Multimodal Data Acquisition and Preprocessing: Acquire multi-source heterogeneous data from target oil and gas wells, including structured production time-series data, unstructured domain text data, visual monitoring data, and audio operation data. Perform preprocessing on each type of data to obtain the initial features of the corresponding modality. S2 Multimodal Data Unified Representation and Cross-Modal Alignment: Construct a multimodal embedding fusion model, perform dimensional unified mapping and intramodal encoding on the initial features of each modality, mine the correlation between features of different modalities through a multi-head cross-attention mechanism, complete cross-modal semantic alignment, and generate a unified multimodal fusion representation vector; S3 Two-Stage Anomaly Diagnosis: The first stage is a lightweight anomaly screening, which uses a pre-trained lightweight anomaly detection model to identify anomalies in the multimodal fusion representation vector in real time and to label the abnormal samples and anomaly dimensions. The second stage is deep diagnosis of the large language model, which inputs the fusion representation of abnormal samples, corresponding multimodal data, and pre-built knowledge base of oil and gas well domain into the fine-tuned large language model of oil and gas well domain, and outputs abnormal root cause analysis, fault type, fault classification and diagnostic confidence. S4 Disposal Plan Generation and Visualization Output: Based on the diagnostic results and the domain knowledge base, a disposal plan matching the target well conditions and fault classification is generated. The interpretable text and multimodal supporting data of the diagnostic basis are output simultaneously, and the visualization display and graded alarm push are completed. S5 Model Closed-Loop Iterative Optimization: Collect feedback data from on-site fault handling and new fault cases, update the training dataset and domain knowledge base, and incrementally fine-tune the multimodal embedding fusion model, anomaly screening model, and domain large language model to complete the closed-loop iteration of the diagnostic system.
2. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In step S1, the structured production time series data includes the target well's oil pressure, casing pressure, temperature, production rate, water cut, motor operating parameters, dynamometer card data, formation static parameters, and historical production operation data. Unstructured domain text data includes target well operation logs, well workover records, historical fault reports, fault case libraries for the same block, oil and gas well industry standards, equipment operation and maintenance manuals, and domain technical literature; visual monitoring data includes real-time monitoring videos of wellhead equipment, downhole television imaging images, dynamometer diagrams, and logging curve images; audio operation data includes real-time operating audio data of pumping units, motors, Christmas trees, and downhole pump sets.
3. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In step S1, the preprocessing specifically includes: removing outliers, filling missing values, normalizing, and segmenting the structured production time-series data to extract initial time-series features; cleaning, segmenting, identifying named entities, and extracting relationships from unstructured domain text data to construct an oil and gas well domain knowledge base and extract initial text features; denoising, extracting keyframes, and detecting targets from visual monitoring data to extract initial visual features; and denoising, detecting endpoints, and extracting acoustic features from audio running data to extract initial audio features.
4. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In step S2, the multimodal embedding fusion model adopts a Transformer architecture, including a temporal feature branch, a text feature branch, a visual feature branch, an audio feature branch, an intramodal encoder, and a cross-modal attention fusion module. Specifically, the initial features of each modality are mapped to a unified dimensional space through a linear mapping layer. The intramodal Transformer encoder mines the contextual features within each modality. The multi-head cross-attention mechanism calculates the cross-modal attention weights using single-modal features as queries and other modal features as keys and values. After semantic alignment, the features are concatenated and fused to generate a multimodal fusion representation vector.
5. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In the first stage of step S3, the lightweight anomaly detection model adopts the TCN-Transformer lightweight architecture and is pre-trained based on the multimodal fusion representation vector of historical normal and abnormal operating conditions. An anomaly confidence threshold is set. When the anomaly confidence of a sample is greater than or equal to the threshold, it is determined to be an abnormal sample. At the same time, the modal dimension, occurrence time and parameter change magnitude corresponding to the anomaly are marked. Normal samples are directly stored in the production database and do not enter the second stage of the diagnostic process.
6. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In the second stage of step S3, the construction method of the large language model in the oil and gas well domain is as follows: an open-source general-purpose large language model is selected as the base, and continuous pre-training is performed based on text data in the oil and gas well domain, injecting domain professional knowledge; based on the historical multimodal fault data and diagnostic result matching dataset, LoRA low-rank adaptation technology is used for fine-tuning to obtain a large language model specifically for the oil and gas well domain; at the same time, a retrieval enhancement RAG system based on a vector database is constructed to retrieve relevant matching knowledge from the domain knowledge base based on the features of abnormal samples, providing support for model inference.
7. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In the second stage of step S3, the fault classification adopts a four-level classification rule, specifically: Level 1 faults are emergency anomalies that may cause major safety accidents and require immediate shutdown and handling; Level 2 faults are serious anomalies that may lead to production stoppage and a significant drop in output and require handling within 24 hours; Level 3 faults are general anomalies that have a certain impact on production but will not lead to production stoppage and require handling within 72 hours; Level 4 faults are early minor anomalies that have no significant impact on production and require key attention during daily inspections.
8. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In step S4, the handling plan includes handling priority, step-by-step operation process, required equipment and materials, safety precautions, handling effect verification standards and experience reference for handling similar faults; interpretable text includes diagnostic logic chain, abnormal feature evidence, historical case matching, corresponding industry standard clauses and root cause reasoning process; multimodal supporting data includes abnormal time series curves, fault image fragments, audio waveform diagrams and relevant case text fragments.
9. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In step S4, the visualization output is achieved through a visualization platform, and the displayed content includes a real-time operating condition dashboard, anomaly alarm pop-ups, fault root cause analysis graphs, handling plan flowcharts, and multimodal supporting data panels; at the same time, according to the fault level, alarm information and handling plans are pushed to the corresponding operation and maintenance personnel and management personnel.
10. The method for diagnosing oil and gas well production anomalies by integrating a large language model according to claim 1, characterized in that, In step S5, the incremental fine-tuning specifically involves: collecting on-site handling feedback data, consistency data between actual faults and diagnostic results, and newly added fault case data, and updating them to the training dataset and domain knowledge base after preprocessing. Incremental learning is employed, combined with catastrophic forgetting suppression techniques, to perform incremental fine-tuning on the multimodal embedding fusion model, the anomaly screening model, and the domain-specific large language model. After passing performance testing, the online model version is updated to complete the closed-loop iteration.