Method and system for constructing power domain model
Through bottom-up methods and large-model technology, intelligently generate and update the knowledge graph triplets, the existing domain modeling methods rely on manpower and complex construction process are solved, and rapid and flexible domain model construction and iterative upgrades are achieved.
Patent Information
- Application Number
- CN202411768388.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-03-25
AI Technical Summary
The existing field modeling methods rely on a large amount of manpower to participate, the construction process is complex and difficult to complete quickly and effectively, and it is difficult to measure the quality of modeling.
Using a bottom-up approach, large-scale model technology is used to intelligently and automatically assist in the generation and update of knowledge graph triplets, and optimize the knowledge graph through entity fusion strategies and vectorized representations to generate a power field model.
It reduces human participation, improves the efficiency and accuracy of domain model construction, and achieves rapid and flexible iteration and upgrading of domain models.
Smart Images

Figure CN119691198A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of power systems, and more specifically, to a method and system for constructing a power field model. Background Art
[0002] Knowledge graph is a structured semantic knowledge base used to quickly describe concepts and their relationships in the physical world. Knowledge graph effectively processes, processes and integrates the data of complex documents into simple and clear "entity-relationship-entity" triples, and finally aggregates a large amount of knowledge to achieve rapid response and reasoning of knowledge. With the continuous development of intelligent information service applications, knowledge graphs have been widely used in intelligent search, intelligent question and answer, personalized recommendation, intelligence analysis, anti-fraud and other fields. In addition, through knowledge graphs, information, data and link relationships on the Web can be aggregated into knowledge, making information resources easier to calculate, understand and evaluate, and forming a set of Web semantic knowledge bases. With its powerful semantic processing capabilities and open interconnection capabilities, knowledge graphs can lay a solid foundation for knowledge interconnection on the World Wide Web.
[0003] Domain models are often used in software development and system design to better understand and solve complex problems. They describe the entities, rules, and relationships in the business domain, and determine the static and dynamic relationships that should exist between business personnel and the objects they process and use in order to produce the expected results. The domain model is a bridge from requirements analysis to object-oriented design, and is an object model that describes the implementation of business use cases.
[0004] Through domain modeling, domain knowledge can be injected into large knowledge graphs, providing a technical foundation for the application of knowledge graphs in vertical fields. Traditionally, domain modeling is generally done through external tools to build models, such as class diagrams, UML diagrams, etc. These technologies can effectively represent the static view of class definitions and describe the properties and methods of classes. At the same time, dynamic views of object collaboration can also be displayed through interaction diagrams, allowing people to see the true appearance of items and be able to modify them in real time. Domain modeling technology can be based on a variety of methods and tools, such as UML, ERD, etc. Among them, UML can be used to build class diagrams, object diagrams, sequence diagrams, etc. of software systems. ERD tools are diagramming tools used to build data models, which can be used to describe data entities and the relationships between them.
[0005] In traditional solutions, domain modeling is a process of manually building each domain model by relying on external tools. For example, first understand the needs and goals of the business domain, including business processes, functions, performance, etc., to provide a basis for modeling. Then, sort out the current business to be modeled, including business rules, core business scenarios in the domain, and specific business processes, and identify entities and attributes from the business. Entities represent objects in the business, and attributes describe the characteristics of these objects. Based on the identified entities and attributes, establish a domain model. The domain model can include class diagrams, object diagrams, sequence diagrams, etc., which are used to describe the relationships and interactions between entities to establish a domain model.
[0006] The original domain modeling solution has the following problems. First, the top-down construction of the domain model requires the participation of a large number of domain experts. The construction of the ontology involves complex levels, relationship combing, entity extraction and entity relationship maintenance. This process requires a lot of manpower to comb through, and it is difficult to complete the construction of the domain model quickly and effectively. In addition, the quality of modeling is difficult to measure. Although there are some auxiliary design tools now, the problem of building a domain model has not been solved.
[0007] In view of the above problems, a method and system for constructing a power field model is urgently needed. Summary of the invention
[0008] In order to solve the deficiencies in the prior art, the present invention provides a method and system for constructing a power field model. In the process of upgrading the traditional architecture to the microservice architecture, a bottom-up approach is adopted, and large model technology is applied to use physical models to intelligently and automatically assist in generating and updating knowledge graph triples.
[0009] The present invention adopts the following technical solution.
[0010] The first aspect of the present invention relates to a method for constructing an electric power domain model, the method comprising the following steps: collecting electric power text from an electric power knowledge base, constructing a triple prompt word template in the electric power domain, extracting electric power text according to the template content and constructing an initial electric power knowledge graph; calculating the degree of the entity, thereby generating a first entity fusion strategy according to the position of the entity in the initial electric power knowledge graph; obtaining a vectorized representation of a non-edge entity, thereby generating a second entity fusion strategy according to the degree of repetition between non-edge entities; presetting the convergence condition of the electric power knowledge graph, and using the first entity fusion strategy and the second entity fusion strategy to calculate the entity quantification index of the electric power knowledge graph during each iteration of the electric power knowledge graph, and if the entity quantification index meets the convergence condition, generating an electric power domain model; the convergence condition is that the coupling degree representing the correct connection between entities in the electric power domain model within a preset range is the lowest, and the aggregation degree index representing the close relationship of the model should be the highest.
[0011] Preferably, power texts are collected from the power knowledge base to construct a triple prompt word template in the power field, including: the triple prompt word template includes entity, relationship, and attribute information; the entity includes personnel roles and work content in the power system; the relationship and attributes between the entities are determined based on the output style and rule constraints of the information in the power system.
[0012] Preferably, the degree of the entity is calculated, thereby generating an entity fusion strategy based on the position of the entity in the electric power knowledge graph, including: dividing the entities in the electric power knowledge graph into edge entities and non-edge entities according to the degree of the entity, and calculating the similarity between the edge entities and the non-edge entities; if the similarity exceeds a first preset threshold, setting the fusion operation between the current edge entity and its corresponding non-edge entity as a first entity fusion strategy.
[0013] Preferably, calculating the similarity between the edge entity and the non-edge entity includes:
[0014]
[0015] In the formula, e i and e j and non-marginal entities, respectively;
[0016] attributes(·) is a collection of attributes of the entity.
[0017] TF(e,k) is the term frequency of the kth attribute in entity e.
[0018] Preferably, a vectorized representation of the non-edge entity is obtained, thereby generating a second entity fusion strategy based on the degree of repetition between the non-edge entities, including: constructing a vectorized representation of the non-edge entity using the vector of each attribute in the non-edge entity and the weight of each attribute; calculating the similarity between any two non-edge entities using the cosine similarity of the vectorized representations between any two non-edge entities; if the similarity between any two non-edge entities exceeds a second preset threshold, setting the fusion operation between the current two non-edge entities as a second entity fusion strategy.
[0019] Preferably, constructing a vectorized representation of the non-edge entity using the vector of each attribute in the non-edge entity and the weight of each attribute includes: the vectorized representation of the non-edge entity is:
[0020]
[0021] In the formula, a k is the kth attribute in entity e,
[0022] A(e) is the attribute set of entity e,
[0023] w k is the weight of the kth attribute in entity e,
[0024] v k is the vector representation of the kth attribute in entity e in the knowledge graph space.
[0025] Preferably, if the similarity between any two non-edge entities exceeds a second preset threshold, the fusion operation between the current two non-edge entities is set as a second entity fusion strategy, including: in the second entity fusion strategy, the non-edge entity e j and non-edge entities e l The new entity after fusion new The vectorization of is the simple addition of vector values in each spatial dimension:
[0026]
[0027] The properties collection of the new entity is:
[0028] A(e new )=attributes(e j )∪attributes(e l )
[0029] Each attribute a in the new entity k,new The weight and vector of are expressed as:
[0030]
[0031] Preferably, the first entity fusion strategy and the second entity fusion strategy are used to calculate the entity quantitative indicators of the power knowledge graph during each iteration of the power knowledge graph, including: selecting one or more elements from the pre-generated first entity fusion strategy and second entity fusion strategy sets, and modifying the initial power knowledge graph through the selected elements to obtain an iteration; after completing one iteration, calculating the coupling degree and aggregation degree of the power knowledge graph after the iteration to determine whether the power knowledge graph after the iteration meets the preset conditions; if so, ending the iteration and generating the power knowledge graph; if not, continuing to the next iteration until the preset conditions are met.
[0032] Preferably, the convergence condition is that the coupling degree representing the correct connection between entities in the power field model within a preset range has the lowest value, and the aggregation index representing the close relationship of the model should be the highest, including: the convergence condition for the lowest coupling degree representing the correct connection between entities is:
[0033]
[0034] In the formula,
[0035] R m,n =num({d|d∈t m ∩t n})
[0036] t m and t n The knowledge graph G consists of the node set E and the edge set T respectively. e (E,T) and any two entities e m and e n The set of connected edges;
[0037] t m ∩t n For entity e m and e n The edge between
[0038] d is the set t m ∩t n The elements in
[0039] num({d|d∈t m ∩t n}) is the set t m ∩t n The number of elements d in ;
[0040] The convergence condition for the highest degree of aggregation index representing the close relationship of the model is:
[0041]
[0042] In the formula,
[0043] W m =num({d|d∈t m}).
[0044] The second aspect of the present invention relates to a system for constructing an electric power domain model, and the system is implemented using a method for constructing an electric power domain model in the first aspect of the present invention; the system includes a construction module, a first strategy module, a second strategy module and an iteration module; wherein the construction module is used to collect electric power text from an electric power knowledge base, construct a triple prompt word template in the electric power field, extract electric power text according to the template content and construct an initial electric power knowledge graph; the first strategy module is used to calculate the degree of the entity, thereby generating a first entity fusion strategy according to the position of the entity in the initial electric power knowledge graph; the second construction module is used to obtain a vectorized representation of a non-edge entity, thereby generating a second entity fusion strategy according to the degree of repetition between non-edge entities; the iteration module is used to preset the convergence condition of the electric power knowledge graph, and calculate the entity quantification index of the electric power knowledge graph in each iteration process of the electric power knowledge graph using the first entity fusion strategy and the second entity fusion strategy. If the entity quantification index meets the convergence condition, a power domain model is generated; the convergence condition is that the coupling degree representing the correct connection between entities in the electric power domain model within a preset range is the lowest, and the aggregation degree index representing the close relationship of the model should be the highest.
[0045] A third aspect of the present invention relates to a terminal, comprising a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to execute the steps of the method described in the first aspect of the present invention.
[0046] A fourth aspect of the present invention relates to a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect of the present invention.
[0047] The beneficial effect of the present invention is that, compared with the prior art, the method and system for constructing a power domain model in the present invention, in the process of upgrading the traditional architecture to the microservice architecture, adopts a bottom-up approach, uses large model technology, and uses physical models to intelligently and automatically assist in generating knowledge graph triples, and then draws the domain knowledge graph to assist in constructing a domain model. In the process of maintaining the domain model, it is also possible to construct a public library and a self-association method of the model classification template, so that when maintaining the domain model, it is not necessary to repeat it, and the process of iterative upgrading of the domain model is more dynamic and flexible.
[0048] The beneficial effects of the present invention also include:
[0049] 1. In the construction of the power system, the domain-driven idea is adopted to design the domain model. By combing and analyzing business scenarios such as marketing, the business domains, subdomains and bounded contexts in various businesses are identified. Then, through the aggregation and splitting principle, the objects are aggregated to form a domain model and classified into different bounded contexts. Finally, various business scenarios are iteratively reconstructed to form a complete domain model design for the power business system.
[0050] 2. The method uses a top-down approach to build a domain model without the participation of domain experts. In the process of entity extraction, relationship combing, and graph update and maintenance, the domain model can only be independently built and updated by computers, and the accuracy of the domain model can be assisted in evaluating by setting convergence conditions reasonably. The method makes full use of the physical model design of the original system. In the process of upgrading the monolithic architecture system to the microservice architecture system, the analysis technology of the large model is used to complete the construction of the domain knowledge graph, and then assist the domain experts to determine whether the domain model meets the characteristics of high clustering and low coupling, and quickly and without omissions to complete the domain model design work, thereby improving the efficiency of the overall construction of the domain model.
[0051] 3. The present invention supports the process of upgrading the traditional monolithic architecture to the microservice architecture, combines the physical model with the large model technology, completes the construction of the domain knowledge graph, and assists in the generation of the domain model. In the present invention, while the nodes are associated, the attributes, services, and events of the model are automatically copied or updated, realizing the flexible and configurable expansion of the domain model.
[0052] 4. Methods By defining and identifying edge entities and non-edge entities, the edge entities and non-edge entities are first merged, and then the similarity matrix is constructed through entity semantic analysis to complete the fusion of non-edge entities. The object network is constructed through the knowledge graph, the object association is calculated, the same objects and attributes are automatically identified, and the domain model is assisted in the construction. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A schematic diagram of the deployment of a method for constructing an electric power domain model according to the present invention;
[0054] Figure 2 This is a schematic diagram of a model in the field of power marketing in the present invention. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the present invention clearer and more accurate, the technical solution of the present invention is described in detail below through multiple specific implementation methods. The embodiments adopted by the present invention are only used to explain the present invention and are not used to limit the content of the present invention.
[0056] Physical entity refers to the general term for objects that need to be observed in the real world. The source object model refers to the new model formed after the physical model is converted into a data type. Nodes are one of the basic components of the graph, which represent entities or concepts. These entities or concepts can be specific things that exist in the objective world, such as people, cities, positions, commodities, etc., or they can be a collection of entities with the same characteristics, such as concepts such as countries, nations, books, computers, etc. These nodes contain information such as the name, description, and explanation of the entity, which can be expressed in multiple forms such as text, images, audio and video. The concept of child nodes involves the hierarchical relationship in the knowledge graph. In a complex knowledge graph, there may be a parent-child relationship between nodes. The parent node represents a broader or more basic concept, while the child node is a specific instance or a more detailed concept under the parent node concept. For example, if there is a parent node representing "animal", then the child nodes may include specific animal species such as "cat", "dog", and "bird". Domain models are often used in software development and system design to better understand and solve complex problems. It describes the entities, rules and relationships in the business domain, and determines the static and dynamic relationships that should exist between business personnel and the objects they process and use in order to produce the expected results. The domain model is a bridge from demand analysis to object-oriented design, and is an object model that describes the implementation of business use cases. Domain objects (Domain Object), also known as entity classes, represent the state of the business, and run through the presentation layer, business layer and persistence layer, and are ultimately persisted in the database. Domain objects are tangible or intangible business entities abstracted from the real world and are an important manifestation of business status. Without considering the inherent relationships between models and the inductive reuse of attributes and service events, each model needs to be manually built and changed independently. In order to maintain a large number of domain models and their attributes, services, and events, a lot of time is required; secondly, it is impossible to perform data governance and data aggregation on the original physical model, and the model relationship is complex and difficult to analyze, which makes it difficult to quickly transform the existing physical model into a domain model. Domain model management includes the management of aggregates, aggregate roots, entities, and value objects. Among them, object information includes object attributes, object relationships, and object behaviors, and provides domain model creation and editing functions. The model classification can contain subordinate classifications. Model classification can initialize some model attributes. When creating subordinate classifications, the superior classification model attributes are automatically inherited. Multiple models can be created under one classification, and the model can be maintained by clicking on the model. Automatic update: For the addition of some new scenarios, the domain model needs to be adjusted accordingly to support the description of existing business, which causes the template to change. During the template change process, the original inheritance relationship and other subordinate sub-objects can also automatically update this change, including attributes, services, events, etc.The model common library includes the attribute common library, the message common library, and the service common library. When maintaining the model, the model common library data can be referenced, and when the common library data is updated, the model that references this common data will also be automatically updated and synchronized. Since the attributes may be just simple values, some attributes can be enumerated, and some attributes do not have only a single basic data type, and some also contain structures. The implementation of this part of the function requires the expansion of two modules, such as the common library structure and the common library enumeration. You only need to establish them in the common library, and reference this enumeration when establishing the enumeration attribute, or reference this common structure when establishing the structure attribute.
[0057] The idea of the present invention is to convert the physical model data into a source object model, build a domain ontology based on the knowledge of the power field, and at the same time, based on the power industry big model, combine the source object and big model technology to complete the extraction of knowledge graph triple data. Finally, according to the knowledge graph triple and ontology structure, the construction of the domain knowledge graph is completed, and finally based on the knowledge graph, a structured domain model is generated.
[0058] On this basis, the present invention constructs a domain model for intelligent updating, iteration and optimization.
[0059] Figure 1 FIG. 1 is a schematic diagram of a deployment method for constructing a power domain model according to the present invention. Figure 1 As shown, the first aspect of the present invention relates to a method for constructing an electric power domain model, and the method includes steps 1 to 3.
[0060] Step 1: Collect power text from the power knowledge base, build a triple prompt word template in the power field, extract power text according to the template content and construct the initial power knowledge graph.
[0061] First, the process of importing relevant data in the field from external data sources into the tool system requires establishing a connection with the external data source first, then reading data from the data source, and finally storing the read data in the system after cleaning and deduplication. The relevant data in the field includes a large amount of text data collected from the power knowledge base, including entity text related to power. The collected data is preprocessed, including denoising, word segmentation, and stop word removal to improve data quality.
[0062] In addition, data conversion rules also include data type conversion and data format conversion. Then, according to the IEC-CIM template, the fields, English names and other contents of the physical model are converted into data types and formats supported by the source object model. Based on the field relationships contained in the physical model, such as in Marketing Ye Weiwu, the customer object contains the ID of the contract object, so as to construct a source object relationship list.
[0063] On this basis, based on the business domain and business subdomain and other power domain knowledge, the business parent class and subclass of the domain ontology are defined, and the attributes of the class are improved according to the business domain knowledge. Based on the source object model, the construction of the domain ontology is completed, which serves as the basis for the subsequent large model to extract entities, relationships and attributes, and better understand the domain background and context information.
[0064] Use the preprocessed data to train the large model of the power knowledge base and construct a triple prompt word template suitable for the power marketing field.
[0065] Preferably, the triple prompt word template includes entity, relationship, and attribute information; the entity includes personnel roles and work content in the power system; the relationship between the entities and the attributes of the entities are determined based on the output style and rule constraints of the information in the power system.
[0066] The work content description part in the prompt word template mainly prompts the large model to extract all the triple information in the input information in combination with the predefined ontology structure in the previously built power field ontology library. On this basis, the output style and rule constraints can define the attributes of entities in the knowledge graph, the relationship between entities, and other contents.
[0067] For example, in a marketing system, a rule constraint is preset: the association between the customer entity s1 and the contract entity s2 is used as the relationship between the entities r, so a piece of data (s1, r, s2) in the source object relationship list is constructed, that is, a source object relationship barrier.
[0068] So far, the source object and the big model are combined to output triples, such as {entity-relationship-entity} or {entity-relationship-attribute}. Based on this, the basic triples are extracted, first queried through the big model, and then the source object query service is called to query the source object model and its associated objects. If there is a match, the association or inclusion relationship is preferentially called to replace the relationship in the original triple. Otherwise, the entities and relationships recognized by the big model are retained until the construction is completed.
[0069] Among other contents, the physical model conversion module supports the conversion of the physical model into the source object model, including rule definition and model conversion. Defining data conversion rules includes data type conversion, which converts the data type in the source data into the data type defined by the source object. For example, converting a string type date to a date type, or converting an integer to a floating point number. Secondly, the data format conversion rule transforms the format of the data to meet the requirements of the source object format, for example, converting a telephone number from a format with an area code to a format without an area code; model conversion provides a rule-based conversion of the physical model into a source object model.
[0070] The source object model management module includes ontology management, node management, label management, etc., which supports the construction of knowledge graph ontology, entity triple construction and entity label definition based on source object model and big model technology.
[0071] According to the general generation method of knowledge graph, each entity in the source object model is vectorized, and the semantic similarity between entities and the semantic similarity between entities and models is calculated, so as to obtain multiple source object relationship groups. The source object relationship group with the highest similarity and greater than the minimum threshold is taken as the matching item of this basic triple, and the basic triple is replaced with the source object relationship group. The unlabeled basic triple is marked as an incremental triple. In this way, the initial domain model is constructed. Based on the output triple structure {entity-relationship-entity} or {entity-relationship-attribute}, the physical storage of triples is completed.
[0072] Based on triples, we build domain knowledge graphs, including automatically building nodes and relationships between them. We can manually change the relationships between objects, such as inheritance, association, inclusion, aggregation, etc., to re-maintain the relationships between nodes. For the same type of business identified, we group them according to the business dimension, which can include marketing, equipment, metering, billing, etc., build corresponding labels, and group the nodes.
[0073] In the prior art, the constructed graph is further improved through expert experience, which consumes a lot of manpower and material resources, and the result is not accurate. In the subsequent steps, the present invention obtains the entity fusion strategy and gradually updates and optimizes the knowledge graph in an iterative manner.
[0074] Step 2, calculate the degree of the entity, thereby generating a first entity fusion strategy according to the position of the entity in the initial power knowledge graph; obtain the vectorized representation of the non-edge entity, thereby generating a second entity fusion strategy according to the degree of repetition between the non-edge entities.
[0075] Preferably, the degree of the entity is calculated, thereby generating an entity fusion strategy based on the position of the entity in the electric power knowledge graph, including: dividing the entities in the electric power knowledge graph into edge entities and non-edge entities according to the degree of the entity, and calculating the similarity between the edge entities and the non-edge entities; if the similarity exceeds a first preset threshold, setting the fusion operation between the current edge entity and its corresponding non-edge entity as a first entity fusion strategy.
[0076] Define the initial power knowledge graph as G e (E, T), the degree of the entity can be calculated. If the degree is 0, there is no association between the entity and other entities. If the degree is 1, the entity is only connected to one other node. According to the size of the entity's degree, it is determined whether the entity is an edge entity. In this way, the edge entities and non-edge entities in the graph are divided.
[0077] The fusion of marginal entities and non-marginal entities is a key step to optimize the structure of the knowledge graph and improve its connectivity and consistency. i If the degree of an entity is 1, that is, the number of edges connected to it, it is an edge entity. i ) represents entity e i The degree of . The edge entity set constructed is:
[0078] {e i |deg(e i )=1}
[0079] Calculate the similarity between non-edge entities and edge entities. For any two entities, calculate the similarity between edge entities and non-edge entities, including:
[0080]
[0081] In the formula, e i and e j and non-marginal entities, respectively;
[0082] attributes(·) is a collection of attributes of the entity.
[0083] TF(e,k) is the term frequency of the kth attribute in entity e.
[0084] in,
[0085]
[0086] Based on the calculated similarity, we can set a threshold T,
[0087] When the similarity between two entities exceeds this threshold, the two entities are considered similar and should be merged.
[0088] After merging the entity pairs, we get
[0089] {(e i ,e j )|S(e i ,e j )≥T}
[0090] For each pair of entities that need to be merged, the knowledge graph needs to be updated, and the attribute set of the merged entity is:
[0091] attributes(e i )=attributes(e i )∪attributes(e j )
[0092] In the following text, attributes(e i ) is simplified as A(e i ).
[0093] Since the edge entity degree is 1, it has no other neighbors, so the neighbor sets do not need to be merged.
[0094] On this basis, the entities removed from the graph are:
[0095] E=E-{e j}
[0096] Through the above steps, the fusion strategy of edge entities and non-edge entities is obtained. However, not all entity fusions are implemented in this step. In practical applications, the strategies can be recorded as strategy sets for selection in step 3. In a single iteration of step 3, one or more strategies in the strategy sets can be used to ensure that the iteration has a large enough impact on the structure of the knowledge graph.
[0097] Preferably, a vectorized representation of the non-edge entity is obtained, thereby generating a second entity fusion strategy based on the degree of repetition between the non-edge entities, including: constructing a vectorized representation of the non-edge entity using the vector of each attribute in the non-edge entity and the weight of each attribute; calculating the similarity between any two non-edge entities using the cosine similarity of the vectorized representations between any two non-edge entities; if the similarity between any two non-edge entities exceeds a second preset threshold, setting the fusion operation between the current two non-edge entities as a second entity fusion strategy.
[0098] For non-edge entities, the similarity between any two non-edge entities is calculated to determine whether there is a potential merging strategy. The vector representation of the non-edge entity is constructed using the vector of each attribute in the non-edge entity and the weight of each attribute, including: the vector representation of the non-edge entity is:
[0099]
[0100] In the formula, a k is the kth attribute in entity e,
[0101] A(e) is the attribute set of entity e,
[0102] w k is the weight of the kth attribute in entity e, which can be determined based on the importance of the attribute or other criteria.
[0103] v k is the vector representation of the kth attribute in entity e in the knowledge graph space, which is obtained through semantic calculation of the natural language model.
[0104] Calculate the similarity of entities. For any two entities, the vector representation is v(e j ) and v(e l ), then the cosine similarity algorithm is:
[0105]
[0106] · represents the Euclidean dot product of vectors, and ||v(e)|| represents the Euclidean norm of vector v(e).
[0107] Construct a similarity matrix using an n×n similarity matrix S. The element s in the matrix S ij Represents entity e i and entity e j The similarity between them. Set a threshold T to determine whether two entities are similar enough to be considered duplicates. ij ≥T, then the entity e i and entity e j is repeated. Remove duplicate entities and merge them. ij ≥T entity pair (e i ,e j ), merging them into one entity e new . You can consider integrating the attributes and relationships of the two entities to form a new, more comprehensive entity.
[0108] At this point, there are:
[0109] Merge i and e j The property set:
[0110] attributes(e j )=attributes(e j )∪attributes(e l )
[0111] Merge i and e j The neighbor set of:
[0112] neighbors(e j )=neighbors(e j )∪neighbors(e l )
[0113] Update entity set:
[0114] E=E-{e j}-{e l}+{e new}
[0115] In the second entity fusion strategy, the non-edge entity e j and non-edge entities e l The new entity after fusion new The vectorization of is the simple addition of vector values in each spatial dimension:
[0116]
[0117] The formula assumes that the vectors of the two entities are equally weighted, but in practice the weights can be adjusted based on the specific situation.
[0118] The properties collection of the new entity is:
[0119] A(e new )=attributes(e j )∪attributes(e l )
[0120] New Entity new The weight w of the kth attribute in k,new This can be determined based on the importance of the attribute or other criteria. j and w i Entity e j and e i The weight of the corresponding attribute in the new entity can be expressed as:
[0121]
[0122] New Entity new The vector representation v of the kth attribute in k,new is obtained through semantic calculation of natural language processing model. k,j and v k,i Entity e j and e i The vector representation of the corresponding attributes in , then the vector representation of the attributes in the new entity can be expressed as:
[0123]
[0124] This formula assumes that the attribute vectors of the two entities are equally weighted. In actual situations, the weights can be adjusted according to the specific situation.
[0125] When a strategy or series of strategies are applied in the subsequent steps, the relationship between entities needs to be rebuilt after the entities are merged to ensure the consistency and accuracy of the knowledge graph. new , recalculate its similarity with other entities and update the similarity matrix S.
[0126] Step 3, preset the convergence conditions of the power knowledge graph, and use the first entity fusion strategy and the second entity fusion strategy to calculate the entity quantitative indicators of the power knowledge graph in each iteration of the power knowledge graph. If the entity quantitative indicators meet the convergence conditions, a power domain model is generated; the convergence conditions are that the coupling degree representing the correct connection between entities in the power domain model within a preset range is the lowest, and the aggregation degree indicator representing the close relationship of the model should be the highest.
[0127] The entity quantitative indicators of the electric power knowledge graph are calculated in each iteration process of the electric power knowledge graph using the first entity fusion strategy and the second entity fusion strategy, including: selecting one or more elements from the pre-generated first entity fusion strategy and second entity fusion strategy set, and modifying the initial electric power knowledge graph by the selected elements to obtain an iteration; after completing one iteration, calculating the coupling degree and aggregation degree of the electric power knowledge graph after the iteration to determine whether the electric power knowledge graph after the iteration meets the preset conditions; if so, ending the iteration and generating the electric power knowledge graph; if not, continuing to the next iteration until the preset conditions are met.
[0128] The convergence condition is that the coupling degree representing the correct connection between entities in the power field model within the preset range has the lowest value, and the aggregation index representing the close relationship of the model should be the highest, including: the convergence condition for the lowest coupling degree representing the correct connection between entities is:
[0129]
[0130] In the formula,
[0131] R m,n =num({d|d∈t m ∩t n})
[0132] t m and t n The knowledge graph G consists of the node set E and the edge set T respectively. e (E,T) and any two entities e m and e n The set of connected edges;
[0133] t m ∩t n For entity e m and e n The edge between
[0134] d is the set t m ∩t n The elements in
[0135] num({d|d∈t m ∩tn}) is the set t m ∩t n The number of elements d in ;
[0136] The convergence condition for the highest degree of aggregation index representing the close relationship of the model is:
[0137]
[0138] In the formula,
[0139] W m =num({d|d∈t m}).
[0140] Construct entity quantitative indicators, calculate the coupling and aggregation of the current overall modeling, and repeat the iterative process. In addition to adjusting the entity merging strategy, you can also improve the graph by changing the adjusted entities to new prompt words until the coupling of the current overall modeling is minimized and the aggregation is maximized, so that the results of domain modeling are more in line with the requirements of high clustering and low coupling.
[0141] Figure 2 This is a schematic diagram of a model in the field of power marketing in the present invention. Figure 2 As shown, in one embodiment of the present invention, taking the business expansion acceptance and market-based transaction business as an example, there are two customer objects involved, one is the electricity customer and the other is the market-based transaction customer. Correspondingly, the electricity customer physical model includes attributes such as unique identification, customer number, customer name, contract capacity, main household mark, electricity category, etc.; the demand-side response customer physical model includes attributes such as unique identification, customer number, customer name, energy sales company identification, energy sales company name, market-based attribute classification, etc., and the data types include Char, Varchar, Varchar2, Nchar, Nvarchar2, Long, Raw, Date, Clob, Blob, etc. In the process of using traditional methods to build a domain model based on the physical model, there are problems such as inconsistent data types between the physical model and the domain model; second, there are problems such as unclear scope of the corresponding domain of the physical model, large amount of data, and difficulty in model relationship analysis; third, the construction of the domain model relies on manpower, does not achieve flexible construction well, and takes a long time. According to the present method and device, the above problems can be effectively solved.
[0142] The second aspect of the present invention relates to a system for constructing an electric power domain model, and the system is implemented using a method for constructing an electric power domain model described in the first aspect of the present invention; the system includes a construction module, a first strategy module, a second strategy module and an iteration module; wherein the construction module is used to collect electric power text from an electric power knowledge base, construct a triple prompt word template in the electric power domain, extract electric power text according to the template content and construct an initial electric power knowledge graph; the first strategy module is used to calculate the degree of an entity, thereby generating a first entity fusion strategy according to the position of the entity in the initial electric power knowledge graph; the second construction module is used to obtain a vectorized representation of a non-edge entity, thereby generating a second entity fusion strategy according to the degree of repetition between non-edge entities; the iteration module is used to preset a convergence condition of the electric power knowledge graph, and calculate the entity quantification index of the electric power knowledge graph in each iteration process of the electric power knowledge graph using the first entity fusion strategy and the second entity fusion strategy, and if the entity quantification index meets the convergence condition, a power domain model is generated; the convergence condition is that the coupling degree representing the correct connection between entities in the electric power domain model within a preset range is the lowest, and the aggregation degree index representing the close relationship of the model should be the highest.
[0143] A third aspect of the present invention relates to a terminal, comprising a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to execute the steps of the method described in the first aspect of the present invention.
[0144] A fourth aspect of the present invention relates to a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect of the present invention.
[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit them. Although the present invention is described in detail with reference to the above embodiments, it should be understood by those skilled in the art that the technical solutions of the present invention still include contents that can modify or replace the specific embodiments of the present invention. Any modification or replacement that does not depart from the spirit and scope of the present invention shall be included in the protection scope of the claims of the present invention.
Claims
1. A method for constructing an electric power domain model, characterized in that: The method comprises the following steps: Collect power text from the power knowledge base, build a triple prompt word template in the power field, extract power text according to the template content and construct an initial power knowledge graph; Calculate the degree of the entity, thereby generating a first entity fusion strategy according to the position of the entity in the initial power knowledge graph; Obtaining a vectorized representation of the non-edge entities, thereby generating a second entity fusion strategy according to the degree of repetition between the non-edge entities; Preset the convergence conditions of the electric power knowledge graph, use the first entity fusion strategy and the second entity fusion strategy to calculate the entity quantitative index of the electric power knowledge graph in each iteration process of the electric power knowledge graph, and generate the electric power domain model if the entity quantitative index meets the convergence conditions; The convergence condition is that the coupling degree representing the correct connection between entities in the power field model should be the lowest within a preset range, and the aggregation index representing the close relationship of the model should be the highest.
2. The method for constructing a power domain model according to claim 1, characterized in that: The method of collecting power text from the power knowledge base and constructing a triplet prompt word template in the power field includes: The triplet prompt word template includes entity, relationship, and attribute information; The entities include roles and work contents of personnel in the power system; The relationships and attributes between the entities are determined based on the output patterns and rule constraints of information in the power system.
3. The method for constructing a power domain model according to claim 2, characterized in that: The degree of the entity is calculated, thereby generating an entity fusion strategy according to the position of the entity in the electric power knowledge graph, including: According to the degree of the entity, the entities in the power knowledge graph are divided into edge entities and non-edge entities, and the similarity between edge entities and non-edge entities is calculated; If the similarity exceeds the first preset threshold, a fusion operation between the current edge entity and its corresponding non-edge entity is set as a first entity fusion strategy.
4. The method for constructing a power domain model according to claim 3, characterized in that: The calculating the similarity between the edge entity and the non-edge entity comprises: In the formula, e i and e j and non-marginal entities, respectively; attributes(·) is a collection of attributes of the entity. TF(e,k) is the term frequency of the kth attribute in entity e.
5. The method for constructing a power domain model according to claim 4, characterized in that: The step of obtaining a vectorized representation of the non-edge entities, thereby generating a second entity fusion strategy according to the degree of repetition between the non-edge entities, includes: Construct a vectorized representation of the non-edge entity using the vector of each attribute in the non-edge entity and the weight of each attribute; The similarity between any two non-edge entities is calculated using the cosine similarity of the vectorized representation between any two non-edge entities; If the similarity between any two non-edge entities exceeds a second preset threshold, the fusion operation between the current two non-edge entities is set as a second entity fusion strategy.
6. The method for constructing a power domain model according to claim 5, characterized in that: The method of constructing a vectorized representation of a non-edge entity using a vector of each attribute in the non-edge entity and a weight of each attribute includes: The vectorized representation of the non-edge entity is: In the formula, a k is the kth attribute in entity e, A(e) is the attribute set of entity e, w k is the weight of the kth attribute in entity e, v k is the vector representation of the kth attribute in entity e in the knowledge graph space.
7. The method for constructing a power domain model according to claim 6, characterized in that: If the similarity between any two non-edge entities exceeds a second preset threshold, setting the fusion operation between the current two non-edge entities as a second entity fusion strategy includes: In the second entity fusion strategy, the non-edge entity e j and non-edge entities e l The new entity after fusion new The vectorization of is the simple addition of vector values in each spatial dimension: The properties collection of the new entity is: A(e new )=attributes(e j )∪attributes(e l ) Each attribute a in the new entity k,new The weight and vector of are expressed as:
8. The method for constructing a power domain model according to claim 7, characterized in that: The method of calculating the entity quantitative index of the electric power knowledge graph in each iteration process of the electric power knowledge graph by using the first entity fusion strategy and the second entity fusion strategy includes: Select one or more elements from the pre-generated first entity fusion strategy and second entity fusion strategy set, and modify the initial power knowledge graph by the selected elements to obtain an iteration; After completing one iteration, the coupling degree and aggregation degree of the iterative power knowledge graph are calculated to determine whether the iterative power knowledge graph meets the preset conditions; If it meets the requirements, the iteration ends and the power knowledge graph is generated; If not, continue to the next iteration until the preset conditions are met.
9. The method for constructing a power domain model according to claim 8, characterized in that: The convergence condition is that the coupling degree representing the correct connection between entities in the power domain model within the preset range is the lowest, and the aggregation index representing the close relationship of the model should be the highest, including: The convergence condition for the lowest value of the coupling degree representing the correct connection between the entities is: In the formula, R m,n =num({d|d∈t m ∩t n }) t m and t n The knowledge graph G consists of the node set E and the edge set T respectively. e (E,T) and any two entities e m and e n The set of connected edges; t m ∩t n For entity e m and e n The edge between d is the set t m ∩t n The elements in num({d|d∈t m ∩t n }) is the set t m ∩t n The number of elements d in ; The convergence condition for the highest degree of aggregation index representing the close relationship of the model is: In the formula, W m =num({d|d∈t m })。 10. A system for constructing a power domain model, characterized in that: The system is implemented by using a method for constructing a power domain model as described in any one of claims 1 to 9; The system includes a construction module, a first strategy module, a second strategy module and an iteration module; wherein, The construction module is used to collect power text from the power knowledge base, construct a triple prompt word template in the power field, extract power text according to the template content and construct an initial power knowledge graph; The first strategy module is used to calculate the degree of the entity, so as to generate a first entity fusion strategy according to the position of the entity in the initial power knowledge graph; The second construction module is used to obtain a vectorized representation of the non-edge entities, thereby generating a second entity fusion strategy according to the degree of repetition between the non-edge entities; The iteration module is used to preset the convergence conditions of the power knowledge graph, and use the first entity fusion strategy and the second entity fusion strategy to calculate the entity quantification index of the power knowledge graph during each iteration of the power knowledge graph. If the entity quantification index meets the convergence conditions, a power domain model is generated; the convergence condition is that the coupling degree representing the correct connection between entities in the power domain model within a preset range is the lowest, and the aggregation index representing the close relationship of the model should be the highest.
Citation Information
Cited By
Power grid knowledge graph construction method fusing hybrid expert network model and semantic partitioning
CN122334438A