Knowledge graph creation method and device, storage medium and program product

By automatically processing entity data and relationship information in documents through a large language model, graph database import statements are generated, which solves the problem of high cost and low efficiency of manual creation of knowledge graphs in existing technologies, and realizes efficient knowledge graph creation that is compatible with multiple graph databases.

CN120706529APending Publication Date: 2025-09-26BEIJING 58 INFORMATION TTECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510820966.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-18
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Existing technologies for creating knowledge graphs require a lot of manual intervention, resulting in high costs and low efficiency. In particular, when switching graph databases, graph database statements need to be manually rewritten, which is inefficient.

Method used

Through the large language model, the entity data and relationship information in the document are automatically processed to generate graph database import statements, support compatibility of multiple graph database types, and realize the creation of knowledge graphs without human intervention.

Benefits of technology

It realizes the automated creation of knowledge graphs, reduces costs, improves efficiency, and supports seamless switching and compatibility of different graph databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120706529A_ABST
    Figure CN120706529A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a knowledge graph creation method and device, a storage medium and a program product, and relates to the technical field of artificial intelligence. The method comprises the steps of triggering a knowledge graph creation task process in response to a knowledge graph creation request sent by a user, and executing the following steps according to the knowledge graph creation task process: obtaining multiple pieces of entity data in a to-be-processed document and target relationship information among the multiple pieces of entity data; inputting the first prompt word, the multiple pieces of entity data and target relationship information among the multiple pieces of entity data into a first large language model to obtain a graph database import statement corresponding to the target graph database; and storing the graph database import statement into a target graph database to create a target knowledge graph based on the target graph database. The scheme is automatically carried out in the whole process, manual participation is not needed, cost is low, and efficiency is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a knowledge graph creation method, device, storage medium and program product. Background Art

[0002] A knowledge graph is a visual network structure formed through structured associations and semantic expressions, which can intuitively present complex relationships between data (such as inheritance, dependency, and interaction relationships).

[0003] At present, the existing technology generally creates knowledge graphs manually. In specific implementation, multiple entity data in the document to be processed and the relationship between the multiple entity data are manually analyzed. Afterwards, a graph database statement is manually written, and based on the graph database statement, multiple entity data and the relationship between the multiple entity data are stored in the graph database to create a knowledge graph. However, this way of creating a knowledge graph requires a lot of manual intervention, and the labor cost is high. In addition, the manual way of writing graph database statements will cause different graph databases to use different query languages. When it is necessary to switch the graph database (that is, when a new graph database is currently needed, or when data migration between different graph databases is performed), it is necessary to manually rewrite the graph database statement, which is inefficient and costly. Summary of the Invention

[0004] The embodiments of the present application provide a knowledge graph creation method, device, storage medium and program product for automatically creating knowledge graphs, reducing costs and improving efficiency.

[0005] In a first aspect, an embodiment of the present application provides a method for creating a knowledge graph, the method comprising:

[0006] In response to a knowledge graph creation request sent by a user, the knowledge graph creation task process is triggered, and the following steps are performed according to the knowledge graph creation task process:

[0007] Acquire multiple entity data in the document to be processed, and target relationship information between the multiple entity data;

[0008] Inputting a first prompt word, the plurality of entity data, and target relationship information between the plurality of entity data into a first large language model to obtain a graph database import statement corresponding to the target graph database; wherein the first large language model includes description text of the target graph database type and description text of data processing rules, and the data processing rules are used to guide the first large language model to output a corresponding graph database import statement according to the target graph database type; the entity data includes an entity type and entity attributes, the target relationship information includes a relationship type and relationship attributes, and the graph database import statement is obtained by mapping the entity type to a node label, mapping the entity attributes to a node attribute, mapping the relationship type to an edge type, and mapping the relationship attributes to an edge attribute through the first large language model;

[0009] The graph database import statement is stored in the target graph database to create a target knowledge graph based on the target graph database.

[0010] In a second aspect, an embodiment of the present application provides a knowledge graph creation device, the device comprising:

[0011] The response module is used to respond to the knowledge graph creation request sent by the user, trigger the knowledge graph creation task process, and execute the steps in the following modules according to the knowledge graph creation task process:

[0012] The determination module is used to obtain multiple entity data in the document to be processed and target relationship information between the multiple entity data.

[0013] An acquisition module is configured to input a first prompt word, the plurality of entity data, and target relationship information between the plurality of entity data into a first large language model to obtain a graph database import statement corresponding to a target graph database; wherein the first large language model includes description text of the target graph database type and description text of data processing rules, and the data processing rules are configured to guide the first large language model to output a corresponding graph database import statement according to the target graph database type; the entity data includes entity types and entity attributes, the target relationship information includes relationship types and relationship attributes, and the graph database import statement is obtained by mapping the entity types to node labels, the entity attributes to node attributes, the relationship types to edge types, and the relationship attributes to edge attributes through the first large language model.

[0014] A creation module is used to store the graph database import statement into the target graph database to create a target knowledge graph based on the target graph database.

[0015] In a third aspect, an embodiment of the present application provides an electronic device comprising: a memory, a processor, and a communication interface; wherein, the memory stores executable code, and when the executable code is executed by the processor, the processor executes the knowledge graph creation method as described in the first aspect.

[0016] In a fourth aspect, an embodiment of the present application provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the knowledge graph creation method as described in the first aspect.

[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes: a computer program, which, when executed by a processor of an electronic device, enables the processor to execute the knowledge graph creation method described in the first aspect.

[0018] The knowledge graph creation method provided in the embodiment of the present application triggers a knowledge graph creation task process in response to a knowledge graph creation request sent by a user, so that the knowledge graph can be created based on the knowledge graph creation task process in the future, laying the foundation for the automated creation of the knowledge graph. In actual applications, by obtaining multiple entity data in the document to be processed, as well as the target relationship information between the multiple entity data, and inputting the first prompt word, multiple entity data, and the target relationship information between the multiple entity data into the first large language model, not only the automated extraction of multiple entity data and corresponding target relationship information in the document to be processed is achieved, but also the first large language model can output the graph database import statement corresponding to the target graph database according to the first prompt word. In simple terms, the first large language model can generate a graph database import statement corresponding to any graph database type according to actual needs. When a new graph database needs to be switched, a graph database import statement corresponding to the new graph database can be directly generated, achieving compatibility with multiple different types of graph databases. After obtaining the graph database import statement corresponding to the target graph database, the graph database import statement can be stored in the target graph database to create a target knowledge graph based on the target graph database. The entire process does not require human participation, with low cost and high efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0020] Figure 1A flowchart of a knowledge graph creation method provided in an embodiment of the present application;

[0021] Figure 2 A flowchart of obtaining multiple entity data in a document to be processed and target relationship information between the multiple entity data provided in an embodiment of the present application;

[0022] Figure 3 Another flowchart of a knowledge graph creation method provided in an embodiment of the present application;

[0023] Figure 4 A schematic diagram of the structure of a knowledge graph creation device provided in an embodiment of the present application;

[0024] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] To make the purpose, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0026] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0027] The following describes some embodiments of the present invention in detail with reference to the accompanying drawings. The following embodiments and features thereof may be combined with one another unless they conflict with each other. Furthermore, the sequence of steps in the following method embodiments is provided for illustrative purposes only and is not intended to be a strict limitation.

[0028] First, the terms or concepts involved in the embodiments of this application are explained:

[0029] Intelligent agents: These robots, based on a large language model as their core controller, are capable of role-playing, search-enhanced generation, tool invocation, and workflow. They can handle not only simple question-and-answer tasks but also complex logical conversations and perform intelligent operations based on specific needs.

[0030] Workflow: It is a flexible way to create intelligent agents. It can freely combine different capability modules such as large models, knowledge bases, plug-ins, etc., to enhance the understanding and execution capabilities of intelligent agents when performing complex procedural tasks. Through the design of workflows, intelligent agents can more effectively manage and complete tasks in multiple links.

[0031] Knowledge graph: A structured semantic knowledge base used to describe concepts and their relationships in the physical world in symbolic form. Its basic building blocks are "entity-relationship-entity" triples, along with entities and their associated attribute-value pairs. Entities are connected through relationships, forming a network-like knowledge structure.

[0032] At present, the existing technology generally creates knowledge graphs manually. In specific implementation, multiple entity data in the document to be processed and the relationship between the multiple entity data are manually analyzed. Afterwards, a graph database statement is manually written, and based on the graph database statement, multiple entity data and the relationship between the multiple entity data are stored in the graph database to create a knowledge graph. However, this way of creating a knowledge graph requires a lot of manual intervention, and the labor cost is high. In addition, the manual way of writing graph database statements will cause different graph databases to use different query languages. When it is necessary to switch the graph database (that is, when a new graph database is currently needed, or when data migration between different graph databases is performed), it is necessary to manually rewrite the graph database statement, which is inefficient and costly.

[0033] In view of this, an embodiment of the present application provides a method for creating a knowledge graph. Figure 1 A flowchart of a knowledge graph creation method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes the following steps:

[0034] 101. In response to a knowledge graph creation request sent by a user, the knowledge graph creation task process is triggered, and the following steps are performed according to the knowledge graph creation task process:

[0035] 1011. Obtain multiple entity data in the document to be processed and target relationship information between the multiple entity data.

[0036] 1012. Input the first prompt word, multiple entity data, and target relationship information between the multiple entity data into the first large language model to obtain a graph database import statement corresponding to the target graph database.

[0037] Among them, the first prompt word includes the description text of the target graph database type and the description text of the data processing rules. The data processing rules are used to guide the first language model to output the corresponding graph database import statement according to the target graph database type; the entity data includes the entity type and entity attributes, and the target relationship information includes the relationship type and relationship attributes. The graph database import statement is obtained by mapping the entity type to the node label, the entity attributes to the node attributes, the relationship type to the edge type, and the relationship attributes to the edge attributes through the first language model.

[0038] 1013. Store the graph database import statement into the target graph database to create a target knowledge graph based on the target graph database.

[0039] In actual applications, after receiving a knowledge graph creation request from a user, the workflow engine automatically triggers the knowledge graph creation task process and executes the following steps according to the knowledge graph creation task process:

[0040] Get multiple entity data in the document to be processed, as well as target relationship information between the multiple entity data. Specifically, for example:

[0041] As an implementation method, an agent can be used to obtain multiple entity data in a document to be processed, as well as target relationship information between the multiple entity data. Specifically, a second prompt word is input into a second language model to obtain multiple entity data in the document to be processed, as well as target relationship information between the multiple entity data. The second prompt word includes a task description text for the document to be processed, generating multiple entity data and target relationship information. The task description text is used to prompt the second language model to identify the multiple entity data and target relationship information in the document to be processed and output them in a format that meets the requirements of the graph database import statement.

[0042] For ease of understanding, the following is an example of the second prompt word:

[0043] Please carefully read and analyze the following document:

[0044] [Paste the contents of the document to be processed here]

[0045] Task requirements (i.e. the above task description text):

[0046] 1. **Identify entities and relationships**: Extract all relevant entities and their types, as well as the relationships between entities (where entities are the aforementioned "entity data" and relationships between entities are the aforementioned "target relationship information") from the document to be processed.

[0047] -Entity examples: specific objects such as people, organizations, places, dates, etc.

[0048] -Relationship examples: connections that connect entities such as "works at", "is located at", "collaborates with", etc.

[0049] 2. **Output triple set**: Present all entity pairs and their relationships in triple form, in the format of `<entity1,relationship,entity2>`.

[0050] 3. **Generate definition set**:

[0051] - **Entity Definition Collection**: Lists the name of each entity and its type definition, ensuring that types are standardized (for example, using common categories such as person, company, place, etc.).

[0052] - **Relationship Definition Set**: Lists the name of each relationship and its semantic description (for example, "represents an employment relationship").

[0053] 4. **Prepare graph database statements**: The output should be easy to convert into graph database statements (such as Cypher statements corresponding to Neo4j).

[0054] Output format requirements:

[0055] The entire output is organized in JSON format and contains three parts:

[0056] An array of triples, each element is `{"entity name","relation name","entity name"}`.

[0057] An array of entity definitions, each element is `{"entity name","type definition"}`.

[0058] An array of relationship definitions, each element is `{"relationship name","relationship description"}`.

[0059] - Please ensure that the output is complete, accurate, and based on the content of the document to be processed; if the content of the document to be processed is invalid or missing, an error message will be output.

[0060] As can be seen in the above example, in addition to the task description text containing the document to be processed, the generation of multiple entity data, and the target relationship information, the second prompt also includes "output format requirements" to ensure that the output format of the second language model meets the specified requirements. It should be noted that in the above second prompt, "**Prepare graph database statements**: The output should be easy to convert into graph database statements (such as Neo4j Cypher queries)" is used to instruct the second language model to output in a format that meets the requirements of graph database import statements.

[0061] For example, suppose the document to be processed is: Group A acquired Group B in 2000 for $3 billion. Then, after the above document to be processed is input into the second largest language model contained in Agent A, the second largest language model will output:

[0062] An array of triples, including: {Group A, Acquires Group B}, {Acquisition event, Occurred in, 2000}, {Acquisition event, Amount involved, USD 3 billion};

[0063] An array of entity definitions, including: {2000, time}, {Group A, company}, {Group B, company}, {USD 3 billion, amount}, {acquisition event, event};

[0064] An array of relationship definitions, including: {acquisition, indicating that one company acquires control of another company through a transaction}, {occurred at, indicating the time point when the event occurred}, and {amount involved, indicating the transaction amount associated with the event}.

[0065] By setting the above-mentioned second prompt word and using the second largest language model to obtain multiple entity data in the document to be processed, as well as the target relationship information between the multiple entity data, the data acquisition efficiency is improved while ensuring the accuracy of the "multiple entity data, as well as the target relationship information between the multiple entity data" finally obtained. In addition, it should be noted that the second prompt word is also used to guide the second largest language model to output in a format that meets the requirements of the graph database import statement. By outputting multiple entity data and the target relationship information between the multiple entity data in a format that meets the requirements of the graph database import statement, it can make it faster to input them into the first largest language model later, achieve seamless connection, and improve overall work efficiency. For example, since the Cypher statement corresponding to Neo4j is in English, in order to facilitate the direct use of the above-mentioned multiple entity data and the relationship information between the multiple entities when generating Cypher statements later, English can be used to express them in the above-mentioned entity definition set and relationship definition set (for example, person PERSON, company COMPANY, location LOCATION), and the final data result is also in English, for example:

[0066]

[0067]

[0068] Among them, "triples" refers to the array of triplets mentioned above, "entity1" refers to entity 1, "entity2" refers to entity 2, "relation" refers to the relationship between entities, and "entity_definitions" refers to the array of entity definitions mentioned above.

[0069] "entity_name" represents the entity name, "type_definition" represents the type definition of the entity, "relation_definitions" refers to the array of the above relationship definitions, "relation_name" represents the relationship name, and "relation_description" represents the relationship description corresponding to the relationship name.

[0070] As another implementation, obtaining multiple entity data in the document to be processed and target relationship information between the multiple entity data may also include the following steps:

[0071] Step 201: Entity data of the document to be processed is identified based on set identification rules to obtain a plurality of entity data in the document to be processed.

[0072] Step 202: Match the document to be processed with multiple relational expressions in a set rule library, where the relational expression is used to describe the association relationship between at least two entity data.

[0073] Step 203: If the target relationship expression is successfully matched, target relationship information between the multiple entity data is determined based on the target relationship expression and the multiple entity data.

[0074] In practical applications, the identification rules can be set as: domain dictionary matching rules, regular expression rules, etc. Specifically:

[0075] For domain dictionary matching rules, for example, based on pre-created dictionaries in multiple fields, such as an organization name dictionary (recording the names of related organizations such as groups and trade unions), a currency unit dictionary (recording related currency units such as "billion", "ten thousand", and "dollars"), etc., the document to be processed can be matched with dictionaries in multiple fields respectively. If there are words in the document to be processed that successfully match the dictionaries in multiple fields, the successfully matched words are extracted as multiple entity data in the document to be processed.

[0076] For example, regular expression rules can be pre-configured to match different types of entity data. For example, the matching pattern for organizational entity data can begin with "Group" followed by a combination of Chinese characters, letters, and numbers (e.g., "Group A," "Group Company X," etc.). The matching pattern for time entity data can be a combination of numbers + year / month / day. Amount entity data can be a combination of numbers (including decimal points) + monetary units such as ten thousand / hundred million. In specific implementations, the document to be processed can be fully scanned, and matching content can be found and extracted from the document according to the matching pattern to serve as multiple entity data in the document to be processed.

[0077] Continuing with the example of the document to be processed being "Group A acquired Group B in 2000 for a transaction amount of USD 3 billion", after entity data recognition using the above set recognition rules, the multiple entity data obtained may be {2000, time},

[0078] {Group A, Company / Organization}, {Group B, Company / Organization}, {US$3 billion, amount}, {Acquisition Event, Event}.

[0079] Afterwards, the document to be processed is matched against multiple relational expressions in the set rule library to determine whether there is a relational expression in the set rule library that matches the content of the document to be processed. For example, assuming that the multiple relational expressions recorded in the set rule library include "(?) Acquired (?)" and "(?) Occurred in (?)", then the document to be processed "Group A acquired Group B in 2000 for US$3 billion" can be matched against multiple relational expressions. If a match is successful, the target relationship information between the multiple entity data can be determined, such as (Group A) acquired (Group B), (acquisition event) occurred in (2000), etc. At this point, the target relationship information between the multiple entity data is determined.

[0080] By identifying entity data of the document to be processed based on set recognition rules and matching the document to be processed with multiple relational expressions in the set rule library, the target relationship information between multiple entity data can be determined if the match is successful. The entire process does not require training data and human participation, and realizes the rapid extraction of multiple entity data in the document to be processed and the target relationship information between multiple entity data.

[0081] Furthermore, if the target relational expression is not matched, the setting statement processing service is called to analyze the document to be processed according to the grammatical rules to determine the first relational information between the plurality of entity data.

[0082] Specifically, if the target relationship expression is not matched, it means that the relationship between the multiple entity data is not found in the set rule library. At this time, the set statement processing service can be called from the outside through the application program interface, and the document to be processed is analyzed according to the corresponding grammatical rules composed of "subject", "predicate", "object", etc. (such as "subject" is before "predicate", "predicate" is generally followed by "object", etc.), and then the first relationship information between the multiple entity data is determined. Determining the first relationship information between the multiple entity data in this way is equivalent to providing a backup for the above-mentioned "relational expression" solution, that is, the embodiment of the present application can successfully determine the first relationship information between the multiple entity data when the target relationship expression is not matched. Among them, the first relationship information is associated with a first confidence level, and the first confidence level is used to describe the credibility of the first target relationship information.

[0083] It should be noted that the first relationship information between multiple entity data determined by only calling the setting statement processing service to analyze the document to be processed according to the grammatical rules may be inaccurate. In view of this, if the target relationship expression is not matched, the document to be processed and multiple entity data can also be input into the setting relationship analysis model to obtain the second relationship information between the multiple entity data, and the second relationship information is associated with a second confidence level; based on the first confidence level and the second confidence level, the first relationship information or the second relationship information is determined as the target relationship information between the multiple entity data, wherein the second confidence level is used to describe the credibility of the second relationship information.

[0084] In a specific implementation, the document to be processed and multiple entity data can be input into a pre-set relationship analysis model (the pre-set relationship analysis model can be a deep learning model pre-trained based on training samples and labels. The training process is conventional and will not be described in detail here). This generates second relationship information between the multiple entity data, which is associated with a second confidence level. Subsequently, based on the first confidence level and the second confidence level, either the first relationship information or the second relationship information can be determined as the target relationship information between the multiple entity data.

[0085] For ease of understanding, for example, assuming that the first relationship information between multiple entity data is determined to be "(Group B) acquires (Group A)", and its first confidence is 0.2, and the second relationship information between multiple entity data is determined to be "(Group A) acquires (Group B)", and its second confidence is 0.8, then it can be determined that the second confidence associated with the second relationship information is greater than the first confidence associated with the first relationship information. At this time, the second relationship information is taken as the basis, and "(Group A) acquires (Group B)" is used as the target relationship information.

[0086] By inputting the document to be processed and multiple entity data into a set relationship analysis model, the relationship information between the multiple entity data (i.e., the second relationship information) can be obtained again. Afterwards, by comparing the first confidence associated with the first relationship information with the second confidence associated with the second relationship information, and selecting the relationship information with higher confidence as the final target relationship information, the accuracy of the target relationship information is further improved.

[0087] After obtaining multiple entity data in the document to be processed and target relationship information between the multiple entity data, the first prompt word, the multiple entity data, and the target relationship information between the multiple entity data are input into the first large language model to obtain a graph database import statement corresponding to the target graph database.

[0088] For ease of understanding, the following is an example of the first prompt word:

[0089] Please generate a standard graph database creation statement based on the following triple data. Specific requirements:

[0090] 1. Target database: `[graph database type] (i.e., description of the target graph database type)` (Supported: Neo4j / JanusGraph / NebulaGraph)

[0091] 2. Input format: Each line contains a strictly standardized triplet in the following format:

[0092] **Entity definition**: `[entity type]|[entity ID] attribute name attribute value`

[0093] (Example: `Person|P1 name"John"`)

[0094] **Relationship definition**: `[source entity type]|[source entity ID]relationship name[target entity type]|[target entity ID]`

[0095] (Example: `Person|P1 lives_in City|C1`)

[0096] 3. Data processing rules (description of data processing rules):

[0097] -String values ​​containing spaces must be enclosed in double quotes

[0098] -ID serves as the node's unique identifier (auto-generated if not provided)

[0099] - Automatically identify the type of attribute value (string / number / Boolean value)

[0100] -Generate corresponding syntax according to the target database type:

[0101] Neo4j → Cypher

[0102] JanusGraph → Gremlin

[0103] NebulaGraph → nGQL

[0104] 4. Example:

[0105] enter:

[0106] Neo4j

[0107] Person|P1 name"John Doe"

[0108] Person|P1 age 30

[0109] City|C1 name"Paris"

[0110] Person|P1 lives_in City|C1

[0111] Output:

[0112] CREATE(P1:Person{name:"John Doe",age:30});

[0113] CREATE(C1:City{name:"Paris"});

[0114] MATCH(s:Person{id:"P1"}),(t:City{id:"C1"})CREATE(s)-[:LIVES_IN]->(t)".

[0115] The above example is explained below. For "input," Neo4j represents the type of the target graph database. Person|P1 means: Create a Person-type node with ID P1, whose corresponding attribute values ​​are "name"John Doe" (name is John Doe) and "age 30" (age is 30 years old). City|C1 means: Create a City-type node with ID C1, whose corresponding attribute value is "name"Paris (name is Paris). Person|P1 lives_in City|C1 indicates the relationship between the two nodes: John Doe lives in Paris.

[0116] "For output", CREATE(P1:Person{name:"John Doe",age:30}) and CREATE(C1:City{name:"Paris"}) mean: create nodes, the nodes include node variable names (P1, C1), node types (Person, City), attribute sets (name"John Doe", age 30, name"Paris"), and in the attribute set, automatically merge attributes with the same ID.

[0117] MATCH(s:Person{id:"P1"}),(t:City{id:"C1"})CREATE(s)-[:LIVES_IN]->(t) means: find the Person node with ID P1 and the City node with ID C1, and determine the relationship between Person and City.

[0118] It should be noted that entity data includes entity types (such as Person, City) and entity attributes (name "JohnDoe", age 30, name "Paris"). The target relationship information includes relationship types (living in) and relationship attributes (indicating the place where the person lives). The graph database import statement is obtained by mapping entity types to node labels, mapping entity attributes to node attributes, mapping relationship types to edge types, and mapping relationship attributes to edge attributes.

[0119] Afterwards, the graph database import statement is stored in the target graph database to create a target knowledge graph based on the target graph database. Specifically, the workflow engine can call the application program interface corresponding to the set graph database interaction service to execute the graph database import statement, where the set graph database interaction service encapsulates a native driver of at least one graph database type; based on the native driver, the graph database import statement is submitted to the target graph database for storage.

[0120] During specific implementation, the workflow engine sends a data entry request to the set graph database interaction service, and the data entry request carries the type of graph database. The set graph database interaction service selects the corresponding native driver according to the type of graph database (if the graph database type is Neo4j, select the Cypher statement), obtains the database connection from the connection pool, and directly executes the graph database import statement through the driver to complete the data entry. The execution result is returned to the workflow engine through the application program interface API. By calling the corresponding application program interface of the set graph database interaction service to execute the graph database import statement, and based on the native driver, the graph database import statement is submitted to the target graph database to perform the entry operation, which is equivalent to building a connection bridge between the workflow engine and the target graph database, ensuring that the graph database import statement can be successfully stored in the target graph database.

[0121] After the warehousing operation is completed, you can search in the target graph database according to the user's actual needs (such as searching according to the set index information) to find the required entity data and corresponding relationship information, and create a knowledge graph based on the required entity data and corresponding relationship information.

[0122] Based on the above, the knowledge graph creation method provided in the embodiment of the present application triggers the knowledge graph creation task process in response to the knowledge graph creation request sent by the user, so that the knowledge graph can be created based on the knowledge graph creation task process in the future, laying the foundation for the automated creation of the knowledge graph. In actual applications, by obtaining multiple entity data in the document to be processed, as well as the target relationship information between the multiple entity data, and inputting the first prompt word, multiple entity data, and the target relationship information between the multiple entity data into the first large language model, not only the automatic extraction of multiple entity data and corresponding target relationship information in the document to be processed is achieved, but also the first large language model can output the graph database import statement corresponding to the target graph database according to the first prompt word. In simple terms, the first large language model can generate a graph database import statement corresponding to any graph database type according to actual needs. When a new graph database needs to be switched, a graph database import statement corresponding to the new graph database can be directly generated, achieving compatibility with multiple different types of graph databases. After obtaining the graph database import statement corresponding to the target graph database, the graph database import statement can be stored in the target graph database to create a target knowledge graph based on the target graph database. The entire process does not require human participation, with low cost and high efficiency.

[0123] Figure 3 Another flow chart of a knowledge graph creation method provided in an embodiment of the present application, such as Figure 3 As shown, the method includes the following steps:

[0124] 301. Input a third prompt word into the third language model to obtain a cleaned document to be processed, wherein the third prompt word includes the document to be processed and a description text of the document cleaning requirements, and the description text of the document cleaning requirements is used to prompt the third language model to clean irrelevant data from the document to be processed.

[0125] 302. Acquire multiple entity data in the document to be processed and target relationship information between the multiple entity data.

[0126] 303. Input the first prompt word, multiple entity data, and target relationship information between the multiple entity data into the first large language model to obtain a graph database import statement corresponding to the target graph database.

[0127] Among them, the first language model includes the description text of the target graph database type and the description text of the data processing rules. The data processing rules are used to guide the first language model to output the corresponding graph database import statement according to the target graph database type; the entity data includes the entity type and entity attributes, and the target relationship information includes the relationship type and relationship attributes. The graph database import statement is obtained by mapping the entity type to the node label, mapping the entity attributes to the node attributes, mapping the relationship type to the edge type, and mapping the relationship attributes to the edge attributes.

[0128] 304. Input the graph database import statement and the fourth prompt word into the fourth language model to obtain a graph database import statement review result, wherein the fourth prompt word includes a description text of the statement review requirement, and the description text of the statement review requirement is used to prompt the fourth language model to perform a correctness review on the graph database import statement.

[0129] 305. Correct incorrect graph database import statements in the graph database import statement review results.

[0130] 306. Store the graph database import statement into the target graph database to create a target knowledge graph based on the target graph database.

[0131] The specific execution process of the above steps 302, 303 and 306 can be found in the above embodiments and will not be described again here.

[0132] For step 301, after obtaining the document to be processed, the workflow engine inputs the document to be processed and the third prompt word into the third language model, thereby cleaning the document to be processed, removing redundant links, template content or irrelevant comments in the document to be processed, and optimizing the document format to make it more concise and structured, laying the foundation for the subsequent rapid extraction of entity data and relationship information.

[0133] For ease of understanding, the following is an example of the third prompt word:

[0134] **Role:** You are now a senior data analyst proficient in data processing, information extraction and format conversion.

[0135] **Task:** Perform data cleaning and conversion on the provided unstructured document content.

[0136] **enter:**

[0137] **Document Content:** `[Paste your unstructured document content here (i.e. the document to be processed)]`

[0138] Requirements (description of document cleaning requirements):

[0139] Standardization:

[0140] Remove all extraneous, redundant information that is irrelevant to the core message (e.g., page numbers, headers, footers, company-irrelevant copyright notices, irrelevant advertising text, repeated greetings / signatures, etc.).

[0141] Clean or normalize any garbled, corrupted, or unrecognizable special characters.

[0142] Clear common interference strings (such as consecutive `***`, `---`, and meaningless `#`).

[0143] Key information extraction:

[0144] Extract the core content, key facts, data points, or arguments from the document to be processed. Focus on the parts that carry the main information.

[0145] Format conversion:

[0146] Convert the cleaned key information into the following structured format:

[0147] Target format:**

[0148] 5. Output requirements:

[0149] Output only the final cleaned and converted results, without any explanations, prompts, step-by-step instructions, or original text.

[0150] The results should conform to the target format requirements and be clear and accurate.

[0151] Make sure the result is semantically complete and fluent (especially when converting to paragraphs).

[0152] 6. Notes:

[0153] Be sure to retain the core information of the original text and do not lose key content due to cleaning.

[0154] Process line breaks and spaces: remove redundant spaces and line breaks (replace multiple consecutive spaces with a single one, and remove unnecessary line breaks), and only retain necessary line breaks or use separators at semantic segmentation points.

[0155] For English text, consider standardizing capitalization (e.g., capitalizing the first letter of proper nouns).

[0156] **Output:**

[0157] `[Output only the final cleansing and conversion results, which conform to the target format requirements]`

[0158] For steps 304-305, by inputting the graph database import statement and the fourth prompt word into the fourth language model to obtain the graph database import statement review result, and correcting the incorrect graph database import statement in the graph database import statement review result, the accuracy of the graph database import statement finally stored in the graph database can be ensured.

[0159] For ease of understanding, the fourth prompt word is described below with an example:

[0160] As a graph database quality verification expert, you need to perform three-fold verification:

[0161] 1.**Syntax check**: Verify whether the statement complies with the grammatical specifications

[0162] 2. **Logical consistency check**: Ensure compliance with knowledge graph constraints

[0163] 3. **Semantic Audit**: Verify business rationality based on domain rules

[0164] Knowledge graph constraints: {.....}

[0165] Domain rules: {......}

[0166] #Verification process

[0167] ##1. Syntax check

[0168] ###Verification requirements:

[0169] -Keyword spelling {......}

[0170] - Closed brackets / quotes

[0171] -Parameter format {......}

[0172] -Special symbols {......}

[0173] ###Output format:

[0174]

[0175] The above example uses "Syntax Verification" as an example for detailed explanation. The prompts for "Logical Consistency Check" and "Semantic Review" are similar to "Syntax Verification," differing only in the verification requirements. This three-tiered verification mechanism of syntax verification, logical consistency checking, and semantic review ensures that graph database import statements comply with graph database specifications.

[0176] It should be noted that, in actual applications, the structures of the above-mentioned first language model, second language model, third language model, and fourth language model may be the same or different, and the first language model, second language model, third language model, and fourth language model may belong to the same intelligent agent or to different intelligent agents respectively, which is not limited here.

[0177] The following describes in detail the knowledge graph creation apparatus of one or more embodiments of the present invention. Those skilled in the art will appreciate that these apparatuses can be configured using commercially available hardware components and the steps taught in this solution.

[0178] Figure 4 A schematic diagram of the structure of a knowledge graph creation device provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the device includes: a responding module 11, a determining module 12, an acquiring module 13 and a creating module 14.

[0179] The response module 11 is used to respond to the knowledge graph creation request sent by the user, trigger the knowledge graph creation task process, and perform the following steps according to the knowledge graph creation task process:

[0180] The determination module 12 is configured to obtain a plurality of entity data in the document to be processed and target relationship information between the plurality of entity data.

[0181] An acquisition module 13 is configured to input a first prompt word, the plurality of entity data, and target relationship information between the plurality of entity data into a first large language model to obtain a graph database import statement corresponding to the target graph database; wherein the first prompt word includes description text of the target graph database type and description text of the data processing rules, and the data processing rules are configured to guide the first large language model to output a corresponding graph database import statement according to the target graph database type; the entity data includes entity types and entity attributes, the target relationship information includes relationship types and relationship attributes, and the graph database import statement is obtained by mapping the entity types to node labels, mapping the entity attributes to node attributes, mapping the relationship types to edge types, and mapping the relationship attributes to edge attributes through the first large language model.

[0182] A creation module 14 is used to store the graph database import statement into the target graph database to create a target knowledge graph based on the target graph database.

[0183] Optionally, the determination module 12 is specifically configured to: input a second prompt word into a second language model to obtain multiple entity data in the document to be processed and target relationship information between the multiple entity data, wherein the second prompt word includes the document to be processed and a task description text for generating the multiple entity data and the target relationship information, the task description text being used to prompt the second language model to identify the multiple entity data and the target relationship information in the document to be processed and output them in a format that meets the requirements of the graph database import statement; and perform entity data recognition on the document to be processed based on set recognition rules to obtain the multiple entity data in the document to be processed; match the document to be processed with multiple relational expressions in a set rule library, the relational expressions being used to describe the association relationship between at least two entity data; if a target relational expression is successfully matched, determine the target relationship information between the multiple entity data based on the target relational expression and the multiple entity data; and if a target relational expression is not matched, call a set statement processing service to analyze the document to be processed according to grammatical rules to determine the first relationship information between the multiple entity data.

[0184] Among them, optionally, the first relationship information is associated with a first confidence level, and the first confidence level is used to describe the credibility of the first target relationship information; the determination module 12 is specifically further used to: input the document to be processed and the multiple entity data into a set relationship analysis model to obtain second relationship information between the multiple entity data, and the second relationship information is associated with a second confidence level, and the second confidence level is used to describe the credibility of the second relationship information; based on the first confidence level and the second confidence level, determine the first relationship information or the second relationship information as the target relationship information between the multiple entity data.

[0185] Optionally, the acquisition module 13 is further configured to: input a third prompt word into a third language model to obtain a cleaned document to be processed, wherein the third prompt word includes the document to be processed and a description text of the document cleaning requirements, wherein the description text of the document cleaning requirements is used to prompt the third language model to clean the document to be processed of irrelevant data; and input the graph database import statement and the fourth prompt word into a fourth language model to obtain a graph database import statement review result, wherein the fourth prompt word includes a description text of the statement review requirements, wherein the description text of the statement review requirements is used to prompt the fourth language model to review the correctness of the graph database import statement; and correct incorrect graph database import statements in the graph database import statement review result.

[0186] Among them, optionally, the creation module 14 is specifically used to: call the application program interface corresponding to the set graph database interaction service to execute the graph database import statement, wherein the set graph database interaction service encapsulates a native driver of at least one graph database type; based on the native driver, submit the graph database import statement to the target graph database to perform the warehousing operation.

[0187] Figure 4 The device shown can execute the steps provided in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments and will not be repeated here.

[0188] In one possible design, the above Figure 4 The structure of the knowledge graph creation device shown can be implemented as an electronic device. Figure 5 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code, and when the executable code is executed by the processor 21, the processor 21 can at least implement the knowledge graph creation method provided in the aforementioned embodiment.

[0189] In addition, an embodiment of the present application provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the knowledge graph creation method provided in the aforementioned embodiment.

[0190] An embodiment of the present application provides a computer program product, including: a computer program, which, when executed by a processor of an electronic device, enables the processor to execute the knowledge graph creation method provided in the aforementioned embodiment.

[0191] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Those skilled in the art can understand and implement the present invention without inventive effort.

[0192] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general-purpose hardware platform, and of course can also be implemented by combining hardware and application programs. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0193] 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 it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A knowledge graph creation method, characterized in that: The method comprises: In response to a knowledge graph creation request sent by a user, the knowledge graph creation task process is triggered, and the following steps are performed according to the knowledge graph creation task process: Acquire multiple entity data in the document to be processed, and target relationship information between the multiple entity data; Inputting a first prompt word, the plurality of entity data, and target relationship information between the plurality of entity data into a first large language model to obtain a graph database import statement corresponding to a target graph database; wherein the first prompt word includes description text of the target graph database type and description text of a data processing rule, and the data processing rule is used to guide the first large language model to output a corresponding graph database import statement according to the target graph database type; the entity data includes an entity type and entity attributes, the target relationship information includes a relationship type and relationship attributes, and the graph database import statement is obtained by mapping the entity type to a node label, mapping the entity attributes to a node attribute, mapping the relationship type to an edge type, and mapping the relationship attributes to an edge attribute through the first large language model; The graph database import statement is stored in the target graph database to create a target knowledge graph based on the target graph database.

2. The method according to claim 1, characterized in that The acquiring of a plurality of entity data in the document to be processed and target relationship information between the plurality of entity data includes: The second prompt word is input into the second largest language model to obtain multiple entity data in the document to be processed and target relationship information between the multiple entity data, wherein the second prompt word includes the document to be processed, a task description text for generating the multiple entity data and the target relationship information, and the task description text is used to prompt the second largest language model to recognize the multiple entity data and the target relationship information in the document to be processed, and output them in a format that meets the requirements of the graph database import statement.

3. The method according to claim 1, characterized in that The acquiring of a plurality of entity data in the document to be processed and target relationship information between the plurality of entity data includes: Perform entity data recognition on the document to be processed based on the set recognition rules to obtain multiple entity data in the document to be processed; Matching the document to be processed with a plurality of relational expressions in a set rule library, wherein the relational expressions are used to describe an association relationship between at least two entity data; If the target relationship expression is successfully matched, target relationship information between the plurality of entity data is determined based on the target relationship expression and the plurality of entity data.

4. The method according to claim 3, characterized in that After matching the document to be processed with the plurality of relational expressions in the set rule base, the method further includes: If the target relational expression is not matched, the setting statement processing service is called to analyze the document to be processed according to the grammatical rules to determine the first relational information between the plurality of entity data.

5. The method according to claim 4, characterized in that The first relationship information is associated with a first confidence level, where the first confidence level is used to describe the credibility of the first target relationship information; the method further includes: Inputting the document to be processed and the plurality of entity data into a set relationship analysis model to obtain second relationship information between the plurality of entity data, wherein the second relationship information is associated with a second confidence level, and the second confidence level is used to describe the credibility of the second relationship information; Based on the first confidence level and the second confidence level, the first relationship information or the second relationship information is determined as target relationship information between the plurality of entity data.

6. The method according to any one of claims 1 to 5, characterized in that Before obtaining a plurality of entity data in the document to be processed and target relationship information between the plurality of entity data, the method further includes: The third prompt word is input into the third largest language model to obtain the cleaned document to be processed, wherein the third prompt word includes the document to be processed and a description text of the document cleaning requirements, and the description text of the document cleaning requirements is used to prompt the third largest language model to clean irrelevant data from the document to be processed.

7. The method according to any one of claims 1 to 5, characterized in that After obtaining the graph database import statement corresponding to the target graph database, the method further includes: Inputting the graph database import statement and the fourth prompt word into the fourth language model to obtain a graph database import statement review result, wherein the fourth prompt word includes a description text of the statement review requirement, and the description text of the statement review requirement is used to prompt the fourth language model to perform a correctness review on the graph database import statement; Correct the incorrect graph database import statements in the graph database import statement audit results.

8. The method according to claim 1, characterized in that The step of storing the graph database import statement into the target graph database includes: Calling an application program interface corresponding to a set graph database interaction service to execute the graph database import statement, wherein the set graph database interaction service encapsulates a native driver of at least one graph database type; Based on the native driver, the graph database import statement is submitted to the target graph database to perform the storage operation.

9. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the knowledge graph creation method as described in any one of claims 1 to 8.

10. A non-transitory machine-readable storage medium, characterized in that The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes the knowledge graph creation method as described in any one of claims 1 to 8.

11. A computer program product, characterized in that include: A computer program, when executed by a processor of an electronic device, causes the processor to execute the knowledge graph creation method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Power grid fault disposal plan retrieval method and system

    CN118820269A

  • Knowledge graph analysis and question answering method and device based on large language model

    CN119691243A

  • Rail transit operation and maintenance industry question and answer method based on mixed retrieval enhancement

    CN119962663A

  • Knowledge graph question-answer method and apparatus based on deep learning technology, and device

    WO2021139283A1

  • Video processing method and apparatus, and terminal device

    WO2025056030A1