Knowledge graph construction method and device, equipment and storage medium
By combining knowledge graphs and language models and using thinking chain technology for in-depth analysis, the problem that existing technology is difficult to capture deep information is solved, and high-quality knowledge graph construction and text analysis effects are achieved.
Patent Information
- Application Number
- CN202510155290.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2025-04-11
AI Technical Summary
When analyzing novels and scripts, existing natural language processing technology is difficult to fully capture complex deep-seated information such as character relationships, emotional changes, and plot development, resulting in incomplete information extraction and affecting the quality of the construction of the knowledge graph.
By combining the structured representation ability of the knowledge graph and the deep understanding ability of the language model, the thinking chain technology is used to guide the language model for more in-depth reasoning and analysis, extract factual information and relationship information of multiple entities in the text, and dynamically define the nodes and association relationships of the knowledge graph according to the content type.
It significantly improves the completeness and accuracy of information extraction, builds a high-quality knowledge graph, and improves the accuracy and practicality of text analysis and processing.
Smart Images

Figure CN119808926A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a knowledge graph construction method, device, equipment and storage medium. Background Art
[0002] In the digital entertainment industry, text analysis of novels and scripts is of great significance for creation, adaptation, and marketing. However, existing natural language processing (NLP) technology still faces the problem of incomplete information extraction when applied to these fields, especially the difficulty in fully capturing complex character relationships, emotional changes, and plot development. This not only limits the in-depth understanding of the text content, but also affects the quality of subsequent knowledge graph construction, resulting in the generated knowledge graph being unable to accurately reflect the core logic and value of the text. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present disclosure provide a knowledge graph construction method, device, equipment and storage medium.
[0004] In a first aspect, the present disclosure provides a method for constructing a knowledge graph, including:
[0005] Get the target text to be processed;
[0006] Extracting first text information from the target text according to a preset first prompt information; wherein the first text information represents factual information of multiple entities in the target text;
[0007] Performing semantic recognition on the first text information to determine the content type of the target text;
[0008] Define multiple nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type;
[0009] The first text information is mapped into the knowledge graph to obtain a target knowledge graph of the target text.
[0010] Optionally, the first prompt information includes entity prompt information and relationship prompt information, wherein the entity prompt information is used to guide the language model to identify and extract specific entities in the target text, and the relationship prompt information is used to guide the language model to determine the relationship between the extracted specific entities.
[0011] Optionally, extracting the first text information from the target text according to the preset first prompt information includes:
[0012] Using the first prompt information and the target text as inputs of the language model;
[0013] Extracting multiple entities from the target text according to the entity prompt information to obtain basic information of the target text; wherein the basic information includes the multiple entities and attributes of each entity;
[0014] Determine the relationship between the multiple entities according to the relationship prompt information to obtain relationship information;
[0015] The first text information includes the basic information and the relationship information.
[0016] Optionally, the entity prompt information includes a first question generated based on at least one keyword of person, event, place, time, organization, object, and content type, the basic information is answer information of the first question, and the multiple entities correspond to the at least one keyword;
[0017] The relationship prompt information includes a second question generated based on at least two entities and reasoning reasons about the second question. The relationship information is answer information of the second question, and the second question is used to inquire about the relationship between at least two entities.
[0018] Optionally, defining a plurality of nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type includes:
[0019] Based on the content type, define node types of multiple nodes in the knowledge graph, wherein each node represents an entity or a word used to describe text content;
[0020] According to the node type, defining an association relationship between at least two of the nodes, wherein the association relationship represents an interaction relationship between at least two of the nodes;
[0021] The knowledge graph is constructed based on the multiple nodes, the node types and the association relationships.
[0022] Optionally, after mapping the first text information to the knowledge graph to obtain a target knowledge graph of the target text, the method further includes:
[0023] Acquire text information structured in the target knowledge graph to obtain second text information;
[0024] The second text information is semantically understood based on the preset second prompt information to generate third text information that meets the intention of the second prompt information.
[0025] Optionally, after mapping the first text information to the knowledge graph to obtain a target knowledge graph of the target text, the method further includes:
[0026] Visualizing the target knowledge graph and obtaining adjustment information for the target knowledge graph;
[0027] The target knowledge graph is updated based on the adjustment information.
[0028] Optionally, the method further includes:
[0029] Obtain text requirements of target users;
[0030] Evaluate whether the target text meets the text requirement through the target knowledge graph;
[0031] In the case that the target text meets the text requirement, recommendation information of the target text is fed back to the target user.
[0032] In a second aspect, an embodiment of the present disclosure provides a knowledge graph construction device, the device comprising:
[0033] An acquisition unit, used for acquiring a target text to be processed;
[0034] An extraction unit, configured to extract first text information from the target text according to a preset first prompt information; wherein the first text information represents factual information of multiple entities in the target text;
[0035] A recognition unit, configured to perform semantic recognition on the first text information to determine the content type of the target text;
[0036] A node definition unit, used to define a plurality of nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type;
[0037] A construction unit is used to map the first text information into the knowledge graph to obtain a target knowledge graph of the target text.
[0038] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0039] Memory;
[0040] Processor; and
[0041] Computer programs;
[0042] The computer program is stored in the memory and is configured to be executed by the processor to implement the method of the first aspect as described above.
[0043] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method of the first aspect as described above.
[0044] The knowledge graph construction method provided by the present disclosure includes: obtaining a target text to be processed; extracting first text information from the target text according to a pre-set first prompt information; wherein the first text information represents the factual information of multiple entities in the target text; performing semantic recognition on the first text information to determine the content type of the target text; defining multiple nodes in the knowledge graph and the association relationship between at least two of the nodes according to the content type; mapping the first text information to the knowledge graph to obtain a target knowledge graph of the target text. The method provided by the present application significantly improves the integrity and accuracy of information extraction, while constructing a high-quality knowledge graph that conforms to the text content type, improving the accuracy and practicality of text analysis and text processing, and has important application value and technical advantages. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0047] Figure 1 A schematic diagram of a process for constructing a knowledge graph provided in an embodiment of the present disclosure;
[0048] Figure 2 for Figure 1 A schematic diagram of a detailed process of S102 in a knowledge graph construction method is shown;
[0049] Figure 3 for Figure 1 A schematic diagram of a detailed process of S104 in a knowledge graph construction method is shown;
[0050] Figure 4 A schematic diagram of another knowledge graph construction method provided in an embodiment of the present disclosure;
[0051] Figure 5 A schematic diagram of the structure of a knowledge graph construction method provided in an embodiment of the present disclosure;
[0052] Figure 6A schematic diagram of the structure of a knowledge graph construction device provided in an embodiment of the present disclosure;
[0053] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0054] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0055] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0056] Specifically, with the booming development of the digital entertainment industry, the creation and analysis of scripts and novels have become increasingly important. Traditional novel and script analysis relies heavily on manual reading and understanding, which is inefficient and highly subjective. In recent years, advances in natural language processing technology have provided new possibilities for the automated analysis of novels and scripts. Among them, knowledge graph technology can structure text information for easy reasoning and query, while large language models (LLMs) demonstrate powerful text understanding and generation capabilities. However, the existing technology still has the following problems:
[0057] (1) Incomplete information extraction: NLP methods based on rules or traditional machine learning have difficulty capturing the complex semantic relationships in scripts and novels, resulting in incomplete information extraction, especially in high-level semantics such as character arcs and thematic metaphors.
[0058] (2) Limited reasoning ability: The construction of knowledge graphs usually relies on manually defined structures and relationships, which makes it difficult to adapt to the flexible expression of different types of scripts and novels, limiting the reasoning ability of knowledge graphs.
[0059] (3) Lack of in-depth understanding: Although LLM can understand texts, when directly applied to script and novel analysis, it lacks structured output and is difficult to conduct quantitative analysis and comparison.
[0060] In response to the above technical problems, the embodiments of the present disclosure provide a knowledge graph construction method, which combines the structured representation capability of the knowledge graph with the deep understanding capability of the language model, and uses the Chain-of-Thought (CoT) technology to guide the language model to perform deeper reasoning and analysis, thereby achieving a refined and structured analysis of the text content. This is described in detail through one or more of the following embodiments.
[0061] The knowledge graph construction method provided in the embodiment of the present disclosure can be applied to text analysis scenarios. The method can be performed by a knowledge graph construction device, which can be implemented by software and / or hardware, and the device can be integrated in an electronic device. Among them, the electronic device can include but is not limited to mobile terminals such as smart phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Tablet Personal Computers, Tablet PCs), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, smart home devices, etc.
[0062] Figure 1 A schematic diagram of a knowledge graph construction method provided in an embodiment of the present disclosure, specifically including the following steps: Figure 1 The following steps are shown:
[0063] S101, obtaining a target text to be processed.
[0064] It can be understood that the target text refers to at least part of the text content of the complete text. The complete text may be a novel or a script, and the target text may be an abstract of the novel, or a certain chapter of the novel.
[0065] S102: extracting first text information from the target text according to preset first prompt information.
[0066] The first text information represents factual information of multiple entities in the target text.
[0067] It can be understood that information extraction is the process of structurally representing key entities, events, relationships, etc. in the text. For novels and scripts, information extraction must not only identify explicit factual information, but also capture implicit high-level semantic information. Specifically, the extraction of factual information can be achieved through a language model. In the process of extracting factual information from the target text through a language model, an analysis and extraction process based on the thinking chain technology is adopted. Among them, CoT mainly simulates the step-by-step thinking process of humans to help the language model better understand the problem, decompose the task, and finally get a reasonable answer. It can not only improve the accuracy of the model, but also enhance its interpretability and transparency. Specifically, the first prompt information is designed based on CoT to decompose the problem-solving process into multiple intermediate steps. Each step is derived based on the result of the previous step. The language model is guided to gradually extract information at different levels through the set first prompt information, and more accurately identify entities, extract entity attributes, content type and other information from them to obtain the first text information. Among them, entities refer to objects or concepts with specific meanings that are identified and extracted from texts, such as character entities, place entities, time entities, event entities, organization entities, etc. Taking the target text as a novel abstract as an example, entities refer to main characters and main events, etc.
[0068] S103: Perform semantic recognition on the first text information to determine the content type of the target text.
[0069] Understandably, based on the above S102, to determine the text content type, the key information extracted from the target text can be comprehensively analyzed to determine the content type. Alternatively, the content type can be determined directly based on certain specific words or phrases extracted from the target text, such as "detective", "case", "clue", etc., which can determine that the content type is suspenseful, but this method of directly determining based on specific words may not be comprehensive and accurate enough. A more effective way is to conduct an in-depth analysis of the first text information. Specifically, a suspense novel is taken as an example to explain in detail. The first text information includes but is not limited to key information, named entity information and event information, etc. According to the first text information, the narrative structure, emotional motivation and theme metaphor are analyzed to comprehensively and accurately determine the content type. The specific analysis method is not repeated.
[0070] S104. Define multiple nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type.
[0071] Understandably, based on the above S103, the knowledge graph is a form of representing knowledge in a graph structure, which consists of nodes and edges and is used to describe the semantic relationship between entities, such as nodes representing entities and edges representing the relationship between two entities. Specifically, the nodes and edges in the knowledge graph are flexibly defined according to the content type. For example, there are significant differences between suspense novels and emotional novels in terms of narrative style, theme expression, character relationships, etc., and the knowledge graphs constructed by the two will also be different. Among them, the core entities of suspense novels are usually cases, suspects, clues, evidence, etc. These entities constitute the main framework of the story and promote the development of the plot. The core entity of emotional novels is the characters, especially the emotional relationship between the main characters. The emotional changes and interactions of the characters are the core driving force of the story. Therefore, the dynamic definition of the knowledge graph according to the content type can adapt it to the analysis needs of texts of different content types. For example, in the knowledge graph of suspense novels, special context nodes are defined, such as case clue nodes, case trend nodes, case reasoning nodes, etc.; in the knowledge graph of emotional novels, special context nodes such as emotional change nodes and relationship change nodes are defined. These special nodes provide high-level abstraction and summary of the text content. Through the knowledge graph, we can better understand the overall context and development trend of the story, and provide strong support for subsequent reasoning, query and analysis.
[0072] S105. Map the first text information to the knowledge graph to obtain a target knowledge graph of the target text.
[0073] It is understandable that, based on the above S104, the first text information refers to factual information or structured data extracted from the target text, including entities (characters, places, events, etc.) and relationships (causal relationships, emotional changes, etc.). After the definition of special nodes is completed according to the content type, the first text information is mapped to the knowledge graph to obtain the target knowledge graph, which includes both special nodes that conform to the content type and factual nodes that reflect text facts. For example, a text of a suspense novel: "Detective A received an emergency call and then rushed to the scene. He found a young woman lying in a pool of blood and found a glove with fingerprints nearby." The first text information includes entities such as "A (detective)", "young woman (victim)", and "gloves (clues)", and the relationship between the entities is "A'investigation'young woman" and "A'discovery'gloves". Each entity is mapped to the fact node in the knowledge graph template, that is, a corresponding node is created for each extracted entity, and the relationship is used as the edge of the two fact nodes, that is, according to the extracted relationship, a connection is established between the nodes. "Gloves, fingerprints (key clues)" can be mapped to special nodes (case clue nodes), that is, high-level information (case clues) are added to the knowledge graph as separate nodes and associated with relevant entity nodes. The specific process of extracting structured information from text and organizing it into a knowledge graph is not limited. This target knowledge graph constructed according to the specific content type and needs of the target text can fully reflect the core logic, plot development and deep-level information of the text.
[0074] Optionally, after mapping the first text information to the knowledge graph to obtain a target knowledge graph of the target text, the method further includes:
[0075] Acquire the text information of the structured representation of the target knowledge graph to obtain second text information; perform semantic understanding on the second text information based on pre-set second prompt information to generate third text information that conforms to the intention of the second prompt information.
[0076] Among them, the second text information is the text information of the structured representation of the knowledge graph.
[0077] It is understandable that the extraction of high-level semantic information is specifically realized based on the second text information represented by the structured knowledge graph, which can extract high-level semantic information such as character arc, emotional motivation, theme metaphor, etc. In the process of extracting high-level semantic information, the thinking chain technology is used to guide the language model to have a deeper semantic understanding, wherein the second prompt information is the guiding information designed according to the thinking chain technology, which is used to guide the language model to extract the required high-level semantic information from the second text information to obtain the third text information.
[0078] It is understandable that when reasoning through a language model, it can also be combined with a knowledge base for reasoning, such as using a common sense knowledge base to supplement the reasoning ability of the language model and reduce the error of reasoning.
[0079] It is understandable that the first text information refers to the factual information extracted from the target text, and the third text information refers to the high-level semantic information further extracted from the target text in combination with the knowledge graph and the first text information. The first text information, the knowledge graph and / or the third text information are integrated to obtain the processing result of the target text. The processing results can be output in a variety of forms later, such as visualizing the knowledge graph, graphically displaying the factual information between multiple entities, and graphically displaying information such as character relationships, event developments, and character emotions when the target text is a novel. The third text information can also be summarized in natural language and then output, such as summarizing the high-level semantic information of the novel in natural language, such as the outline, worldview, and character arc.
[0080] Optionally, after mapping the first text information to the knowledge graph to obtain a target knowledge graph of the target text, the method further includes:
[0081] Visualize the target knowledge graph and obtain adjustment information for the target knowledge graph; and update the target knowledge graph based on the adjustment information.
[0082] Understandably, visualize the target knowledge graph, and introduce a user feedback mechanism to correct and improve the knowledge graph. Specifically, obtain the user's adjustment information for the target knowledge graph. The adjustment information can be a modification of the structure of the knowledge graph, such as connecting node A to node B, or a modification of the first text information, such as changing the friendship between character A and character B to an enemy relationship, or a modification of the third text information, such as adding character B's growth experience, etc. The target knowledge graph can be adjusted later based on the adjustment information, and the specific adjustment process will not be described in detail.
[0083] Optionally, after completing the construction of the target knowledge graph, the method further includes:
[0084] Obtaining text requirements of a target user; evaluating whether the target text meets the text requirements through the target knowledge graph; and feeding back recommendation information of the target text to the target user if the target text meets the text requirements.
[0085] It is understandable that before processing the target text, or after obtaining the processing result of the target text, the text demand of the target user is obtained. The text demand can be a script evaluation demand, an IP development demand or a content recommendation demand. Among them, the script evaluation demand refers to analyzing the script to provide an objective basis for the script evaluation. Under this demand, the target text refers to a script to be evaluated, and the recommended information refers to the target text generated based on the evaluation result as the analysis result of the script; the IP development demand refers to mining the potential value in the script to provide a direction for IP development. Under this demand, the target text refers to the script to be developed for IP, and the recommended information refers to the development suggestion information for the target text generated based on the development result; the content recommendation demand refers to recommending related novels according to user preferences. Under this demand, the target text refers to the novel to be recommended, and the recommended information is the reasoning information in the target text that meets the user's preferences. After obtaining the text demand, the target knowledge graph is used to evaluate whether the target text meets the text demand. The specific evaluation method is not described in detail. If the target text meets the text demand, the recommended information of the target text is fed back to the target user.
[0086] The knowledge graph construction method provided by the embodiment of the present disclosure extracts information from text content through language models and thought chain technology, which can more accurately capture the complex semantic relationships of texts and improve the completeness and accuracy of information extraction. The structure of the knowledge graph is dynamically adjusted according to texts of different content types, which improves the flexibility and adaptability of knowledge graph construction.
[0087] Based on the above embodiments, Figure 2 for Figure 1 The detailed flow diagram of S102 in a knowledge graph construction method shown in FIG. 1 is shown in FIG. 2 , wherein optionally, extracting the first text information from the target text according to the preset first prompt information specifically includes: Figure 2 The following steps are shown:
[0088] The first prompt information includes entity prompt information and relationship prompt information, wherein the entity prompt information is used to guide the language model to identify and extract specific entities in the target text, and the relationship prompt information is used to guide the language model to determine the relationship between the extracted specific entities. The entity prompt information includes a first question generated based on at least one keyword of person, event, place, time, organization, object, and content type, the basic information is the answer information of the first question, and the multiple entities correspond to the at least one keyword; the relationship prompt information includes a second question generated based on at least two entities and the reasoning reasons about the second question, the relationship information is the answer information of the second question, and the second question is used to inquire about the relationship between at least two entities.
[0089] It is understandable that the first prompt information includes entity prompt information and relationship prompt information. The entity prompt information is used to guide the language model to extract basic information from the target text, specifically including the first question generated based on at least one keyword of person, event, place, time, organization, object, and content type. The entity prompt information includes an unlimited number of first questions, such as the first question A is "When did this event happen? Where?", and the first question B is "Which characters are mentioned in the text? What are their names?". There may also be a sequence between multiple first questions, such as the first question C is "What happened to character B mentioned in the text (the answer given by the first question B)", that is, the first question C should be asked after the first question B. In addition, there is a corresponding relationship between entities and keywords, such as keywords are characters, and entities are specific character names.
[0090] It is understandable that the relationship hint information is used to guide the language model to extract high-level semantic information in the target text, specifically including the second questions generated by at least two entities and the reasoning reasons / reasoning basis for the second questions. The number of second questions included in the relationship hint information is not limited. For example, the second question A is "What is the relationship between role A and role B? Please provide evidence in the text", and the second question B is "What is the relationship between role A and role C? Please explain your reasons." In addition, there can be different ways of asking for the determination of the relationship between two specific entities. For example, another way of asking the second question A is "What is role A's attitude towards role B? Please explain your reasons." Other descriptions of multiple second questions are not limited here.
[0091] S201: Use the first prompt information and the target text as inputs of the language model.
[0092] It is understandable that the language model can be a pre-trained model for named entity recognition, and the specific training method is not described in detail. Subsequently, the language model identifies the specific entities in the target text and the relationship between the specific entities according to the guidance of the first prompt information. The specific implementation process of the language model is shown in S202 and S203.
[0093] S202: extract multiple entities from the target text according to the entity prompt information to obtain basic information of the multiple entities.
[0094] The basic information includes the multiple entities and attributes of each entity.
[0095] It is understandable that through multiple first questions in the entity prompt information, the language model is gradually guided to accurately identify entities from the target text and extract entity attributes for subsequent knowledge graph construction.
[0096] It is understandable that before extracting the basic information of the target text, the target text can be preprocessed to convert the target text into a format suitable for language model processing. For example, the target text can be segmented into paragraphs or scenes so that the language model can process each semantic unit separately, which is convenient for syntactic analysis and information extraction.
[0097] S203: Determine the relationship between the multiple entities according to the relationship prompt information to obtain relationship information.
[0098] The first text information includes the basic information and the relationship information.
[0099] It can be understood that on the basis of the above S202, based on multiple entities and entity attributes in the basic information, the relationship prompt information is used to gradually guide the language model to extract the relationship between entities, such as extracting the kinship, friendship, hostility, etc. between character entities.
[0100] The disclosed embodiment provides a knowledge graph construction method, which, in the process of extracting basic information, gradually guides the language model to more accurately identify entities and entity attributes through entity prompt information. In the process of extracting relationship information, gradually guides the language model to accurately identify the relationship between entities through relationship prompt information, which can not only improve the accuracy of relationship extraction, but also provide explanations, making it easier for users to understand the reasoning process of the language model.
[0101] Based on the above embodiments, Figure 3 for Figure 1 The detailed flow diagram of S104 in a knowledge graph construction method shown in FIG. 1 is shown. Optionally, the multiple nodes in the knowledge graph and the association relationship between at least two of the nodes are defined according to the content type, specifically including: Figure 3 The following steps are shown:
[0102] S301. Based on the content type, define node types of multiple nodes in the knowledge graph, wherein each node represents an entity or a word used to describe text content.
[0103] Understandably, the node types and edge types of the knowledge graph are predefined according to the content type. For example, a knowledge graph template dedicated to the suspense type is defined, and the first text information is subsequently directly mapped to the knowledge graph template to realize the dynamic construction of the knowledge graph. Among them, the defined knowledge graph template includes a first type of node and a second type of node. The first type of node is used to represent the structural relationship of multiple entities in fact, such as there is a structural relationship between character A and event A, and there is also a structural relationship between event A and location A. The second type of node represents an entity or a word used to describe the content of the text. The second node can be understood as a node unique to a certain content type, that is, the special node mentioned above. The second node can also be understood as an exclusive node corresponding to different themes. For example, the suspense theme needs a separate node to represent the case clues and the direction of the case. In this case, the second type of node includes the case clue node and the case direction node. The case clues and the case direction are words that describe the high-level information of the suspense theme. For example, emotional themes require separate nodes to represent character emotions and relationship change trends. In this case, the second type of nodes includes character emotion nodes and relationship change trend nodes. Character emotions and relationship change trends are words that describe high-level information about emotional themes.
[0104] S302: Define an association relationship between at least two of the nodes according to the node type, wherein the association relationship represents an interaction relationship between at least two of the nodes.
[0105] It is understandable that, based on the above S301, the node type represents the category of entities or concepts, such as people, places, events, emotional changes, case clues, etc., and each node type has specific attributes and functions. The association relationship is used to describe the semantic connection or interaction between two or more nodes. The association relationship can be direct (such as a causal relationship) or indirect (such as a relationship transmitted through an intermediate node). The interaction relationship refers to the interaction or influence between nodes in logic, time, space or semantics, such as the interaction between characters, the causal relationship between events, the impact of clues on the case, etc. Based on the above example, the case clue (fingerprint) "leads to" the direction of the case (the suspect is arrested), that is, the interaction relationship between the case clue node and the case direction node is caused. Under this kind of interaction relationship, it can be inferred that "the fingerprint clue leads to the arrest of the suspect."
[0106] S303: construct the knowledge graph based on the multiple nodes, the node types and the association relationships.
[0107] Understandably, on the basis of the above S302, the extracted multiple nodes (entities or concepts), clear node types (such as characters, events, clues, etc.) and defined association relationships (such as cause and effect, interaction, leading, etc.) are integrated into a structured graph model (graph structure) to form a network composed of nodes (entities) and edges (relationships), thus completing the construction of the knowledge graph. Subsequently, the extracted first text information is integrated into the constructed knowledge graph to form a complete knowledge representation, and a target knowledge graph with core logic and deep information that can fully express the text content is obtained for the target text.
[0108] A knowledge graph construction method provided by the embodiments of the present disclosure flexibly adjusts the structure of the knowledge graph according to the text content type, realizes the dynamic construction of the knowledge graph, can meet the analysis requirements of different text content types, and improves the flexibility and adaptability of the knowledge graph construction.
[0109] Based on the above embodiments, Figure 4 A flow chart of another knowledge graph construction method provided in an embodiment of the present disclosure, wherein optionally, the semantic understanding of the second text information based on the pre-set second prompt information to generate third text information that conforms to the intention of the second prompt information specifically includes the following steps: Figure 4 The following steps are shown:
[0110] S401: Decompose the second prompt information into questions to determine a target entity, a target question for the target entity, and a response requirement for the target question.
[0111] It is understandable that the second prompt information represents the high-level semantic information to be extracted, that is, the second prompt information includes multiple third questions, and the multiple third questions are used to guide the language model to extract the required high-level semantic information, such as extracting high-level semantic information such as story lines, character arcs, theme metaphors, etc. For example, the second prompt information is "How does the character of character A change? Please analyze it in combination with the specific plot", "What is the theme of this story? Please summarize it in one sentence", "What metaphors are used in the text? What do these metaphors mean?". In this case, the second prompt information is decomposed into questions to determine the target entity, target question, and answer requirement. Based on the above example, the target entity is character A, the target question is "How does the character of character A change?", and the answer requirement is "Analyze it in combination with the specific plot."
[0112] S402: Perform semantic understanding based on the target text information related to the target entity in the second text information to generate a target answer that meets the response requirement.
[0113] It is understandable that, based on the above S401, the target question is gradually inferred based on the second text information to generate a target answer that meets the answer requirement, which can be specifically achieved through a language model. Each third question included in the second prompt information has a corresponding target answer.
[0114] S403: Generate third text information according to the target answer.
[0115] It can be understood that, based on the above S402, all generated target answers are integrated to obtain the third text information.
[0116] It is understandable that the extraction of the above basic information, relational information and high-level semantic information can all be achieved through a language model.
[0117] A knowledge graph construction method provided by the embodiments of the present disclosure enables a language model to perform deeper semantic understanding and achieve accurate extraction of high-level semantic information through accurate representation of structured knowledge graph information and thought chain technology, providing a deeper perspective for subsequent text analysis, breaking through the limitations of directly using language models to extract relevant information, and obtaining more accurate and rich high-level semantic information.
[0118] Based on the above embodiments, Figure 5 A schematic diagram of a knowledge graph construction method provided in an embodiment of the present disclosure, specifically including the following: Figure 5 The following steps are shown:
[0119] 1) Text input; 2) Text preprocessing; 3) Extraction of basic information and relational information through the big prediction model; 4) Definition of the structure of the knowledge graph based on the text content type, and knowledge fusion and knowledge representation based on the basic information and relational information; 5) Through the thinking chain technology, on the basis of the structured representation of knowledge graph information, problem decomposition, step-by-step reasoning and evidence extraction are carried out to complete the extraction of high-level semantic information; 6) Output the knowledge graph and high-level semantic information, visualize the knowledge graph and describe the high-level semantic information through natural language.
[0120] It is understandable that the specific implementation process of the above 1) to 6) can be found in the above embodiment and will not be repeated here.
[0121] Figure 6 The schematic diagram of the structure of a knowledge graph construction device provided in the embodiment of the present disclosure is as follows. The knowledge graph construction device provided in the embodiment of the present disclosure can execute the processing flow provided in the embodiment of the knowledge graph construction method, such as Figure 6 As shown, the knowledge graph construction device 600 includes an acquisition unit 601, an extraction unit 602, an identification unit 603, a node definition unit 604 and a construction unit 605, wherein:
[0122] An acquisition unit 601 is used to acquire a target text to be processed;
[0123] An extraction unit 602 is used to extract first text information from the target text according to a preset first prompt information; wherein the first text information represents factual information of multiple entities in the target text;
[0124] The recognition unit 603 is used to perform semantic recognition on the first text information to determine the content type of the target text;
[0125] A node definition unit 604, configured to define a plurality of nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type;
[0126] The construction unit 605 is used to map the first text information into the knowledge graph to obtain a target knowledge graph of the target text.
[0127] Optionally, the first prompt information includes entity prompt information and relationship prompt information, wherein the entity prompt information is used to guide the language model to identify and extract specific entities in the target text, and the relationship prompt information is used to guide the language model to determine the relationship between the extracted specific entities.
[0128] Optionally, the extraction unit 602 is used to:
[0129] Using the first prompt information and the target text as inputs of the language model;
[0130] Extracting multiple entities from the target text according to the entity prompt information to obtain basic information of the target text; wherein the basic information includes the multiple entities and attributes of each entity;
[0131] Determine the relationship between the multiple entities according to the relationship prompt information to obtain relationship information;
[0132] The first text information includes the basic information and the relationship information.
[0133] Optionally, the entity prompt information includes a first question generated based on at least one keyword of person, event, place, time, and content type, the basic information is answer information of the first question, and the multiple entities correspond to the at least one keyword;
[0134] The relationship prompt information includes a second question generated based on at least two entities and reasoning reasons about the second question. The relationship information is answer information of the second question, and the second question is used to inquire about the relationship between at least two entities.
[0135] Optionally, the node definition unit 604 is used to:
[0136] Based on the content type, define node types of multiple nodes in the knowledge graph, wherein each node represents an entity or a word used to describe text content;
[0137] According to the node type, defining an association relationship between at least two of the nodes, wherein the association relationship represents an interaction relationship between at least two of the nodes;
[0138] The knowledge graph is constructed based on the multiple nodes, the node types and the association relationships.
[0139] Optionally, the knowledge graph construction device 600 is further used for:
[0140] Acquire text information structured in the target knowledge graph to obtain second text information;
[0141] The second text information is semantically understood based on the preset second prompt information to generate third text information that meets the intention of the second prompt information.
[0142] Optionally, the knowledge graph construction device 600 is further used for:
[0143] Visualizing the target knowledge graph and obtaining adjustment information for the target knowledge graph;
[0144] The target knowledge graph is updated based on the adjustment information.
[0145] Optionally, the knowledge graph construction device 600 is further used for:
[0146] Obtain text requirements of target users;
[0147] Evaluate whether the target text meets the text requirement through the target knowledge graph;
[0148] In the case that the target text meets the text requirement, recommendation information of the target text is fed back to the target user.
[0149] Figure 6 The knowledge graph construction device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0150] Figure 7 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 7, which shows a schematic diagram of the structure of an electronic device 700 suitable for implementing the embodiment of the present disclosure. The electronic device 700 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0151] like Figure 7 As shown, the electronic device 700 may include a processing device 701 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 to a random access memory (RAM) 703 to implement the knowledge graph construction method of the embodiment described in the present disclosure. In RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, ROM 702, and RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0152] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0153] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the knowledge graph construction method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 709, or installed from the storage device 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0154] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0155] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0156] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0157] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0158] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0159] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0160] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, constitute a limitation on the unit itself.
[0161] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0162] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0163] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or gateway that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or gateway. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or gateway that includes the elements.
[0164] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A knowledge graph construction method, characterized in that: The method comprises: Get the target text to be processed; Extracting first text information from the target text according to a preset first prompt information; wherein the first text information represents factual information of multiple entities in the target text; Performing semantic recognition on the first text information to determine the content type of the target text; Define multiple nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type; The first text information is mapped into the knowledge graph to obtain a target knowledge graph of the target text.
2. The method according to claim 1, characterized in that The first prompt information includes entity prompt information and relationship prompt information, wherein the entity prompt information is used to guide the language model to identify and extract specific entities in the target text, and the relationship prompt information is used to guide the language model to determine the relationship between the extracted specific entities. The first text information is extracted from the target text according to the preset first prompt information, including: Using the first prompt information and the target text as inputs of the language model; Extracting multiple entities from the target text according to the entity prompt information to obtain basic information of the target text; wherein the basic information includes the multiple entities and attributes of each entity; Determine the relationship between the multiple entities according to the relationship prompt information to obtain relationship information; The first text information includes the basic information and the relationship information.
3. The method according to claim 2, characterized in that The entity prompt information includes a first question generated based on at least one keyword of person, event, place, time, and content type, the basic information is answer information of the first question, and the multiple entities correspond to the at least one keyword; The relationship prompt information includes a second question generated based on at least two entities and reasoning reasons about the second question. The relationship information is answer information of the second question, and the second question is used to inquire about the relationship between at least two entities.
4. The method according to claim 1, characterized in that: Defining a plurality of nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type includes: Based on the content type, define node types of multiple nodes in the knowledge graph, wherein each node represents an entity or a word used to describe text content; According to the node type, defining an association relationship between at least two of the nodes, wherein the association relationship represents an interaction relationship between at least two of the nodes; The knowledge graph is constructed based on the multiple nodes, the node types and the association relationships.
5. The method according to claim 1, characterized in that After mapping the first text information to the knowledge graph to obtain a target knowledge graph of the target text, the method further includes: Acquire text information structured in the target knowledge graph to obtain second text information; The second text information is semantically understood based on the preset second prompt information to generate third text information that meets the intention of the second prompt information.
6. The method according to claim 1, characterized in that After mapping the first text information to the knowledge graph to obtain a target knowledge graph of the target text, the method further includes: Visualizing the target knowledge graph and obtaining adjustment information for the target knowledge graph; The target knowledge graph is updated based on the adjustment information.
7. The method according to claim 1, characterized in that The method further comprises: Obtain text requirements of target users; Evaluate whether the target text meets the text requirement through the target knowledge graph; In the case that the target text meets the text requirement, recommendation information of the target text is fed back to the target user.
8. A knowledge graph construction device, characterized in that: The device comprises: An acquisition unit, used for acquiring a target text to be processed; An extraction unit, configured to extract first text information from the target text according to a preset first prompt information; wherein the first text information represents factual information of multiple entities in the target text; A recognition unit, configured to perform semantic recognition on the first text information to determine the content type of the target text; A node definition unit, used to define a plurality of nodes in the knowledge graph and an association relationship between at least two of the nodes according to the content type; A construction unit is used to map the first text information into the knowledge graph to obtain a target knowledge graph of the target text.
9. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; Wherein, the computer program is stored in the memory and is configured to be executed by the processor to implement the knowledge graph construction method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the knowledge graph construction method as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Request response method and device, electronic equipment and storage medium
CN120407755A
Knowledge graph generation method and device based on large model, electronic equipment and medium
CN120764647A
Content processing method and device and storage medium
CN120929586A