Knowledge graph generation method and device in historical and cultural field, equipment and medium
Through BiLSTM and GCN models, the sub-map generation and fusion of target dynasties and user intentions are solved, and the problems of low efficiency and poor quality of knowledge graph generation in the historical and cultural field are achieved efficient and personalized knowledge graph generation, and user information is improved. Acquisition and utilization.
Patent Information
- Application Number
- CN202410123733.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-29
- Publication Date
- 2024-12-13
AI Technical Summary
The knowledge graph generation efficiency and poor quality in the field of history and culture make it difficult for users to quickly obtain effective information and have low utilization rates. This is mainly due to the complex and diverse entity relationships, and traditional methods cannot effectively organize and utilize these data.
By receiving and analyzing the knowledge graph generation request, the first historical and cultural sub-map and the second historical and cultural sub-map are generated using the preset BiLSTM and GCN models, and inter-special fusion is carried out, combining the target dynasty and user intentions to optimize entity recognition and Relationship extraction to generate high-quality and personalized knowledge graphs.
The generation efficiency and quality of knowledge graphs are improved, and users can quickly obtain historical and cultural information, improving the utilization rate and overall efficiency of knowledge graphs.
Smart Images

Figure CN119129716A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph technology, and in particular to a method, device, equipment and medium for generating a knowledge graph in the field of history and culture. Background Art
[0002] The data in the field of history and culture is complex and diverse, covering culture and art, politics and institutions, economy, military, science and technology and many other aspects. With the development of the information age, a large amount of digital historical data is stored for users to query through the Internet. Traditional search methods rely on users' retrieval experience and retrieval skills, which is not conducive to users' systematic learning and research on history and culture. Knowledge graph technology can reasonably organize huge and scattered knowledge through entity recognition, entity relationship extraction and knowledge fusion processing, so that users can intuitively and systematically understand the relevant knowledge in this field. Among them, entity relationship extraction plays a key role in the quality of the generated knowledge graph.
[0003] Traditional knowledge graphs usually display all searched triples, but the historical and cultural fields have complex and diverse entity relationships. The network architecture constructed by traditional knowledge graphs through entity relationship extraction is relatively complex, the generation efficiency of knowledge graphs is low and the quality is poor. It is difficult for users to quickly obtain effective information when facing knowledge graph data, and the utilization rate of knowledge graphs is low. Summary of the invention
[0004] The present invention provides a method, device, equipment and medium for generating a knowledge graph in the field of history and culture, which is used to solve the problems that there are many entity relationships in the field of history and culture, the knowledge graph architecture is complex, the generation efficiency of the knowledge graph is low and the quality is poor, it is difficult for users to quickly obtain effective information when facing the knowledge graph data, and the utilization rate of the knowledge graph data is low.
[0005] The first aspect of the present invention provides a method for generating a knowledge graph in the field of history and culture, comprising: receiving a knowledge graph generation request and historical and cultural data to be extracted; parsing the knowledge graph generation request to obtain a target dynasty and a target user intention; inputting the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph; inputting the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph; performing inter-spectrum fusion based on the first historical and cultural subgraph and the second historical and cultural subgraph to obtain a target historical and cultural knowledge graph.
[0006] The second aspect of the present invention provides a knowledge graph generation device in the field of history and culture, including: a receiving module, used to receive a knowledge graph generation request and historical and cultural data to be extracted; a parsing module, used to parse the knowledge graph generation request to obtain a target dynasty and a target user intention; a first generating module, used to input the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph; a second generating module, used to input the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph; an inter-spectrum fusion module, used to perform inter-spectrum fusion based on the first historical and cultural subgraph and the second historical and cultural subgraph to obtain a target historical and cultural knowledge graph.
[0007] The third aspect of the present invention provides an electronic device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the electronic device executes the above-mentioned knowledge graph generation method in the field of history and culture.
[0008] A fourth aspect of the present invention provides a computer-readable storage medium, which stores instructions that, when executed on a computer, enable the computer to execute the above-mentioned method for generating a knowledge graph in the field of history and culture.
[0009] In the technical solution provided by the present invention, the target dynasty and the historical and cultural data to be extracted are input into the first knowledge graph generation model to improve the correlation between the first historical and cultural sub-graph and the target dynasty, thereby improving the quality of the historical and cultural knowledge graph; the target user intention and the historical and cultural data to be extracted are input into the preset second knowledge graph generation model to generate a personalized second historical and cultural sub-graph, thereby improving the utilization rate and generation efficiency of the historical and cultural knowledge graph; the first historical and cultural sub-graph and the second historical and cultural sub-graph are then fused between the graphs, thereby taking into account the generation quality and efficiency of the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 A schematic diagram of an embodiment of a method for generating a knowledge graph in the field of history and culture according to an embodiment of the present invention;
[0011] Figure 2 A schematic diagram of another embodiment of a method for generating a knowledge graph in the field of history and culture according to an embodiment of the present invention;
[0012] Figure 3 A schematic diagram of an embodiment of a knowledge graph generating device in the field of history and culture in an embodiment of the present invention;
[0013] Figure 4 A schematic diagram of another embodiment of a knowledge graph generating device in the field of history and culture according to an embodiment of the present invention;
[0014] Figure 5 A schematic diagram of an embodiment of an electronic device for generating a knowledge graph in the field of history and culture in an embodiment of the present invention. DETAILED DESCRIPTION
[0015] The present invention provides a method, device, equipment and medium for generating a knowledge graph in the field of history and culture, which is used to solve the problems that there are many entity relationships in the field of history and culture, the knowledge graph architecture is complex, the generation efficiency of the knowledge graph is low and the quality is poor, it is difficult for users to quickly obtain effective information when facing the knowledge graph data, and the utilization rate of the knowledge graph data is low.
[0016] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0017] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 In the embodiment of the present invention, a method for generating a knowledge graph in the field of history and culture includes:
[0018] 101. Receive a knowledge graph generation request and historical and cultural data to be extracted.
[0019] It is understandable that the execution subject of the present invention can be a knowledge graph generation device in the field of history and culture, or a terminal or a server, wherein the terminal can be a computer, a laptop, etc., which is not specifically limited here. The embodiment of the present invention is described by taking the server as the execution subject as an example.
[0020] The server accepts knowledge graph generation requests and historical and cultural data to be extracted. The knowledge graph generation request is the demand information input by the user based on the topic of interest, research purpose, and use. For example, the origin and development of poetry culture in the Tang Dynasty, the study of the group of generals fighting against Shu in Cao Wei, the geographical study of folk beliefs in Sichuan in the Qing Dynasty, and the application research of the Three Kingdoms culture in tourism landscape design.
[0021] In this embodiment, the historical and cultural data to be extracted is used to indicate the historical and cultural data used to construct the knowledge graph. Since the data in the field of history and culture are in various forms, and cultural knowledge cannot be fully studied only in text form, for example, for research on cultural relics, ancient characters, etc., image information is conducive to users' intuitive understanding of the specific forms of cultural relics and ancient characters, and for research on music, musical instruments, etc., audio data plays an irreplaceable role in research and learning in related fields. Therefore, the historical and cultural data to be extracted in this embodiment may include multimodal forms such as text data, image data, and audio data. Among them, text data can be directly extracted from text carriers such as paper historical archives through text detection and recognition technologies such as OCR, and the voice information of audio and video data can be converted into text data through speech recognition technologies such as ASR; while image data and audio data need to carry keyword tags, and the keyword tags are used to mark the names and related feature information of images and audio, such as the name of the cultural relic, dynasty, place of origin, characteristic patterns in the cultural relics, totems, etc. corresponding to the cultural relic image data, and the name of the music, dynasty, and author corresponding to the audio image data of string music, so that the knowledge graph generation model can identify their association.
[0022] It should be further explained that the historical and cultural data of this embodiment is exemplified by Chinese historical and cultural data. The knowledge graph generation method in the historical and cultural field of this embodiment can also generate knowledge graphs for the historical and cultural fields of other countries, such as Europe, India, etc., without specific limitation.
[0023] 102. Parse the knowledge graph generation request to obtain the target dynasty and target user intention.
[0024] The server parses the request to generate the knowledge graph to obtain the target dynasty and target user intention. The target dynasty is used to indicate the historical period involved in the knowledge graph generated by the user. Due to the differences in the focus of historical and cultural research in different dynasties, the entity names and relationship types of each dynasty have dynasty characteristics. The target dynasty can improve the processing efficiency of the knowledge graph generation model for extracting historical and cultural data.
[0025] In this embodiment, the target user intent is used to indicate the specific goals or needs that are expected to be achieved when using the knowledge graph, such as cultural heritage protection, academic research, tourism planning, and educational learning. Since the relationship types between entities in the historical and cultural fields overlap or intersect, the relationship type between two entities is not fixed depending on the user intent. The target user intent can be used to optimize the knowledge graph generation model, reduce the extraction of entity relationships beyond the target user intent, improve the knowledge graph generation model's personalized processing of extracted historical and cultural data, and improve users' utilization of subsequent knowledge graphs.
[0026] 103. Input the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural sub-graph.
[0027] The first knowledge graph generation model of this embodiment is a model built based on bidirectional long short-term memory (BiLSTM) network technology. The BiLSTM model considers the forward and backward information of the input sequence at each time step. The forward LSTM processes the information from the beginning of the sequence to the current time step, and the backward LSTM processes the information from the end of the sequence to the current time step, so as to understand the sequence more comprehensively. The first knowledge graph generation model built based on BiLSTM can effectively capture and learn the temporal features in the historical and cultural fields. By introducing gating mechanisms such as input gates, forget gates, and output gates at each time step, the problems of gradient vanishing and gradient exploding in traditional RNNs are effectively solved, so that the network can better capture long-term dependencies. This embodiment does not impose specific restrictions on the construction and training process of the first knowledge graph generation model.
[0028] The first knowledge graph generation model of this embodiment includes an embedding layer, a bidirectional long short-term memory network layer and a first output layer, wherein the embedding layer is used to preprocess the historical and cultural data to be extracted to obtain a text sequence constructed by multiple word vectors, the bidirectional long short-term memory network layer is used to perform entity recognition and relationship extraction to obtain multiple triples, and the first output layer is used to output the multiple triples as a first historical and cultural subgraph.
[0029] In this embodiment, different dynasties have different contents with analytical value. The target dynasty can adjust the entity type focused on by the first knowledge graph generation model, and focus on entity extraction, which helps to improve the accuracy of entity extraction and make the generation quality of the first historical and cultural sub-graph higher.
[0030] 104. Input the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph.
[0031] The second knowledge graph generation model of this embodiment is a model built based on the graph convolutional network (GCN) technology. The knowledge graph is composed of nodes and edges. Each node represents an entity, and each edge represents the relationship between nodes. The relationship between nodes can be effectively learned through GCN. This embodiment does not impose specific restrictions on the construction and training process of the second knowledge graph generation model.
[0032] The first knowledge graph generation model of this embodiment includes an input layer, a graph convolution layer and a second output layer, wherein the input layer is used to initialize the historical and cultural data to be extracted to obtain an adjacency matrix and a feature matrix corresponding to each node, wherein each node corresponds to an entity, and the feature matrix corresponding to each node includes a feature vector corresponding to each node. The adjacency matrix is used to represent the connection relationship between nodes. For example, the element A[i][j] of the adjacency matrix A represents whether there is an edge connecting node i and node j. For a directed graph, the elements of the adjacency matrix can also represent the direction of the edge. The graph convolution layer is used for the neighboring relationship of nodes, so that the representation of the node can be updated by interacting with the information of the adjacent nodes to obtain the updated triples, and multiple triples are output as the second historical and cultural subgraph through the second output layer.
[0033] 105. Perform inter-spectral fusion based on the first historical and cultural sub-graph and the second historical and cultural sub-graph to obtain the target historical and cultural knowledge graph.
[0034] In this embodiment, inter-spectral fusion is used to merge the first historical and cultural sub-graph and the second historical and cultural sub-graph to obtain a target historical and cultural knowledge graph.
[0035] In this embodiment, there are many types of relationships in the field of history and culture. The relationship types focused on by the second knowledge graph generation model can be adjusted according to the target user intention, and focused relationship extraction helps to improve the accuracy of relationship extraction and make the generation quality of the second historical and cultural sub-graph higher.
[0036] In this embodiment, the target dynasty and target user intention are analyzed to improve the generation quality and efficiency of the first knowledge graph generation model and the second knowledge graph generation model. The target historical and cultural knowledge graph obtained through inter-spectrum fusion takes into account the target analysis entities of different dynasties and user intentions, and can quickly and effectively extract historical and cultural information from historical and cultural data to be extracted, construct an accurate and personalized knowledge graph, and improve the utilization, generation efficiency and quality of the knowledge graph.
[0037] See also Figure 2 Another embodiment of the method for generating a knowledge graph in the field of history and culture in the embodiment of the present invention includes:
[0038] 201. Receive a knowledge graph generation request and historical and cultural data to be extracted.
[0039] Step 201 can be performed with reference to step 101 and will not be described in detail here.
[0040] 202. Perform dynasty matching on the knowledge graph generation request to obtain the target dynasty.
[0041] Obtain the historical text to be extracted, and determine whether there is time information in the historical text to be extracted; if there is time information, determine the target dynasty based on the time information; if there is no time information, determine whether there is character information in the historical text to be extracted; if there is character information, determine the target dynasty based on the character information; if there is no character information, segment the historical text to be extracted, extract valid word segments, and determine the target dynasty based on the valid word segments.
[0042] In this embodiment, the time information is used to indicate the time that can represent the target dynasty. The time information may include digital time information, text time information, and a combination of digital time information and text time information, such as 1614, Tang Dynasty, 203 BC, etc., which can directly represent the target dynasty.
[0043] In this embodiment, the character information is used to indicate the time that can represent the target dynasty. The character information includes the character's name, courtesy name, pseudonym, and title, or a combination of any two or more. The title can be an official title, posthumous title, temple name, etc., for example, Emperor Gaozu of Han Liu Bang, Dongpo Jushi, Xie An, whose courtesy name was Anshi, etc.
[0044] In this embodiment, the valid word segment is used to indicate the valid field that can represent the target dynasty, such as event information, work information, etc. For example, "Dream of Red Mansions" is a Chinese classical novel created by the Qing Dynasty writer Cao Xueqin, which can represent the target dynasty as the Qing Dynasty; the Battle of Bashu is a war between the Qin State and the Shu State, which can represent the target dynasty as the Qin Dynasty.
[0045] It can be understood that the historical and cultural data to be extracted may include any one or more of the above-mentioned information representing the target dynasty, and there may be one or more of each type of information representing the target dynasty. A dynasty set can be constructed based on the historical and cultural data to be extracted, and the number of occurrences of each dynasty in the dynasty set can be counted. The dynasty with the largest number of occurrences can be determined as the target dynasty corresponding to the historical text to be extracted, or at least one dynasty with a number of occurrences greater than a preset value can be determined as the target dynasty, that is, the target dynasty may include one or more.
[0046] 203. Identify the intent of the knowledge graph generation request to obtain the target user's intent.
[0047] The knowledge graph generation request is segmented and serialized to obtain the corresponding target request sequence; the target request sequence is matched with the preset intent corpus to obtain the target user intent.
[0048] Specifically, the target request sequence is matched with a preset intent corpus to obtain at least one intent request sequence, and the similarity between the target request sequence and the intent request sequence in the query result is calculated to obtain a similarity calculation result; the corpus intent request sequence whose similarity calculation result is greater than a preset matching value is determined as a matching result, and the user intent corresponding to the intent request sequence is determined as the target user intent.
[0049] Among them, the intent corpus pre-stores multiple intent request sequences and the user intent corresponding to each intent request sequence. For example, the recommendation of historical and cultural tourism routes in Shandong Province is used to represent the user intent of tourism planning; the interpretation of Qin Dynasty history college entrance examination test points is used to represent the user intent of education and learning; the geographical research of Sichuan folk beliefs in the Qing Dynasty is used to represent the user intent of academic research; the protection of Dunhuang Sixteen Kingdoms and Northern Dynasties Grottoes and Tomb Art is used to represent the user intent of cultural heritage protection.
[0050] 204. Input the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph.
[0051] According to the target dynasty, the parameters of the preset first knowledge graph generation model are adjusted to obtain a first optimization model, which includes an embedding layer, a bidirectional long short-term memory network layer and a first output layer; each character line in the historical and cultural data to be extracted is encoded by the embedding layer to obtain a character vector corresponding to each character; the word vector corresponding to each character is subjected to knowledge extraction by the bidirectional long short-term memory network layer to obtain multiple first objects, each of which is a triplet; the multiple first objects are output as a first historical and cultural subgraph by the first output layer.
[0052] Optionally, a preset entity recognition rule set corresponding to the first knowledge graph generation model is obtained, where the entity recognition rule set includes multiple entity types; weight optimization is performed on each entity type according to the target dynasty to obtain a first optimized model.
[0053] Since each dynasty has different characteristics and the historical data left behind are different, the research focus of each dynasty in later generations is also different. After updating the model parameters according to the weight value corresponding to each entity type in the target dynasty, the accuracy and efficiency of the first optimization model in entity recognition in the extracted text can be improved, and the information displayed in the final first historical text subgraph can be screened.
[0054] The entity types of this embodiment may include one or more of historical figures, historical events, cultural works, political systems, nationalities, folk customs, religions, buildings, and cultural relics. The weight corresponding to each entity type is determined by the target dynasty. For example, the historical and cultural research during the Qin Dynasty focuses on the unification of the six kingdoms, the legal system, the military system, etc., while also paying attention to the achievements of Qin Shihuang and his impact on Chinese history. The Tang Dynasty was the peak period of ancient Chinese literature, and the historical and cultural research of this period focuses on the study of entities such as cultural works and cultural relics.
[0055] The first knowledge graph generation model of this embodiment is a BiLSTM model. Specifically, knowledge is extracted from the word vector corresponding to each character through a bidirectional long short-term memory network layer to obtain multiple first objects, each of which is a triplet including: preprocessing the historical and cultural data to be extracted through an embedding layer to obtain multiple characters, wherein the preprocessing includes text cleaning and word segmentation to obtain multiple characters, encoding the multiple characters to obtain the word vector corresponding to each character, and inputting the word vector corresponding to each character into the bidirectional long short-term memory network layer for entity recognition to obtain an entity set, wherein the entity set includes multiple entities and an entity category corresponding to each entity; performing relationship extraction on the entity set based on preset relationship extraction rules to obtain multiple first objects, each of which is a triplet.
[0056] 205. Input the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph.
[0057] According to the target user's intention, the parameters of the preset second knowledge graph generation model are adjusted to obtain a second optimization model, which includes an input layer, a graph convolution layer and a second output layer; the historical and cultural data to be extracted are initialized through the input layer to obtain an adjacency matrix and an initial node feature matrix; the adjacency matrix and the initial node feature matrix are convolved through the graph convolution layer to obtain multiple second objects, each second object is a triplet; the multiple second objects are output as a second historical and cultural knowledge graph through the second output layer.
[0058] Optionally, a relationship extraction rule set corresponding to a preset second knowledge graph generation model is obtained, where the relationship extraction rule set includes multiple relationship types; weight optimization is performed on each relationship type according to the target dynasty to obtain a second optimization model.
[0059] In a feasible implementation, the relationship weights of the preset second knowledge graph generation model are adjusted according to the target dynasty and the target user intention to obtain a second optimization model.
[0060] Optionally, a set of relation extraction rules corresponding to the candidate knowledge graph generation model is determined according to the target dynasty, and the set of relation extraction rules includes at least one relation type; a weight is assigned to each target relation type according to the target user's intention to obtain a second optimization model. This embodiment now determines the set of relation extraction rules corresponding to the target dynasty according to the research focus of each dynasty, for example
[0061] Optionally, determine the first weight corresponding to each relationship type in the second knowledge graph generation model according to the target dynasty; determine the second weight corresponding to each relationship type in the preset second knowledge graph generation model according to the target user intention; multiply the first weight corresponding to each relationship type by the second weight corresponding to each relationship type to obtain the target weight corresponding to each relationship type; adjust the parameters of the second knowledge graph generation model according to the target weight corresponding to each relationship type to obtain a second optimized model.
[0062] This embodiment improves the generation efficiency of the knowledge graph by adjusting the weights of the relationship rules of the knowledge graph generation model, generates a personalized knowledge graph, and improves the utilization rate of the knowledge graph.
[0063] The second knowledge graph generation model of this embodiment is a GCN model. Specifically, the historical and cultural data to be extracted are initialized through the input layer to obtain an adjacency matrix and an initial node feature matrix, including: extracting each entity and its attribute information from the historical and cultural data to be extracted and storing them in the node feature matrix, performing relationship extraction on the node feature matrix, storing the relationship between two entities in the adjacency matrix, and performing convolution operations according to the adjacency matrix and the initial node feature matrix through the graph convolution layer based on the weight ratio corresponding to each target relationship type to obtain multiple second objects, each second object being a triplet.
[0064] In this embodiment, the adjacency matrix includes entity relationships, event relationships, character relationships, cultural relic relationships, architectural relationships and cultural relationships, among which entity relationships include time and place relationships, etc.; event relationships are the relationships between different events, including causal relationships, conditional relationships, etc.; character relationships represent the relationships between different characters, including monarch-subject relationships, master-apprentice relationships, fellow-school relationships, husband-wife relationships, mother-child relationships, etc.; cultural relic relationships represent the relationships between cultural relics, including the usage relationships and style relationships of cultural relics, etc.; architectural relationships represent the relationships between buildings, including builders, designers, architectural styles, etc.; cultural relationships represent the relationships between cultures, including the development, transfer, integration, and influence of cultures, etc.
[0065] It can be understood that this embodiment does not specifically limit the training data set construction, model training, and model-generated knowledge graph evaluation process of the first knowledge graph generation model and the second knowledge graph generation model.
[0066] 206. Perform inter-spectral fusion based on the first historical and cultural sub-graph and the second historical and cultural sub-graph to obtain the target historical and cultural knowledge graph.
[0067] Perform triple matching on the first historical and cultural subgraph and the second historical and cultural subgraph; if there are any two identical triplets, delete the second objects corresponding to the triplets to obtain at least one remaining second object; if there are two identical entities in any two triplets and the relationship between the two entities is different, delete the first objects corresponding to the triplets to obtain at least one remaining first object; connect the at least one remaining first object and the at least one remaining second object to obtain the target historical and cultural knowledge graph.
[0068] In this embodiment, the first knowledge graph generation model is a model built based on the bidirectional long short-term memory network technology. The entity recognition accuracy of the first historical and cultural subgraph extracted according to the target dynasty is higher and the coverage is comprehensive, which improves the recognition rate of the entity. The second knowledge graph generation model is a model built based on the graph convolutional network technology. The entity relationship in the second historical and cultural subgraph generated by combining the target user's intention is more in line with user needs, and the personalization of relationship extraction is realized.
[0069] Among them, if there are any two identical triples, that is, if any first object in the first historical and cultural subgraph is the same as the second object in the second historical and cultural subgraph, that is, the two entities in the triples corresponding to the first object and the second object and the relationship between the entities are the same, then only one of the triples needs to be retained. If there are two identical entities in any two triples, and the relationship between the two entities is different, and the entity relationship of the second object is more in line with user needs, therefore, it is preferred to retain the second object and delete the corresponding first object, so that the final target knowledge graph has a higher utilization rate. For example, the first object is [Liu Bei, sworn brotherhood, Guan Yu], and the second object is [Liu Bei, monarch-minister relationship, Guan Yu];
[0070] Optionally, connecting the remaining at least one first object and the remaining at least one second object to obtain the target historical and cultural knowledge graph includes: performing entity matching on the remaining at least one first object and the remaining at least one second object, and connecting the first object and the second object that have any identical entity, and determining the entity relationship between the first object and the second object according to a preset relationship extraction rule, traversing each first object and the second object to obtain the target historical and cultural knowledge graph.
[0071] Specifically, connecting a first object and a second object having any same entity includes:
[0072] If the first agent corresponding to the first object is the same as the second agent corresponding to the second object, then the first agent corresponding to the first object is connected to the second patient corresponding to the second object; if the first agent corresponding to the first object is the same as the second patient corresponding to the second object, then the first agent corresponding to the first object is connected to the second patient corresponding to the second object; if the first patient corresponding to the first object is the same as the second patient corresponding to the second object, then the first patient corresponding to the first object is connected to the second patient corresponding to the second object; if the first patient corresponding to the first object is the same as the second patient corresponding to the second object, then the first patient corresponding to the first object is connected to the second agent corresponding to the second object;
[0073] This embodiment connects the same agent or patient in the first object and the second object to achieve inter-spectrum fusion and enrich the entity relationship in the target historical and cultural knowledge graph.
[0074] It can be understood that the above-mentioned agent and patient are used to indicate the entity composition in the triple. The agent is the entity that initiates or performs an action or behavior, and the patient refers to the entity that accepts an action or behavior. For example, in the triple [Qin Shihuang, monarch-minister relationship, Li Si], Qin Shihuang is the agent and Li Si is the patient.
[0075] To facilitate understanding, an example is provided. The first object is [Ying Zheng, posthumous title, First Emperor], and the second object is [Ying Zheng, monarch-minister relationship, Li Si]. The entity node Ying Zheng in the target historical and cultural knowledge graph includes two edges, which are connected to the two entity nodes First Emperor and Li Si respectively.
[0076] In this embodiment, the target dynasty and target user intention are analyzed to improve the generation quality and efficiency of the first knowledge graph generation model and the second knowledge graph generation model. The target historical and cultural knowledge graph obtained through inter-spectrum fusion takes into account the target analysis entities of different dynasties and user intentions, and can quickly and effectively extract historical and cultural information from historical and cultural data to be extracted, construct an accurate and personalized knowledge graph, and improve the utilization, generation efficiency and quality of the knowledge graph.
[0077] The above describes the method for generating a knowledge graph in the field of history and culture in an embodiment of the present invention. The following describes the device for generating a knowledge graph in the field of history and culture in an embodiment of the present invention. Figure 3 , an embodiment of a knowledge graph generation device in the field of history and culture in an embodiment of the present invention includes:
[0078] A receiving module 301 is used to receive a knowledge graph generation request and historical and cultural data to be extracted;
[0079] The parsing module 302 is used to parse the knowledge graph generation request to obtain the target dynasty and the target user intention;
[0080] The first generation module 303 is used to input the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph;
[0081] The second generation module 304 is used to input the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph;
[0082] The inter-spectrum fusion module 305 is used to perform inter-spectrum fusion based on the first historical and cultural sub-graph and the second historical and cultural sub-graph to obtain a target historical and cultural knowledge graph.
[0083] In this embodiment, the target dynasty and target user intention are analyzed to improve the generation quality and efficiency of the first knowledge graph generation model and the second knowledge graph generation model. The target historical and cultural knowledge graph obtained through inter-spectrum fusion takes into account the target analysis entities of different dynasties and user intentions, and can quickly and effectively extract historical and cultural information from historical and cultural data to be extracted, construct an accurate and personalized knowledge graph, and improve the utilization, generation efficiency and quality of the knowledge graph.
[0084] See also Figure 4 Another embodiment of the knowledge graph generation device in the field of history and culture in the embodiment of the present invention includes:
[0085] A receiving module 301 is used to receive a knowledge graph generation request and historical and cultural data to be extracted;
[0086] The parsing module 302 is used to parse the knowledge graph generation request to obtain the target dynasty and the target user intention;
[0087] The first generation module 303 is used to input the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph;
[0088] The second generation module 304 is used to input the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph;
[0089] The inter-spectrum fusion module 305 is used to perform inter-spectrum fusion based on the first historical and cultural sub-graph and the second historical and cultural sub-graph to obtain a target historical and cultural knowledge graph.
[0090] Optionally, the first generating module 303 includes:
[0091] A first adjustment unit 3031 is used to adjust parameters of a preset first knowledge graph generation model according to a target dynasty to obtain a first optimization model, wherein the first optimization model includes an embedding layer, a bidirectional long short-term memory network layer, and a first output layer;
[0092] An encoding unit 3032 is used to encode each character line in the extracted historical and cultural data through an embedding layer to obtain a character vector corresponding to each character;
[0093] An extraction unit 3033 is used to extract knowledge from the word vector corresponding to each character through a bidirectional long short-term memory network layer to obtain multiple first objects, each of which is a triple;
[0094] The first generating unit 3034 is used to output the multiple first objects as a first historical and cultural sub-graph through a first output layer.
[0095] Optionally, the first adjustment unit 3031 is specifically used to: obtain a preset entity recognition rule set corresponding to the first knowledge graph generation model, where the entity recognition rule set includes multiple entity types;
[0096] The weight of each entity type is optimized according to the target dynasty to obtain the first optimization model.
[0097] Optionally, the second generating module 304 includes:
[0098] A second adjustment unit 3041 is used to adjust parameters of a preset second knowledge graph generation model according to the target user's intention to obtain a second optimization model, where the second optimization model includes an input layer, a graph convolution layer, and a second output layer;
[0099] Initialization unit 3042, used to initialize the historical and cultural data to be extracted through the input layer to obtain an adjacency matrix and an initial node feature matrix;
[0100] A convolution unit 3043 is used to perform a convolution operation on the adjacency matrix and the initial node feature matrix through a graph convolution layer to obtain a plurality of second objects, each of which is a triple;
[0101] The second generating unit 3044 is used to output the plurality of second objects as a second historical and cultural knowledge graph through a second output layer.
[0102] Optionally, the second adjustment unit 3041 is specifically used to obtain a relationship extraction rule set corresponding to a preset second knowledge graph generation model, where the relationship extraction rule set includes multiple relationship types;
[0103] The weight of each relationship type is optimized according to the target dynasty to obtain the second optimization model.
[0104] Optionally, the inter-spectrum fusion module 305 is specifically used to: perform triple matching on the first historical and cultural subgraph and the second historical and cultural subgraph;
[0105] If there are any two identical triples, the second objects corresponding to the triples are deleted to obtain at least one remaining second object;
[0106] If there are two entities in any two triples that are the same, and the relationship between the two entities is different, then the first object corresponding to the triple is deleted to obtain at least one remaining first object;
[0107] The remaining at least one first object and the remaining at least one second object are connected to obtain a target historical and cultural knowledge graph.
[0108] Optionally, the parsing unit 302 is specifically used to: perform dynasty matching on the knowledge graph generation request to obtain a target dynasty; and identify the intent of the knowledge graph generation request to obtain the target user intent.
[0109] In this embodiment, the target dynasty and target user intention are analyzed to improve the generation quality and efficiency of the first knowledge graph generation model and the second knowledge graph generation model. The target historical and cultural knowledge graph obtained through inter-spectrum fusion takes into account the target analysis entities of different dynasties and user intentions, and can quickly and effectively extract historical and cultural information from historical and cultural data to be extracted, construct an accurate and personalized knowledge graph, and improve the utilization, generation efficiency and quality of the knowledge graph.
[0110] above Figure 3 and Figure 4 The knowledge graph generating device in the field of history and culture in this embodiment is described in detail from the perspective of modular functional entities, and the electronic device in this embodiment is described in detail from the perspective of hardware processing.
[0111] See also Figure 5 As shown, the electronic device includes a processor 500 and a memory 501, wherein the memory 501 stores machine executable instructions that can be executed by the processor 500, and the processor 500 executes the machine executable instructions to implement the above-mentioned knowledge graph generation method in the field of history and culture.
[0112] Further, Figure 5 The electronic device shown further includes a bus 502 and a communication interface 503 , and the processor 500 , the communication interface 503 and the memory 501 are connected via the bus 502 .
[0113] The memory 501 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), for example, at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 503 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 502 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0114] The processor 500 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 500. The above processor 500 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor to be executed, or a combination of hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 501 , and the processor 500 reads the information in the memory 501 and completes the method steps of the above-mentioned embodiment in combination with its hardware.
[0115] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the method for generating a knowledge graph in the field of history and culture. The steps specifically include:
[0116] Receive a knowledge graph generation request and historical and cultural data to be extracted; parse the knowledge graph generation request to obtain a target dynasty and target user intent; input the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph; input the target user intent and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph; perform inter-spectrum fusion based on the first historical and cultural subgraph and the second historical and cultural subgraph to obtain a target historical and cultural knowledge graph. This embodiment improves the generation quality and efficiency of the first knowledge graph generation model and the second knowledge graph generation model by parsing the target dynasty and the target user intent. The target historical and cultural knowledge graph obtained by inter-spectrum fusion takes into account the target analysis entities of different dynasties and the user intent, and can quickly and effectively extract historical and cultural information from the historical and cultural data to be extracted, construct an accurate and personalized knowledge graph, and improve the utilization rate, generation efficiency, and quality of the knowledge graph.
[0117] The above-mentioned input of the target dynasty and the historical and cultural data to be extracted into the preset first knowledge graph generation model to obtain the first historical and cultural subgraph includes: adjusting the parameters of the preset first knowledge graph generation model according to the target dynasty to obtain a first optimization model, the first optimization model including an embedding layer, a bidirectional long short-term memory network layer and a first output layer; encoding each character line in the historical and cultural data to be extracted through the embedding layer to obtain the character vector corresponding to each character; performing knowledge extraction on the character vector corresponding to each character through the bidirectional long short-term memory network layer to obtain multiple first objects, each first object being a triple; and outputting multiple first objects as the first historical and cultural subgraph through the first output layer. This embodiment optimizes the parameters of the first knowledge graph generation model according to the target dynasty, generates the first historical and cultural subgraph based on the bidirectional long short-term memory network technology, and considers contextual information at the same time, thereby enhancing the ability to understand complex contexts and making it better adapt to the historical and cultural characteristics of the target dynasty.
[0118] The above-mentioned parameter adjustment of the preset first knowledge graph generation model according to the target dynasty to obtain the first optimized model includes: obtaining the entity recognition rule set corresponding to the preset first knowledge graph generation model, the entity recognition rule set includes multiple entity types; optimizing the weight of each entity type according to the target dynasty to obtain the first optimized model. This embodiment adjusts the weight of each entity type according to the target dynasty, so that the entity recognition of the first knowledge graph model can better adapt to the research focus of different dynasties, thereby improving the generation quality of the first historical and cultural subgraph.
[0119] The above-mentioned input of the target user intention and the historical and cultural data to be extracted into the preset second knowledge graph generation model to obtain the second historical and cultural subgraph includes: adjusting the parameters of the preset second knowledge graph generation model according to the target user intention to obtain a second optimization model, the second optimization model includes an input layer, a graph convolution layer and a second output layer; initializing the historical and cultural data to be extracted through the input layer to obtain an adjacency matrix and an initial node feature matrix; performing convolution operations on the adjacency matrix and the initial node feature matrix through the graph convolution layer to obtain multiple second objects, each second object is a triple; outputting the multiple second objects as a second historical and cultural knowledge graph through the second output layer. This embodiment optimizes the parameters of the second knowledge graph generation model according to the target user intention, extracts the second historical and cultural knowledge graph based on the graph convolution technology, improves the correlation between the entity relationship and the user intention in the second historical and cultural knowledge graph, and realizes personalized relationship extraction.
[0120] The above-mentioned parameter adjustment of the preset second knowledge graph generation model according to the target user intention to obtain the second optimization model includes: obtaining the relationship extraction rule set corresponding to the preset second knowledge graph generation model, the relationship extraction rule set includes multiple relationship types; optimizing the weight of each relationship type according to the target dynasty to obtain the second optimization model. This embodiment adjusts the weight of each relationship type according to the target user intention, so that the relationship extraction of the second knowledge graph model can better meet user needs, realize personalized relationship extraction, and improve the utilization rate of the first historical and cultural subgraph.
[0121] The above-mentioned inter-spectral fusion based on the first historical and cultural subgraph and the second historical and cultural subgraph to obtain the target historical and cultural knowledge graph includes: performing triple matching on the first historical and cultural subgraph and the second historical and cultural subgraph; if there are any two identical triplets, the second object corresponding to the triple is deleted to obtain at least one remaining second object; if there are two identical entities in any two triplets, and the relationship between the two entities is different, the first object corresponding to the triple is deleted to obtain at least one remaining first object; the remaining at least one first object and the remaining at least one second object are connected to obtain the target historical and cultural knowledge graph. This embodiment merges the first historical and cultural subgraph and the second historical and cultural subgraph through inter-spectral fusion, deletes duplicate information and information irrelevant to the target user's intention, eliminates redundancy between different subgraphs, and improves the overall quality of the knowledge graph.
[0122] The above-mentioned parsing of the knowledge graph generation request to obtain the target dynasty and the target user intention includes: performing dynasty matching on the knowledge graph generation request to obtain the target dynasty; and identifying the intention of the knowledge graph generation request to obtain the target user intention. This embodiment optimizes the knowledge graph generation model in a targeted manner by obtaining the target dynasty and the target user intention from the knowledge graph generation request, thereby improving the generation quality and efficiency of the knowledge graph.
[0123] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0124] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0125] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. 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 embodiments of the present invention.
Claims
1. A method for generating a knowledge graph in the field of history and culture, characterized in that: The method for generating a knowledge graph in the field of history and culture includes: Receive knowledge graph generation requests and historical and cultural data to be extracted; Parsing the knowledge graph generation request to obtain the target dynasty and the target user intention; Inputting the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph; Inputting the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph; The target historical and cultural knowledge graph is obtained by performing inter-spectral fusion on the first historical and cultural sub-graph and the second historical and cultural sub-graph.
2. The method for generating a knowledge graph in the field of history and culture according to claim 1, characterized in that: The step of inputting the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph includes: Adjusting parameters of the preset first knowledge graph generation model according to the target dynasty to obtain a first optimization model, wherein the first optimization model includes an embedding layer, a bidirectional long short-term memory network layer, and a first output layer; Encoding each character line in the historical and cultural data to be extracted through the embedding layer to obtain a character vector corresponding to each character; The word vector corresponding to each character is subjected to knowledge extraction through the bidirectional long short-term memory network layer to obtain a plurality of first objects, each of which is a triple; The plurality of first objects are output as a first historical and cultural subgraph through a first output layer.
3. The method for generating a knowledge graph in the field of history and culture according to claim 2, characterized in that: The step of adjusting parameters of the preset first knowledge graph generation model according to the target dynasty to obtain a first optimization model includes: Obtaining a preset entity recognition rule set corresponding to a first knowledge graph generation model, wherein the entity recognition rule set includes multiple entity types; The weight of each entity type is optimized according to the target dynasty to obtain a first optimization model.
4. The method for generating a knowledge graph in the field of history and culture according to claim 1, characterized in that: The step of inputting the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph includes: Adjusting parameters of the preset second knowledge graph generation model according to the target user intention to obtain a second optimization model, wherein the second optimization model includes an input layer, a graph convolution layer, and a second output layer; Initializing the historical and cultural data to be extracted through the input layer to obtain an adjacency matrix and an initial node feature matrix; Performing a convolution operation on the adjacency matrix and the initial node feature matrix through the graph convolution layer to obtain a plurality of second objects, each of which is a triple; The multiple second objects are output as a second historical and cultural knowledge graph through the second output layer.
5. The method for generating a knowledge graph in the field of history and culture according to claim 4, characterized in that: The step of adjusting parameters of the preset second knowledge graph generation model according to the target user intention to obtain a second optimization model includes: Obtain a relationship extraction rule set corresponding to a preset second knowledge graph generation model, wherein the relationship extraction rule set includes multiple relationship types; The weight of each relationship type is optimized according to the target dynasty to obtain a second optimization model.
6. The method for generating a knowledge graph in the field of history and culture according to claim 1, characterized in that: The step of performing inter-spectral fusion according to the first historical and cultural subgraph and the second historical and cultural subgraph to obtain a target historical and cultural knowledge graph includes: Perform triple matching on the first historical and cultural subgraph and the second historical and cultural subgraph; If there are any two identical triples, the second objects corresponding to the triples are deleted to obtain at least one remaining second object; If two entities in any two triples are the same, and the relationship between the two entities is different, the first objects corresponding to the triples are deleted to obtain at least one remaining first object; The remaining at least one first object and the remaining at least one second object are connected to obtain a target historical and cultural knowledge graph.
7. The method for generating a knowledge graph in the field of history and culture according to any one of claims 1 to 6, characterized in that: The parsing of the knowledge graph generation request to obtain the target dynasty and the target user intention includes: Performing dynasty matching on the knowledge graph generation request to obtain a target dynasty; The intent of the request for generating the knowledge graph is identified to obtain the target user intent.
8. A knowledge graph generation device in the field of history and culture, characterized in that: The knowledge graph generation device in the field of history and culture includes: A receiving module, used to receive a knowledge graph generation request and historical and cultural data to be extracted; A parsing module, used to parse the knowledge graph generation request to obtain a target dynasty and a target user intention; A first generation module, used for inputting the target dynasty and the historical and cultural data to be extracted into a preset first knowledge graph generation model to obtain a first historical and cultural subgraph; A second generation module, used for inputting the target user intention and the historical and cultural data to be extracted into a preset second knowledge graph generation model to obtain a second historical and cultural subgraph; The inter-spectrum fusion module is used to perform inter-spectrum fusion based on the first historical and cultural sub-graph and the second historical and cultural sub-graph to obtain a target historical and cultural knowledge graph.
9. An electronic device, characterized in that: The electronic device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory so that the electronic device executes the knowledge graph generation method in the historical and cultural field as described in any one of claims 1-7.
10. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instruction is read and executed, it executes the knowledge graph generation method in the historical and cultural field as described in any one of claims 1-7.
Citation Information
Cited By
Cross-culture melody feature extraction and musical instrument matching system based on deep learning
CN121459847A
