A knowledge graph driven small sample pumping unit fault diagnosis method and system
Patent Information
- Application Number
- CN202610914625.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-24
- Publication Date
- 2026-09-15
AI Technical Summary
但这些方法存在两方面的不足:其一,语义嵌入与数据原型的融合权重通常是固定的,不能根据当前任务中支持集样本的数量和质量进行自适应调整;其二,语义信息仅在原型层面注入,未作用于样本特征表示,无法从数据层面缓解小样本带来的特征退化问题
[0026] By explicitly integrating knowledge graphs into the few-shot learning loop and guiding the construction of meta-tasks through graph relationships, the support set and query set samples in the meta-tasks are semantically related along the symptom paths. The task distribution closely matches real-world fault diagnosis scenarios, significantly improving the model's generalization ability across fault classes and avoiding ineffective training caused by random task construction. Compared to traditional randomly sampled meta-tasks, the tasks constructed in this invention follow physical causal relationships, enabling the model to learn the evolutionary patterns of faults during the training phase, fundamentally improving the efficiency of few-shot learning.
Smart Images

Figure CN122751985A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial equipment fault diagnosis and intelligent operation and maintenance technology, and in particular to a knowledge graph-driven method and system for diagnosing small-sample oil pumping units. Background Technology
[0002] Pumping units are critical equipment in oilfield production, and their operational status directly affects crude oil output and operational safety. Traditional fault diagnosis relies on manual inspections and dynamometer card analysis, which is inefficient and highly subjective, making it difficult to meet the needs of digital transformation in oilfields. In recent years, data-driven intelligent diagnostic methods have developed rapidly. Deep neural networks can automatically extract fault features from massive amounts of monitoring data, achieving high-precision identification. However, pumping unit faults are often sporadic, and in actual production, it is difficult to accumulate sufficient standard samples for each fault mode, especially for rare faults, compound faults, or faults under new operating conditions, where the available samples are often only a handful. Under such small sample conditions, deep models are prone to overfitting, leading to a sharp drop in diagnostic accuracy and severely insufficient generalization. Furthermore, the operating parameters of different oil wells, such as stroke, number of strokes, and pump hanger depth, vary significantly, causing the signal manifestation of the same fault to drift, further exacerbating the difficulty of small-sample diagnosis. Therefore, how to achieve accurate and robust pumping unit fault diagnosis under conditions of extremely limited labeled samples is one of the core challenges of industrial intelligent operation and maintenance.
[0003] To alleviate the problem of few-shot errors, meta-learning and metric learning methods have been introduced into the field of fault diagnosis, such as prototype networks and matching networks. Prototype networks calculate the mean of each class of samples in the embedding space as a prototype, and then classify based on the distance between the query sample and the prototype. In few-shot scenarios, prototype networks are simple and effective, but when the support set is extremely small, the prototype, composed of only one or two sample means, is highly unstable and easily affected by noisy samples, leading to a shift in the classification boundary. Matching networks use an attention mechanism to weight the support set samples, but they also heavily rely on the quality of the support set samples and do not introduce any external knowledge for constraint. While these methods can learn cross-task generalization capabilities on a large number of historical tasks, their essence remains entirely data-driven, failing to effectively utilize long-accumulated domain knowledge, such as fault mechanisms, component correlations, and expert experience. This knowledge contains the inherent laws of fault evolution and is extremely valuable for constraining the few-shot learning space and improving diagnostic robustness. For example, the fault of a leaking travel valve, based on equipment structure knowledge, is necessarily related to the travel valve's auxiliary components and often exhibits signs of a sudden drop in dynamometer load. If this kind of knowledge can be effectively integrated into the diagnostic model, it can assist in the judgment based on structural causal relationships, even if the training samples are scarce.
[0004] On the other hand, knowledge graphs, as a graph-structured knowledge base, can systematically express semantic relationships between entities and have begun to be applied to industrial fault diagnosis. For example, constructing a device-fault-symptom knowledge graph and performing fault reasoning through graph traversal or graph matching. However, such methods usually require a one-to-one mapping between fault instances and graph nodes. When there are few fault category samples, the correspondence in the graph is sparse, limiting reasoning ability and making it difficult to handle fault patterns that are not fully recorded. Other methods attempt to combine knowledge graphs with graph neural networks, using node embedding to improve fault classification performance. However, these methods often form a large-scale heterogeneous graph of devices, faults, and symptoms and perform inductive node classification on this graph. When a new fault category is added, the new node needs to be added to the graph and retrained, resulting in poor scalability and still relying on a large number of labeled instances for node representation learning, failing to effectively handle small sample scenarios. In addition, some studies introduce category semantic embedding as a prototype prior in prototype networks, such as using fault text descriptions or knowledge graph embeddings, to fuse with data prototypes with fixed weights. However, these methods have two shortcomings: First, the fusion weights of semantic embedding and data prototypes are usually fixed and cannot be adaptively adjusted according to the quantity and quality of support set samples in the current task; second, semantic information is only injected at the prototype level and does not affect the sample feature representation, thus failing to alleviate the feature degradation problem caused by small samples at the data level. In other words, existing knowledge fusion methods have failed to fully explore the rich structural relationships in the knowledge graph, such as the hierarchical path of "symptom-location-component," to enhance the feature representation of each diagnostic sample.
[0005] It is particularly noteworthy that current meta-task construction in few-shot learning generally employs random category and sample selection, neglecting the inherent physical semantic relationships within the task. In oil pumping unit fault diagnosis, different fault categories may exhibit drastically different combinations of symptoms. If tasks are constructed randomly, it is highly likely that the support set samples and query set samples will belong to physically unrelated subspaces, making it difficult for the meta-learner to learn effective diagnostic patterns. Therefore, how to introduce structured causal relationships from knowledge graphs into meta-task generation, ensuring that the task distribution aligns with the physical world of faults, is a crucial but unresolved issue for improving the generalization of few-shot diagnosis.
[0006] Therefore, how to fully utilize the structured priors of domain knowledge graphs and deeply integrate them with data-driven few-shot learning methods, both by enhancing representations through graph relationships at the sample feature level and by adaptively incorporating knowledge graph embeddings into prototype computation, so as to achieve high-precision and strong-generalization pumping unit fault diagnosis under few-shot conditions, is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0007] This invention aims to provide a knowledge graph-driven method and system for diagnosing small-sample oil pumping unit faults. By constructing an oil pumping unit fault knowledge graph and designing a graph semantic-guided meta-learning framework, graph attention-enhanced sample representation, and fusion prototype computation, the method overcomes the barriers of small-sample and domain knowledge utilization, significantly improving diagnostic performance.
[0008] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0009] A knowledge graph-driven method for diagnosing small-sample oil pumping unit faults includes the following steps:
[0010] S1. Collect operating status data of the oil pumping unit under various operating conditions, perform data preprocessing and feature extraction, and form a sample set labeled with fault type and at least one symptom entity label; the symptom entity label is obtained by establishing a mapping relationship with symptom entities in the knowledge graph, specifically: based on expert rules or a lightweight classifier, determine whether the sample features match the description of a certain symptom, and if they match, add the corresponding symptom entity label to the sample.
[0011] S2. Based on knowledge of the pumping unit domain, construct a fault knowledge graph. Graph entities should include at least fault type, symptoms, components, causes, and measures; relationships should include at least manifestation, location, cause, and solution. Fill the graph according to the hierarchical structure and causal relationships of "fault-manifestation → symptom-location → component". This graph explicitly encodes the physical path of pumping unit fault propagation.
[0012] S3. Embedding learning is performed on the fault knowledge graph to obtain a low-dimensional vector representation of each entity as a domain semantic prior, and all entity vectors are fixed; the preferred embedding method is the translation-based TransE model.
[0013] S4. Based on the "manifestation" relationship path between fault type entities and symptom entities, and the "location" relationship path between symptom entities and component entities, a set of meta-tasks for small-sample learning is constructed from the sample set. Each meta-task includes a support set and a query set. During meta-task construction, for each fault class, samples in the sample set with symptom entity labels associated with the fault via "manifestation" are preferentially selected. If the number of samples in a certain class is less than K, samples with corresponding labels are retrieved from other symptom entities associated along the "manifestation" path to supplement the set, ensuring that the support set samples have semantic association with the fault class. This construction method essentially uses the physical causal chain contained in the knowledge graph as a constraint condition for task generation, ensuring that each meta-task follows the objective law of "fault-manifestation-symptom-location-component," avoiding semantic mismatch of tasks that may be caused by random construction, and enabling the meta-learner to master the physical associations required for diagnosis during training.
[0014] S5. Using the data points of the sample to be diagnosed as nodes, calculate the similarity between the sample node and all symptom entity vectors in the knowledge graph, and select the symptom entities with the highest similarity as first-level neighbors; using the existing "located" relationships in the knowledge graph, designate the component entities connected to the first-level neighbors as second-level neighbors; construct a heterogeneous graph with the sample node as the center, together with the first-level neighbors and second-level neighbors, with the sample node connected to the first-level neighbors through attention edges, and the first-level neighbors connected to the second-level neighbors through relation edges; apply a multi-head graph attention network to the heterogeneous graph for information propagation, updating only the representation of the sample node to obtain knowledge-enhanced sample features; during the propagation process, the vectors of the first-level neighbors and second-level neighbors come from fixed knowledge graph embeddings and do not participate in the update, thereby maintaining the stability of the graph semantics while introducing structured knowledge and preventing knowledge from being erroneously drifted under small sample conditions.
[0015] S6. For each meta-task, calculate the fusion prototype for each category in its support set. The fusion prototype is obtained by weighting the mean of the enhanced features of the support samples of that category with the entity embedding vector of that fault type in the knowledge graph using a learnable balancing factor. The learnable balancing factor is constrained to the range (0,1) by the sigmoid function and is jointly optimized with the parameters of feature extraction and graph attention network in the outer loop of meta-training. This allows the model to adaptively adjust its reliance on prior knowledge and data observations based on the quantity and quality of the support set samples in each meta-task, rather than relying on fixed hyperparameters. This adaptive mechanism is key to achieving prototype stability under small sample sizes.
[0016] S7. Use the fusion prototype to measure the distance to the query set samples and classify them. With the goal of minimizing the meta-task classification loss, train the graph attention network parameters and fusion factor, while keeping the knowledge graph embedding parameters fixed. The training adopts a meta-learning process optimized by second-order gradient. The inner loop updates the weights quickly on the support set, and the outer loop optimizes the basic network parameters.
[0017] S8. Deploy the trained model to the fault diagnosis system, perform feature enhancement in step S5 and prototype matching in step S6 on the sample of the pumping unit to be diagnosed, and output the fault diagnosis results. For new fault types, only entities and relationships need to be added to the graph, and a fusion prototype needs to be calculated using a small number of samples. There is no need to retrain the model.
[0018] A knowledge graph-driven small-sample oil pumping unit fault diagnosis system includes:
[0019] The data acquisition and feature extraction module is used to acquire the operating status signal of the oil pumping unit and extract fault-sensitive features, while labeling the samples with fault type and at least one symptom entity label.
[0020] The knowledge graph construction and embedding module is used to define entities and relationships in the oil pumping unit fault domain, construct a knowledge graph and perform embedding learning, and generate and store a fixed entity vector library.
[0021] The meta-task generation module is connected to the knowledge graph construction and embedding module and the sample set. Based on the fault-manifestation-symptom-location-component path in the knowledge graph, it extracts samples with corresponding symptom tags from the sample set to construct small sample meta-tasks. This module generates tasks by constraining the semantic path of the knowledge graph, ensuring that the support set and the query set have physical consistency at the symptom level, thereby guiding the meta-learner to learn the discrimination pattern that conforms to the fault evolution law.
[0022] The graph attention enhancement network module receives sample features and selects neighbors based on the similarity with the symptom entity vector. It constructs a heterogeneous graph containing sample nodes, symptom entities, and component entities. Through multi-head attention, it aggregates neighbor information only on sample nodes and outputs enhanced sample features. This module encodes component structure information into the sample features, effectively alleviating the feature degradation problem under small sample conditions.
[0023] The fusion prototype diagnosis module is connected to the graph attention enhancement network module and the knowledge graph construction and embedding module. It is used to obtain the mean value of the enhancement features of each category in the support set, read the corresponding fault entity embedding from the entity vector library, fuse them by weighted according to the learnable balance factor, calculate the fusion prototype, and determine the fault category of the query sample based on the distance metric. The learnable balance factor is automatically optimized in the meta-training outer loop and can adaptively adjust the fusion ratio of prior and data according to the quality of the support set.
[0024] The model training and inference coordination module controls the internal and external training processes of meta-learning, keeps the knowledge graph embedding fixed during training, updates only the graph attention network and fusion factors, and coordinates the various modules to complete online diagnosis.
[0025] Compared with the prior art, the beneficial effects of the present invention are:
[0026] By explicitly integrating knowledge graphs into the few-shot learning loop and guiding the construction of meta-tasks through graph relationships, the support set and query set samples in the meta-tasks are semantically related along the symptom paths. The task distribution closely matches real-world fault diagnosis scenarios, significantly improving the model's generalization ability across fault classes and avoiding ineffective training caused by random task construction. Compared to traditional randomly sampled meta-tasks, the tasks constructed in this invention follow physical causal relationships, enabling the model to learn the evolutionary patterns of faults during the training phase, fundamentally improving the efficiency of few-shot learning.
[0027] By leveraging graph attention networks to propagate information along the knowledge graph, relevant symptoms and component semantics are dynamically aggregated for each sample. With fixed graph embeddings, only the sample representation is updated. This approach prevents overfitting to the knowledge graph while incorporating domain knowledge. The generated enhanced features combine data-driven patterns with component structural information, effectively mitigating representation degradation in small sample sizes. In particular, through two-hop aggregation based on "representation" and "location," hierarchical knowledge of "fault-symptom-component" is embedded in the sample features. Even if the original data features are affected by noise, they can still be corrected at the knowledge level.
[0028] In prototype computation, fault entity embeddings from the atlas are introduced as prior prototypes. A learnable balancing factor dynamically adjusts the weights of the data prototype and the prior prototype, making class centers more stable and accurate under small sample conditions. This factor also adapts to the sample quality of different fault classes, significantly improving the accuracy of classification boundaries. When the support set samples are extremely small, the model automatically favors the prior knowledge to avoid prototype bias; when the samples are relatively abundant, it places greater trust in the data prototype, making full use of observational information. This adaptive adjustment capability is not possessed by fixed-weight fusion methods.
[0029] It supports inductive diagnostics. When a new fault type appears that was not included in the training, it can be identified simply by adding the corresponding entity and relationship to the knowledge graph and calculating its fusion prototype using a small number of samples, without retraining the entire model. This feature has good scalability and practicality. This characteristic significantly reduces the cost of field deployment and maintenance in oilfields. Attached Figure Description
[0030] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0031] Figure 1 This is the main flowchart of the method of the present invention.
[0032] Figure 2 This is a structural diagram of a knowledge graph for oil pumping unit malfunctions.
[0033] Figure 3 This is a schematic diagram of the small-sample meta-learning training process driven by knowledge graphs.
[0034] Figure 4 This is a schematic diagram illustrating how a graph attention network enhances the updating of sample features.
[0035] Figure 5 A flowchart illustrating the prototype computation and classification principles for integrating knowledge graph embedding.
[0036] Figure 6 This is a module structure diagram of the fault diagnosis system.
[0037] Figure 7 This is a timing interaction diagram for online system diagnostics. Detailed Implementation
[0038] To make the technical problems to be solved, the technical solutions, and the beneficial effects of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present invention and are not intended to limit the present invention.
[0039] Example 1: Small Sample Pumping Unit Fault Diagnosis Based on Dysfunction Diagram
[0040] This embodiment applies the method of the present invention to the dynamometer card diagnosis scenario of common pumping unit faults. Fault types include floating valve leakage, fixed valve leakage, pump top collision, pump bottom collision, sucker rod breakage, and well sand production. The number of samples for these faults in actual production is extremely uneven; some categories have only a few historical cases, making it difficult for traditional deep learning methods to train effectively.
[0041] Step 1: Data Acquisition and Feature Extraction. Load and displacement signals during the up and down strokes are simultaneously acquired using load and displacement sensors installed at the pumping unit's suspension cable, forming a ground dynamometer map. After normalization and noise reduction preprocessing, geometric and frequency domain features are extracted from the dynamometer map. Geometric features include, but are not limited to, the location of curvature inflection points, the dynamometer map envelope area ratio, and the difference between maximum and minimum loads. Frequency domain features utilize the first few orders of the Fourier descriptor coefficients. All features are concatenated into a fixed-dimensional feature vector. Simultaneously, based on expert experience and fault diagnosis manuals, each sample is labeled with a fault type. Furthermore, according to the correspondence between the shape features of the dynamometer map and the symptoms, at least one symptom entity label is manually added or through rule-based reasoning, such as sudden load drop, abnormal slope in the loading segment, or jitter in the unloading segment. These symptom labels strictly correspond to symptom entities in the knowledge graph, thus establishing a mapping bridge between samples and the knowledge graph.
[0042] Step 2: Construct a knowledge graph of pumping unit faults. Referring to the pumping unit maintenance manual, fault diagnosis expert experience, and equipment structure, define entity types: fault types such as traveling valve leakage and fixed valve leakage; symptoms such as sudden load drop on the indicator diagram and current fluctuations; components such as traveling valve assembly, fixed valve seat, and crank pin; causes such as valve ball wear, scaling, and sand discharge; and measures such as replacing the valve assembly and chemical dewaxing. Define relationships: fault - manifestation → symptom, symptom - located in → component, fault - cause → cause, cause - solution → measure, component - contains → component, etc. Use these entities and relationships to construct a directed heterogeneous graph and store it in a graph database. Each relationship in the graph has a clear direction and physical meaning, forming a clear causal path from fault to component. This graph explicitly expresses the physical association that traveling valve leakage manifests as a sudden load drop on the indicator diagram, and that the load drop phenomenon is located in the traveling valve assembly, laying the knowledge foundation for subsequent semantic construction tasks.
[0043] Step 3: Knowledge Graph Embedding Learning. The TransE embedding model, based on translation, is used to train embeddings of entities and relations in the graph. The optimization objective is to make the sum of the head entity vector and the relation vector approximately equal to the tail entity vector. After training, each entity receives a low-dimensional dense vector, such as a fault entity vector or a symptom entity vector. All entity vectors are then fixed and no longer participate in gradient updates during subsequent meta-learning training. This fixing strategy ensures the stability of knowledge semantics, prevents the graph embeddings from being incorrectly updated and losing structured priors during training with a small number of samples, and allows the model to focus on how to utilize this stable knowledge.
[0044] Step 4: Meta-task Construction. Unlike the random categories and random sample extraction in conventional few-shot learning, this invention generates a few-shot classification task based on the association structure of a knowledge graph, using the graph's semantic path as a hard constraint for task construction. Specifically: For a fault type F, the set of directly associated symptom entities is found in the graph through "representation" relationships. When constructing the N-way K-shot task, N categories are randomly selected from all fault types. For each category k, samples with the fault label and any symptom label from the aforementioned symptom entity set are retrieved from the sample set. If the number of retrieved samples is less than K, secondary related symptom entities related to fault k are searched along the "representation" relationship path, such as other symptoms bridged by component entities. These are then used to expand the support set samples until K samples are found or the upper limit of available samples is reached. Query set samples are randomly extracted from the remaining matching samples. The task constructed in this way generates support and query set samples not randomly, but within a semantic framework of the same fault type and the same symptom path. This forces the meta-learner to focus on the physical connection between faults and symptoms, rather than the surface noise of data distribution. This fundamentally avoids the problem of the support set and query set symptoms being unrelated that may occur in the construction of random tasks, making each meta-task a simulation of a real diagnostic scenario.
[0045] Step 5: Graph Attention Enhancement Sample Representation. For each sample point x in the meta-task, its original feature is f. First, a multilayer perceptron maps f to the same dimension as the knowledge graph entity embedding, obtaining the initial sample node feature h^(0). Then, the cosine similarity between h^(0) and all symptom entity vectors in the graph is calculated, and the M symptom entities with the highest similarity are selected as first-level neighbor nodes. This similarity-based neighbor selection mechanism enables each sample to dynamically activate the knowledge graph symptom most relevant to its current performance, achieving personalized knowledge introduction. Based on the existing "located" relationships in the knowledge graph, the component entities connected to each first-level neighbor are obtained as second-level neighbor nodes. Thus, a three-layer heterogeneous graph is constructed: the center is the sample node, the second layer is the first-level neighbor (symptom), and the third layer is the second-level neighbor (component). The sample node and the first-level neighbor are connected by attention edges, and the weight of the attention edges is calculated by the interaction between the sample node vector and the symptom entity vector; the first-level neighbor and the second-level neighbor are connected by relationship edges, the relationship edge type is "located", and the strength is fixed at 1. A multi-head graph attention network is applied to this local graph to aggregate neighbor information and update the representation of the sample nodes. The update formula is shown in equation (1):
[0046] (1)
[0047] in, For sample nodes The set of first-level neighbors, The attention coefficients are obtained by performing a linear transformation on the features of the sample node and its first-level neighbor nodes, and then applying LeakyReLU and softmax. It is a learnable linear transformation matrix; The ReLU activation function is used. During this process, the vectors of first-level and second-level neighbors remain fixed and do not participate in the update; only the representation of the sample node is iteratively updated. Through multi-hop information aggregation, the sample node indirectly incorporates component structure information, enabling the enhanced features to not only include the variation patterns of the data itself but also embed structured knowledge of which component anomaly typically causes the symptom. This significantly enhances the discriminative power and interpretability of the features under small sample conditions, effectively compensating for feature degradation caused by insufficient data.
[0048] Step 6: Fusion Prototype Calculation. On the support set S of the N-way K-shot task, for each class k, first calculate the mean prototype of the enhancement features of the support samples for that class. Simultaneously, obtain the entity embedding vector corresponding to that fault class from a fixed knowledge graph embedding library. The fusion prototype is calculated using equation (2):
[0049] (2)
[0050] in, For category Support set, For enhancing features of sample x, For category The fixed embedding vector of the corresponding faulty entity in the knowledge graph. The balancing factor is a learnable element, constrained within an open interval of 0 to 1 by the sigmoid function. The key point is... These are not fixed hyperparameters set manually, but rather adaptive coefficients learned through gradient descent along with the graph attention network parameters and feature map parameters in the meta-training outer loop. When the number or quality of support samples for a certain class is extremely small, the data prototype may deviate significantly from the true center; in this case, the meta-optimization will automatically increase... This makes the fusion prototype rely more on graph priors. Conversely, when the support set samples are relatively sufficient and have good consistency, It automatically reduces the size and trusts the data prototype. This adaptive capability allows the prototype calculation to remain stable under different small sample conditions, which is the core difference between this invention and the fixed-weight fusion scheme.
[0051] Step 7: Classification Loss and Meta-Optimization. For the query set samples... Calculate its enhanced features With various fusion prototypes The Euclidean distance is calculated, and the predicted probability distribution is obtained through the softmax function. Training employs a MAML-style process with second-order gradient optimization: the inner loop calculates the loss on the support set and updates the one-step or multi-step fast weights of the sample representation mapping network; the outer loop accumulates the gradient on the query set loss and updates the graph attention network parameters, the initial parameters of the mapping network, and the fusion factor. The knowledge graph embedding is fixed throughout the process and does not participate in any gradient calculations. Through iterative training with a large number of meta-tasks, the model ultimately gains the ability to quickly adapt and accurately diagnose new fault categories with only a very small number of labeled samples.
[0052] Step 8: Online Diagnosis. For the newly collected indicator diagram samples of the new pumping unit, feature extraction, graph neighbor retrieval, and graph attention enhancement are performed. Fault entity embeddings are obtained from a fixed knowledge graph embedding library, and various fault fusion prototypes retained during the training phase are directly used. Distance classification is performed, and diagnostic results are output. For new fault types, only the corresponding entities and relationships need to be added to the graph, and the enhanced features are obtained through forward propagation using a small number of samples of the new type. Substituting these features into equation (2) will calculate the fusion prototype of the new fault, without needing to retrain the entire model. This gives the system good field scalability.
[0053] Example 2: Small Sample Fault Diagnosis Across Oil Well Conditions
[0054] In actual production, pumping units are deployed in different oil wells, and the operating parameters of each well, such as stroke, number of strokes, pumping depth, and crude oil viscosity, vary, causing signal drift for the same fault mode. Traditional methods often require collecting a large amount of labeled data for each well to retrain the model, which is extremely costly. This embodiment demonstrates how to achieve cross-well small-sample diagnosis using the present invention. That is, through a single training, the model can be shared among multiple oil wells, and only a very small number of samples are needed to adapt it to new oil wells.
[0055] Based on Example 1, this example extends as follows: During knowledge graph construction, a "working condition" entity type is added, such as high stroke rate, deep pump hanger, high water cut, heavy oil, etc., and a "correlated working condition" relationship is established with fault and symptom entities. In the data annotation of step 1, in addition to fault type and symptom labels, the working condition parameter range of the well to which each sample is located is additionally labeled, mapped to the corresponding working condition entity label. During meta-task construction, cross-well task sampling uses working condition entities as conditions: the sample set is layered according to working condition entities. When sampling N fault categories, it is ensured that the support set samples come from one working condition domain, while the query set samples come from another working condition domain. Simultaneously, along the fault-related working condition → working condition entity path and the fault-manifestation → symptom path, sample pairs with common symptom semantics in the two working condition domains are selected to generate cross-working condition meta-tasks. This construction again utilizes graph semantic constraints, forcing the model to learn to extract the working condition-independent fault essence from working condition-related signal manifestations during the training phase. When enhancing graph attention, the neighbor selection range of sample nodes is expanded to include working condition entities: when selecting first-level neighbors for similarity calculation, both symptom entities and working condition entities are considered, thus encoding working condition context information in the enhanced features. The calculation and training process of the fusion prototype is consistent with Example 1. When only a few labeled samples are needed for new oil wells, prior embedding and adaptation in the fusion prototype are used. This allows for rapid adaptation to new working conditions and accurate diagnosis.
[0056] Example 3: Small Sample Diagnosis Based on Multi-Source Signals and Complex Faults
[0057] Oil pumping unit failures are sometimes not single-type but rather complex, such as simultaneous fixed valve leakage and sand production. Diagnosing complex failures is more challenging because their signal manifestations are a coupling of multiple individual fault characteristics, and labeled samples of complex failures are often extremely scarce in actual production. This embodiment combines two data sources—dynamometer diagrams and motor current signals—and expands the complex failure entity in the knowledge graph to demonstrate the invention's ability to diagnose complex failures with a small sample size.
[0058] First, a motor current sensor is added to synchronously acquire current waveforms, extracting time-domain statistical features and frequency-domain features to form a current feature vector. The dynamometer feature vector and the current feature vector are mapped to the knowledge graph embedding dimension through their respective independent feature mapping networks, resulting in two initial sample nodes. These are then fused element-wise as a unified input. During knowledge graph construction, composite fault entities are added, connected to single fault entities through "containment" relationships, and symptom entities specific to composite faults are defined. In the graph attention enhancement stage, sample nodes simultaneously establish neighbor connections with symptom entities related to both signals and introduce components through "located" relationships. During prototype fusion calculation, the data prototype of the composite fault category is embedded and fused with the composite fault entity. Because the knowledge graph encodes the combined semantics of composite and single faults, the fused prototype can effectively represent the characteristics of the composite fault even with a very small number of support set samples. Query samples can accurately identify composite fault categories by calculating the distance to each fused prototype. This embodiment further verifies the effectiveness of the invention under multi-source signals and complex fault modes.
[0059] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0060] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A knowledge graph-driven method for diagnosing faults in small-sample oil pumping units, characterized in that, include: Acquire pumping unit operating status data, extract features, and form a sample set labeled with fault type and at least one symptom entity label; Construct a knowledge graph of pumping unit failures, wherein the entities in the knowledge graph include at least failure type, symptoms, and components, and the relationships include at least manifestation and location. The knowledge graph is embedded to obtain low-dimensional vector representations of entities, and all entity vectors are fixed. Based on the "representation" relationship path between fault type entities and symptom entities, and the "location" relationship path between symptom entities and component entities, a meta-learning task containing a support set and a query set is constructed from the sample set for each fault category, wherein the support set samples are selected along the path by their symptom entity labels. For a sample to be diagnosed, calculate its similarity to all symptom entity vectors in the knowledge graph, and select the symptom entities with the highest similarity as first-level neighbors; according to the "located" relationship, obtain the component entities connected to the first-level neighbors as second-level neighbors; construct a heterogeneous graph containing sample nodes, first-level neighbors, and second-level neighbors, with attention edges between sample nodes and first-level neighbors, and relationship edges between first-level neighbors and second-level neighbors; apply a multi-head graph attention network to the heterogeneous graph to propagate information, updating only the sample node representation to obtain enhanced sample features; For each meta-task, a fusion prototype for each category in its support set is computed. The fusion prototype is obtained by weighting the mean of the enhanced features of the support samples of that category with the entity embedding vector of that fault type in the knowledge graph using a learnable balance factor. The fusion prototype is used to classify the query set samples by distance metric. By minimizing the meta-task classification loss, the graph attention network parameters and the learnable balance factor are optimized. For new pumping unit samples, the enhanced sample feature extraction and fusion prototype matching are performed, and the fault diagnosis results are output.
2. The method as described in claim 1, characterized in that, The construction of the knowledge graph for pumping unit failures further includes: defining entity types such as failure, symptoms, components, causes, and measures, as well as relationship types such as manifestation, location, cause, and solution; extracting historical failure cases, maintenance records, and expert knowledge, and filling the graph according to the hierarchical structure and causal relationship of "failure-manifestation → symptom-location → component".
3. The method as described in claim 1, characterized in that, The meta-learning task is constructed as follows: N fault categories are randomly selected. For each category k, samples with fault label k and any symptom entity label associated with the fault through the "manifestation" relationship are retrieved from the sample set as candidate support sets. If the number of candidate samples is less than K, the associated symptom entity set is expanded by supplementing samples of the same type with expanded symptom labels until K are satisfied or the available samples are exhausted. The query set is extracted from the remaining matching samples.
4. The method as described in claim 1, characterized in that, During the propagation of the graph attention network on the heterogeneous graph, the sample nodes The update formula is: in, For sample nodes The set of first-level neighbors, The attention coefficients are normalized using softmax. It is a learnable linear transformation matrix. The activation function is used; the vectors of first-level and second-level neighbors come from fixed knowledge graph embeddings and are not updated.
5. The method as described in claim 1, characterized in that, The calculation method for the fusion prototype is as follows: in, For category Support set, For the sample Enhanced features, For category The fixed embedding vector of the corresponding faulty entity in the knowledge graph. It is a learnable balance factor, constrained between (0,1) by the sigmoid function.
6. The method as described in claim 1, characterized in that, The distance metric classification uses Euclidean distance, and the probability of a query sample belonging to each category is calculated using the softmax function. During training, second-order gradient optimization is used, with the inner loop updating the weights quickly on the support set and the outer loop optimizing the graph attention network and fusion factor. The knowledge graph embedding is fixed throughout the process.
7. The method as described in claim 1, characterized in that, The symptom entity label is obtained in the following way: based on expert rules or a lightweight classifier, it is determined from the sample features whether it conforms to the description of a certain symptom entity in the knowledge graph. If it does, the symptom entity label is added to the sample to establish a mapping between the sample and the symptom in the knowledge graph.
8. The method as described in claim 1, characterized in that, For new fault types, add corresponding fault entities and their relationships with symptoms and components to the knowledge graph, and generate enhanced features from a small number of samples of the new type according to step S5. Calculate the fusion prototype using the calculation method of the fusion prototype, which can expand the diagnostic range without retraining the model.
9. A knowledge graph-driven small-sample oil pumping unit fault diagnosis system, characterized in that, include: The data acquisition and feature extraction module is used to acquire the operating status signal of the oil pumping unit and extract fault-sensitive features, while labeling the samples with fault type and at least one symptom entity label. The knowledge graph construction and embedding module is used to define entities and relationships in the oil pumping unit fault domain, construct a knowledge graph and perform embedding learning, and generate and store a fixed entity vector library. The meta-task generation module is connected to the knowledge graph construction and embedding module. Based on the path of fault-manifestation → symptom-location → component in the knowledge graph, it extracts samples with corresponding symptom tags from the sample set to construct small sample meta-tasks. The graph attention enhancement network module receives sample features, selects neighbors by calculating the similarity with the symptom entity vector, constructs a heterogeneous graph containing sample nodes, symptom entities, and component entities, and uses multi-head attention to aggregate information only on sample nodes to output enhanced sample features. The fusion prototype diagnosis module is connected to the graph attention enhancement network module and the knowledge graph construction and embedding module. It is used to calculate the mean value of the enhancement features of each category in the support set, obtain the fixed embedding of the fault entity from the entity vector library, and fuse them into a fusion prototype by weighting according to the learnable balance factor. It also determines the fault category of the query sample based on the distance metric. The model training and inference coordination module is used to control the internal and external training processes of meta-learning, keep the knowledge graph embedding fixed, update the graph attention network and fusion factors, and coordinate online diagnosis.
10. The system as described in claim 9, characterized in that, The graph attention enhancement network module specifically performs the following steps: It maps the original features of the samples to the same dimension as the knowledge graph embedding using a multilayer perceptron; calculates the cosine similarity between the mapped vector and all symptom entity vectors; selects the M symptom entities with the highest similarity as first-level neighbors; obtains the component entities of the first-level neighbors as second-level neighbors through the "location" relationship of the graph; performs multi-head attention on this local heterogeneous graph subgraph, aggregating neighbor information to update the sample nodes, while keeping the embeddings of the first-level and second-level neighbors fixed.