Electrical drawing analysis method and system based on few-sample learning
By integrating few-shot learning and electrical domain rule verification, the problems of data dependency and generalization ability in the automated parsing of electrical drawings are solved, achieving efficient and accurate parsing of electrical drawings. It can handle non-standard drawings and generate structured knowledge that can be used in engineering.
Patent Information
- Application Number
- CN202511380365.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2026-01-06
AI Technical Summary
Existing technologies for automated parsing of electrical drawings suffer from problems such as strong data dependence, weak generalization ability, high maintenance costs, poor flexibility, and inability to deeply understand engineering semantics, making it difficult to meet the needs of deep semantic understanding and structured parsing of diverse and non-standard electrical drawings.
This paper employs a few-shot learning approach, performing domain-adaptive training on a pre-trained multimodal large model and combining prompt words with electrical engineering domain rules to achieve automated parsing of electrical drawings. The method includes acquiring sample data, domain-adaptive training, generating prompt words, model inference, and result verification. Parameter fine-tuning is performed using low-rank adaptive or adapter tuning techniques, and the parsing results are stored through a knowledge graph.
It significantly reduces data dependence and cost, achieves high accuracy and strong generalization ability, can handle non-standard, hand-drawn or noisy drawings, ensures the engineering usability and accuracy of the analysis results, and realizes the leap from symbol recognition to engineering understanding.
Smart Images

Figure CN121281084A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method and system for parsing electrical drawings based on few-shot learning. Background Technology
[0002] Automated parsing of electrical drawings is a key technology for realizing intelligent operation and maintenance and digital transformation of power systems.
[0003] There are two main approaches to current technology. The first is a recognition approach based on traditional deep learning. This approach typically uses a deep learning model based on convolutional neural networks to identify electrical components, combines optical character recognition (OCR) technology to extract text information, and analyzes the topological connections between components using image processing algorithms. The drawbacks of this approach are that it requires a large-scale, finely annotated dataset of drawings for model training, resulting in strong data dependence, high annotation costs, and weak generalization ability for new drawing styles or non-standard symbols, leading to a significant drop in recognition accuracy. Furthermore, whenever a new type of component needs to be identified, the entire model often needs to be retrained, resulting in high maintenance costs and long iteration cycles.
[0004] The second approach is a template-matching-based parsing scheme. This scheme uses a predefined library of standard electrical symbol templates to locate and identify symbols within the drawing. The drawback of this scheme is its severe lack of flexibility. It is highly sensitive to symbol rotation, scaling, deformation, and issues such as drawing damage or occlusion, resulting in poor robustness. Furthermore, this scheme requires maintaining multiple independent template libraries for different industry standards, leading to a huge workload in management and expansion. Moreover, this method is entirely based on geometric feature matching and cannot understand the engineering logic and contextual semantics embedded in the drawing, making it prone to misidentification in complex scenarios.
[0005] In summary, existing technologies cannot achieve a balance between low cost, high efficiency, and high accuracy, and are insufficient to meet the practical needs for in-depth semantic understanding and structured analysis of diverse and non-standard electrical drawings. Summary of the Invention
[0006] The purpose of this application is to provide an electrical drawing parsing method and system based on few-shot learning, so as to solve the problems of strong data dependence, weak generalization ability, high maintenance cost, poor flexibility and inability to deeply understand engineering semantics in the existing technology of automated electrical drawing parsing.
[0007] To achieve the above objectives, this application provides the following technical solution: Firstly, this application provides a method for parsing electrical drawings based on few-shot learning, which includes the following steps: Obtain sample data containing electrical drawing images and their corresponding structured knowledge annotations; Based on the sample data, the pre-trained multimodal large model is subjected to domain-adaptive training to obtain the drawing analysis model; Based on the sample data and the predefined knowledge graph schema, prompt words are generated to guide the drawing parsing model in parsing the drawings; The electrical drawing image to be parsed and the prompt words are input into the drawing parsing model to obtain an initial parsing result containing electrical entities and the relationships between entities; Based on preset rules in the field of electrical engineering, the initial analysis results are verified and corrected to generate the final structured knowledge.
[0008] Based on the above method, optionally, the domain-adaptive training of the pre-trained multimodal large model specifically includes: freezing the main parameters of the pre-trained multimodal large model using a parameter-efficient fine-tuning technique, and training only the parameters introduced by the parameter-efficient fine-tuning technique.
[0009] Based on the above methods, the parameter fine-tuning technique may optionally include low-rank adaptive or adapter tuning.
[0010] Based on the above method, optionally, the prompt words adopt a three-part structure, including: system prompt words for setting the role of the drawing parsing model; task prompt words for clarifying the drawing parsing task objectives; and example prompt words for standardizing the output format of the initial parsing results.
[0011] Based on the above method, optionally, the steps of generating prompt words and inputting the electrical drawing image to be parsed and the prompt words into the drawing parsing model specifically include: adopting a multi-step prompt word strategy to decompose the drawing parsing task into multiple sub-tasks, and generating corresponding prompt words for each sub-task; executing the multiple sub-tasks in a preset order, wherein the output of the previous sub-task serves as the context information for the input of the next sub-task.
[0012] Based on the above method, optionally, the multiple sub-tasks include: an entity recognition task for identifying electrical components and their locations; a text association task for associating component models and parameters; and a relationship building task for constructing connections between components.
[0013] Based on the above methods, optionally, the verification and correction based on preset electrical engineering rules specifically includes at least one of the following: performing entity standardization, mapping the identified entity names to preset standard terms; performing relationship verification, checking whether the connection relationship between entities conforms to electrical principles or engineering specifications; and performing consistency checks, detecting whether there are isolated device nodes that are not connected to other components.
[0014] Based on the above method, optionally, the verification and correction steps further include: on the user interface, generating a prompt message for manual review for results in the initial analysis result with a confidence level lower than a preset threshold or that violate the rules of the electrical engineering field; receiving a correction instruction for the prompt message input through the user interface, and converting the correction instruction into new annotation data for updating the drawing analysis model or the rules of the electrical engineering field.
[0015] Based on the above method, optionally, the method further includes: storing the final structured knowledge in a graph database to construct a knowledge graph.
[0016] Secondly, embodiments of this application also provide an electrical drawing parsing system based on few-shot learning, which includes: The data acquisition module is used to acquire sample data containing electrical drawing images and their corresponding structured knowledge annotations; The training module is used to perform domain-adaptive training on the pre-trained multimodal large model based on the sample data obtained by the data acquisition module, so as to obtain the drawing analysis model. The prompt word generation module is used to generate prompt words to guide the drawing parsing model in parsing drawings, based on the sample data obtained by the data acquisition module and the predefined knowledge graph schema. The reasoning module is used to input the electrical drawing image to be parsed and the prompt words into the drawing parsing model to obtain an initial parsing result containing electrical entities and the relationships between entities; In addition, a verification module is used to verify and correct the initial analysis results based on preset electrical engineering rules in order to generate the final structured knowledge.
[0017] Compared with existing technologies, this application systematically integrates few-shot learning, cue word engineering, and electrical domain rule verification, which has the following advantages: 1. Significantly reduces data dependence and cost; only a small number of samples are needed to complete the domain-adaptive training of the model, greatly reducing the cost and cycle of data collection and labeling; 2. Achieve high accuracy and strong generalization ability. Through domain-adaptive training of multimodal large models and precise guidance from prompt words, it can effectively handle non-standard, hand-drawn or noisy drawings. 3. Achieve deep engineering semantic understanding, enabling the parsing of engineering logic contained in drawings, thus realizing a leap from symbol recognition to engineering understanding; 4. Ensure the engineering usability of the analysis results. By introducing verification and correction steps based on rules in the field of electrical engineering, erroneous results that do not conform to engineering specifications can be automatically filtered out, ensuring that the final generated structured knowledge is accurate and reliable. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. Furthermore, these drawings and textual descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concepts of this application to those skilled in the art through reference to specific embodiments.
[0019] Figure 1 A functional architecture diagram of an electrical drawing parsing system based on few-shot learning is provided for embodiments of this application; Figure 2 A flowchart illustrating an electrical drawing parsing method based on few-shot learning, provided as an embodiment of this application; Figure 3 This is a schematic diagram of the adaptive prompt word template structure provided in an embodiment of this application. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the embodiments of this application. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0021] Example 1 This embodiment provides a basic implementation scheme for an electrical drawing parsing method and system based on few-shot learning. It aims to fully demonstrate the entire process from data preparation, model training, inference parsing to result verification, so as to achieve efficient and accurate automated parsing of electrical drawings.
[0022] Reference Figure 1This document illustrates the functional architecture of an electrical drawing parsing system provided in this application embodiment. Specifically, the system can be divided into four main layers. At the bottom is the data and model layer 10, which provides the basic data and model resources for the entire system. This includes a drawing database for storing massive amounts of electrical drawings, a sample library for model training containing a small number of high-quality annotations, and a pre-trained multimodal large model as a technical starting point. Above this is the core engine layer 20, which serves as the core for executing drawing parsing tasks. It integrates multiple collaborative modules, including a domain-adaptive training module 21 responsible for model optimization, a prompt word generation module 22 responsible for constructing task instructions, a model inference module 23 responsible for executing parsing tasks, and a post-processing verification module 24 responsible for ensuring result quality. The processing results of the core engine layer 20, i.e., structured knowledge, are transmitted to the knowledge storage layer 30 for persistence. This layer is typically implemented as a knowledge graph database. At the top is the application interface layer 40, which serves as the window for system interaction with the outside world, providing users or downstream applications with services such as data querying, graph analysis, and result visualization.
[0023] The method flow provided in this embodiment can be referred to Figure 2 As shown, the entire process begins with sample data acquisition step S100, providing the foundation for subsequent model training and prompt word generation. The process then unfolds in parallel into two key preparatory steps: the first is domain-adaptive training step S200, designed to adapt the general-purpose model to the specific characteristics of the electrical field; the second is prompt word generation step S300, which creates clear instructions for the parsing task. After the preparatory work is completed, the process enters the core model inference step S400, combining the drawings to be parsed, the trained model, and the generated prompt words for intelligent parsing. After inference, preliminary parsing data, which may contain noise, is obtained in the initial result acquisition step S500. To ensure engineering usability, the initial results must undergo verification and correction step S600, using domain rules to clean and correct them. Finally, in the final knowledge generation step S700, high-quality structured knowledge is output, thus completing the entire parsing process.
[0024] The following will combine Figures 1 to 3 The specific implementation details of this embodiment will be described in detail.
[0025] First, execute the corresponding Figure 2 Step S100 involves acquiring and preparing sample data. This means acquiring sample data containing electrical drawing images and their corresponding structured knowledge annotations.
[0026] In this embodiment, this step can be performed by a system administrator or domain expert. Twenty to fifty representative high-voltage power distribution primary system diagrams are carefully selected from the drawing database as initial samples. These diagrams should cover as many different design styles, symbol standards, and common equipment types as possible. Subsequently, these diagrams are meticulously annotated by professional electrical engineers. The annotation is in the form of structured knowledge, specifically using a "entity-relationship-entity" triple format. For example, in a scenario where an air circuit breaker (designated ACB1) supplies power to a busbar (designated MCC1) in a drawing, the annotator would generate a triple: ("ACB1", "connected to", "MCC1"). Simultaneously, entity attributes are also annotated, such as ("ACB1", "model", "Masterpact MTZ") and ("ACB1", "rated current", "1600A"). All these annotations together constitute structured knowledge annotation.
[0027] Simultaneously, a knowledge graph schema needs to be predefined. This schema, serving as the skeleton of the knowledge graph, defines the allowed entity types (e.g., air circuit breakers, transformers, busbars, feeders, etc.), entity attributes (e.g., model, rated current, voltage level, etc.), and allowed relationship types between entities (e.g., connected to, supplied to, belongs to, etc.). This schema provides a unified standard for subsequent model training and result validation.
[0028] All the annotated drawing images and their corresponding triplet data together constitute the sample data, which is stored in the sample library of data and model layer 10 for use in subsequent steps.
[0029] Secondly, the execution corresponds to Figure 2 The next step, S200, involves domain-adaptive training of the model. This means that based on sample data, the pre-trained multimodal large model is subjected to domain-adaptive training to obtain the drawing analysis model.
[0030] This step aims to transform a general pre-trained multimodal large model into a specialized drawing parsing model proficient in electrical drawing analysis, which can be automatically executed by the domain adaptive training module 21 in the core engine layer 20. In this embodiment, a high-performance open-source multimodal large model (such as the Qwen-VL model) is selected from the data and model layer 10 as the base. To achieve efficient and high-quality training with a small number of samples (20-50 in this example), this embodiment employs a parameter-efficient fine-tuning technique, specifically, the low-rank adaptive LoRA technique. During training, the domain adaptive training module 21 freezes the original, large number of main parameters of the pre-trained large model to preserve the general visual and language capabilities learned by the model from massive amounts of data. Correspondingly, additional, trainable low-rank matrices are injected into key parts of the model (such as the attention layer of the Transformer structure). During training, only the parameters of these newly injected, minimal low-rank matrices are updated. In this way, the model can quickly learn and absorb professional knowledge in the electrical field without changing its basic capabilities, such as recognizing specific electrical symbols and understanding the topological relationships between symbols. This training method not only greatly reduces the demand for computing resources, but also effectively avoids the overfitting problem that is prone to occur when performing full fine-tuning on small datasets. After training, the optimized model is the drawing analysis model, which is stored in the core engine layer 20 or updated back to the data and model layer 10 for inference.
[0031] Again, execute the corresponding Figure 2 The adaptive prompt word generation in step S300 involves generating prompt words based on sample data and a predefined knowledge graph schema to guide the drawing parsing model in drawing parsing.
[0032] This step is performed by the prompt word generation module 22 in the core engine layer 20. It should be noted that a well-designed prompt word can greatly improve the understanding ability of a large model and the quality of the output results. In this embodiment, a structured three-segment prompt word template is designed and adopted, the structure of which can be referred to... Figure 3 .
[0033] Reference Figure 3 The template includes: 1. System prompt 410 for setting the role of the drawing analysis model: This section is used to set a clear "role" for the drawing analysis model, thereby activating its related knowledge base. For example, system prompt 410 could be set as: "You are a professional electrical engineer, proficient in electrical drawing analysis and interpretation. Your task is to accurately and comprehensively convert the input electrical drawing images into structured knowledge data. Please strictly follow the specified format to output the results." 2. Task prompt word 420 used to clarify the task objectives of drawing analysis: This section is used to issue specific and clear analysis tasks, and can be dynamically generated according to the type of drawing to be analyzed or the specific needs of the user. For example, for a high-voltage power distribution diagram, task prompt word 420 can be set as: "Please identify all circuit breakers, transformers, busbars, capacitors, and reactors in the drawing. For each identified component, please extract its equipment number, model, rated voltage, and rated current. At the same time, please analyze and extract the physical connection relationships between these components." 3. Example prompts for standardizing the initial parsing output format 430: This section demonstrates the desired output format to the model by providing one or more input / output examples (i.e., few-sample examples), which is crucial for ensuring the structured and standardized nature of the output. For example, a complete JSON object can be provided as an example, clearly defining the two keys "entities" (a list of entities) and "relationships" (a list of relationships), and showing the specific fields of each entity and relationship object.
[0034] The prompt generation module 22 will combine these three parts into a complete prompt based on the task requirements, for use in subsequent reasoning steps.
[0035] Subsequently, model inference and result generation are performed, a process that encompasses... Figure 2 The model reasoning step S400 and the initial result acquisition step S500 are as follows: The electrical drawing image to be parsed and the prompt words are input into the drawing parsing model to obtain the initial parsing results containing electrical entities and the relationships between entities.
[0036] The core executor of this process is the model inference module 23. When a user uploads an electrical drawing image to be parsed through the application interface layer 40, the image, along with a parsing request, is sent to the model inference module 23. Upon receiving the request, the model inference module 23 first requests a prompt word suitable for the current task from the prompt word generation module 22. After receiving the constructed three-part prompt word, the model inference module 23 takes the drawing image to be parsed and the prompt word as input and calls the drawing parsing model that has been trained adaptively in the domain. Under the precise guidance of the prompt word, the model performs in-depth visual and semantic analysis on the drawing image, identifies the electrical entities and their attributes in the image, and understands the connections between them. After the inference is completed, the model generates an initial parsing result according to the format specified in the example prompt word 430. This result is usually a JSON string containing a list of all electrical entities identified by the model and the relationships between them; this is the output of the initial result acquisition step S500.
[0037] Next, execute the corresponding Figure 2The results of step S600 are verified and corrected. This involves verifying and correcting the initial analytical results based on pre-defined rules in the electrical engineering field to generate the final structured knowledge.
[0038] Because large models may produce "illusions" or errors that contradict common sense in engineering during the reasoning process, the initial analysis results must be rigorously verified and corrected. This step is performed by the post-processing verification module 24. The post-processing verification module 24 is pre-configured with a rule base based on rules in the electrical engineering field. This rule base can be stored in the knowledge storage layer 30 and continuously updated by experts. In this embodiment, the rule base contains at least the following three types of rules: 1. Entity standardization rules: used to unify terminology. For example, the rule base defines the standard name "air circuit breaker" and maps various variants that the model may recognize, such as "ACB", "Air Circuit Breaker", and "air switch", to "air circuit breaker" through table lookup or fuzzy matching.
[0039] 2. Relationship Verification Rules: These rules are used to check the rationality of the topology connections. These rules are derived from electrical principles and engineering design specifications. For example, one rule might be "One end of a circuit breaker must be connected to the power supply side (such as a busbar or transformer), and the other end must be connected to the load side (such as a feeder or another busbar)"; another rule might be "In the same electrical circuit, the rated voltage levels of all series-connected components should match." The post-processing verification module 24 iterates through each relation triplet in the initial results and verifies it using these rules.
[0040] 3. Consistency Check Rules: Used to detect global structural errors. For example, one rule is "check for isolated device nodes in the diagram," meaning a device entity that never appears in the relationship list, or whose all connections point to itself. Understandably, such isolated nodes usually indicate an identification error or a problem with the drawing itself.
[0041] The post-processing verification module 24 applies these rules one by one, scanning the initial parsing results. For data that does not conform to the rules, the system can adopt different strategies, such as directly discarding it, marking it as low confidence, or attempting automatic correction based on the context. This step can greatly improve the accuracy and reliability of the final output knowledge.
[0042] Finally, the execution corresponds to Figure 2The final knowledge generation and storage in step S700. After verification and correction steps S600, clean, standardized, and accurate structured knowledge is obtained. The model reasoning module 23 sends these verified triples to the knowledge storage layer 30 and stores them in a graph database (e.g., Neo4j). In the graph database, each electrical entity is created as a node, the attributes of each entity become the attributes of that node, and the relationships between entities are created as edges connecting the nodes. In this way, a static electrical drawing image is successfully transformed into a dynamic, queryable, and analyzable electrical knowledge graph. Finally, the parsing result or success status can be returned to the user through the application interface layer 40.
[0043] Through the above steps, this embodiment can quickly train a high-precision electrical drawing analysis model with minimal manual annotation cost, and combine it with domain rule verification to ensure that the quality of the final generated knowledge graph data meets the requirements of engineering applications.
[0044] Example 2 It should be noted that the technical solution of this application is not limited to a specific multimodal large model or a specific parameter fine-tuning technique. This embodiment aims to illustrate the universality and flexibility of the technical solution, demonstrating that the technical effects to be achieved by using other models and training strategies can also be realized.
[0045] In this embodiment, the overall architecture of the system (such as...) Figure 1 (as shown) and method flow (such as) Figure 2 (As shown) is consistent with Example 1. The main difference lies in the base model and training technique used in the domain adaptive training step S200.
[0046] Regarding model selection, as an optional implementation, this embodiment uses another popular open-source vision-language pre-trained model (such as the LLaVA model) as the base model. This model also has powerful image and text understanding capabilities and can be used as an alternative to the Qwen-VL model in Embodiment 1.
[0047] Regarding the training strategy, this embodiment employs another mainstream parameter-efficient fine-tuning technique, namely Adapter-Tuning, to replace the low-rank adaptive LoRA used in Embodiment 1. Specifically, when performing the training task, the domain adaptive training module 21 inserts small neural network modules called "adapters" between the layers of the Transformer structure of the pre-trained LLaVA model. These adapter modules typically have a bottleneck structure, meaning they first project high-dimensional features to a low-dimensional space, then, after a nonlinear transformation, project them back to the original high-dimensional space. During domain adaptive training, all the original parameters of the LLaVA model are frozen; only the parameters of these newly inserted adapter modules, which have a very small number of parameters, are set to a trainable state.
[0048] The training process is as follows: The sample data containing 20-50 labeled samples prepared in Example 1 is input into the LLaVA model loaded with the adapter module. Using the standard gradient descent algorithm, only the weights of the adapter module are optimized, enabling it to learn the ability to map general features to electrical domain-specific features.
[0049] During inference, the model inference module 23 loads both the pre-trained LLaVA main model and the trained adapter modules. When the drawing image and prompts are received, the input data flows through these adapter modules simultaneously with the main model, enabling the model's output to combine general capabilities with domain-specific knowledge.
[0050] The subsequent steps, including the generation of prompt words (S300), model reasoning (S400), obtaining initial results (S500), rule-based verification and correction (S600), and the generation and storage of final knowledge (S700), are implemented in exactly the same way as described in Example 1.
[0051] As can be seen from this embodiment, the core idea of this application—namely, to efficiently fine-tune the parameters of a pre-trained large model using a small number of sample data, combined with prompt word engineering and domain rule post-processing—has good scalability. Developers can flexibly choose different base large models and different efficient parameter fine-tuning techniques (whether it is low-rank adaptive LoRA, adapter-tuning, or other similar techniques such as prefix-tuning) according to actual conditions (such as model performance, hardware resources, community support, etc.), all of which can achieve low-cost and high-efficiency domain adaptation, thereby achieving the beneficial effects expected by this application and avoiding the technical route being locked by a single supplier or specific technology.
[0052] Example 3 For electrical drawings with exceptionally complex structures, extremely high information density, or significant overlap and obstruction, using the single-prompt word approach in Example 1 for end-to-end parsing may lead to the model being unable to process all details at once, resulting in information omissions or disordered relationships. As an alternative implementation, this example demonstrates a more refined parsing strategy: employing a dynamic multi-step prompt word strategy. This strategy decomposes the complex parsing task into a series of simpler, more focused sub-tasks, and completes the parsing step by step through a "thinking chain" approach.
[0053] The method in this embodiment still follows the overall process. Figure 2 The framework shown is similar, but the core difference lies in the enhanced implementation of the prompt generation step S300 and the model inference step S400. Specifically, these two steps are merged and iteratively executed, forming a multi-step inference loop.
[0054] In this embodiment, the prompt word generation module 22 and the model reasoning module 23 work together to decompose a complete drawing analysis task into the following three consecutive sub-tasks, each using specially designed prompt words: Step 1: Entity Recognition Task. The goal of this task is to first locate all individual electrical components in the drawing, regardless of their specific parameters and connections. To this end, the prompt generation module 22 generates prompts for this step, such as: “Task: Electrical Component Recognition. Carefully examine the input drawing image, identify and list all visible electrical components in the drawing, such as circuit breakers, transformers, busbars, etc. For each identified component, provide its category and location coordinates in the drawing (e.g., bounding box coordinates [x_min, y_min, x_max, y_max]). Output the results as a JSON list, where each object contains two fields: 'type' and 'bbox'.” The model inference module 23 inputs the drawing image and the prompts into the drawing parsing model. After the model performs inference, it outputs a JSON list containing all identified components and their location information.
[0055] Step 2: Text Association Task. The goal of this task is to associate the text annotations in the drawing with the electrical components identified in the previous step. The model inference module 23 uses the original drawing image and the component list JSON output from the first step as context information, and the prompt word generation module 22 generates the prompt words for the second step. For example: "Context: The component list and its location in the drawing have been identified. Task: Component parameter association. Based on the provided component list, please find the text annotations near the corresponding locations in the drawing image and associate each component with its detailed parameters such as equipment number, model, rated current, and voltage level. Please update the input JSON list and add attribute fields such as 'id', 'model', and 'current' to each component object." The model performs inference again, this time focusing on the vicinity of each component, using its optical character recognition and understanding capabilities to read the text and associate it with the corresponding component, and then outputs an updated component list JSON containing detailed parameters.
[0056] Step 3: Relationship Building Task. This is the final step, and its goal is to analyze the topological connections between components. The model inference module 23 uses the original drawing image and the JSON component list with detailed parameters output from Step 2 as context, and the prompt word generation module 22 generates prompt words for Step 3. For example: "Context: All components and their detailed parameters have been identified. Task: Topological relationship building. Please analyze the wiring and connection relationships between these components and build 'connected to' or 'powered by' relationships between them. Please output all relationships in the format of 'entity-relationship-entity' triples, where entities should use their device numbers. The final output is a JSON object containing the 'relationships' key." In this step, the model focuses on analyzing the lines and connection points in the drawing, combining the component location information to infer the electrical connection logic between them, and outputs the final relationship list.
[0057] Through the above three steps, a complex parsing task is decomposed and completed. It is understood that the output of each step provides a solid foundation and clear context for the next step, effectively reducing the complexity of a single-step task and thus significantly improving the accuracy and completeness of parsing complex drawings. The outputs of these three sub-tasks are finally merged to form a complete initial parsing result, which is then sent to the post-processing verification module 24 for verification and correction steps S600, the process of which is exactly the same as in Example 1.
[0058] This embodiment demonstrates the flexibility and power of prompt word engineering. By combining task decomposition and step-by-step reasoning, it can effectively cope with more challenging parsing scenarios, providing a more robust and refined implementation path for the technical solution of this application.
[0059] Example 4 While the rule-based automated verification described in Example 1 can filter out most obvious errors, some engineering logic errors that are not covered by the rule base or are very subtle may still exist. Furthermore, the automated rules themselves require continuous iteration and improvement. Therefore, this example, building upon Example 1, introduces a human-machine collaborative verification closed-loop mechanism, combining automated verification with review by domain experts. The aim is to establish a system capable of continuous learning and self-optimization, striving to approach 100% parsing accuracy.
[0060] The core of this embodiment is the extension of the verification and correction step S600, and the enhancement of the interaction between the system and the user. The overall system architecture and module interactions are as follows: Figure 1 As shown, the post-processing verification module 24 has enhanced functionality and workflow.
[0061] The specific implementation is as follows: First, the processing logic of the post-processing verification module 24 is modified when it performs automated verification. When a parsed result (an entity or a relation) is detected to violate electrical engineering rules, or when the model's confidence score for its prediction is lower than a preset threshold (e.g., 70%), the system no longer directly rejects or attempts to automatically correct it. Instead, the system marks the suspicious result.
[0062] Secondly, the system generates prompts for manual review of these flagged suspicious results. These prompts are structured and displayed on a user interface designed for domain experts, provided by the application interface layer 40. The prompts typically include, but are not limited to: 1. Original drawing fragment: Extract a partial drawing image containing suspicious results and highlight the relevant components or connecting lines.
[0063] 2. Preliminary judgment of the model: Display the initial analytical results of the model output, such as ("Circuit breaker A", "Connected to", "Circuit breaker B").
[0064] 3. Reason for system labeling: Clearly state the reason why the result was labeled, such as "confidence too low (65%)" or "rule violation: two circuit breakers cannot be directly connected in series".
[0065] The electrical engineer (user) can then log into the user interface to view this "manual review queue." For each message in the queue, the engineer can interact with it, for example: Error Confirmation: If the engineer agrees with the system's judgment, the result can be confirmed as an error and removed from the final result.
[0066] Corrections: If an engineer finds a model identification error that can be corrected, they can directly modify the data on the interface. For example, correcting the incorrect entity type "capacitor" to the correct "reactor," or correcting an incorrect connection.
[0067] Ignore warnings: If an engineer determines that this is a special but reasonable engineering design, and the system rules are too rigid, leading to misjudgment, he can ignore the warning and confirm that the result is correct.
[0068] As the core of this closed-loop mechanism, the system captures every review operation by the engineer and receives it as a correction instruction. For example, when an engineer changes an entity type from "A" to "B", the system records this operation. Understandably, this correction instruction is extremely valuable because it is equivalent to a domain expert providing high-quality, targeted data annotation.
[0069] The system will automatically convert these correction instructions into new annotation data. For example, an engineer's correction operation can be converted into a new, correct triplet annotation or entity attribute annotation. This newly generated, high-quality annotation data will be added back to the sample library of data and model layer 10.
[0070] This accumulated new labeled data can be used for continuous optimization in two aspects: 1. Incremental Model Optimization: After accumulating a certain number of new samples (e.g., 100), the domain adaptive training module 21 can be triggered periodically to perform an incremental fine-tuning of the drawing parsing model, enabling it to learn from previous mistakes and avoid similar errors in the future.
[0071] 2. Rule Base Update: By analyzing warnings that are frequently "ignored" by experts, it may indicate that existing validation rules are flawed or overly stringent. The system can summarize these situations and provide them to the rule maintenance personnel as a basis for optimizing and updating the internal rule base of the post-processing validation module 24.
[0072] By introducing this closed-loop mechanism of human-machine collaboration, this embodiment constructs an electrical drawing parsing system capable of continuous learning and self-evolution. The system's accuracy is no longer static, but continuously improves with increased usage time and expert review, ultimately ensuring the high quality and high availability of the knowledge graph, and providing a more advanced and intelligent implementation method for the "verification and correction" steps of this application.
[0073] Compared with the prior art, the solutions in the above embodiments have the following advantages by systematically integrating few-shot learning, prompt word engineering, and electrical domain rule verification: 1. Significantly reduces data dependence and cost; only a small number of samples are needed to complete the domain-adaptive training of the model, greatly reducing the cost and cycle of data collection and labeling; 2. Achieve high accuracy and strong generalization ability. Through domain-adaptive training of multimodal large models and precise guidance from prompt words, it can effectively handle non-standard, hand-drawn or noisy drawings. 3. Achieve deep engineering semantic understanding, enabling the parsing of engineering logic contained in drawings, thus realizing a leap from symbol recognition to engineering understanding; 4. Ensure the engineering usability of the analysis results. By introducing verification and correction steps based on rules in the field of electrical engineering, erroneous results that do not conform to engineering specifications can be automatically filtered out, ensuring that the final generated structured knowledge is accurate and reliable.
[0074] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0075] It should be noted that, in the description of this invention, unless otherwise stated, "a plurality of" means at least two.
[0076] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0077] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. An electrical diagram parsing method based on few-shot learning, characterized by, The method comprises the following steps: obtaining sample data comprising electrical drawing images and their corresponding structured knowledge annotations; based on the sample data, the pre-trained multi-modal large model is subjected to domain adaptation training to obtain a drawing analysis model; based on the sample data and a pre-defined knowledge graph Schema, prompt words are generated to guide the drawing analysis model to analyze the drawing; the electrical drawing image to be analyzed and the prompt words are input into the drawing analysis model to obtain an initial analysis result comprising electrical entities and inter-entity relationships; based on pre-set electrical engineering domain rules, the initial analysis result is verified and corrected to generate the final structured knowledge.
2. The method of claim 1, wherein, The domain adaptation training of the pre-trained multi-modal large model specifically comprises: using a parameter-efficient fine-tuning technique to freeze the main parameters of the pre-trained multi-modal large model, and only training part of the parameters introduced by the parameter-efficient fine-tuning technique.
3. The method of claim 2, wherein, The parameter-efficient fine-tuning technique includes low-rank adaptation LoRA or adapter tuning Adapter-Tuning.
4. The method of claim 1, wherein, The prompt words adopt a three-section structure, including: system prompt words for setting the role of the drawing analysis model; task prompt words for clearly defining the task target of drawing analysis; and example prompt words for specifying the output format of the initial analysis result.
5. The method of claim 1, wherein, Among them, The step of generating prompt words and the step of inputting the electrical drawing image to be analyzed and the prompt words into the drawing analysis model specifically comprise: using a multi-step prompt word strategy to decompose the drawing analysis task into multiple sub-tasks, and generating corresponding prompt words for each sub-task; the multiple sub-tasks are executed in a pre-set order, wherein the output of a previous sub-task is used as the context information input for a subsequent sub-task.
6. The method of claim 5, wherein, The multiple sub-tasks include: an entity recognition task for identifying electrical components and their positions; a text association task for associating component models and parameters; and a relationship construction task for constructing the connection relationships between components.
7. The method of claim 1, wherein, The verification and correction based on the pre-set electrical engineering domain rules specifically comprise at least one of the following: performing entity standardization to map the identified entity names to pre-set standard terms; performing relationship verification to check whether the connection relationships between entities conform to electrical principles or engineering specifications; performing consistency checking to detect whether there are isolated device nodes that are not connected to other components.
8. The method of claim 1, wherein, The verification and correction steps further comprise: on a user interface, generating prompt information for manual review for results in the initial analysis result that have a confidence level below a pre-set threshold or violate the electrical engineering domain rules; receiving correction instructions input through the user interface in response to the prompt information, and converting the correction instructions into new annotation data for updating the drawing analysis model or the electrical engineering domain rules.
9. The method of claim 1, wherein, The method further comprises: storing the final structured knowledge in a graph database to construct a knowledge graph.
10. An electrical diagram sheet analysis system based on few-shot learning, characterized by, It comprises: a data acquisition module for acquiring sample data comprising electrical drawing images and their corresponding structured knowledge annotations; The training module is configured to perform field self-adaptive training on the pre-trained multi-modal large model based on the sample data obtained by the data acquisition module, so as to obtain a drawing analysis model. The prompt word generation module is configured to generate a prompt word for guiding the drawing analysis model to analyze the drawing based on the sample data obtained by the data acquisition module and a predefined knowledge graph Schema. The inference module is configured to input an electrical drawing image to be analyzed and the prompt word into the drawing analysis model, so as to obtain an initial analysis result containing electrical entities and relationships between the entities. The verification module is configured to verify and correct the initial analysis result based on a preset electrical engineering field rule, so as to generate a final structured knowledge.