Knowledge extraction method, knowledge extraction model training method and device
By first determining the target relationship in knowledge extraction, then extracting entity association types based on the relationship, and using multi-label classification and entity extraction network, the problems of entity redundancy and error accumulation in the existing technology are solved, and efficient and accurate knowledge triple extraction is achieved.
Patent Information
- Application Number
- CN202310318411.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2043-03-28
AI Technical Summary
When the prior art extracts knowledge triplets from unstructured or semi-structured knowledge texts, there is entity redundancy and error accumulation, resulting in low accuracy of relationship classification, high cost of end-to-end model training, poor efficiency and performance.
By first determining the potential target relationship in the knowledge text, and then determining the entity association type of the text pair based on the target relationship, using a multi-label classification network, entity extraction network and entity association type prediction network, gradually extracting the subject entity and object entities to form a high-accurate knowledge triple.
It improves the accuracy and efficiency of knowledge extraction, reduces entity redundancy and error, and improves the overall performance of knowledge extraction.
Smart Images

Figure CN116361484B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, in particular to the field of artificial intelligence technologies such as natural language processing and knowledge graphs, and specifically to a knowledge extraction method and device, a knowledge extraction model training method and device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] Artificial intelligence (AI) is the study of how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily encompass computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graphs.
[0003] A knowledge graph is a structured semantic knowledge base that can be represented as a network topology consisting of nodes and edges, where nodes represent entities and edges represent relationships between them. Knowledge graphs offer strong knowledge representation capabilities and flexibility, enabling them to support diverse application scenarios such as information retrieval, machine question answering, and content recommendations.
[0004] The approaches described in this section are not necessarily approaches that have been previously conceived or employed. Unless otherwise indicated, it should not be assumed that any approach described in this section is prior art simply by virtue of its inclusion in this section. Similarly, unless otherwise indicated, the issues raised in this section should not be considered as having been recognized in any prior art. Summary of the Invention
[0005] The present disclosure provides a knowledge extraction method, a training method and device for a knowledge extraction model, an electronic device, a computer-readable storage medium, and a computer program product.
[0006] According to one aspect of the present disclosure, a knowledge extraction method is provided, comprising: acquiring a knowledge text to be extracted; determining a target relationship included in the knowledge text from a plurality of preset candidate relationships, wherein the target relationship indicates a relationship between a subject entity and an object entity included in the knowledge text; combining a plurality of characters in the knowledge text in pairs to obtain a plurality of character pairs; determining an entity association type corresponding to each character pair in the plurality of character pairs based on the target relationship, the entity association type being used to indicate an inclusion relationship between each character pair and at least one of the subject entity and the object entity; and determining the subject entity and the object entity from the knowledge text based on the entity association type corresponding to each character pair in the plurality of character pairs to obtain a knowledge triple including the target relationship, the subject entity and the object entity.
[0007] According to one aspect of the present disclosure, a training method for a knowledge extraction model is provided, wherein the knowledge extraction model includes a multi-label classification network, an entity extraction network, and an entity association type prediction network, and the method includes: obtaining sample knowledge text and annotation information, wherein the annotation information includes real subject entities, real object entities, and real target relationships between the real subject entities and real object entities in the sample knowledge text; inputting the sample knowledge text into the multi-label classification network to obtain confidences of multiple preset labels output by the multi-label classification network, wherein the multiple preset labels correspond to multiple candidate relationships; based on the confidences of the multiple preset labels, determining a predicted target relationship from the multiple candidate relationships; inputting the predicted target relationship and the sample knowledge text into the entity extraction network to obtain The entity extraction network outputs multiple candidate entities; multiple characters in the sample knowledge text are combined in pairs to obtain multiple sample text pairs; for each sample text pair in the multiple sample text pairs, the predicted target relationship and the character vector corresponding to the sample text pair are input into the entity association type prediction network to obtain the entity association type corresponding to the sample text pair output by the entity association type prediction network; based on the entity association type corresponding to each sample text pair in the multiple sample text pairs, a predicted subject entity and a predicted object entity are determined from the multiple candidate entities; and based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship, the parameters of the knowledge extraction model are adjusted.
[0008] According to another aspect of the present disclosure, a knowledge extraction device is provided, comprising: a first acquisition unit, configured to acquire a knowledge text to be extracted; a first determination unit, configured to determine a target relationship included in the knowledge text from a plurality of preset candidate relationships, wherein the target relationship indicates a relationship between a subject entity and an object entity included in the knowledge text; a first combination unit, configured to perform pairwise combination of a plurality of characters in the knowledge text to obtain a plurality of character pairs; a second determination unit, configured to determine an entity association type corresponding to each character pair in the plurality of character pairs based on the target relationship, the entity association type being used to indicate an inclusion relationship between each character pair and at least one of the subject entity and the object entity; and a third determination unit, configured to determine the subject entity and the object entity from the knowledge text based on the entity association type corresponding to each character pair in the plurality of character pairs to obtain a knowledge triple including the target relationship, the subject entity and the object entity.
[0009] According to another aspect of the present disclosure, a training device for a knowledge extraction model is provided, wherein the knowledge extraction model includes a multi-label classification network, an entity extraction network and an entity association type prediction network, and the device includes: a second acquisition unit, configured to acquire sample knowledge text and annotation information, wherein the annotation information includes real subject entities, real object entities and real target relationships between the real subject entities and real object entities in the sample knowledge text; a first input unit, configured to input the sample knowledge text into the multi-label classification network to obtain confidences of multiple preset labels output by the multi-label classification network, wherein the multiple preset labels correspond to multiple candidate relationships; a fourth determination unit, configured to determine a predicted target relationship from the multiple candidate relationships based on the confidences of the multiple preset labels; a second input unit, configured to input the predicted target relationship and the sample knowledge text into the entity extraction network to obtain the confidences of the multiple preset labels. Acquire multiple candidate entities output by the entity extraction network; a second combination unit is configured to perform pairwise combination of multiple characters in the sample knowledge text to obtain multiple sample character pairs; a third input unit is configured to input the predicted target relationship and the corresponding character vector of the sample character pair into the entity association type prediction network for each sample character pair in the multiple sample character pairs to obtain the corresponding entity association type of the sample character pair output by the entity association type prediction network; a fifth determination unit is configured to determine the predicted subject entity and the predicted object entity from the multiple candidate entities based on the corresponding entity association type of each sample character pair in the multiple sample character pairs; and a parameter adjustment unit is configured to adjust the parameters of the knowledge extraction model based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
[0010] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any of the above methods.
[0011] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the above methods.
[0012] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program can implement any of the above methods when executed by a processor.
[0013] According to one or more embodiments of the present disclosure, the accuracy of knowledge extraction can be improved.
[0014] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings illustrate exemplary embodiments and constitute a part of the specification. Together with the description of the specification, they serve to explain exemplary implementation of the embodiments. The illustrated embodiments are for illustrative purposes only and do not limit the scope of the claims. Throughout the drawings, the same reference numerals designate similar, but not necessarily identical, elements.
[0016] Figure 1 A schematic diagram illustrating an exemplary system in which the various methods described herein may be implemented according to exemplary embodiments of the present disclosure;
[0017] Figure 2 A flow chart of a knowledge extraction method according to an exemplary embodiment of the present disclosure is shown;
[0018] Figure 3 shows a schematic structural diagram of a knowledge extraction model according to an exemplary embodiment of the present disclosure;
[0019] Figure 4 A flowchart of a method for training a knowledge extraction model according to an exemplary embodiment of the present disclosure is shown;
[0020] Figure 5 shows a structural block diagram of a knowledge extraction device according to an exemplary embodiment of the present disclosure;
[0021] Figure 6 A structural block diagram of a training device for a knowledge extraction model according to an exemplary embodiment of the present disclosure is shown;
[0022] Figure 7 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0023] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0024] In this disclosure, unless otherwise specified, the use of terms such as "first" and "second" to describe various elements is not intended to limit the positional relationship, temporal relationship, or importance relationship of these elements. Such terms are only used to distinguish one element from another. In some examples, the first element and the second element may refer to the same instance of the element, while in some cases, based on the context of the description, they may also refer to different instances.
[0025] The terms used in the descriptions of the various examples described in this disclosure are for the purpose of describing specific examples only and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element may be one or more. In addition, the term "and / or" used in this disclosure encompasses any one and all possible combinations of the listed items.
[0026] Knowledge can be represented as a triple of the form (S, P, O), also known as an SPO triple. Here, S (Subject) is the subject entity, O (Object) is the object entity, and P (Predicate) is the target relationship between the subject and object entities. Based on this triple, we can construct two adjacent nodes (entities) and their connecting edge (relationship) in the knowledge graph.
[0027] In the related art, one approach is to extract knowledge triples from unstructured or semi-structured knowledge texts based on a linear process, that is, first perform entity extraction, then pair the obtained entities with each other, and perform multi-relationship label classification based on the pairing results to obtain knowledge triples consisting of entity pairs and relationships. However, this approach will lead to entity redundancy and error accumulation. When there is error redundancy in the entity extraction results, it will seriously affect the accuracy of relationship classification, thereby increasing the complexity of error handling. Another approach is to use an end-to-end model to extract knowledge triples based on knowledge texts. However, this approach fails to fully utilize the dependency between the entity extraction task and the relationship classification task, resulting in high model training costs and poor efficiency and performance.
[0028] Based on this, the embodiments of the present disclosure provide a knowledge extraction method and a training method for a knowledge extraction model, which first determines the potential target relationship in the knowledge text, then determines the entity association type of each text pair in the knowledge text based on the target relationship, and determines the subject entity and object entity in the knowledge text based on the entity association type prediction results, thereby obtaining knowledge triples with higher accuracy and improving the efficiency and accuracy of knowledge extraction.
[0029] The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0030] Figure 1FIG2 is a schematic diagram of an exemplary system 100 in which the various methods and apparatuses described herein may be implemented according to an embodiment of the present disclosure. Figure 1 , the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 can be configured to execute one or more applications.
[0031] In an embodiment of the present disclosure, the server 120 may run one or more services or software applications that enable execution of the knowledge extraction method.
[0032] In some embodiments, server 120 may also provide other services or software applications, which may include non-virtualized environments and virtualized environments. In some embodiments, these services may be provided as web-based services or cloud services, such as provided to users of client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) model.
[0033] exist Figure 1 In the configuration shown, the server 120 may include one or more components that implement the functions performed by the server 120. These components may include software components, hardware components, or a combination thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may, in turn, utilize one or more client applications to interact with the server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from the system 100. Therefore, Figure 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
[0034] The user may use client devices 101, 102, 103, 104, 105 and / or 106 to send the knowledge text to be extracted. The client device may provide an interface that enables the user of the client device to interact with the client device. The client device may also output information to the user via the interface. Figure 1 Only six client devices are depicted, but one skilled in the art will appreciate that the present disclosure can support any number of client devices.
[0035] Client devices 101, 102, 103, 104, 105, and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptops), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, gaming systems, thin clients, various messaging devices, sensors or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux, or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT Windows Mobile OS, iOS, Windows Phone, and Android. Portable handheld devices may include cellular phones, smartphones, tablet computers, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Gaming systems may include various handheld gaming devices, internet-enabled gaming devices, etc. The client device is capable of executing various different applications, such as various Internet-related applications, communication applications (eg, email applications), Short Message Service (SMS) applications, and may use various communication protocols.
[0036] The network 110 may be any type of network known to those skilled in the art that can support data communications using any of a variety of available protocols, including but not limited to TCP / IP, SNA, IPX, etc. By way of example only, the one or more networks 110 may be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a blockchain network, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.
[0037] Server 120 may include one or more general-purpose computers, specialized server computers (e.g., PC (personal computer) servers, UNIX servers, mid-range servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and / or combination. Server 120 may include one or more virtual machines running virtual operating systems, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain a server's virtual storage device). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
[0038] The computing units in the server 120 may run one or more operating systems including any of the operating systems described above as well as any commercially available server operating systems. The server 120 may also run any of a variety of additional server applications and / or middle-tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, and the like.
[0039] In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display the data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
[0040] In some embodiments, server 120 may be a distributed system server or a server integrated with blockchain. Server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host equipped with artificial intelligence technology. A cloud server is a host product within the cloud computing service system that addresses the management difficulties and poor scalability of traditional physical hosts and virtual private servers (VPS) services.
[0041] The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as audio files and video files. The databases 130 may reside in a variety of locations. For example, the database used by the server 120 may be local to the server 120, or may be remote from the server 120 and communicate with the server 120 via a network-based or dedicated connection. The databases 130 may be of different types. In some embodiments, the databases used by the server 120 may be, for example, relational databases. One or more of these databases may store, update, and retrieve data to and from the databases in response to commands.
[0042] In some embodiments, one or more of the databases 130 may also be used by applications to store application data. The databases used by the applications may be different types of databases, such as a key-value store, an object store, or a conventional store backed by a file system.
[0043] Figure 1The system 100 may be configured and operated in various ways to enable application of the various methods and apparatuses described in accordance with the present disclosure.
[0044] Figure 2 FIG. 2 shows a flow chart of a knowledge extraction method 200 according to an exemplary embodiment of the present disclosure. Figure 2 As shown, the method 200 includes:
[0045] Step S201: Obtain the knowledge text to be extracted;
[0046] Step S202: determining a target relationship included in the knowledge text from a plurality of preset candidate relationships, wherein the target relationship indicates a relationship between a subject entity and an object entity included in the knowledge text;
[0047] Step S203: combining multiple characters in the knowledge text in pairs to obtain multiple character pairs;
[0048] Step S204: determining an entity association type corresponding to each of the plurality of character pairs based on the target relationship, wherein the entity association type is used to indicate an inclusion relationship between each character pair and at least one of the subject entity and the object entity; and
[0049] Step S205: Based on the entity association type corresponding to each of the multiple text pairs, determine the subject entity and the object entity from the knowledge text to obtain a knowledge triple including the target relationship, the subject entity and the object entity.
[0050] Therefore, by first determining the potential target relationship in the knowledge text, and then determining the entity association type of each text pair in the knowledge text based on the target relationship, the entity association type class of each text pair is used to indicate the position of the subject entity and object entity corresponding to the target relationship in the knowledge text, so that the subject entity and object entity in the knowledge text can be more accurately determined based on the entity association type prediction results, so as to obtain more accurate knowledge triples and improve the efficiency and accuracy of knowledge extraction.
[0051] According to some embodiments, the entity association type is used to indicate whether the two characters in each character pair belong to the subject entity and the object entity, respectively. Thus, based on the entity association type, the positions of the subject entity and the object entity corresponding to the target relationship in the knowledge document can be more accurately indicated, thereby obtaining more accurate knowledge triples.
[0052] According to some embodiments, in step S205, determining the subject entity and the object entity from the knowledge text based on the entity association type corresponding to each of the multiple text pairs includes: extracting multiple candidate entities from the knowledge text based on the target relationship; and determining the subject entity and the object entity from the multiple candidate entities based on the entity association type corresponding to each of the multiple text pairs. In this way, it is possible to first determine the potential target relationship in the knowledge text, then determine the entity association type of each text pair in the knowledge text based on the target relationship, and at the same time extract entities in the knowledge text based on the target relationship, and jointly determine the subject entity and the object entity in the knowledge text based on the entity extraction result and the entity association type prediction result, thereby improving the accuracy of knowledge extraction.
[0053] In one example, when the knowledge text is "AAA sang the song BBB," it can be seen that the knowledge text contains two entities, "AAA" and "song BBB," and the two entities have a "singer" relationship. By using step S202 to predict the target relationship "singer" that may be contained in the knowledge text, the corresponding subject entity (singer name) and object entity (song name) can be further determined based on the target relationship to obtain a structured knowledge triple.
[0054] In some examples, the knowledge text may include multiple knowledge triples, that is, multiple target relations. In this case, after obtaining multiple target relations using step S202, steps S203 to S206 may be executed separately based on each target relation to obtain the knowledge triple corresponding to each target relation.
[0055] According to some embodiments, determining the target relationship included in the knowledge text from multiple candidate relationships in step S202 includes: inputting the knowledge text into a multi-label classification network to obtain confidence scores for multiple preset labels output by the multi-label classification network, where the multiple preset labels correspond to the multiple candidate relationships; and determining the target relationship from the multiple candidate relationships based on the confidence scores for the multiple preset labels. In this way, the multi-label classification network can be used to determine the target relationship, improving the efficiency and accuracy of relationship prediction.
[0056] In some examples, the knowledge text may be first encoded using a word vector encoding layer to obtain a corresponding sentence vector, and then the sentence vector is input into a multi-label classification network to obtain the prediction result output by the network for each preset label, based on which the target relationship is determined.
[0057] In some examples, the target relationship may be determined based on a preset threshold, for example, a candidate relationship corresponding to a preset tag having a confidence level not less than the preset threshold is determined as the target relationship.
[0058] According to some embodiments, extracting multiple candidate entities from the knowledge text based on the target relationship in step S203 includes: inputting the target relationship and the knowledge text into an entity extraction network to obtain multiple candidate entities output by the entity extraction network, wherein the entity extraction network is trained using sample knowledge texts and sample relationships annotated with real entities. Thus, the entity extraction network can be used to extract candidate entities, thereby improving the efficiency and accuracy of entity extraction.
[0059] In some examples, a target relationship vector corresponding to the target relationship can be retrieved from a relationship vector table. The target relationship vector and the knowledge text can then be input into an entity extraction network to obtain multiple candidate entities output by the entity extraction network. By using relationship vectors to characterize the characteristics of different preset relationships, the accuracy of entity extraction can be further improved.
[0060] According to some embodiments, the entity extraction network includes a pointer network, and the pointer network is configured to annotate each word in the knowledge text as an entity head or entity tail based on the target relationship. Inputting the target relationship and the knowledge text into the entity extraction network to obtain multiple candidate entities output by the entity extraction network includes: inputting the entity extraction network into the pointer network to obtain the annotation results output by the pointer network; and determining multiple candidate entities based on the annotation results. In this way, the pointer network can be used to more efficiently and accurately obtain entity head and entity tail annotation results, thereby improving the accuracy of entity extraction.
[0061] In one example, for each word in the knowledge text, the word vector and the target relationship vector corresponding to the word are concatenated and input into the pointer network to obtain the entity head labeling result and the entity tail labeling result output by the pointer network, thereby improving the accuracy of entity extraction.
[0062] According to some embodiments, the determining of multiple candidate entities based on the annotation results includes: in response to determining that the annotation results indicate that the first and second characters in the knowledge text are entity heads, and in response to determining that the annotation results indicate that the third and fourth characters located between the first and second characters in the knowledge text are entity tails, determining a first candidate entity with the first character as the entity head and the third character as the entity tail; and determining a second candidate entity with the first character as the entity head and the fourth character as the entity tail. Thus, based on the entity head and entity tail annotations, the first candidate entity and the second candidate entity with overlapping relationships can be accurately determined, thereby improving the accuracy of entity extraction.
[0063] In one example, when the knowledge text contains the segment "compilation of Wang's anthology", by applying the above technical means, the entity head and entity tail annotation results shown in Table 1 can be obtained:
[0064] Table 1
[0065] Word king certain arts set of Compilation Editor Entity Head 1 0 0 0 0 1 0 Entity tail 0 1 0 1 0 0 1
[0066] From the annotation results shown in Table 1, it can be seen that there are 2 entity tails "mou" between the entity head "Wang" and the entity head "bian". Based on this, the first candidate entity "Wang Mou" with "Wang" as the entity head and "mou" as the entity tail can be determined, and the second candidate entity "Wang's anthology" with "Wang" as the entity head and "ji" as the entity tail can be determined, so as to accurately determine the first candidate entity and the second candidate entity with a text overlap relationship, improving the accuracy of entity extraction.
[0067] According to some embodiments, in step S205, determining the entity association type corresponding to each word pair in the multiple word pairs based on the target relationship includes: for each word pair in the multiple word pairs, inputting the target relationship and the word vector corresponding to this word pair into an entity association type prediction network to obtain the entity association type corresponding to this word pair output by the entity association type prediction network, and the entity association type prediction network is trained using sample word pairs and sample relationships annotated with true entity association types. Thus, by using a neural network to predict the entity association type of a word pair, the prediction efficiency and accuracy can be improved.
[0068] In some examples, it may be to query the target relationship vector corresponding to the target relationship from a relationship vector table, splice the word vector and the target relationship vector corresponding to each word pair and input them into the entity association type prediction network to obtain the entity association type prediction result output by the neural network, thereby improving the prediction accuracy.
[0069] According to some embodiments, for each word pair in the multiple word pairs, determining the distance information between the two words included in this word pair in the knowledge text; and inputting the target relationship, the word vector corresponding to this word pair, and the distance information into the entity association type prediction network to obtain the entity association type corresponding to this word pair output by the entity association type prediction network. Thus, the entity association type can be predicted by combining the position features of the two words in the word pair, further improving the prediction accuracy.
[0070] In some examples, a distance vector corresponding to the distance between the two characters included in each character pair in the knowledge text can be queried from a distance vector table, and then the target relationship vector, the distance vector corresponding to each character pair, and the character vector corresponding to each character pair are input into the entity association type prediction network. By using the distance vector to represent the positional features of the character pair, the accuracy of the entity association type prediction can be further improved.
[0071] According to some embodiments, the entity association type includes a first subtype and a second subtype, the first subtype is used to indicate whether the two characters in each character pair are respectively the characters in the subject entity at the first preset position and the characters in the object entity at the first preset position, and the second subtype is used to indicate whether the two characters in each character pair are respectively the characters in the subject entity at the second preset position and the characters in the object entity at the second preset position, the entity association type prediction network includes a first subnetwork and a second subnetwork, and wherein, for each character pair in the multiple character pairs, the target relationship and the character vector corresponding to the character pair are input into the first subnetwork and the second subnetwork respectively to obtain the first subtype and the second subtype output by the first subnetwork and the second subnetwork. Thus, the two subtypes can be combined to more accurately indicate whether the character pair belongs to the subject entity and the object entity.
[0072] In some examples, the first preset position may refer to an entity head position, i.e., the first subtype is used to indicate whether the two characters in each character pair are a subject entity head and an object entity head, respectively. The first preset position may refer to an entity tail position, i.e., the second subtype is used to indicate whether the two characters in each character pair are a subject entity tail and an object entity tail, respectively.
[0073] In some examples, in step S204, word pairs with identical text content but different order may be retained, and the entity association type prediction network may be instructed to output discrete binary prediction results to indicate the entity association type of each word pair. For example, a positive prediction result may be output for the word pair "AB" to indicate that word "A" is a subject entity header and word "B" is an object entity header, while a negative prediction result may be output for the word pair "BA" to indicate that word "A" is not a subject entity header and word "B" is not an object entity header.
[0074] In some examples, in step S204, text pairs with the same text content but different order may be deleted, thereby causing the entity association type prediction network to output a discrete ternary prediction result. For example, for the text pair "AB" and the text pair "BA", the text pair "BA" may be deleted, and then a first prediction result may be output for the text pair "AB", indicating that the first text "A" in the text pair is the subject entity header and the second text "B" is the object entity header. For another example, the text pair "AB" may be deleted, and then a first prediction result may be output for the text pair "BA", indicating that the second text "A" in the text pair is the subject entity header and the first text "B" in the text pair is the object entity header.
[0075] According to some embodiments, in step S206, determining the subject entity and the object entity from the multiple candidate entities based on the entity association type corresponding to each of the multiple text pairs includes: for each of the multiple text pairs, in response to determining that two characters in the text pair belong to the subject entity and the object entity respectively, and in response to determining that two target entities in the multiple candidate entities include the two characters in the text pair respectively, determining that the two target entities are the subject entity and the object entity respectively. Thus, the subject entity and the object entity can be determined based on the intersection of the entity association type prediction result and the entity extraction result of the text pair to improve accuracy.
[0076] Figure 3 FIG. 3 shows a schematic diagram of the structure of a knowledge extraction model 300 according to an exemplary embodiment of the present disclosure. Figure 3 As shown, the knowledge extraction model 300 includes a word vector encoding layer 301, a multi-label classification network 302, an entity extraction network 303 and an entity association type prediction network 304.
[0077] In some examples, knowledge extraction can be performed by performing the following steps:
[0078] Step S1: Input the knowledge text into the word vector encoding layer 301 to obtain the sentence vector corresponding to the knowledge text;
[0079] Step S2: input the sentence vector corresponding to the knowledge text into the multi-label classification network 302 to obtain the target relationship output by the multi-label classification network 302;
[0080] Step S3: Query the target relationship vector corresponding to the target relationship from the relationship vector table;
[0081] Step S4: concatenate the word vector of each word in the knowledge text with the target relationship vector and input the concatenated word vectors into the entity extraction network 303 to obtain multiple candidate entities output by the entity extraction network 303;
[0082] Step S5: combining multiple characters in the knowledge text in pairs to obtain multiple character pairs;
[0083] Step S6: for each character pair, query the distance vector corresponding to the distance between the two characters included in the character pair in the knowledge text from the distance vector table;
[0084] Step S7: Concatenate the character vector corresponding to each character pair, the distance vector corresponding to each character pair, and the target relationship vector and input the concatenated vectors into the entity association type prediction network 304 to obtain the entity association type of each character pair output by the entity association type prediction network 304;
[0085] Step S8: Based on the entity association type corresponding to each text pair, determine the subject entity and the object entity from multiple candidate entities to obtain a knowledge triple including the target relationship, the subject entity and the object entity.
[0086] In some examples, the entity association type prediction network includes a first subnetwork and a second subnetwork, and the entity association type includes a first subtype and a second subtype. Step S8 may include:
[0087] Step S81: for each character pair, in response to determining that the first subtype indicates that two characters in the character pair are respectively a character at a first preset position in a subject entity and a character at a first preset position in an object entity, and in response to determining that the characters at the first preset positions in two first entities among the plurality of candidate entities are respectively the two characters in the character pair, determining that the two first entities are respectively a first candidate subject entity and a first candidate object entity;
[0088] Step S82: for each character pair, in response to determining that the second subtype indicates that two characters in the character pair are respectively a character at a second preset position in the subject entity and a character at a second preset position in the object entity, and in response to determining that the characters at the second preset positions in two second entities in the plurality of candidate entities are respectively the two characters in the character pair, determining that the two second entities are respectively a second candidate subject entity and a second candidate object entity; and
[0089] Step S83: In response to determining that the first candidate subject entity and the second candidate subject entity are the same, and in response to determining that the first candidate object entity and the second candidate object entity are the same, determine that the first candidate subject entity and the first candidate object entity are the subject entity and the object entity respectively.
[0090] In this way, the subject entity and the object entity can be determined based on the intersection of the first sub-network prediction result, the second sub-network prediction result and the entity extraction result, thereby further improving the accuracy.
[0091] According to another aspect of the present disclosure, a method for training a knowledge extraction model is also provided. Figure 4 FIG2 shows a flow chart of a method 400 for training a knowledge extraction model according to an exemplary embodiment of the present disclosure, wherein the knowledge extraction model includes a multi-label classification network, an entity extraction network, and an entity association type prediction network. Figure 4 As shown, the method 400 includes:
[0092] Step S401: Acquire sample knowledge text and annotation information, wherein the annotation information includes real subject entities, real object entities, and real target relationships between the real subject entities and the real object entities in the sample knowledge text;
[0093] Step S402: inputting the sample knowledge text into the multi-label classification network to obtain confidences of a plurality of preset labels output by the multi-label classification network, wherein the plurality of preset labels correspond to a plurality of candidate relationships;
[0094] Step S403: determining a predicted target relationship from the multiple candidate relationships based on the confidence levels of the multiple preset labels;
[0095] Step S404: inputting the predicted target relationship and the sample knowledge text into the entity extraction network to obtain a plurality of candidate entities output by the entity extraction network;
[0096] Step S405: combining multiple characters in the sample knowledge text in pairs to obtain multiple sample character pairs;
[0097] Step S406: For each sample character pair in the plurality of sample character pairs, input the predicted target relationship and the character vector corresponding to the sample character pair into the entity association type prediction network to obtain the entity association type corresponding to the sample character pair output by the entity association type prediction network;
[0098] Step S407: determining a prediction subject entity and a prediction object entity from the plurality of candidate entities based on the entity association type corresponding to each of the plurality of sample text pairs; and
[0099] Step S408: Adjust the parameters of the knowledge extraction model based on the prediction subject entity, the prediction object entity, the prediction target relationship, the real subject entity, the real object entity and the real target relationship.
[0100] Therefore, by configuring the model structure, the model can first determine the potential target relationship in the knowledge text, then extract the entities in the knowledge text based on the target relationship, and then jointly determine the subject entity and object entity in the knowledge text based on the entity extraction results and the entity association type prediction results. This can obtain a knowledge extraction model with higher prediction accuracy, so that the trained model can be used to perform efficient and accurate knowledge extraction.
[0101] According to some embodiments, in step S404, inputting the predicted target relationship and the sample knowledge text into the entity extraction network includes: querying the predicted target relationship vector corresponding to the predicted target relationship from the relationship vector table; and inputting the predicted target relationship vector and the sample knowledge text into the entity extraction network to obtain multiple candidate entities output by the entity extraction network, and method 400 also includes: adjusting the predicted target relationship vector stored in the relationship vector table based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship. In this way, the relationship vector can be used to represent the characteristics of different preset relationships, and the content stored in the relationship vector table can be synchronously iterated during the training process to improve the accuracy of the knowledge extraction model.
[0102] According to some embodiments, for each of the plurality of sample word pairs, distance information between two characters included in the sample word pair in the knowledge document is determined; and the predicted target relationship, the word vector corresponding to the sample word pair, and the distance information are input into the entity association type prediction network to obtain the entity association type corresponding to the sample word pair output by the entity association type prediction network. This allows the entity association type to be predicted by combining the positional features of the two characters in the word pair, further improving the accuracy of the knowledge extraction model.
[0103] According to some embodiments, in step S406, inputting the predicted target relationship, the word vector corresponding to the sample text pair, and the distance information into the entity association type prediction network includes: querying the target distance vector corresponding to the distance information from the distance vector table; and inputting the predicted target relationship, the word vector corresponding to the sample text pair, and the target distance vector into the entity association type prediction network to obtain the entity association type corresponding to the sample text pair output by the entity association type prediction network, and method 400 also includes: adjusting the target distance vector stored in the distance vector table based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity, and the real target relationship. In this way, the distance vector can be used to represent the positional features of the text pair, and the content stored in the distance vector table can be synchronously iterated during the training process to improve the accuracy of the knowledge extraction model.
[0104] According to another aspect of the present disclosure, a knowledge extraction device is also provided. Figure 5 FIG. 5 shows a structural block diagram of a knowledge extraction device 500 according to an exemplary embodiment of the present disclosure. Figure 5 As shown, the apparatus 500 includes:
[0105] A first acquisition unit 501 is configured to acquire the knowledge text to be extracted;
[0106] A first determining unit 502 is configured to determine a target relationship included in the knowledge text from a plurality of preset candidate relationships, wherein the target relationship indicates a relationship between a subject entity and an object entity included in the knowledge text;
[0107] A first combining unit 503 is configured to combine multiple characters in the knowledge text in pairs to obtain multiple character pairs;
[0108] A second determining unit 504 is configured to determine, based on the target relationship, an entity association type corresponding to each of the plurality of character pairs, the entity association type being used to indicate an inclusion relationship between each character pair and at least one of the subject entity and the object entity; and
[0109] The third determination unit 505 is configured to determine the subject entity and the object entity from the knowledge text based on the entity association type corresponding to each text pair in the multiple text pairs, so as to obtain a knowledge triple including the target relationship, the subject entity and the object entity.
[0110] According to some embodiments, the third determination unit 505 includes: an extraction subunit, configured to extract multiple candidate entities from the knowledge text based on the target relationship; and a determination subunit, configured to determine the subject entity and the object entity from the multiple candidate entities based on the entity association type corresponding to each text pair in the multiple text pairs.
[0111] According to some embodiments, the entity association type is used to indicate whether the two characters in each character pair belong to the subject entity and the object entity respectively.
[0112] According to some embodiments, the second determination unit 504 is configured to: for each text pair among the multiple text pairs, input the target relationship and the character vector corresponding to the text pair into the entity association type prediction network to obtain the entity association type corresponding to the text pair output by the entity association type prediction network, and the entity association type prediction network is trained using sample text pairs and sample relationships labeled with real entity association types.
[0113] According to some embodiments, the second determination unit 504 is configured to: for each character pair among the multiple character pairs, input the target relationship, the character vector corresponding to the character pair, and the distance between the two characters included in the character pair in the knowledge text into the entity association type prediction network to obtain the entity association type corresponding to the character pair output by the entity association type prediction network.
[0114] According to some embodiments, the entity association type includes a first subtype and a second subtype, the first subtype is used to indicate whether the two characters in each character pair are respectively the characters in the subject entity at a first preset position and the characters in the object entity at a first preset position, and the second subtype is used to indicate whether the two characters in each character pair are respectively the characters in the subject entity at a second preset position and the characters in the object entity at a second preset position, the entity association type prediction network includes a first subnetwork and a second subnetwork, and wherein the second determination unit 505 is configured to: for each character pair in the multiple character pairs, input the target relationship and the corresponding character vector of the character pair into the first subnetwork and the second subnetwork respectively, to obtain the first subtype and the second subtype output by the first subnetwork and the second subnetwork.
[0115] According to some embodiments, the first determination unit 502 is configured to: input the knowledge text into a multi-label classification network to obtain the confidence of multiple preset labels output by the multi-label classification network, where the multiple preset labels correspond to the multiple candidate relationships; and determine the target relationship from the multiple candidate relationships based on the confidence of the multiple preset labels.
[0116] According to some embodiments, the extraction subunit is configured to: input the target relationship and the knowledge text into an entity extraction network to obtain multiple candidate entities output by the entity extraction network, and the entity extraction network is trained using sample knowledge texts and sample relationships labeled with real entities.
[0117] According to some embodiments, the entity extraction network includes a pointer network, which is configured to label each word in the knowledge text as an entity head or entity tail based on the target relationship, and the extraction sub-unit is configured to: input the entity extraction network into the pointer network to obtain the labeling results output by the pointer network; and determine multiple candidate entities based on the labeling results.
[0118] According to some embodiments, the extraction sub-unit is configured to: in response to determining that the annotation result indicates that the first and second words in the knowledge text are entity heads, and in response to determining that the annotation result indicates that the third and fourth words located between the first and second words in the knowledge text are entity tails, determine a first candidate entity with the first word as the entity head and the third word as the entity tail; and determine a second candidate entity with the first word as the entity head and the fourth word as the entity tail.
[0119] According to some embodiments, the third determination unit 505 is configured to: for each text pair in the multiple text pairs, in response to determining that the two characters in the text pair belong to the subject entity and the object entity respectively, and in response to determining that two target entities in the multiple candidate entities respectively include the two characters in the text pair, determine that the two target entities are the subject entity and the object entity respectively.
[0120] According to another aspect of the present disclosure, a training device for a knowledge extraction model is also provided. Figure 6 The structure block diagram of the training device 600 of the knowledge extraction model according to the exemplary embodiment of the present disclosure is shown, wherein the knowledge extraction model includes a multi-label classification network, an entity extraction network and an entity association type prediction network. Figure 6 As shown, the apparatus 600 includes:
[0121] The second acquisition unit 601 is configured to acquire a sample knowledge text and annotation information, wherein the annotation information includes a real subject entity, a real object entity, and a real target relationship between the real subject entity and the real object entity in the sample knowledge text;
[0122] A first input unit 602 is configured to input the sample knowledge text into the multi-label classification network to obtain confidences of multiple preset labels output by the multi-label classification network, where the multiple preset labels correspond to multiple candidate relationships;
[0123] The fourth determining unit 603 is configured to determine a predicted target relationship from the multiple candidate relationships based on the confidence levels of the multiple preset labels;
[0124] A second input unit 604 is configured to input the predicted target relationship and the sample knowledge text into the entity extraction network to obtain a plurality of candidate entities output by the entity extraction network;
[0125] The second combining unit 605 is configured to combine multiple characters in the sample knowledge text in pairs to obtain multiple sample character pairs;
[0126] A third input unit 606 is configured to input the predicted target relationship and the word vector corresponding to each sample word pair in the plurality of sample word pairs into the entity association type prediction network to obtain the entity association type corresponding to the sample word pair output by the entity association type prediction network;
[0127] a fifth determining unit 607 configured to determine a prediction subject entity and a prediction object entity from the plurality of candidate entities based on the entity association type corresponding to each of the plurality of sample text pairs; and
[0128] The parameter adjustment unit 608 is configured to adjust the parameters of the knowledge extraction model based on the prediction subject entity, the prediction object entity, the prediction target relationship, the real subject entity, the real object entity and the real target relationship.
[0129] According to some embodiments, the second input unit 604 is configured to: query the predicted target relationship vector corresponding to the predicted target relationship from the relationship vector table; and input the predicted target relationship vector and the sample knowledge text into the entity extraction network to obtain multiple candidate entities output by the entity extraction network, and the parameter adjustment unit 608 is also configured to: adjust the predicted target relationship vector stored in the relationship vector table based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
[0130] According to some embodiments, the third input unit 606 is configured to determine, for each sample text pair among the multiple sample text pairs, the distance information of the two characters included in the text pair in the knowledge text; and input the predicted target relationship, the character vector corresponding to the sample text pair and the distance information into the entity association type prediction network to obtain the entity association type corresponding to the sample text pair output by the entity association type prediction network.
[0131] According to some embodiments, the third input unit 606 is configured to: query the target distance vector corresponding to the distance information from the distance vector table; and input the predicted target relationship, the corresponding character vector of the sample text pair and the target distance vector into the entity association type prediction network to obtain the entity association type corresponding to the sample text pair output by the entity association type prediction network, and the parameter adjustment unit 608 is also configured to: adjust the target distance vector stored in the distance vector table based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
[0132] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0133] According to another aspect of the present disclosure, an electronic device is also provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute at least one of the above-mentioned knowledge extraction method and knowledge extraction model training method.
[0134] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is further provided, wherein the computer instructions are used to enable the computer to execute at least one of the above-mentioned knowledge extraction method and knowledge extraction model training method.
[0135] According to another aspect of the present disclosure, a computer program product is further provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements at least one of the above-mentioned knowledge extraction method and knowledge extraction model training method.
[0136] refer to Figure 7 , a block diagram of an electronic device 700 that can serve as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0137] like Figure 7 As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. Various programs and data required for the operation of the device 700 can also be stored in the RAM 703. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0138] Multiple components within device 700 are connected to I / O interface 705, including an input unit 706, an output unit 707, a storage unit 708, and a communication unit 709. Input unit 706 can be any device capable of inputting information into device 700. Input unit 706 can receive input numeric or character information and generate key signal input related to user settings and / or function control of the electronic device. It can include, but is not limited to, a mouse, keyboard, touch screen, trackpad, trackball, joystick, microphone, and / or remote control. Output unit 707 can be any device capable of presenting information and can include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. Storage unit 708 can include, but is not limited to, a magnetic disk or an optical disk. Communication unit 709 allows device 700 to exchange information / data with other devices via computer networks such as the Internet and / or various telecommunication networks. It can include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver and / or chipset, such as a Bluetooth™ device, an 802.11 device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0139] The computing unit 701 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as at least one of the knowledge extraction method and the training method of the knowledge extraction model. For example, in some embodiments, at least one of the knowledge extraction method and the training method of the knowledge extraction model can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of at least one of the knowledge extraction method and the training method of the knowledge extraction model described above can be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute at least one of the knowledge extraction method and the knowledge extraction model training method in any other appropriate manner (for example, by means of firmware).
[0140] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0141] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0142] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0143] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0144] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0145] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0146] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.
[0147] Although the embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above-mentioned methods, systems and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples. Various elements in the embodiments or examples may be omitted or replaced by their equivalent elements. In addition, each step may be performed in an order different from that described in the present disclosure. Further, the various elements in the embodiments or examples may be combined in various ways. It is important that as technology evolves, many of the elements described herein may be replaced by equivalent elements that appear after the present disclosure.
Claims
1. A knowledge extraction method, comprising: Obtain the knowledge text to be extracted; Determining a target relationship included in the knowledge text from a plurality of preset candidate relationships, wherein the target relationship indicates a relationship between a subject entity and an object entity included in the knowledge text; Combining multiple characters in the knowledge text in pairs to obtain multiple character pairs; Determining an entity association type corresponding to each character pair in the plurality of character pairs based on the target relationship, the entity association type being used to indicate whether two characters in each character pair belong to the subject entity and the object entity, respectively; and Based on the entity association type corresponding to each of the plurality of character pairs, the subject entity and the object entity are determined from the knowledge text to obtain a knowledge triple including the target relationship, the subject entity, and the object entity, including: extracting a plurality of candidate entities from the knowledge text based on the target relationship; and The subject entity and the object entity are determined from the plurality of candidate entities based on the entity association type corresponding to each of the plurality of character pairs.
2. The method according to claim 1, wherein The determining, based on the target relationship, the entity association type corresponding to each of the plurality of character pairs includes: For each of the multiple text pairs, the target relationship and the character vector corresponding to the text pair are input into an entity association type prediction network to obtain the entity association type corresponding to the text pair output by the entity association type prediction network. The entity association type prediction network is trained using sample text pairs and sample relationships labeled with real entity association types.
3. The method of claim 2, wherein: For each character pair in the plurality of character pairs, Determining distance information between two characters included in the character pair in the knowledge text; as well as The target relationship, the character vector corresponding to the character pair, and the distance information are input into an entity association type prediction network to obtain an entity association type corresponding to the character pair output by the entity association type prediction network.
4. The method according to claim 2, wherein: The entity association type includes a first subtype and a second subtype, the first subtype is used to indicate whether the two characters in each character pair are respectively the characters at a first preset position in the subject entity and the characters at a first preset position in the object entity, and the second subtype is used to indicate whether the two characters in each character pair are respectively the characters at a second preset position in the subject entity and the characters at a second preset position in the object entity, the entity association type prediction network includes a first subnetwork and a second subnetwork, And wherein, for each of the multiple character pairs, the target relationship and the character vector corresponding to the character pair are input into the first sub-network and the second sub-network respectively to obtain the first sub-type and the second sub-type output by the first sub-network and the second sub-network.
5. The method according to any one of claims 1 to 4, wherein The step of determining the target relationship included in the knowledge text from a plurality of preset candidate relationships includes: Inputting the knowledge text into a multi-label classification network to obtain confidences of a plurality of preset labels output by the multi-label classification network, wherein the plurality of preset labels correspond to the plurality of candidate relationships; and The target relationship is determined from the multiple candidate relationships based on the confidence levels of the multiple preset labels.
6. The method according to any one of claims 1 to 4, wherein The step of extracting a plurality of candidate entities from the knowledge text based on the target relationship includes: The target relationship and the knowledge text are input into an entity extraction network to obtain a plurality of candidate entities output by the entity extraction network, wherein the entity extraction network is trained using sample knowledge texts and sample relationships labeled with real entities.
7. The method according to claim 6, wherein The entity extraction network includes a pointer network, and the pointer network is configured to mark whether each word in the knowledge text is an entity head or entity tail based on the target relationship. Inputting the target relationship and the knowledge text into the entity extraction network to obtain multiple candidate entities output by the entity extraction network includes: Inputting the entity extraction network into the pointer network to obtain a labeling result output by the pointer network; and Based on the labeling results, multiple candidate entities are determined.
8. The method of claim 7, wherein: The determining of a plurality of candidate entities based on the labeling result includes: In response to determining that the annotation result indicates that a first word and a second word in the knowledge text are entity heads, and in response to determining that the annotation result indicates that a third word and a fourth word in the knowledge text are entity tails, wherein the third word and the fourth word are located between the first word and the second word, Determine a first candidate entity with the first character as the entity head and the third character as the entity tail; and A second candidate entity is determined, which has the first character as an entity head and the fourth character as an entity tail.
9. The method according to any one of claims 1 to 4, wherein The determining the subject entity and the object entity from the plurality of candidate entities based on the entity association type corresponding to each of the plurality of character pairs comprises: For each of the multiple text pairs, in response to determining that the two characters in the text pair belong to the subject entity and the object entity respectively, and in response to determining that two target entities in the multiple candidate entities include the two characters in the text pair respectively, the two target entities are determined to be the subject entity and the object entity respectively.
10. A method for training a knowledge extraction model, the knowledge extraction model comprising a multi-label classification network, an entity extraction network, and an entity association type prediction network, the method comprising: Acquire a sample knowledge text and annotation information, wherein the annotation information includes a real subject entity, a real object entity, and a real target relationship between the real subject entity and the real object entity in the sample knowledge text; Inputting the sample knowledge text into the multi-label classification network to obtain confidences of a plurality of preset labels output by the multi-label classification network, wherein the plurality of preset labels correspond to a plurality of candidate relations; Determining a predicted target relationship from the plurality of candidate relationships based on the confidence levels of the plurality of preset labels; Inputting the predicted target relationship and the sample knowledge text into the entity extraction network to obtain a plurality of candidate entities output by the entity extraction network; Combining multiple characters in the sample knowledge text in pairs to obtain multiple sample character pairs; For each sample word pair in the plurality of sample word pairs, inputting the predicted target relationship and the word vector corresponding to the sample word pair into the entity association type prediction network to obtain an entity association type corresponding to the sample word pair output by the entity association type prediction network, wherein the entity association type is used to indicate whether two words in each sample word pair belong to a subject entity and an object entity in the predicted target relationship, respectively; Determining a predicted subject entity and a predicted object entity from the plurality of candidate entities based on the entity association type corresponding to each sample text pair in the plurality of sample text pairs; as well as Parameters of the knowledge extraction model are adjusted based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity, and the real target relationship.
11. The method of claim 10, wherein: The inputting the predicted target relationship and the sample knowledge text into the entity extraction network comprises: Querying the predicted target relationship vector corresponding to the predicted target relationship from the relationship vector table; and Inputting the predicted target relationship vector and the sample knowledge text into the entity extraction network to obtain multiple candidate entities output by the entity extraction network, And the method further includes: The predicted target relationship vector stored in the relationship vector table is adjusted based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
12. The method according to claim 10 or 11, wherein For each sample text pair in the plurality of sample text pairs, Determining distance information between two characters included in the sample character pair in the knowledge text; as well as The predicted target relationship, the word vector corresponding to the sample text pair, and the distance information are input into the entity association type prediction network to obtain the entity association type corresponding to the sample text pair output by the entity association type prediction network.
13. The method of claim 12, wherein: The step of inputting the predicted target relationship, the word vector corresponding to the sample word pair, and the distance information into the entity association type prediction network includes: Querying a target distance vector corresponding to the distance information from a distance vector table; and Input the predicted target relationship, the word vector corresponding to the sample word pair, and the target distance vector into the entity association type prediction network to obtain the entity association type corresponding to the sample word pair output by the entity association type prediction network. And the method further includes: The target distance vector stored in the distance vector table is adjusted based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
14. A knowledge extraction device comprising: A first acquisition unit is configured to acquire the knowledge text to be extracted; a first determining unit configured to determine a target relationship included in the knowledge text from a plurality of preset candidate relationships, wherein the target relationship indicates a relationship between a subject entity and an object entity included in the knowledge text; a first combining unit configured to combine a plurality of characters in the knowledge text in pairs to obtain a plurality of character pairs; a second determining unit configured to determine, based on the target relationship, an entity association type corresponding to each character pair in the plurality of character pairs, the entity association type being used to indicate whether two characters in each character pair belong to the subject entity and the object entity, respectively; and a third determining unit configured to determine the subject entity and the object entity from the knowledge text based on the entity association type corresponding to each of the plurality of character pairs, so as to obtain a knowledge triple including the target relationship, the subject entity, and the object entity; The third determining unit includes: an extraction subunit configured to extract a plurality of candidate entities from the knowledge text based on the target relationship; and The determining subunit is configured to determine the subject entity and the object entity from the plurality of candidate entities based on the entity association type corresponding to each of the plurality of character pairs.
15. The apparatus of claim 14, wherein: The second determining unit is configured to: For each of the multiple text pairs, the target relationship and the character vector corresponding to the text pair are input into an entity association type prediction network to obtain the entity association type corresponding to the text pair output by the entity association type prediction network. The entity association type prediction network is trained using sample text pairs and sample relationships labeled with real entity association types.
16. The apparatus of claim 15, wherein: The second determining unit is configured to: for each character pair in the plurality of character pairs, Determining distance information between two characters included in the character pair in the knowledge text; as well as The target relationship, the character vector corresponding to the character pair, and the distance information are input into an entity association type prediction network to obtain an entity association type corresponding to the character pair output by the entity association type prediction network.
17. The apparatus of claim 15, wherein: The entity association type includes a first subtype and a second subtype, the first subtype is used to indicate whether the two characters in each character pair are respectively the characters at a first preset position in the subject entity and the characters at a first preset position in the object entity, and the second subtype is used to indicate whether the two characters in each character pair are respectively the characters at a second preset position in the subject entity and the characters at a second preset position in the object entity, the entity association type prediction network includes a first subnetwork and a second subnetwork, And wherein, the second determination unit is configured to: for each character pair in the multiple character pairs, input the target relationship and the character vector corresponding to the character pair into the first sub-network and the second sub-network respectively, to obtain the first sub-type and the second sub-type output by the first sub-network and the second sub-network.
18. The device according to any one of claims 14 to 17, wherein: The first determining unit is configured to: Inputting the knowledge text into a multi-label classification network to obtain confidences of a plurality of preset labels output by the multi-label classification network, wherein the plurality of preset labels correspond to the plurality of candidate relationships; as well as The target relationship is determined from the multiple candidate relationships based on the confidence levels of the multiple preset labels.
19. The device according to any one of claims 14 to 17, wherein: The extraction subunit is configured as follows: The target relationship and the knowledge text are input into an entity extraction network to obtain a plurality of candidate entities output by the entity extraction network, wherein the entity extraction network is trained using sample knowledge texts and sample relationships labeled with real entities.
20. The apparatus of claim 19, wherein The entity extraction network includes a pointer network, which is configured to mark each word in the knowledge text as an entity head or entity tail based on the target relationship. The extraction subunit is configured to: Inputting the entity extraction network into the pointer network to obtain the annotation result output by the pointer network; as well as Based on the labeling results, multiple candidate entities are determined.
21. The apparatus of claim 20, wherein: The extraction subunit is configured as follows: In response to determining that the annotation result indicates that a first word and a second word in the knowledge text are entity heads, and in response to determining that the annotation result indicates that a third word and a fourth word in the knowledge text are entity tails, wherein the third word and the fourth word are located between the first word and the second word, Determine a first candidate entity with the first character as the entity head and the third character as the entity tail; and A second candidate entity is determined, which has the first character as an entity head and the fourth character as an entity tail.
22. The device according to any one of claims 14 to 17, wherein The third determining unit is configured to: For each of the multiple text pairs, in response to determining that the two characters in the text pair belong to the subject entity and the object entity respectively, and in response to determining that two target entities in the multiple candidate entities include the two characters in the text pair respectively, the two target entities are determined to be the subject entity and the object entity respectively.
23. A training device for a knowledge extraction model, the knowledge extraction model comprising a multi-label classification network, an entity extraction network, and an entity association type prediction network, the device comprising: a second acquisition unit configured to acquire a sample knowledge text and annotation information, wherein the annotation information includes a real subject entity, a real object entity, and a real target relationship between the real subject entity and the real object entity in the sample knowledge text; A first input unit is configured to input the sample knowledge text into the multi-label classification network to obtain confidences of multiple preset labels output by the multi-label classification network, where the multiple preset labels correspond to multiple candidate relationships; a fourth determining unit, configured to determine a predicted target relationship from the plurality of candidate relationships based on the confidence levels of the plurality of preset labels; A second input unit is configured to input the predicted target relationship and the sample knowledge text into the entity extraction network to obtain a plurality of candidate entities output by the entity extraction network; a second combining unit configured to combine a plurality of characters in the sample knowledge text in pairs to obtain a plurality of sample character pairs; a third input unit configured to input, for each sample character pair among the plurality of sample character pairs, the predicted target relationship and the character vector corresponding to the sample character pair into the entity association type prediction network, so as to obtain an entity association type corresponding to the sample character pair output by the entity association type prediction network, wherein the entity association type is used to indicate whether the two characters in each sample character pair belong to the subject entity and the object entity in the predicted target relationship, respectively; a fifth determining unit configured to determine a prediction subject entity and a prediction object entity from the plurality of candidate entities based on an entity association type corresponding to each of the plurality of sample text pairs; as well as A parameter adjustment unit is configured to adjust the parameters of the knowledge extraction model based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
24. The apparatus of claim 23, wherein: The second input unit is configured as: Querying a prediction target relationship vector corresponding to the prediction target relationship from a relationship vector table; as well as Inputting the predicted target relationship vector and the sample knowledge text into the entity extraction network to obtain multiple candidate entities output by the entity extraction network, And the parameter adjustment unit is further configured to: The predicted target relationship vector stored in the relationship vector table is adjusted based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
25. The apparatus of claim 23 or 24, wherein: The third input unit is configured to, for each sample text pair in the plurality of sample text pairs, Determining distance information between two characters included in the sample character pair in the knowledge text; as well as The predicted target relationship, the word vector corresponding to the sample text pair, and the distance information are input into the entity association type prediction network to obtain the entity association type corresponding to the sample text pair output by the entity association type prediction network.
26. The apparatus of claim 25, wherein: The third input unit is configured as: Querying a target distance vector corresponding to the distance information from a distance vector table; as well as Input the predicted target relationship, the word vector corresponding to the sample word pair, and the target distance vector into the entity association type prediction network to obtain the entity association type corresponding to the sample word pair output by the entity association type prediction network. And the parameter adjustment unit is further configured to: The target distance vector stored in the distance vector table is adjusted based on the predicted subject entity, the predicted object entity, the predicted target relationship, the real subject entity, the real object entity and the real target relationship.
27. An electronic device comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; in The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 13.
28. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause a computer to execute the method according to any one of claims 1-13.
29. A computer program product comprising a computer program, wherein The computer program implements the method according to any one of claims 1 to 13 when executed by a processor.
Citation Information
Patent Citations
Medical entity relationship extraction method and device
CN112599211A
Text knowledge triple extraction method and device and storage medium
CN112948535A