Method and system for automatically constructing a knowledge graph, computer device and storage medium
By automatically filtering and transforming data from relational databases to construct knowledge graphs, this technology solves the problem of relying on human experience in existing technologies, and achieves efficient and universal knowledge graph construction that is applicable to multiple industries.
Patent Information
- Application Number
- CN202211548745.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-05
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2042-12-05
AI Technical Summary
In existing technologies, knowledge graph construction relies on human experience, which is inefficient, has weak generalization ability, is difficult to reuse effectively, and is heavily dependent on professionals.
This paper provides a method for automatically constructing knowledge graphs. By automatically filtering and transforming relational data from relational databases according to business needs, a knowledge graph is constructed. This includes corpus information processing, natural language analysis, and visualization adjustments, thereby achieving automatic data mapping and transformation.
It enables efficient knowledge graph construction centered on business needs, reduces reliance on professionals, improves construction efficiency, enhances the universality and reusability of the construction, and reduces costs.
Smart Images

Figure CN115858810B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a method for automatically constructing a knowledge graph, a system for automatically constructing a knowledge graph, a computer device, and a computer readable storage medium. BACKGROUND
[0002] The basic design concept of a relational database is to model around entities, which lacks direct support for relationships between entities, and needs to indirectly maintain relationships between entities through association tables. This results in a large number of association tables when using a relational database for business support in practice, and low execution efficiency of operations such as queries.
[0003] A graph database represents entities and relationships with points and edges, respectively, and can more clearly reveal complex data models. With the rapid development of mobile Internet, Internet of Things and other businesses, the value of invisible associations between data is increasingly prominent. As the most basic underlying application scenario of a graph database, a knowledge graph makes full use of the advantages of a graph data model in storage and querying to provide large-scale knowledge bases for numerous industries and to support business applications. Since the 1980s, a relational database has been the mainstream of database development, and various industries have accumulated a large amount of relational data. For industries that naturally have a graph topology, such as telecommunications, transportation, and Internet social networking, how to quickly and effectively construct a knowledge graph has become the first problem to be solved in knowledge graph applications.
[0004] Traditional knowledge graph construction methods rely on human experience, and need to manually design a knowledge graph schema, then map pre-prepared node data, relationship data, and attribute data to the graph schema, and then import the data to complete the construction of the graph. This traditional construction method relies heavily on professionals, has low construction efficiency, and the constructed graph has weak generalization and is difficult to effectively reuse. SUMMARY
[0005] The present application is completed in order to at least partially solve the technical problems of heavy reliance on professionals, low construction efficiency, weak generalization of the constructed graph, and difficulty in effective reuse in the prior art.
[0006] According to an aspect of the present application, a method for automatically constructing a knowledge graph is provided, which can include the following steps: S1, inputting query information according to business requirements; S2, automatically filtering relational data required for constructing a knowledge graph from a relational database according to the query information; and S3, automatically converting the filtered relational data into graph data to construct a knowledge graph.
[0007] Optionally, the method further comprises: S4, performing a graph analysis service according to the constructed knowledge graph; and S5, outputting a query result related to the service requirement.
[0008] Optionally, the step S2 comprises: S21, collecting corpus information related to the service requirement; S22, performing natural language processing modeling according to the corpus information to obtain a natural language processing model; S23, analyzing the query information by using the natural language processing model to obtain semantics of a service operation; S24, supplementing and confirming detailed information required by the service operation; and S25, screening the relational data required for constructing the knowledge graph from the relational database according to the detailed information.
[0009] Optionally, the corpus information comprises one or more of a business management specification, a data model specification, an application scenario white paper, and a business development work guideline.
[0010] Optionally, the natural language processing modeling comprises cleaning the corpus information, and performing natural language processing model training based on the cleaned corpus information by using a large-scale pre-training model.
[0011] Optionally, the step S3 comprises: S31, visualizing the screened relational data as a conceptual data model; S32, customizing the conceptual data model; S33, selecting a mapping rule of the relational data to graph data; S34, mapping the customized conceptual data model to obtain a schema of a knowledge graph according to the mapping rule; and S35, constructing the knowledge graph according to the schema of the knowledge graph.
[0012] Optionally, the conceptual data model is constructed to present table information of the screened relational data, including an entity table and a relationship table; the data table of the relational data only displays a name, a field name, and a data type, and marks a primary key and a foreign key; and the association relationship between the data tables based on the primary key and the foreign key is displayed by a connection line.
[0013] Optionally, the step S32 comprises the following customization of the conceptual data model by a user through a visual operation of dragging, pulling, and dropping on demand: adding, deleting, splitting, and merging a data table, field information, and a connection line.
[0014] Optionally, the mapping rule can include: each row in the screened data table of the relational data is converted into a node in the graph data; the name of each data table is converted into a label of the node in the graph data; each field in the data table is converted into an attribute of the node in the graph data; each foreign key is converted into a relationship in the graph data, and the field name of the foreign key is converted into a label of the relationship; or each row in the screened entity table of the relational data is converted into a node in the graph data; the name of each entity table is converted into a label of the node in the graph data; each field in the entity table is converted into an attribute of the node in the graph data; each row in the relationship table is converted into a relationship in the graph data; the name of each relationship table is converted into a label of the relationship in the graph data; each field in the relationship table is converted into an attribute of the relationship in the graph data; each foreign key is converted into a relationship in the graph data, and the field name of the foreign key is converted into a label of the relationship; or a part of the relationship table in the screened data table of the relational data is specified, the part of the relationship table is set to be converted into a relationship, and the conversion type of the other relationship table and the entity table is set to be a node; for the data table of the conversion type of the node, each row in the data table is converted into a node in the graph data, the name of each data table is converted into a label of the node in the graph data, and each field in the data table is converted into an attribute of the node in the graph data; for the relationship table of the conversion type of the relationship, each row in the relationship table is converted into a relationship in the graph data, the name of each relationship table is converted into a label of the relationship in the graph data, and each field in the relationship table is converted into an attribute of the relationship in the graph data; each foreign key is converted into a relationship in the graph data, and the field name of the foreign key is converted into a label of the relationship.
[0015] According to another aspect of the present application, a system for automatically constructing a knowledge graph is provided, which can include: an input module configured to input query information according to a business requirement; a screening module configured to automatically screen relational data required for constructing a knowledge graph from a relational database according to the query information (for example, according to step S2 in the method for automatically constructing a knowledge graph described above); a construction module configured to automatically convert the screened relational data into graph data, thereby constructing a knowledge graph (for example, constructing a knowledge graph according to step S3 in the method for automatically constructing a knowledge graph described above); an execution module configured to execute a graph analysis business according to the constructed knowledge graph; and an output module configured to output a query result related to the business requirement.
[0016] According to still another aspect of the present application, a computer device is provided, which includes a memory and a processor, and the memory stores a computer program, when the processor runs the computer program stored in the memory, the processor executes the method for automatically constructing a knowledge graph described above.
[0017] According to another aspect of the present application, there is provided a computer readable storage medium having stored thereon a computer program, which, when executed by a processor, causes the processor to perform the community division method.
[0018] The technical solution provided by the present application can include the following beneficial effects:
[0019] The method for automatically constructing a knowledge graph provided by the present application proposes a more efficient way of constructing a knowledge graph, realizes automatic construction of a knowledge graph with business demand as the core, reduces the dependence on professional personnel in the process of constructing a knowledge graph, improves the construction efficiency, and reduces the construction cost. In addition, this business demand-oriented automatic construction method of a knowledge graph is more versatile and can be replicated and promoted in many industries, facilitating enterprises to associate business with data resources and further tap the value of data application.
[0020] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent to those skilled in the art from the description, or can be learned by practice of the present application. The objects and other advantages of the present application will be realized and achieved by the structure particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF DRAWINGS
[0021] The accompanying drawings are included to provide a further understanding of the technical solutions of the present application, and constitute a part of the specification, and are used together with the embodiments of the present application to explain the technical solutions of the present application, and do not constitute a limitation on the technical solutions of the present application.
[0022] Figure 1 A flowchart of a method for automatically constructing a knowledge graph provided by an embodiment of the present application is shown in the figure;
[0023] Figure 2 A flowchart of a screening step (automatically acquiring relational data) in a method for automatically constructing a knowledge graph provided by an embodiment of the present application is shown in the figure;
[0024] Figure 3 A flowchart of a construction step (automatically converting relational data into graph data) in a method for automatically constructing a knowledge graph provided by an embodiment of the present application is shown in the figure;
[0025] Figure 4 A structure diagram of a system for automatically constructing a knowledge graph provided by an embodiment of the present application is shown in the figure;
[0026] Figure 5 A structure diagram of a computer device provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0027] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the specific embodiments of the present application are described in detail below with reference to the drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application.
[0028] The present application provides a method for automatically constructing a knowledge graph based on business requirements, which comprises the following steps: Figure 1
[0029] S1, inputting query information according to business requirements (inputting query information);
[0030] S2, automatically screening relational data required for constructing a knowledge graph from a relational database (such as a traditional relational database) according to the query information (automatically obtaining relational data); and
[0031] S3, automatically converting the screened relational data into graph data, thereby constructing a knowledge graph (automatically converting relational data into graph data)。
[0032] Optionally, the method for automatically constructing a knowledge graph can further comprise the following steps after step S3:
[0033] S4, performing a graph analysis service according to the constructed knowledge graph (performing a graph analysis service); and
[0034] S5, outputting query results related to the business requirements (outputting query information)。
[0035] Steps S1 to S3 are a knowledge graph automatic construction process based on business requirements, and steps S4 and S5 are a knowledge graph application process.
[0036] Referring to Figure 2 , the above step S2 is a data screening process based on business requirements, which can specifically comprise the following steps:
[0037] S21, collecting corpus information related to business requirements. For example, the corpus information can be related standards, guidelines, white papers, etc. of an enterprise. More specifically, the corpus information can include but is not limited to one or more of business management specifications, data model specifications, application scenario white papers, and business development guidelines.
[0038] S22, performing natural language processing modeling according to the above corpus information to obtain a natural language processing model. For example, the natural language processing modeling can include cleaning the corpus information (mainly including abnormal symbol processing, etc.), and using a large-scale pre-training model (such as Bert) to train a natural language processing model based on the cleaned corpus information.
[0039] S23, analyze the query information (business operation information) by a natural language processing model to obtain semantics of the business operation (for example, semantics of a business operation related to an enterprise).
[0040] S24, supplement and confirm detailed information required for the business operation. For example, according to the semantics of the business operation, a business scenario template is matched, and the user supplements and confirms detailed information required for the related business operation based on the business scenario template.
[0041] S25, according to the detailed information, relational data required for constructing the knowledge graph is screened from a relational database (for example, a multi-field traditional relational database of an enterprise). The relational data includes, for example, database, data table and field information, and the like.
[0042] Reference Figure 3 The step S3 described above is to automatically construct a knowledge graph from the screened relational data, and specifically can include the following steps:
[0043] S31, the screened relational data is visualized and presented as a conceptual data model. For example, the conceptual data model can be constructed as follows: table information of the screened relational data is presented, including entity tables and relationship tables; the data table of the relational data only shows the name, field name and data type, and the primary key and foreign key are marked; and the association relationship between the data tables based on the primary key and foreign key is displayed through a connection line.
[0044] S32, the conceptual data model is self-defined and adjusted. For example, the user can adjust the conceptual data model as needed through simple visual operations such as dragging, pulling and dragging, including adding, deleting, splitting and merging data tables (which will be described in detail below).
[0045] S33, a mapping rule of the relational data to the graph data is selected (which will be described in detail below).
[0046] S34, according to the mapping rule, the adjusted conceptual data model is mapped to obtain the schema of the knowledge graph.
[0047] S35, the knowledge graph is constructed according to the schema of the knowledge graph. Specifically, data is imported according to the schema of the knowledge graph that has been created, and the construction of the required knowledge graph is completed.
[0048] As described above, in step S32, the user adjusts the conceptual data model on demand by simple visual operations such as dragging, pulling, and the like. For adding, deleting, and the like of data tables, field information, and links, the range of addition can be an enterprise multi-field conventional relational database. For splitting and merging data tables, the splitting operation is a selected field range, and the data table is split into a master table and a slave table, the slave table reuses the master key of the master table, and the master table adds a foreign key matching the master key of the slave table. The merging operation is a selected field range of the same property of different data tables, a new data table is created, and the relevant fields in the original data table are deleted, the new data table is set with a self-defined primary key, and a foreign key matching the primary key of the original data table is added. It should be noted that if the selected field is a foreign key in the original data table, its foreign key property and association are retained in the new data table.
[0049] As described above, in step S33, a mapping rule of relational data to graph data is selected, which can optionally include one of the following mapping rules 1 to 3.
[0050] Mapping rule 1: Each row in the data table of the selected relational data is converted into a node in the graph data; the name of each data table is converted into the label of the node in the graph data; each field in the data table is converted into the attribute of the node in the graph data; each foreign key is converted into a relationship in the graph data, and the field name of the foreign key is converted into the label of the relationship.
[0051] Mapping rule 2: Each row in the entity table of the selected relational data is converted into a node in the graph data; the name of each entity table is converted into the label of the node in the graph data; each field in the entity table is converted into the attribute of the node in the graph data; each row in the relationship table is converted into a relationship in the graph data; the name of each relationship table is converted into the label of the relationship in the graph data; each field in the relationship table is converted into the attribute of the relationship in the graph data; each foreign key is converted into a relationship in the graph data, and the field name of the foreign key is converted into the label of the relationship.
[0052] Mapping rule 3: A part of the relationship table in the selected relational data table is specified, the part of the relationship table is set to be converted to a relationship, and the conversion type of the other relationship table and the entity table is set to be a node; for the data table with the conversion type of a node, each row in the data table is converted into a node in the graph data, the name of each data table is converted into the label of the node in the graph data, and each field in the data table is converted into the attribute of the node in the graph data; for the relationship table with the conversion type of a relationship, each row in the relationship table is converted into a relationship in the graph data, the name of each relationship table is converted into the label of the relationship in the graph data, and each field in the relationship table is converted into the attribute of the relationship in the graph data; each foreign key is converted into a relationship in the graph data, and the field name of the foreign key is converted into the label of the relationship.
[0053] The application further provides a system 10 for automatically constructing a knowledge graph, as shown in the accompanying drawings. Figure 4 The system 10 comprises an input module 11 configured to input query information according to business requirements; a screening module 12 configured to automatically screen relational data required for constructing the knowledge graph according to step S2 of the method for automatically constructing the knowledge graph; a construction module 13 configured to construct the knowledge graph according to step S3 of the method for automatically constructing the knowledge graph; an execution module 14 configured to execute graph analysis business according to the constructed knowledge graph; and an output module 15 configured to output query results related to the business requirements.
[0054] Based on the same technical concept, the application further provides a computer device 20, as shown in the accompanying drawings. Figure 5 The computer device 20 comprises a memory 21 and a processor 22, and the memory 21 stores a computer program, and when the processor 22 runs the computer program stored in the memory 21, the processor 22 executes the method for automatically constructing the knowledge graph.
[0055] Based on the same technical concept, the application further provides a computer readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the processor executes the method for automatically constructing the knowledge graph.
[0056] The method for automatically constructing the knowledge graph based on business requirements has strong versatility, and is particularly suitable for industries that naturally have a graph topology structure, such as the telecommunications, transportation, and Internet social industries. The main difference between the method in the actual application of different enterprises is the collection and training of the corpus of the business operation semantic analysis model, and the setting of the business scenario template. Taking the telecommunications industry as an example, the operator has multi-dimensional data such as B domain and O domain, which are stored in relational databases, and the data range can include customers, products, services, resources, marketing, enterprise management, etc. If the knowledge graph of the network infrastructure topology and the user communication behavior topology is constructed based on the graph database, and this is used as the data model basis, it can be more convenient to mine the value hidden in the massive data, and typical business application scenarios can include communication link queries in the resource domain, high-value user maintenance in the customer domain, etc.
[0057] In summary, the method, system, computer device, and storage medium for automatically constructing the knowledge graph provided by the application propose a more efficient knowledge graph construction method, realize the automatic construction of the knowledge graph based on business requirements, reduce the dependence on professionals in the knowledge graph construction process, improve the construction efficiency, and reduce the construction cost. In addition, the knowledge graph construction method based on business requirements has stronger versatility and can be replicated and promoted in many industries.
[0058] Those skilled in the art can understand that all or some of the steps in the method disclosed above, the functional modules / units in the system and the device can be implemented as software, firmware, hardware and appropriate combinations thereof. In the hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component can have multiple functions, or one function or step can be performed by several physical components in cooperation. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer readable medium, which can include computer storage media (or non-transitory media) and communication media (or transitory media). As known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as known to those skilled in the art, communication media typically includes computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and can include any information delivery medium.
[0059] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method of automatically constructing a knowledge graph, characterized by, The method comprises the following steps: S1, inputting query information according to business requirements; S2, automatically screening relational data required for constructing a knowledge graph from a relational database according to the query information; S3, automatically converting the screened relational data into graph data, thereby constructing a knowledge graph, Step S2 comprises the following steps: S21, collecting corpus information related to the business requirements; S22, modeling natural language processing according to the corpus information to obtain a natural language processing model; S23, analyzing the query information through the natural language processing model to obtain semantics of business operations; S24, supplementing and confirming detailed information required for the business operations; and S25, screening the relational data required for constructing a knowledge graph from the relational database according to the detailed information. The method further comprises the following steps:
2. The method of claim 1, wherein, S4, performing graph analysis business according to the constructed knowledge graph; and S5, outputting query results related to the business requirements.
3. The method of claim 1, wherein The corpus information comprises one or more of business management specifications, data model specifications, application scenario white papers, and business development guidelines.
4. The method of claim 1, wherein The natural language processing modeling comprises cleaning the corpus information, and training a natural language processing model based on the cleaned corpus information using a large-scale pre-training model. Step S3 comprises the following steps:
5. The method according to claim 1 or 2, characterized in that, S31, visualizing the screened relational data as a conceptual data model; S32, customizing the conceptual data model; S33, selecting mapping rules of the relational data to graph data; S34, mapping the customized conceptual data model to obtain a schema of a knowledge graph according to the mapping rules; and S35, constructing a knowledge graph according to the schema of the knowledge graph. The conceptual data model is configured to present table information of the screened relational data, including entity tables and relationship tables; the data tables of the relational data only display names, field names, and data types, and mark primary keys and foreign keys; 6. The method of claim 5, wherein, And the association between the data tables based on the primary keys and foreign keys is displayed through a connection line. Step S32 comprises the following customizations of the conceptual data model by a user through visual operations of dragging, pulling, and dropping as needed: adding or deleting data tables, field information, and connection lines; and splitting or merging data tables.
7. The method of claim 6, wherein, The mapping rules comprise:
8. The method of claim 6, wherein, Each row in the data table of the screened relational data is converted into a node in the graph data; the name of each data table is converted into a label of a node in the graph data; each field in the data table is converted into an attribute of a node in the graph data; each foreign key is converted into a relationship in the graph data, and the field name of the foreign key is converted into a label of the relationship; or each row in the entity table of the screened relational data is converted into a node in the graph data; the name of each entity table is converted into a label of the node in the graph data; each field in the entity table is converted into an attribute of the node in the graph data; each row in the relation table is converted into a relation in the graph data; the name of each relation table is converted into a label of the relation in the graph data; each field in the relation table is converted into an attribute of the relation in the graph data; each foreign key is converted into a relation in the graph data, and the field name of the foreign key is converted into a label of the relation; or a part of the relation tables in the screened data table of the relational data is specified, the part of the relation tables is set to have a conversion type of relation, and the conversion types of the other relation tables and entity tables are set to be node; for the data table having the conversion type of node, each row in the data table is converted into a node in the graph data, the name of each data table is converted into a label of the node in the graph data, and each field in the data table is converted into an attribute of the node in the graph data; for the relation table having the conversion type of relation, each row in the relation table is converted into a relation in the graph data, the name of each relation table is converted into a label of the relation in the graph data, and each field in the relation table is converted into an attribute of the relation in the graph data; each foreign key is converted into a relation in the graph data, and the field name of the foreign key is converted into a label of the relation. 9.A system for automatically constructing a knowledge graph, characterized in that, comprising: an input module configured to input query information according to a business requirement; a screening module configured to automatically screen relational data required for constructing a knowledge graph from a relational database according to the query information; a construction module configured to automatically convert the screened relational data into graph data, thereby constructing the knowledge graph; an execution module configured to execute a graph analysis business according to the constructed knowledge graph; and an output module configured to output a query result related to the business requirement. automatically screening relational data required for constructing a knowledge graph from a relational database according to query information comprises the following steps: collecting corpus information related to the business requirement; obtaining a natural language processing model according to natural language processing modeling based on the corpus information; obtaining semantics of a business operation by analyzing the query information through the natural language processing model; supplementing and confirming detailed information required for the business operation; and screening the relational data required for constructing the knowledge graph from the relational database according to the detailed information. a computer program is stored in a memory, and when a processor executes the computer program stored in the memory, the processor executes the method for automatically constructing a knowledge graph according to any one of claims 1 to 8.
10. A computer device, comprising: the computer program is executed by the processor, and the processor executes the method for automatically constructing a knowledge graph according to any one of claims 1 to 8.
11. A computer readable storage medium having stored thereon a computer program, characterized in that,
Citation Information
Patent Citations
Knowledge graph data storage method, intelligent construction method and implementation system thereof
CN111104475A
Template-free universal intelligent question-answering method based on dynamic knowledge graph
CN111159385A