A method and system for constructing subject knowledge graphs applicable to multiple courses
By adopting entity extraction and relational classification models based on prompt learning in the construction of subject knowledge graphs, the problem of poor results in entity extraction and relational classification in the existing technology is solved, and efficient and accurate knowledge graph construction is achieved.
Patent Information
- Application Number
- CN202410360426.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-27
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-03-27
AI Technical Summary
When building a subject knowledge graph, the prior art faces the problem of poor physical extraction and relationship classification, especially in the case of small or zero samples.
Using a entity extraction and relational classification model based on cue learning, a new cue template is defined to achieve small sample or even zero sample learning by introducing a cue-based guidance layer into a neural network model of self-attention mechanism.
It effectively improves the efficiency and accuracy of the construction of knowledge graphs in subject areas, and solves the problem of poor results in extraction of small or zero-sample entities and relationship classification.
Smart Images

Figure CN118153680B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method and system for constructing a subject knowledge graph applicable to multiple courses. Background Art
[0002] In the era of "Internet + Education", knowledge has exploded, accompanied by serious knowledge fragmentation, which makes it difficult for learners to see the relationship between knowledge, which is not conducive to the formation of a systematic knowledge network and an overall cognitive system. In order to solve this problem, explore new paths for the construction of teaching resources and new models for talent training, and effectively promote the reform of teaching methods. In recent years, scholars have begun to try to construct subject knowledge maps in order to establish a structured and systematic knowledge management framework. This effort aims to present the concepts, theories, methods, applications and other knowledge of the subject in the form of maps, so that learners can master and apply subject knowledge more efficiently through knowledge connections.
[0003] However, it is not easy to build a comprehensive and accurate subject knowledge graph. First, the complexity of subject knowledge itself requires that the graph can fully cover its broad knowledge field. There are few knowledge graphs for subject fields, and the construction process is cumbersome. Most construction methods rely on a large amount of labeled data and consume a lot of manpower. Secondly, the knowledge graph needs to be presented in an intuitive and easy-to-understand way so that learners can quickly find the required knowledge points and understand their connection with other knowledge points. In addition, as research continues to deepen, the knowledge graph must have the ability to be easily and dynamically updated to reflect the latest research results and knowledge structure of the subject. Therefore, the existing technology has the problem of poor results in entity extraction and relationship classification with a small number of samples or zero samples. Summary of the invention
[0004] In order to solve the above technical problems existing in the prior art, the embodiment of the present invention provides a subject knowledge graph construction method and system applicable to multiple courses. The technical solution is as follows:
[0005] On the one hand, a method for constructing a subject knowledge graph applicable to multiple courses is provided, the method comprising: preprocessing the subject resources of the target course to obtain the preprocessed subject materials; using an entity extraction model based on prompt learning to extract the entity set of the preprocessed subject resources; using an entity relationship classification model based on prompt learning to extract the entity relationship set in the entity set; and constructing the subject knowledge graph of the target course based on the entity set and the entity relationship set.
[0006] Optionally, the subject resources include: teaching materials, handouts, tutorial books and question banks.
[0007] Optionally, the subject resources of the target course are preprocessed to obtain preprocessed subject materials, including: digitizing the subject resources to obtain digital subject materials; deduplicating and eliminating non-relevant information from the digital subject materials to obtain the preprocessed subject materials.
[0008] Optionally, the entity extraction model based on prompt learning includes: an entity extraction model consisting of introducing a prompt-based guidance layer into a neural network model based on a self-attention mechanism.
[0009] Optionally, the entity relationship classification model based on prompt learning includes: an entity relationship classification model composed of a prompt-based guidance layer introduced into a neural network model based on a self-attention mechanism.
[0010] Optionally, based on the entity set and the entity relationship set, constructing a subject knowledge graph of the target course includes: importing the entity set and the entity relationship set into a graph database to obtain the subject knowledge graph of the target course.
[0011] Optionally, after constructing the subject knowledge graph of the target course based on the entity set and the entity relationship set, the method further includes: building a subject knowledge graph middle platform of the target course based on the subject knowledge graph of the target course, so that users can perform knowledge point queries and knowledge association queries based on the subject knowledge graph middle platform.
[0012] On the other hand, a subject knowledge graph construction system applicable to multiple courses is also provided, the system comprising: a preprocessing module, a first extraction module, a second extraction module and a construction module; wherein the preprocessing module is used to preprocess the subject resources of the target course to obtain the subject materials after preprocessing; the first extraction module is used to extract the entity set of the subject resources after preprocessing by adopting an entity extraction model based on prompt learning; the second extraction module is used to extract the entity relationship set in the entity set by adopting an entity relationship classification model based on prompt learning; the construction module is used to construct the subject knowledge graph of the target course based on the entity set and the entity relationship set.
[0013] Optionally, the system also includes: a building module, which is used to build a subject knowledge graph middle platform of the target course based on the subject knowledge graph of the target course, so that users can perform knowledge point queries and knowledge association queries based on the subject knowledge graph middle platform.
[0014] On the other hand, a computer-readable storage medium is provided, in which a program code is stored. The program code can be called by a processor to execute the method provided by the present invention.
[0015] The beneficial effects brought about by the technical solution provided by the present invention include at least:
[0016] The embodiments of the present invention provide a method and system for constructing a subject knowledge graph applicable to multiple courses. By defining a new prompt template, the model can perform learning with a small number of samples or even zero samples, thereby effectively realizing entity extraction and relationship classification tasks, greatly improving the efficiency and accuracy of constructing subject knowledge graphs, and alleviating the problem that the existing technology has poor results in entity extraction and relationship classification with a small number of samples or zero samples. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 It is a flow chart of a method for constructing a subject knowledge graph applicable to multiple courses provided by an embodiment of the present invention;
[0019] Figure 2 It is a schematic diagram of a subject knowledge graph construction system applicable to multiple courses provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0020] The technical solution of the present invention is described below in conjunction with the accompanying drawings.
[0021] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.
[0022] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0023] Embodiment 1
[0024] Figure 1 FIG. 1 is a flowchart of a method for constructing a subject knowledge graph applicable to multiple courses according to an embodiment of the present invention. Figure 1 As shown, the method specifically comprises the following steps:
[0025] Step S102, preprocessing the subject resources of the target course to obtain the preprocessed subject materials.
[0026] Preferably, subject resources include various forms of educational materials such as textbooks, handouts, tutorial books and question banks.
[0027] Step S104, using the prompt learning-based entity extraction model to extract the entity set of the subject resources after preprocessing.
[0028] Step S106: extracting an entity relationship set from the entity set by using an entity relationship classification model based on prompt learning.
[0029] Step S108, constructing a subject knowledge graph of the target course based on the entity set and the entity relationship set.
[0030] Specifically, step S102 further includes:
[0031] Digitalize subject resources to obtain digital subject materials;
[0032] The digital subject data are deduplicated and non-relevant information is removed to obtain the pre-processed subject data.
[0033] In an embodiment of the present invention, in order to enable these physical subject resources to be digitized, they first need to be converted into a format suitable for electronic processing, such as pictures, PDF, Word documents, etc. After completing this conversion step, the system will use OCR technology to convert the text content. Finally, a series of complex data processing operations are performed, including but not limited to data deduplication and elimination. Deduplication is to prevent duplicate information from appearing, and elimination is to delete irrelevant or low-quality content, such as watermarks, irrelevant annotations, etc. The purpose of these operations is to improve the quality and accuracy of the knowledge graph and ensure that it provides accurate and reliable subject knowledge.
[0034] Specifically, in an embodiment of the present invention, the entity extraction model based on prompt learning includes: an entity extraction model composed of a prompt-based guidance layer introduced into a neural network model based on a self-attention mechanism.
[0035] In the embodiment of the present invention, the idea of prompt-based learning is introduced into the entity extraction model to improve the learning effect of a small number of samples or even zero samples. Template information is integrated into the entity extraction sentence information and the model attention mechanism. Specifically, the implementation ideas of this part mainly include the following points:
[0036] Task definition: For a given original sentence X = {x1, x2, ...x i ,...x n}, for each type of entity to be extracted, construct a sentence about that type of entity. If the entity type to be extracted is e, then what needs to be integrated into the entity extraction sentence is: X p ={[CLS],e,[SEP],x1,x2,…x i , …x n , [SEP]}, and then predict the entity of this type in X p The position in (usually the entity start index and entity end index), specifically for an X p Sequence, predicting whether each character position is the starting position or the ending position of the entity type.
[0037] Entity extraction model that introduces the idea of prompt learning: It mainly introduces an attention layer based on prompt learning. This architecture is mainly a continuation of the Transformer model proposed by Vaswani et al., and introduces a prompt-based guidance layer on the original query (Q), key (K), and value (V) layers. In general, the attention based on prompt guidance can readjust the attention mechanism according to the prompt content. The specific implementation process is as follows:
[0038] First, set a set of parameters {φ 1 ,φ 2 , ..., φ N}, N is the number of transformer layers, φ θ ∈R 2*|P|*d , |P| is the prompt length, d is the dimension of the initial embedding, and 2 means it is applied to key and value respectively.
[0039] Given an input sequence X = {x1, x2, ...x i , …x n}, the corresponding initial hidden state is X∈R n*d . First use X to get the corresponding QKV:
[0040] Q l =X l W Q , K l =X l W K , V l =X l W V
[0041] On this basis, add the above φ θ , this step can readjust the distribution of attention:
[0042]
[0043] Loss function: Since the final prediction is whether each character position is the starting position or the ending position of the entity, the task is transformed into a multi-label binary classification problem. For an original sample, assuming the sequence length is n, then there are n binary classification problems. The final loss function consists of two parts: start_loss and end_loss.
[0044] When designing the loss function, the loss function of traditional classification tasks mostly uses cross entropy as the loss function. However, if the BIO entity labeling rule is adopted, the number of labels of B and I is much smaller than the number of labels of 0. Therefore, in order to solve this kind of problem, the Focal Loss loss function is introduced. The formula is as follows:
[0045] FL(p t )=-α t (1-p t ) γ log(p t )
[0046] In this formula: FL(p t ) is the Focal Loss function. t is the model's predicted probability for each category. t is a coefficient used to adjust the importance of different classes. γ is a tuning factor used to reduce the weight of easy samples (those that the model can easily classify correctly) in the total loss.
[0047] Data enhancement: Due to the limited labeled data, it is necessary to use a variety of natural language processing techniques to expand the data set. One of the methods used is to use the generation capability of the large model to rewrite the non-entity part while retaining the sentence entity.
[0048] Specifically, the entity relationship classification model based on prompt learning includes: an entity relationship classification model composed of introducing a prompt-based guidance layer into a neural network model based on a self-attention mechanism.
[0049] In the entity relationship classification model based on prompt learning provided by the embodiment of the present invention, the task definition is: for a given sentence X containing entity e1 and entity e2 = {x1, x2, ... x i, …x n}, for the entity relationship to be extracted, add special tags at the beginning and end of entity e1 and entity e2 respectively. Entity e1 uses " <e1>< / e1> " symbol, entity e2 uses " <e2>< / e2> " symbol, and use the hard template to prompt the learning sentence. The final sentence representation to be extracted becomes:
[0050] X p={[CLS], x1, <e1> ,e1,< / e1> , ..., <e2> ,e2,< / e2> , ..., x n ,[SEP]e1[MASK]e2[SEP]
[0051] Here, [MASK] is predicted to establish a connection with the actual entity relationship.
[0052] Entity relationship classification model with prompt learning: It mainly introduces an attention layer based on prompt learning. This architecture is mainly a continuation of the Transformer model proposed by Vaswani et al., and introduces a prompt-based guidance layer on the original query (Q), key (K), and value (V) layers. In general, the attention based on prompt guidance can readjust the attention mechanism according to the prompt content. The specific implementation process is as follows:
[0053] First, set a set of parameters {φ 1 ,φ 2 , ..., φ N}, N is the number of transformer layers, φ θ ∈R 2*|P|*d , |P| is the prompt length, d is the dimension of the initial embedding, and 2 means it is applied to key and value respectively.
[0054] Given an input sequence X = {x1, x2, ...x i , …x n}, the corresponding initial hidden state is X∈R n*d . First use X to get the corresponding QKV:
[0055] Q l =X l W Q , K l =X l W K , V l =X l W V
[0056] On this basis, add the above φ θ , this step can readjust the distribution of attention:
[0057]
[0058] If the entity type to be extracted is: e, then the entity extraction sentence needs to be integrated into it, and the final result is: X p ={[CLS],e,[SEP],x1,x2,…x i ,...x n, [SEP]}, and then predict the entity of this type in X p The position in (usually the entity start index and entity end index), specifically for an X p Sequence, predicting whether each character position is the starting position or the ending position of the entity type.
[0059] Loss function: Now we need to map the [MASK] vector output by the encoder to the actual relationship, add a fully connected layer and a Softmax layer, and the process can be expressed as:
[0060] H=WH mask +b
[0061] p = softmax(H)
[0062] Where W and b are the parameters of the fully connected layer, H mask is the vector representation of the [MASK] position, and p is the final relationship classification probability distribution.
[0063] Due to the imbalance of relation classification data and the large difference in difficulty, the Focal Loss loss function is introduced. The formula is as follows:
[0064] FL(p t )=-α t (1-p t ) γ log(p t )
[0065] In this formula: FL(p t ) is the Focal Loss function. pt is the model's predicted probability for each category. α t is a coefficient used to adjust the importance of different classes. γ is a tuning factor used to reduce the weight of easy samples (those that the model can easily classify correctly) in the total loss.
[0066] Introducing the adversarial training FGM algorithm: FGM is an adversarial training algorithm that is mainly used to improve the robustness of machine learning models, especially in the field of deep learning. In natural language processing, FGM can be used to enhance the model's resistance to small perturbations of the input data, thereby improving the model's generalization ability and security. Specifically, the working principle of FGM is as follows:
[0067] Calculate gradients: First, for a trained model, the algorithm calculates the gradient of the model output relative to the input data. This gradient reflects how the input data affects the model's predictions.
[0068] Generate adversarial examples: The algorithm then uses these gradients to create adversarial examples. These examples are generated by adding a small perturbation to the original input data that is in the same direction as the gradient. This perturbation is designed to produce the largest change in the model’s output.
[0069] Retrain the model: Finally, these adversarial examples are used to train the model again. In this way, the model learns to recognize and correctly process input data that has been slightly modified, thereby improving its resistance to adversarial attacks.
[0070] Specifically, step S108 further includes: importing the entity set and the entity relationship set into a graph database to obtain a subject knowledge graph of the target course. Optionally, the graph database includes a Neo4j graph database.
[0071] Specifically, by implementing entity extraction and relationship classification tasks on subject data, entity tables and relationship tables based on subject data can be obtained. The obtained data contains a large amount of triple knowledge in the format of (entity, relationship, entity), so frequent query operations on relationships will be involved. When a relational database performs a relational query operation, it often needs to add new tables and fields or generate new table connections, while a graph database only needs to insert entity nodes and relationship edges, and it is more flexible. Therefore, the embodiment of the present invention selects the Neo4j graph database to store subject knowledge data and uses a graph algorithm to implement subject knowledge point query and knowledge association query.
[0072] Neo4j stores subject knowledge data in the form of nodes, relationships, and attributes. It is a non-relational database based on graph theory, suitable for storing a series of complex topological structures, and has high efficiency in traversing entity nodes and entity relationships. Neo4j's dedicated query language Cypher has simple syntax, is easy to operate, and supports a variety of commands, including creating, adding or updating node attributes, querying, deleting nodes and their associated relationships, merging, etc. By importing the obtained entity table and relationship table into the Neo4j graph database, a subject knowledge graph can be obtained. Then, the Neo4j dedicated Cypher language can be used to perform a series of operations such as graph parsing and knowledge path retrieval on the entities and relationships in the subject data.
[0073] Preferably, after step S108, the method provided by the embodiment of the present invention further includes: based on the subject knowledge graph of the target course, building a subject knowledge graph middle platform of the target course, so that users can perform knowledge point queries and knowledge association queries based on the subject knowledge graph middle platform.
[0074] Specifically, the FLASK framework is used to build a knowledge graph platform, and a well-designed interactive page is used to provide users with functions such as knowledge point query and knowledge association query. Among them, for subject knowledge point query, the user's knowledge point input is obtained, and the corresponding content is sent to the back end. The Cypher language can be used to directly search for the corresponding knowledge point and its related knowledge points, and return them to the front-end page for users to learn.
[0075] From the above description, it can be seen that the embodiment of the present invention provides a method for constructing a subject knowledge graph applicable to multiple courses. Compared with the prior art, this method has at least the following beneficial technical effects:
[0076] In the present invention, a prompt-learning-based entity extraction and relationship classification method is used to pre-train the language model using a large amount of original text, and by defining a new prompt template, the model is able to perform a small number of samples or even zero-sample learning, thereby effectively realizing entity extraction and relationship classification tasks, greatly improving the efficiency and accuracy of subject area knowledge graph construction.
[0077] Embodiment 2
[0078] Figure 2 Schematic diagram of a subject knowledge graph construction system applicable to multiple courses provided according to an embodiment of the present invention. Figure 2 As shown, the system includes: a preprocessing module 10, a first extraction module 20, a second extraction module 30 and a construction module 40.
[0079] Specifically, the preprocessing module 10 is used to preprocess the subject resources of the target course to obtain the preprocessed subject materials.
[0080] The first extraction module 20 is used to extract the entity set of the subject resources after preprocessing by adopting the entity extraction model based on prompt learning.
[0081] The second extraction module 30 is used to extract the entity relationship set from the entity set by adopting the entity relationship classification model based on prompt learning.
[0082] The construction module 40 is used to construct a subject knowledge graph of the target course based on the entity set and the entity relationship set.
[0083] Specifically, Figure 2 As shown, the system also includes: a building module 50, which is used to build a subject knowledge graph middle platform of the target course based on the subject knowledge graph of the target course, so that users can perform knowledge point queries and knowledge association queries based on the subject knowledge graph middle platform.
[0084] An embodiment of the present invention further provides a computer-readable storage medium, in which a program code is stored. The program code can be called by a processor to execute the method in the above-mentioned embodiment 1.
[0085] It should be understood that the memory in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DRRAM).
[0086] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented by software, the above embodiments 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 or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0087] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0088] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0089] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0090] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0091] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0092] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0093] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the 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 enabling 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 methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0094] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for constructing a subject knowledge graph applicable to multiple courses, characterized in that: The method comprises: Preprocess the subject resources of the target course to obtain the preprocessed subject materials; Using a prompt learning-based entity extraction model to extract entity sets from the subject resources after the preprocessing; Using an entity relationship classification model based on prompt learning, extracting an entity relationship set from the entity set; Based on the entity set and the entity relationship set, construct a subject knowledge graph of the target course; The entity extraction model based on prompt learning includes: an entity extraction model composed of a prompt-based guidance layer introduced into a neural network model based on a self-attention mechanism; including: Task definition: For a given original sentence X = {x1, x2, ... x i ,…x n }, for each type of entity to be extracted, construct a sentence about that type of entity. If the entity type to be extracted is e, then the entity extraction sentence that needs to be integrated into it is: X p ={[CLS],e,[SEP],x1,x2,…x i ,…x n ,[SEP]}, then predict the entity of this type in X p Specifically, for an X p Sequence, predict whether each character position is the starting position or the ending position of the entity type; Introducing the entity extraction model with the idea of prompt learning: First, set a set of parameters {φ 1 ,φ 2 ,…,φ N }, N is the number of transformer layers, φ θ ∈R 2*|P|*d , |P| is the prompt length, d is the dimension of the initial embedding, and 2 means it is applied to key and value respectively; Given an input sequence X = {x1, x2, ... x i ,…x n }, the corresponding initial hidden state is X∈R n*d ; First use X to get the corresponding QKV: Q l =X l W Q ,K l =X l W K ,V l =X l W V On this basis, add the above φ θ , this step can readjust the distribution of attention: The entity relationship classification model based on prompt learning includes: an entity relationship classification model composed of a prompt-based guidance layer introduced into a neural network model based on a self-attention mechanism; including: Task definition: Given a sentence X containing entity e1 and entity e2 = {x1, x2, ... x i ,…x n }, for the entity relationship to be extracted, add special tags at the beginning and end of entity e1 and entity e2 respectively, and entity e1 uses " <e1>< / e1> "Symbol, entity e2 uses" <e2>< / e2> " symbol, and use the hard template to prompt the learning sentence. The final sentence representation to be extracted becomes: X p ={[CLS],x1, <e1> ,e1,< / e1> ,…, <e2> ,e2,< / e2> ,…,x n ,[SEP]e1[MASK]e2[SEP] Establish connections with actual entity relationships by predicting [MASK]; The entity relationship classification model with the idea of prompt learning is introduced: First, a set of parameters {φ 1 ,φ 2 ,…,φ N }, N is the number of transformer layers, φ θ ∈R 2*|P|*d , |P| is the prompt length, d is the dimension of the initial embedding, and 2 means it is applied to key and value respectively; Given an input sequence X = {x1, x2, ... x i ,…x n }, the corresponding initial hidden state is X∈R n*d ; First use X to get the corresponding QKV: Q l =X l W Q ,K l =X l W K ,V l =X l W V On this basis, add the above φ θ , this step can readjust the distribution of attention: If the entity type to be extracted is: e, then the entity extraction sentence needs to be integrated into it, and the final result is: X p ={[CLS],e,[SEP],x1,x2,…x i ,…x n ,[SEP]}, then predict the entity of this type in X p Specifically, for an X p Sequence, predicting whether each character position is the starting position or the ending position of the entity type.
2. The method according to claim 1, characterized in that The subject resources include: textbooks, handouts, tutorial books and question banks.
3. The method according to claim 1, characterized in that Preprocess the subject resources of the target course to obtain the preprocessed subject materials, including: Digitally process the subject resources to obtain digital subject materials; The digital subject data is deduplicated and non-related information is removed to obtain the subject data after the preprocessing.
4. The method according to claim 1, characterized in that: Based on the entity set and the entity relationship set, constructing a subject knowledge graph of the target course, including: The entity set and the entity relationship set are imported into a graph database to obtain a subject knowledge graph of the target course.
5. The method according to claim 1, characterized in that After constructing the subject knowledge graph of the target course based on the entity set and the entity relationship set, the method further includes: Based on the subject knowledge graph of the target course, a subject knowledge graph middle platform of the target course is built to enable users to perform knowledge point queries and knowledge association queries based on the subject knowledge graph middle platform.
6. A subject knowledge graph construction system applicable to multiple courses, characterized in that: The system comprises: a preprocessing module, a first extraction module, a second extraction module and a construction module; wherein, The preprocessing module is used to preprocess the subject resources of the target course to obtain the preprocessed subject materials; The first extraction module is used to extract the entity set of the subject resources after the preprocessing by adopting the entity extraction model based on prompt learning; The second extraction module is used to extract the entity relationship set in the entity set by adopting the entity relationship classification model based on prompt learning; The construction module is used to construct the subject knowledge graph of the target course based on the entity set and the entity relationship set.
7. The system according to claim 6, characterized in that The system also includes: a building module, which is used to build a subject knowledge graph middle platform of the target course based on the subject knowledge graph of the target course, so that users can perform knowledge point queries and knowledge association queries based on the subject knowledge graph middle platform.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Atlas construction method and device, electronic equipment and computer readable medium
CN116128055A