Knowledge graph construction method and device for target culture resources and electronic equipment
By conducting multi-domain knowledge graph training on large language models and fine-tuning of text data of target cultural resource resources, the problem of incomplete construction of knowledge graphs in the field of sparse data is solved, high-quality knowledge graph construction is achieved, and the efficiency of entity recognition and relationship extraction is improved.
Patent Information
- Application Number
- CN202411351933.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-02-28
AI Technical Summary
When building a knowledge graph, the existing technology limits the learning and representation ability of entity information for areas with relatively sparse data samples, resulting in incomplete knowledge graphs, poor connectivity, more subgraphs, lack of sufficient connections between nodes, and poor presentation results.
By obtaining knowledge graphs from multiple different fields, training large language models is made, structured information is integrated into language representation, and the large language model is fine-tuned using the relevant text data of the target cultural resource. Through the fine-tuned model, relevant knowledge in the form of triple-type can be obtained, and the knowledge graph is finally constructed.
When the sample data is relatively sparse, the natural language understanding, text generation ability and information extraction ability of the large language model are used to accurately identify and extract entities and relationships, and the construction of small sample knowledge graphs with sparse target cultural resources is completed, improving the integrity and connectivity of the knowledge graph.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and more specifically, relates to a method, device and electronic device for constructing a knowledge graph for target cultural resources. Background Art
[0002] At present, although there has been extensive research on knowledge graphs in general fields at home and abroad, most of them are concentrated in popular fields such as film and television, music, law and finance. In the process of traditional knowledge graph construction methods, for fields with relatively sparse data samples, the traditional architecture's ability to learn and represent entity information is limited, and the traditional relationship extraction model ignores the learning of contextual feature information of relationships, resulting in insufficient mining of relationship features. Therefore, the constructed knowledge graph is incomplete, has poor connectivity, has many subgraphs, lacks sufficient connections between nodes, and presents poor results. Summary of the invention
[0003] In view of the defects of the prior art, the purpose of this application is to provide a method, device and electronic device for constructing a knowledge graph for target cultural resources, aiming to effectively solve the problem of poor presentation results of knowledge graph construction caused by sparse data samples.
[0004] To achieve the above objectives, in the first aspect, the present application provides a method for constructing a knowledge graph for target cultural resources, including:
[0005] Acquire knowledge graphs in multiple different fields, and train a large language model based on the knowledge graphs, so that the structured information of the knowledge graphs is integrated into the language representation of the large language model;
[0006] Acquire text data related to target cultural resources, and fine-tune the large language model based on the text data related to the target cultural resources;
[0007] Through the fine-tuned large language model, knowledge is extracted from the text data related to the target cultural resources to obtain relevant knowledge in the form of triples;
[0008] Based on the related knowledge in the form of triples, a knowledge graph is constructed.
[0009] This application uses existing knowledge graph data to train a large language model, and then uses a large number of data sets containing text and annotated corresponding triples to fine-tune the large language model, training a large language model specifically suitable for extracting knowledge from the text data of the target cultural resources, so that it can generate high-quality language output. When the sample data is relatively sparse, the powerful natural language understanding, text generation, and information extraction capabilities of the large language model are used to accurately perform entity recognition and relationship extraction on the sparse data, and complete the construction of the sparse small sample knowledge graph of the target cultural resources.
[0010] According to the method for constructing a knowledge graph for target cultural resources provided by the present invention, the training of a large language model based on the knowledge graph includes:
[0011] Based on the knowledge graph, the first prediction task, the second prediction task and the third prediction task are set to train the large language model;
[0012] The first prediction task includes: replacing some words or characters in the input text data with masks, and inputting the masks into the large language model, so that the large language model predicts the masked words or characters according to the context;
[0013] The second prediction task includes: replacing some words or characters in the input text data with masks, and inputting the masks into the large language model, so that the large language model predicts the masked words or characters according to the context and entity information in the knowledge graph;
[0014] The third prediction task includes: inputting a sentence containing two or more entities into a large language model, so that the large language model predicts their association relationship through the relationship in the knowledge graph.
[0015] Based on the knowledge graph, this application constructs three prediction tasks to pre-train the large language model, so that the structured information of the knowledge graph can be effectively integrated into the language representation of the large prediction model. By combining the contextual information of the text and introducing rich information from the external knowledge graph to train the model, the model's understanding ability can be enhanced.
[0016] According to the method for constructing a knowledge graph for a target cultural resource provided by the present invention, fine-tuning the large language model based on text data related to the target cultural resource includes:
[0017] Fine-tuning the large language model based on the target cultural resource-related text data, so that the large language model learns extensive target cultural knowledge and semantic relationships, as well as specific language patterns and expressions in the text data;
[0018] Corresponding triples are annotated in the target cultural resource-related text data, and the annotated text data is used to fine-tune the large language model so that the large language model can more accurately identify and extract triple information in the unstructured data.
[0019] This application uses a large number of data sets containing text and corresponding triples annotated to fine-tune the large language model, so that the model can learn a wide range of target cultural knowledge and semantic relationships, as well as learn specific language patterns and expressions in text data, and can more accurately identify and extract triple information in unstructured data, thereby improving the ability of the large language model to understand complex grammatical structures and semantic relationships, enabling it to effectively identify and extract entities, relationships and attributes from sparse small sample data of target cultural resources, improving the efficiency of entity recognition and relationship extraction, and being suitable for fields with scarce data.
[0020] According to the knowledge graph construction method for target cultural resources provided by the present invention, the large language model is Llama3-70B.
[0021] The large language model used in this application is Llama3-70B. Its training data has been strictly filtered and processed, and has increased from 2T of Llama2 to 15T, which can better capture the complex relationships and characteristics of language and text.
[0022] According to the method for constructing a knowledge graph for target cultural resources provided by the present invention, the knowledge graph is constructed based on the related knowledge in the triple form, including:
[0023] The related knowledge in the form of triples is saved in a csv file in the form of entity-relationship-entity or entity-relationship-attribute;
[0024] Import the csv file into the graph database, and build a knowledge graph based on the preset graph data model.
[0025] According to the knowledge graph construction method for target cultural resources provided by the present invention, the graph database is Neo4j.
[0026] This application uses Neo4j as the graph database. Neo4j can be used to efficiently store and manage knowledge graph data.
[0027] In a second aspect, the present application provides a knowledge graph construction device for target cultural resources, including:
[0028] A training module is used to obtain knowledge graphs in multiple different fields and train a large language model based on the knowledge graphs so that the structured information of the knowledge graphs is integrated into the language representation of the large language model;
[0029] A fine-tuning module, used to obtain text data related to target cultural resources and fine-tune the large language model based on the text data related to the target cultural resources;
[0030] The extraction module is used to extract knowledge from the target cultural resource-related text data through the fine-tuned large language model to obtain relevant knowledge in the form of triples;
[0031] A building module is used to build a knowledge graph based on the relevant knowledge in the form of triples.
[0032] In a third aspect, the present application provides an electronic device comprising: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory. When the programs stored in the memory are executed, the processor is used to execute the knowledge graph construction method for the target cultural resources described in the first aspect or any possible implementation method of the first aspect.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the knowledge graph construction method for the target cultural resources described in the first aspect or any possible implementation of the first aspect.
[0034] In a fifth aspect, the present application provides a computer program product, which, when executed on a processor, enables the processor to execute the knowledge graph construction method for target cultural resources described in the first aspect or any possible implementation of the first aspect.
[0035] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.
[0036] In general, the above technical solutions conceived by this application have the following beneficial effects compared with the prior art:
[0037] By using existing knowledge graph data to train the large language model, and then fine-tuning the large language model using a large dataset containing text and annotated corresponding triples, the large language model is trained to be specifically suitable for extracting knowledge from the text data of the target cultural resources, so that it can generate high-quality language output. When the sample data is relatively sparse, the large language model's powerful natural language understanding, text generation, and information extraction capabilities are used to accurately perform entity recognition and relationship extraction on sparse data, completing the construction of the sparse small sample knowledge graph of the target cultural resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 It is a flowchart of a method for constructing a knowledge graph for target cultural resources provided in an embodiment of the present application;
[0040] Figure 2 is a schematic diagram of text data related to target cultural resources provided in an embodiment of the present application;
[0041] Figure 3 It is a schematic diagram of knowledge extraction using a large language model provided in an embodiment of the present application;
[0042] Figure 4 It is a schematic diagram of a csv file provided in an embodiment of the present application;
[0043] Figure 5 is a schematic diagram of inputting triples into a Neo4j database provided in an embodiment of the present application;
[0044] Figure 6 is a schematic diagram of the knowledge graph provided in the embodiment of the present application;
[0045] Figure 7 It is a schematic diagram of the structure of a knowledge graph construction device for target cultural resources provided in an embodiment of the present application;
[0046] Figure 8 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] The term "and / or" in this article is a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The symbol " / " in this article indicates that the associated objects are in an or relationship, for example, A / B means A or B.
[0049] The terms "first" and "second" in the specification and claims herein are used to distinguish different objects rather than to describe a specific order of the objects. For example, a first response message and a second response message are used to distinguish different response messages rather than to describe a specific order of the response messages.
[0050] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0051] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two. For example, multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
[0052] Next, combine Figure 1-Figure 6 The knowledge graph construction method for target cultural resources provided in the embodiments of the present application is introduced.
[0053] Figure 1 is a flow chart of a method for constructing a knowledge graph for target cultural resources provided in an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0054] Step 100, obtaining knowledge graphs in multiple different fields, and training a large language model based on the knowledge graphs, so that the structured information of the knowledge graphs is integrated into the language representation of the large language model;
[0055] Optionally, the present application first uses existing knowledge graph data from multiple different fields to train a large language model, so that the structured information of the knowledge graph is integrated into the language representation of the large language model to enhance the model's understanding ability.
[0056] Optionally, the selected knowledge graph needs to contain entity and relationship data.
[0057] Optionally, the present application does not limit the method of obtaining knowledge graphs in multiple different fields, and they can be obtained through the Internet or other means.
[0058] Optionally, this application does not limit the field of the knowledge graph, which can be the field of education, or other fields.
[0059] Step 110, obtaining text data related to target cultural resources, and fine-tuning the large language model based on the text data related to target cultural resources;
[0060] Optionally, the target cultural resources may be cultural resources in any field, such as historical culture, tea culture, etc.
[0061] Optionally, the target cultural resource-related text data may be articles, news, books, etc. related to the target cultural resources.
[0062] Figure 2 is a schematic diagram of target cultural resource related text data provided by an embodiment of the present application. In one embodiment of the present application, the target cultural resource related text data obtained is as follows Figure 2 shown.
[0063] Optionally, the present application does not limit the method for obtaining text data related to the target cultural resources, and the data can be obtained through the Internet or other means.
[0064] After training the large language model, the present application fine-tunes the large language model based on the text data related to the target cultural resources, so that the large language model can learn the structural patterns of the text data and adapt to the processing tasks of the text data of the target cultural resources, thereby improving the ability of the large language model to understand complex grammatical structures and semantic relationships.
[0065] Step 120, extracting knowledge from the target cultural resource related text data through the fine-tuned large language model to obtain related knowledge in the form of triples;
[0066] First, we obtain text data related to the target cultural resources, and then use this text data to ask questions to the fine-tuned large language model, allowing it to identify possible entities and relationships, as well as some attribute information from a large amount of unstructured text data, and output it in the form of triples of knowledge representation.
[0067] Figure 3 Schematic diagram of knowledge extraction using a large language model provided in an embodiment of the present application. In one embodiment of the present application, knowledge is extracted from text data related to target cultural resources using a fine-tuned large language model. Figure 3 shown.
[0068] Using a fine-tuned large language model for knowledge extraction tasks can more accurately identify entities and relationships in text data related to the target cultural resources.
[0069] Optionally, after obtaining the relevant knowledge in the form of triples output by the large language model, the output triples need to be screened and sorted, and triples that do not meet the requirements need to be deleted to maintain data consistency and ensure high-quality knowledge extraction for further knowledge storage and processing.
[0070] Step 130, construct a knowledge graph based on the related knowledge in the form of triples.
[0071] A knowledge graph can be constructed based on related knowledge in the form of triples, and the knowledge graph can be presented in a visual way. The Cypher language can also be used to dynamically adjust and query data.
[0072] The knowledge graph construction method for target cultural resources provided by the present invention uses existing knowledge graph data to train a large language model, and then uses a large number of data sets containing text and annotated corresponding triples to fine-tune the large language model, and trains a large language model specifically suitable for extracting knowledge from the text data of target cultural resources, so that it can generate high-quality language output. In the case of sparse sample data, the powerful natural language understanding, text generation, and information extraction capabilities of the large language model are used to accurately perform entity recognition and relationship extraction on sparse data, and complete the construction of the sparse small sample knowledge graph of the target cultural resources.
[0073] In some embodiments, step 100 specifically includes:
[0074] Based on the knowledge graph, the first prediction task, the second prediction task and the third prediction task are set to train the large language model;
[0075] The first prediction task includes: replacing some words or characters in the input text data with masks, and inputting the masks into the large language model, so that the large language model predicts the masked words or characters according to the context;
[0076] The second prediction task includes: replacing some words or characters in the input text data with masks and inputting them into the large language model, so that the large language model predicts the masked words or characters based on the context and entity information in the knowledge graph;
[0077] The third prediction task includes: inputting a sentence containing two or more entities into the large language model, so that the large language model predicts their association relationship through the relationship in the knowledge graph.
[0078] This application uses the knowledge graph embedding method to embed entities and relationships in the knowledge graph into a low-dimensional vector space. For the knowledge graph, a subgraph self-attention mechanism is used to process the knowledge graph information. A subgraph refers to a part of the knowledge graph extracted from the original knowledge graph that is related to the entity in the input text. The subgraph self-attention mechanism is used to aggregate the information of neighbor nodes and pass this information as input to the large language model.
[0079] The advantages of using subgraph self-attention embedding include:
[0080] 1a. Using subgraphs instead of the entire knowledge graph helps to strike a balance between computational efficiency and information utilization.
[0081] 2a. The self-attention mechanism can adaptively focus on important nodes in a subgraph without relying on predefined relationship weights, which is conducive to processing structures with sparse relationships or uneven importance in knowledge graphs.
[0082] 3a. The subgraph self-attention mechanism can capture the deep relationships in the knowledge graph, making the language model more capable in handling complex reasoning tasks.
[0083] Through the entity-level cross-knowledge graph attention mechanism, an enhanced entity representation that combines text context information and knowledge graph information is output. Through this mechanism, the model assigns weights to tokens in the text based on the information of related entities and relationships in the knowledge graph. The weight reflects the relevance of the token to an entity or relationship in the knowledge graph. Finally, the representation is regenerated based on the weight information.
[0084] When training the large language model, three training tasks are set up, including:
[0085] 1b. The first prediction task, namely the masked language prediction task, is a standard self-supervised task in which the model needs to predict the masked words or characters.
[0086] Input into the large language model: replace some words or characters in the text data with masks, and then input them into the large language model. The model needs to predict the masked words based on the context.
[0087] Large language model output: The model predicts the masked words and calculates the loss by comparing them with the true words.
[0088] 2b. The second prediction task, namely the knowledge graph enhanced masked language prediction task, introduces entity information in the knowledge graph on the basis of the ordinary masked language prediction task, so that the model not only assists word prediction based on the context, but also through the entity relationship in the knowledge graph.
[0089] Input into the large language model: replace some words or characters in the text data with masks, and then input them into the large language model. The model needs to predict the masked words based on the context and entities in the knowledge graph and their associations.
[0090] Large language model output: By combining the knowledge graph and context, the model predicts masked words more accurately.
[0091] 3b. The third prediction task, namely entity relationship prediction, aims to use the relationship information in the knowledge graph to help the model predict the relationship between two entities in the text.
[0092] Input into the large language model: Given a sentence containing two or more entities, the model predicts their associations through the relationships in the knowledge graph.
[0093] Large language model output: The model outputs the relationship category between entities and calculates the loss by comparing it with the true relationship category.
[0094] In some embodiments, step 110 specifically includes:
[0095] Step 1101, fine-tuning the large language model based on the target cultural resource-related text data, so that the large language model learns extensive target cultural knowledge and semantic relationships, as well as specific language patterns and expressions in the text data;
[0096] Step 1102, annotate corresponding triples in the target cultural resource related text data, and use the annotated text data to fine-tune the large language model so that the large language model can more accurately identify and extract triple information in the unstructured data.
[0097] After completing the training of the large language model, the task of fine-tuning is to first collect a large amount of target cultural resource text data, such as articles, news, books, etc., and use this data to fine-tune the model so that the model can learn a wide range of target cultural knowledge and semantic relationships, as well as learn specific language patterns and expressions in the text data.
[0098] Then the text data is annotated, the corresponding triples are annotated, and the annotated data set is used for supervised learning tasks, which specifically includes the following process:
[0099] 1c. Entity type recognition: The purpose of entity type recognition is to identify entities from a sentence and classify them into a certain type (such as names of people, places, organizations, etc.).
[0100] Input to the large language model: Given a sentence containing an entity, the entity is labeled as a specific type. The model uses contextual information and the knowledge graph during fine-tuning to predict the type of the entity.
[0101] Training objective: Optimize the model by minimizing the gap between the predicted entity type and the true type, using the cross entropy loss function for loss calculation and model optimization.
[0102] 2c. Relation classification: The goal of the relationship classification task is to identify the specific relationship between two entities. Based on the entity type recognition, the semantic relationship between entities is further predicted.
[0103] Input into the large language model: Given a sentence and the position information of two entities in the sentence, the model needs to predict the relationship between them based on the context and the knowledge graph.
[0104] Training goal: By comparing with the actual relationship labels, minimize the gap between the predicted relationship and the actual relationship, and use the cross entropy loss function for loss calculation and model optimization.
[0105] Optionally, for tags that mention entities in the text: all tags within the entity span are pooled using the self-attention span pooling method, and a corresponding representation for each entity span is calculated; for tags that do not represent entities in the text, a vector representation is obtained using the self-attention mechanism.
[0106] In some embodiments, the large language model is Llama3-70B.
[0107] This application selects Llama3-70B as the pre-trained language model architecture. Its training data has been strictly filtered and processed, and has increased from 2T of Llama2 to 15T, which can better capture the complex relationships and characteristics of language and text.
[0108] In some embodiments, step 130 specifically includes:
[0109] Step 1301, save the related knowledge in the form of triples into a csv file in the form of entity-relationship-entity or entity-relationship-attribute;
[0110] Step 1302, import the csv file into the graph database, and build a knowledge graph based on the preset graph data model.
[0111] Figure 4 is a schematic diagram of a csv file provided in an embodiment of the present application, such as Figure 4 As shown, in one embodiment of the present application, the related knowledge in the form of triples is saved in a csv file in the form of entity-relationship-entity or entity-relationship-attribute.
[0112] After obtaining the csv file, you can import it into the graph database and build a knowledge graph based on the preset graph data model.
[0113] Optionally, the graph database may be any graph database, such as Neo4j, JanusGraph, etc., and this application does not limit this.
[0114] When constructing the target cultural resource knowledge graph, it is necessary to design an appropriate graph data model, including different node types, relationships between nodes, and attributes of nodes and relationships.
[0115] In some embodiments, the graph database is Neo4j.
[0116] This application uses Neo4j for data storage and knowledge graph construction. Neo4j can be used to efficiently store and manage knowledge graph data.
[0117] Figure 5 is a schematic diagram of inputting triples into a Neo4j database provided in an embodiment of the present application, such as Figure 5 As shown, in one embodiment of the present application, the Cypher language is used to import into the Neo4j database, create nodes and relationships, and construct a knowledge graph.
[0118] Figure 6 is a schematic diagram of the knowledge graph provided in the embodiment of the present application, such as Figure 6 As shown, the csv file with the header is imported into Neo4j, and the elements in the first column and the third column are used as nodes, and the middle elements are used as relationships. The elements are associated with each other to generate a knowledge graph, which can intuitively display the information of entity-relationship-entity or entity-relationship-attribute.
[0119] Combine the following Figure 7 The knowledge graph construction device for the target cultural resources provided by the present invention is described. The knowledge graph construction device for the target cultural resources described below and the knowledge graph construction method for the target cultural resources described above can be referenced to each other.
[0120] Figure 7 is a schematic diagram of the structure of a knowledge graph construction device for target cultural resources provided in an embodiment of the present application, such as Figure 7 As shown, the system includes a training module 710, a fine-tuning module 720, an extraction module 730 and a construction module 740, wherein:
[0121] A training module 710 is used to obtain knowledge graphs in multiple different fields and train a large language model based on the knowledge graphs so that the structured information of the knowledge graphs is integrated into the language representation of the large language model;
[0122] A fine-tuning module 720, configured to obtain text data related to target cultural resources and fine-tune the large language model based on the text data related to the target cultural resources;
[0123] An extraction module 730 is used to extract knowledge from the target cultural resource related text data through the fine-tuned large language model to obtain related knowledge in the form of triples;
[0124] The construction module 740 is used to construct a knowledge graph based on the relevant knowledge in the form of triples.
[0125] It should be understood that the above-mentioned device is used to execute the method in the above-mentioned embodiment. The implementation principle and technical effect of the corresponding program module in the device are similar to those described in the above-mentioned method. The working process of the device can refer to the corresponding process in the above-mentioned method, which will not be repeated here.
[0126] Based on the method in the above embodiment, Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8 As shown, an embodiment of the present application provides an electronic device, which may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the knowledge graph construction method for the target cultural resource in the above embodiment.
[0127] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application can essentially or partly contribute to the prior art or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the knowledge graph construction method for the target cultural resources described in each embodiment of the present application.
[0128] Based on the method in the above embodiment, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the knowledge graph construction method for the target cultural resources in the above embodiment.
[0129] Based on the method in the above embodiment, an embodiment of the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the knowledge graph construction method for the target cultural resources in the above embodiment.
[0130] It is understandable that the processor in the embodiment of the present application can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor can be a microprocessor or any conventional processor.
[0131] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
[0132] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0133] It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.
[0134] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for constructing a knowledge graph for target cultural resources, characterized in that: include: Acquire knowledge graphs in multiple different fields, and train a large language model based on the knowledge graphs, so that the structured information of the knowledge graphs is integrated into the language representation of the large language model; Acquire text data related to target cultural resources, and fine-tune the large language model based on the text data related to the target cultural resources; Through the fine-tuned large language model, knowledge is extracted from the text data related to the target cultural resources to obtain relevant knowledge in the form of triples; Based on the related knowledge in the form of triples, a knowledge graph is constructed.
2. The method for constructing a knowledge graph for target cultural resources according to claim 1, characterized in that: The training of the large language model based on the knowledge graph includes: Based on the knowledge graph, the first prediction task, the second prediction task and the third prediction task are set to train the large language model; The first prediction task includes: replacing some words or characters in the input text data with masks, and inputting the masks into the large language model, so that the large language model predicts the masked words or characters according to the context; The second prediction task includes: replacing some words or characters in the input text data with masks, and inputting the masks into the large language model, so that the large language model predicts the masked words or characters according to the context and entity information in the knowledge graph; The third prediction task includes: inputting a sentence containing two or more entities into a large language model, so that the large language model predicts their association relationship through the relationship in the knowledge graph.
3. The method for constructing a knowledge graph for target cultural resources according to claim 1, characterized in that: The fine-tuning of the large language model based on the target cultural resource-related text data includes: Fine-tuning the large language model based on the target cultural resource-related text data, so that the large language model learns extensive target cultural knowledge and semantic relationships, as well as specific language patterns and expressions in the text data; Corresponding triples are annotated in the target cultural resource-related text data, and the annotated text data is used to fine-tune the large language model so that the large language model can more accurately identify and extract triple information in the unstructured data.
4. The method for constructing a knowledge graph for target cultural resources according to claim 1, characterized in that: The large language model is Llama3-70B.
5. The method for constructing a knowledge graph for target cultural resources according to claim 1, characterized in that: The step of constructing a knowledge graph based on the related knowledge in the triple form includes: The related knowledge in the form of triples is saved in a csv file in the form of entity-relationship-entity or entity-relationship-attribute; Import the csv file into the graph database, and build a knowledge graph based on the preset graph data model.
6. The method for constructing a knowledge graph for target cultural resources according to claim 5, characterized in that: The graph database is Neo4j.
7. A knowledge graph construction device for target cultural resources, characterized in that: include: A training module is used to obtain knowledge graphs in multiple different fields and train a large language model based on the knowledge graphs so that the structured information of the knowledge graphs is integrated into the language representation of the large language model; A fine-tuning module, used to obtain text data related to target cultural resources and fine-tune the large language model based on the text data related to the target cultural resources; The extraction module is used to extract knowledge from the target cultural resource-related text data through the fine-tuned large language model to obtain relevant knowledge in the form of triples; A building module is used to build a knowledge graph based on the relevant knowledge in the form of triples.
8. An electronic device, characterized in that: include: at least one memory for storing a computer program; At least one processor is used to execute the program stored in the memory. When the program stored in the memory is executed, the processor is used to execute the knowledge graph construction method for the target cultural resources as described in any one of claims 1-6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program runs on a processor, the processor executes the knowledge graph construction method for the target cultural resources as described in any one of claims 1-6.
10. A computer program product, characterized in that When the computer program product runs on a processor, the processor executes the knowledge graph construction method for the target cultural resources as described in any one of claims 1-6.
Citation Information
Patent Citations
Model pre-training and natural language processing method and device, equipment and storage medium
CN114780691A
Pre-training language model knowledge enhancement method for jointly learning internal and external knowledge
CN117151209A
Public security risk assessment method based on knowledge graph
CN118093889A
Method and device for automatically extracting and aligning triple of industrial field knowledge graph
CN118535729A
Triple information extraction method, apparatus, and device, and computer-readable storage medium
WO2022116417A1
Cited By
Knowledge graph generation method and system and terminal equipment
CN119940513A
Knowledge graph generation method based on large language model
CN120258117A
Method and device for acquiring literature information and automatically constructing literature knowledge graph
CN120509472A
Knowledge graph generation method and device based on large model, electronic equipment and medium
CN120764647A
Domain knowledge graph construction method and system based on large model iteration enhancement, terminal and medium
CN122547986A