Method, device, electronic device and medium for generating training data
By acquiring and filtering knowledge triples and combining them with text data for pattern matching, the problem of low training data generation efficiency and uncontrollable quality in existing technologies is solved, thus achieving efficient training and improved generalization ability of the information extraction model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING BAIDU NETCOM SCI & TECH CO LTD
- Filing Date
- 2022-12-19
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies suffer from problems such as high manpower costs, limited data sources, limited data volume, and uncontrollable quality when generating training data for information extraction models, resulting in insufficient model generalization ability.
By acquiring data containing knowledge triple information, parsing and filtering out high-quality knowledge triple sets, combining them with text data for preprocessing and pattern matching, and constructing a multi-pattern matching tree to automatically match knowledge triples and text blocks, training data is generated.
It improves the generalization ability of the information extraction model, enhances the quality and efficiency of training data, and reduces the need for manual annotation.
Smart Images

Figure CN115952416B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and more particularly to the field of knowledge graph and natural language processing technology, specifically to a method, apparatus, electronic device, computer-readable storage medium, and computer program product for generating training data. Background Technology
[0002] Artificial intelligence (AI) is the study of enabling computers to 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, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies mainly include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.
[0003] Thanks to the development of artificial intelligence and deep learning technologies, natural language processing technologies such as information extraction have seen rapid progress in recent years. Information extraction technology can utilize information extraction models to assist industries in addressing needs that rely on information processing and retrieval, such as intelligent question answering and intelligent customer service. Therefore, improving the generalization ability of information extraction models can expand and enhance the application and performance of information extraction technology in different scenarios.
[0004] The methods described in this section are not necessarily methods that had been previously conceived or adopted. Unless otherwise specified, no method described in this section should be assumed to be prior art simply because it is included in this section. Similarly, unless otherwise specified, the issues mentioned in this section should not be considered to be accepted in any prior art. Summary of the Invention
[0005] This disclosure provides a method, apparatus, electronic device, computer-readable storage medium, and computer program product for generating training data.
[0006] According to one aspect of this disclosure, a method for generating training data is provided, comprising: acquiring first data containing knowledge triple information; parsing the first data based on the knowledge triple information to obtain a first knowledge triple set; filtering the first knowledge triple set to obtain a second knowledge triple set; acquiring second text data; preprocessing the second text data to obtain a plurality of target text blocks; for each of the plurality of target text blocks, performing pattern matching between the second knowledge triple set and the target text block; and generating training data for a triple information extraction model based on the pattern matching result.
[0007] According to another aspect of this disclosure, an apparatus for generating training data is provided, comprising: a first acquisition module configured to acquire first data containing knowledge triple information; a parsing module configured to parse the first data based on the knowledge triple information to obtain a first knowledge triple set; a filtering module configured to filter the first knowledge triple set to obtain a second knowledge triple set; a second acquisition module configured to acquire second text data; a processing module configured to preprocess the second text data to obtain a plurality of target text blocks; a matching module configured to perform pattern matching between the second knowledge triple set and each of the plurality of target text blocks; and a generation module configured to generate training data for a triple information extraction model based on the pattern matching result.
[0008] According to another aspect of this 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, the instructions being executed by the at least one processor to enable the at least one processor to perform the methods described above.
[0009] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform the above-described method.
[0010] According to another aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the above-described method.
[0011] According to one or more embodiments of this disclosure, a method for generating training data is provided, which obtains knowledge triples based on data containing knowledge triple information, obtains text blocks based on text data, and determines the correspondence between knowledge triples and text blocks by performing pattern matching between text blocks and knowledge triples, thereby enabling the construction of massive training data to train an information extraction model and improve the generalization ability of the information extraction model.
[0012] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0013] The accompanying drawings exemplify embodiments and form part of the specification, serving together with the textual description to explain exemplary implementations 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 refer to similar but not necessarily identical elements.
[0014] Figure 1 This is a schematic diagram illustrating example systems in which the various methods described herein can be implemented according to exemplary embodiments.
[0015] Figure 2 A flowchart illustrating a method for generating training data according to embodiments of the present disclosure is shown;
[0016] Figure 3 A flowchart of a portion of a method for generating training data according to an embodiment of the present disclosure is shown;
[0017] Figure 4 A flowchart of a portion of a method for generating training data according to an embodiment of the present disclosure is shown;
[0018] Figure 5 A flowchart of a portion of a method for generating training data according to an embodiment of the present disclosure is shown;
[0019] Figure 6 A structural block diagram of a training apparatus for a model according to an embodiment of the present disclosure is shown; and
[0020] Figure 7 A structural block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0021] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0022] In this disclosure, unless otherwise stated, the use of terms such as "first," "second," etc., to describe various elements is not intended to limit the positional, temporal, or importance relationships of these elements; such terms are merely used to distinguish one element from another. In some examples, the first element and the second element may refer to the same instance of that element, while in other cases, based on the context, they may refer to different instances.
[0023] The terminology used in the description of the various examples described in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context explicitly indicates otherwise, an element may be one or more unless the number of elements is specifically limited. Furthermore, the term "and / or" as used in this disclosure covers any one of the listed items and all possible combinations thereof.
[0024] In related technologies, the correspondence between knowledge triples and corpora can be obtained through manual annotation to obtain training data for information extraction models. However, this method is labor-intensive and inefficient. Data augmentation can also be used to expand training data, but this method obtains data from a single source and with limited data volume, which cannot meet training requirements. Alternatively, pseudo-labels for knowledge triples can be generated for the corpus through pre-trained models to obtain training data. However, this method is highly dependent on the effectiveness of the pre-trained model, and the extraction quality of knowledge triples is uncontrollable, which may lead to poor training performance of the information extraction model.
[0025] To address the aforementioned issues, this disclosure provides a method for generating training data. This method obtains knowledge triples based on data containing knowledge triple information, obtains text blocks based on text data, and determines the correspondence between knowledge triples and text blocks through pattern matching between text blocks and knowledge triples. This enables the construction of massive amounts of training data to train the information extraction model, thereby improving the generalization ability of the information extraction model.
[0026] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.
[0027] Figure 1 A schematic diagram of an exemplary system 100 in which the various methods and apparatus described herein can be implemented according to embodiments of this disclosure is shown. Reference 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.
[0028] In embodiments of this disclosure, server 120 may run one or more services or software applications that enable the execution of methods for generating training data.
[0029] In some embodiments, server 120 may also provide other services or software applications that may include non-virtual and virtual environments. In some embodiments, these services may be provided as web-based services or cloud services, such as to users of client devices 101, 102, 103, 104, 105 and / or 106 under a Software as a Service (SaaS) model.
[0030] exist Figure 1 In the configuration shown, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or combinations thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 can sequentially interact with server 120 using one or more client applications to utilize the services provided by these components. It should be understood that various different system configurations are possible and may differ from system 100. Therefore, Figure 1 This is an example of a system used to implement the methods described herein, and is not intended to be limiting.
[0031] Users can use client devices 101, 102, 103, 104, 105, and / or 106 to execute methods for generating training data. The client devices can provide an interface that allows users to interact with the client devices. The client devices can also output information to the user through this interface. Although... Figure 1 Only six client devices are described, but those skilled in the art will understand that this disclosure can support any number of client devices.
[0032] 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. These computer devices can 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, tablets, 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. Client devices are capable of executing various applications, such as various internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and can use various communication protocols.
[0033] Network 110 can be any type of network well known to those skilled in the art, and can support data communication using any of a variety of available protocols (including but not limited to TCP / IP, SNA, IPX, etc.). By way of example only, one or more networks 110 can be a local area network (LAN), an Ethernet-based network, a token ring network, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, 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.
[0034] Server 120 may include one or more general-purpose computers, special-purpose 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 a virtual operating system, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that can be virtualized to maintain virtual storage devices for servers). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
[0035] The computing unit in server 120 can run one or more operating systems, including any of the aforementioned operating systems and any commercially available server operating system. Server 120 can also run any of a variety of additional server applications and / or middleware applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
[0036] In some implementations, server 120 may include one or more applications to analyze and merge 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 data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
[0037] In some implementations, server 120 can be a server for a distributed system or a server integrated with blockchain. Server 120 can also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in the cloud computing service system, designed to address the shortcomings of traditional physical hosts and Virtual Private Server (VPS) services, such as high management difficulty and weak business scalability.
[0038] 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. Databases 130 may reside in various locations. For example, a database used by server 120 may be local to server 120, or it may be located away from server 120 and may communicate with server 120 via a network-based or dedicated connection. Databases 130 may be of different types. In some embodiments, the database used by server 120 may be, for example, a relational database. One or more of these databases may store, update, and retrieve data from and from the databases in response to commands.
[0039] In some embodiments, one or more of the databases 130 may also be used by an application to store application data. The databases used by the application may be of different types, such as key-value stores, object stores, or regular stores supported by a file system.
[0040] Figure 1 The system 100 can be configured and operated in various ways to enable the application of the various methods and apparatus described in this disclosure.
[0041] Figure 2 A flowchart of a method for generating training data according to an embodiment of the present disclosure is shown.
[0042] like Figure 2 As shown, the method 200 for generating training data includes:
[0043] Step S201: Obtain the first data containing knowledge triple information;
[0044] Step S202: Parse the first data based on the knowledge triple information to obtain the first knowledge triple set;
[0045] Step S203: Filter the first knowledge triplet set to obtain the second knowledge triplet set;
[0046] Step S204: Obtain the second text data;
[0047] Step S205: Preprocess the second text data to obtain multiple target text blocks;
[0048] Step S206: For each of the plurality of target text blocks, perform pattern matching between the second knowledge triplet set and the target text block; and
[0049] Step S207: Based on the pattern matching results, generate training data for the triplet information extraction model.
[0050] For example, the first data in step S201 can be knowledge graphs or encyclopedic structured data from various fields and industries, which contain knowledge triple information. In step S202, the first data is parsed to extract the knowledge triples contained in the first data and form a first triple set.
[0051] In one example, the knowledge graphs of various domains and industries can be parsed to extract every two adjacent nodes and their connecting edges as knowledge triples, forming a first set of knowledge triples. The first set of triples can include multiple subsets of first knowledge triples, each subset containing knowledge triples contained in the knowledge graph of the corresponding domain or industry.
[0052] For example, the second text data in step S204 may include webpage text data from various data sources crawled using a crawling template, or text data obtained from a self-built data source, to collect corpora from different data sources and of different types to obtain corresponding text blocks and knowledge triples for matching. In one example, multiple target text blocks obtained based on the second text data can be classified and saved according to domain or industry to match text blocks and knowledge triples in the same domain or industry, thereby improving matching efficiency.
[0053] Therefore, by step S202, knowledge triples for the corresponding domain and industry are obtained based on the first data from different domains and industries. By step S204, text blocks are obtained based on text data from different data sources. By step S206 and step S207, pattern matching is performed between text blocks from different data sources and knowledge triples from different domains and industries to determine the correspondence between knowledge triples and text blocks. This enables the construction of massive training data to train the information extraction model and improve the generalization ability of the information extraction model.
[0054] According to some embodiments, each knowledge triple in the first knowledge triple set consists of three elements: at least one first entity, a relation, and at least one second entity that has the relation with the at least one first entity.
[0055] Understandably, the first entity is also called the Subject, the second entity is also called the Object, and the relationship between the first and second entities is called the Predicate. Therefore, a knowledge triple is also called an SPO triple. A knowledge triple can have various forms: a knowledge triple can include one first entity and one second entity (SPO form); a knowledge triple can also include one first entity and multiple second entities (SPmO form); a knowledge triple can also include multiple first entities and one second entity (mSPO form); and a knowledge triple can also include multiple first entities and multiple second entities (mSPmO form). Each entity in a knowledge triple is called a slot.
[0056] For example,
Drug A, Dosage and Administration, (Population: Adults, Route of Administration: Oral, Symptom: Anti-allergy, Maximum Single Dose: 25, Unit: mg)
[0057] Figure 3 A flowchart of a portion of a method for generating training data according to an embodiment of the present disclosure is shown.
[0058] like Figure 3 As shown, step S203 includes:
[0059] Step S301: Obtain preset rules, wherein the preset rules include the expected character length corresponding to at least one of the three elements and / or the expected frequency of the at least one element appearing in the first knowledge triplet set;
[0060] Step S302: Remove knowledge triples and / or duplicate knowledge triples from the first knowledge triple set that do not conform to the preset rules; and
[0061] Step S303: Determine the second knowledge triplet set based on the remaining knowledge triplets in the first knowledge triplet set.
[0062] Understandably, the first set of knowledge triples can be filtered by pre-defined rules to remove some low-quality knowledge triples and obtain a second set of higher-quality knowledge triples, thereby improving matching efficiency and the quality of training data.
[0063] The inventors discovered that the character length of each element in low-quality knowledge triples is either too long or too short. Therefore, low-quality knowledge triples can be filtered based on the character length of each element. Low-quality knowledge triples are typically composed of entities or relations with low expected frequencies of occurrence. Therefore, low-quality knowledge triples can be further filtered based on the expected frequency of each element's appearance in the first set of knowledge triples. Furthermore, for relations, there may be mapping errors that render them meaningless. Therefore, knowledge triples can be filtered based on the actual meaning of the relations. In addition to removing low-quality knowledge triples from the first set, duplicate knowledge triples can also be removed to reduce computational load in subsequent matching processes and improve matching efficiency.
[0064] According to some embodiments, step S303 includes: determining whether the first entity and the second entity in the remaining knowledge triples in the first knowledge triple set both have a type; and in response to determining that the first entity and / or the second entity in each of the remaining knowledge triples both have a type, determining the remaining knowledge triples in the first knowledge triple set as the second knowledge triple set; or in response to determining that there are knowledge triples in the remaining knowledge triples that lack entity types, supplementing the type corresponding to the entity based on a preset concept library and the entity lacking a type, so as to obtain the second knowledge triple set.
[0065] It is understandable that the same word or phrase may have different meanings in different contexts. Therefore, the meaning of each entity can be clarified by defining its type, thereby improving the accuracy of subsequent matching of knowledge triples with text blocks.
[0066] Taking the knowledge triple
(Person: Person P), Position, (Specific Position, Start Time: January 20, 2009, End Time: January 20, 2017)
(person: person P), position, (position: specific position, start time: January 20, 2009, end time: January 20, 2017)
[0067] According to some embodiments, the second data includes a first plurality of text blocks with hierarchy and a second plurality of text blocks without hierarchy, wherein step S205 includes: performing hierarchical parsing on the first plurality of text blocks in the second data; and removing abnormal characters and text blocks whose length does not meet the preset length from the parsed first plurality of text blocks and second plurality of text blocks to obtain the plurality of target text blocks.
[0068] It is understandable that web page text data crawled from different data sources contains hierarchical text data. For example, in encyclopedia data, the path-level text data can be formed from the entry name to each level of heading to the content under that heading. Therefore, hierarchical parsing can be performed on multiple hierarchical text blocks to obtain hierarchical text data, thereby accelerating the subsequent matching process between Chinese text blocks and knowledge triples.
[0069] In addition, the text data is cleaned to remove abnormal characters, special characters, or images, as well as text blocks that are too long or too short, in order to obtain multiple target text blocks with higher text quality that are easier to match.
[0070] According to some embodiments, step S206 includes: constructing a multi-mode matching tree based on the second knowledge triple set; and matching the multi-mode matching tree with each of the plurality of target text blocks to determine the knowledge triple set in the second knowledge triple set that matches the target text block.
[0071] Therefore, the target text block can be matched by a multi-modal matching tree constructed based on the second set of knowledge triples, realizing automatic matching between knowledge triples and text blocks without manual annotation, thus improving the matching efficiency between knowledge triples and text blocks and automatically obtaining the correspondence between knowledge triples and text blocks.
[0072] In one example, a multi-pattern matching algorithm, such as a Trie tree, the AC automaton algorithm, or the WM algorithm, can be used to construct a multi-pattern matching tree based on the second knowledge triplet set for sequential matching with the target text block.
[0073] According to some embodiments, the multimodal matching tree includes a first multimodal matching tree and a second multimodal matching tree.
[0074] Figure 4 A flowchart of a portion of a method for generating training data according to an embodiment of the present disclosure is shown.
[0075] like Figure 4 As shown, the method 400 for constructing a multi-modal matching tree based on the second knowledge triplet set includes:
[0076] Step S401: Generate a first vocabulary based on the first entity of each knowledge triplet in the second knowledge triplet set;
[0077] Step S402: Generate a second vocabulary based on the second entity of each knowledge triplet in the second knowledge triplet set;
[0078] Step S403: Construct the first multi-mode matching tree based on the first vocabulary; and
[0079] Step S404: Construct the second multi-mode matching tree based on the second vocabulary.
[0080] Therefore, by constructing multi-mode matching trees for the first entity and the second entity respectively, and matching them sequentially with the target text block, the set of first entities and the set of second entities that successfully match the target text block can be determined. Furthermore, based on the set of first entities and the set of second entities that successfully match the target text block, the knowledge triples that successfully match the target text block can be determined, which further accelerates the matching process between the knowledge triples and the target text block and improves the matching efficiency.
[0081] Figure 5 A flowchart of a portion of a method for generating training data according to an embodiment of the present disclosure is shown.
[0082] like Figure 5 As shown, the method 500 for determining the knowledge triples in the second knowledge triple set that match the target text block by matching the multi-mode matching tree with each of the plurality of target text blocks includes:
[0083] Step S501: For each of the plurality of target text blocks, match the first multi-mode matching tree with the target text block to determine the first entity in the second knowledge triplet set that matches the target text block;
[0084] Step S502: Match the second multi-mode matching tree with the target text block to determine the second entity in the second knowledge triplet set that matches the target text block;
[0085] Step S503: Generate a configuration file based on the second knowledge triple set, wherein the configuration file includes a knowledge triple corresponding to each first entity, a knowledge triple corresponding to each relation, a knowledge triple corresponding to each second entity, and a slot value corresponding to each knowledge triple in the second knowledge triple set, wherein the slot value is the sum of the number of first entities, relations, and second entities in that knowledge triple set; and
[0086] Step S504: Based on the configuration file, the first entity in the second knowledge triplet set that matches the target text block, and the second entity in the second knowledge triplet set that matches the target text block, determine the knowledge triplet in the second knowledge triplet set that matches the target text block.
[0087] Steps S501 and S502 respectively determine the first entity set and the second entity set that successfully match the target text block. Step S503 generates a configuration file to determine the knowledge triples that match the target text block based on the first entity set and the second entity set determined in steps S501 and S502, thereby achieving the matching of knowledge triples with the target text block.
[0088] For example, when a knowledge triple is [(first entity A, first entity B), relation, (second entity C, second entity D, second entity C)], the target text block is successfully matched with the knowledge triple only if it matches both first entity A and first entity B in the first matching tree and also matches both second entity C, second entity D and second entity C in the second matching tree.
[0089] In one example, once the target text block successfully matches a preset number of knowledge triples, the matching process between the knowledge triples and the target text block stops, and the preset number of knowledge triples and the target text block are used as the final matching result to shorten the matching time and improve matching efficiency.
[0090] According to another aspect of this disclosure, an apparatus for generating training data is provided. For example... Figure 6 As shown, the apparatus 600 for generating training data includes: a first acquisition module 601 configured to acquire first data containing knowledge triple information; a parsing module 602 configured to parse the first data based on the knowledge triple information to obtain a first knowledge triple set; a filtering module 603 configured to filter the first knowledge triple set to obtain a second knowledge triple set; a second acquisition module 604 configured to acquire second text data; a processing module 605 configured to preprocess the second text data to obtain a plurality of target text blocks; a matching module 606 configured to perform pattern matching between the second knowledge triple set and each of the plurality of target text blocks; and a generation module 607 configured to generate training data for a triple information extraction model based on the pattern matching result.
[0091] For example, the first data acquired by the first acquisition module 601 may be knowledge graphs or encyclopedic structured data from various fields and industries, which contain knowledge triple information. The first data is then parsed by the parsing module 602 to extract the knowledge triples contained in the first data and form a first triple set.
[0092] In one example, the knowledge graphs of various domains and industries can be parsed to extract every two adjacent nodes and their connecting edges as knowledge triples, forming a first set of knowledge triples. The first set of triples can include multiple subsets of first knowledge triples, each subset containing knowledge triples contained in the knowledge graph of the corresponding domain or industry.
[0093] For example, the second text data acquired by the second acquisition module 604 may include web page text data from various data sources crawled using a crawling template, or text data acquired from a self-built data source, to collect corpora from different data sources and of different types for matching corresponding text blocks with knowledge triples. In one example, multiple target text blocks obtained based on the second text data can be categorized and saved based on domain or industry to match text blocks and knowledge triples within the same domain or industry, thereby improving matching efficiency.
[0094] Therefore, the parsing module 602 obtains knowledge triples for the corresponding domain and industry based on first data from different domains and industries, the second acquisition module 604 obtains text blocks based on text data from different data sources, and the matching module 606 and the generation module 607 perform pattern matching between text blocks from different data sources and knowledge triples from different domains and industries to determine the correspondence between knowledge triples and text blocks. This enables the construction of massive training data to train the information extraction model and improve the generalization ability of the information extraction model.
[0095] Understandably, the first entity is also called the Subject, the second entity is also called the Object, and the relationship between the first and second entities is called the Predicate. Therefore, a knowledge triple is also called an SPO triple. A knowledge triple can have various forms: a knowledge triple can include one first entity and one second entity (SPO form); a knowledge triple can also include one first entity and multiple second entities (SPmO form); a knowledge triple can also include multiple first entities and one second entity (mSPO form); and a knowledge triple can also include multiple first entities and multiple second entities (mSPmO form). Each entity in a knowledge triple is called a slot.
[0096] For example,
Drug A, Dosage and Administration, (Population: Adults, Route of Administration: Oral, Symptom: Anti-allergy, Maximum Single Dose: 25, Unit: mg)
[0097] According to some embodiments, each knowledge triplet in the first knowledge triplet set consists of three elements: at least one first entity, a relation, and at least one second entity having the relation with the at least one first entity. The filtering module 603 includes: an acquisition unit configured to acquire preset rules, the preset rules including the expected character length corresponding to at least one of the three elements and / or the expected frequency of the at least one element appearing in the first knowledge triplet set; a first removal unit configured to remove knowledge triplets in the first knowledge triplet set that do not conform to the preset rules and / or duplicate knowledge triplets; and a determination unit configured to determine the second knowledge triplet set based on the remaining knowledge triplets in the first knowledge triplet set.
[0098] Understandably, the filtering module 603 can filter the first set of knowledge triples using preset rules to filter out some low-quality knowledge triples and obtain a second set of knowledge triples with better quality, thereby improving matching efficiency and the quality of training data.
[0099] The inventors discovered that the character length of each element in low-quality knowledge triples is either too long or too short. Therefore, low-quality knowledge triples can be filtered based on the character length of each element. Low-quality knowledge triples are typically composed of entities or relations with low expected frequencies of occurrence. Therefore, low-quality knowledge triples can be further filtered based on the expected frequency of each element's appearance in the first set of knowledge triples. Furthermore, for relations, there may be mapping errors that render them meaningless. Therefore, knowledge triples can be filtered based on the actual meaning of the relations. In addition to removing low-quality knowledge triples from the first set, duplicate knowledge triples can also be removed to reduce computational load in subsequent matching processes and improve matching efficiency.
[0100] According to some embodiments, the determining unit includes: a first determining subunit configured to determine whether the first entity and the second entity in the remaining knowledge triplets in the first knowledge triplet set both have a type; and a second determining subunit configured to, in response to determining that the first entity and the second entity in each of the remaining knowledge triplets both have a type, determine the remaining knowledge triplets in the first knowledge triplet set as the second knowledge triplet set; or a supplementing subunit configured to, in response to determining that there are knowledge triplets in the remaining knowledge triplets that lack an entity type, supplement the type corresponding to the entity based on a preset concept library and the entity lacking a type, to obtain the second knowledge triplet set.
[0101] It is understandable that the same word or phrase may have different meanings in different contexts. Therefore, the meaning of each entity can be clarified by defining its type, thereby improving the accuracy of subsequent matching of knowledge triples with text blocks.
[0102] Taking the knowledge triple
(Person: Person P), Position, (Specific Position, Start Time: January 20, 2009, End Time: January 20, 2017)
(person: person P), position, (position: specific position, start time: January 20, 2009, end time: January 20, 2017)
[0103] According to some embodiments, the second data includes a first plurality of text blocks with hierarchy and a second plurality of text blocks without hierarchy, wherein the processing module 605 includes: a parsing unit configured to perform hierarchical parsing on the first plurality of text blocks in the second data; and a second removal unit configured to remove abnormal characters and text blocks whose length does not meet a preset length from the parsed first plurality of text blocks and second plurality of text blocks, so as to obtain the plurality of target text blocks.
[0104] It is understandable that web page text data crawled from different data sources contains hierarchical text data. For example, in encyclopedia data, the path-level text data can be formed from the entry name to each level of heading to the content under that heading. Therefore, the parsing unit can perform hierarchical parsing on the second or more text blocks with hierarchical structure to obtain hierarchical text data, thereby accelerating the subsequent matching process between Chinese text blocks and knowledge triples.
[0105] In addition, the second removal unit cleans the text data to remove abnormal characters, special characters or images, as well as text blocks that are too long or too short, in order to obtain multiple target text blocks with high text quality that are easy to match.
[0106] According to some embodiments, the matching module 606 includes: a construction unit configured to construct a multi-mode matching tree based on the second knowledge triple set; and a matching unit configured to match the multi-mode matching tree with each of the plurality of target text blocks to determine the knowledge triple set in the second knowledge triple set that matches the target text block.
[0107] Therefore, the matching unit can match the target text block by constructing a multi-mode matching tree based on the second knowledge triple set, thereby achieving automatic matching between knowledge triples and text blocks without manual annotation, improving the matching efficiency between knowledge triples and text blocks, and thus automatically obtaining the correspondence between knowledge triples and text blocks.
[0108] In one example, the building unit can utilize any of the multi-pattern matching algorithms such as Trie trees, AC automata algorithms, and WM algorithms to construct a multi-pattern matching tree based on the second knowledge triple set for sequential matching with the target text block.
[0109] According to some embodiments, the multimodal matching tree includes a first multimodal matching tree and a second multimodal matching tree, wherein the construction unit includes: a first generation subunit configured to generate a first vocabulary based on a first entity of each knowledge triplet in the second knowledge triplet set; a second generation subunit configured to generate a second vocabulary based on a second entity of each knowledge triplet in the second knowledge triplet set; a first construction subunit configured to construct the first multimodal matching tree based on the first vocabulary; and a second construction subunit configured to construct the second multimodal matching tree based on the second vocabulary.
[0110] Therefore, by constructing multi-mode matching trees for the first entity and the second entity through the first and second construction sub-units respectively, and matching them sequentially with the target text block, the first entity set and the second entity set that successfully match the target text block are determined. Furthermore, based on the first entity set and the second entity set that successfully match the target text block, the knowledge triplet that successfully matches the target text block can be determined, which further accelerates the matching process between the knowledge triplet and the target text block and improves the matching efficiency.
[0111] According to some embodiments, the matching unit includes: a first matching subunit configured to match the first multi-modal matching tree with each of the plurality of target text blocks to determine a first entity in the second knowledge triplet set that matches the target text block; a second matching subunit configured to match the second multi-modal matching tree with the target text block to determine a second entity in the second knowledge triplet set that matches the target text block; a third generation subunit configured to generate a configuration file based on the second knowledge triplet set, wherein the configuration file includes a knowledge triplet corresponding to each first entity in the second knowledge triplet set, a knowledge triplet corresponding to each relation, a knowledge triplet corresponding to each second entity, and a slot value corresponding to each knowledge triplet, and wherein the slot value is the sum of the number of first entities, relations, and second entities in the knowledge triplet set; and a third determination subunit configured to determine the knowledge triplet in the second knowledge triplet set that matches the target text block based on the configuration file, the first entity in the second knowledge triplet set that matches the target text block, and the second entity in the second knowledge triplet set that matches the target text block.
[0112] The first and second matching subunits respectively determine the first entity set and the second entity set that successfully match the target text block. The third generation subunit generates a configuration file to determine the knowledge triples that match the target text block based on the first and second entity sets determined by the first and second matching subunits, thus achieving the matching of the knowledge triples with the target text block.
[0113] For example, when a knowledge triple is [(first entity A, first entity B), relation, (second entity C, second entity D, second entity C)], the target text block is successfully matched with the knowledge triple only if it matches both first entity A and first entity B in the first matching tree and also matches both second entity C, second entity D and second entity C in the second matching tree.
[0114] In one example, once the target text block successfully matches a preset number of knowledge triples, the matching unit stops the matching process between the knowledge triples and the target text block, and uses the preset number of knowledge triples and the target text block as the final matching result, in order to shorten the matching time and improve the matching efficiency.
[0115] According to another aspect of this 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, the instructions being executed by the at least one processor to enable the at least one processor to perform a method for generating training data.
[0116] According to another aspect of this disclosure, a non-transitory computer-readable storage medium storing computer instructions is also provided, wherein the computer instructions are used to cause the computer to perform a method for generating training data.
[0117] According to another aspect of this disclosure, a computer program product is also provided, including a computer program, wherein the computer program, when executed by a processor, implements a method for generating training data.
[0118] like Figure 7 As shown, the electronic 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. The RAM 703 may also store various programs and data required for the operation of the electronic device 700. The computing unit 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0119] Multiple components in electronic device 700 are connected to I / O interface 705, including: input unit 706, output unit 707, storage unit 708, and communication unit 709. Input unit 706 can be any type of device capable of inputting information to electronic device 700. Input unit 706 can receive input digital or character information and generate key signal input related to user settings and / or function control of electronic device, and may 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 type of device capable of presenting information, and may include, but is not limited to, a monitor, speaker, video / audio output terminal, vibrator, and / or printer. Storage unit 708 may include, but is not limited to, disk and optical disk. Communication unit 709 allows electronic device 700 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers, and / or chipsets, such as Bluetooth. TM Devices, 802.11 devices, WiFi devices, WiMax devices, cellular communication devices and / or the like.
[0120] The computing unit 701 can be a variety of general-purpose and / or special-purpose 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 special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as methods for generating training data. For example, in some embodiments, the method for generating training data may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the method for generating training data described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the method for generating training data by any other suitable means (e.g., by means of firmware).
[0121] Various embodiments of the systems and techniques described above herein 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), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0122] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0123] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0124] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, 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 sound input, voice input, or tactile input).
[0125] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0126] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0127] It should be understood that the various forms of processes shown above can be used to rearrange, 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 result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0128] While embodiments or examples of this disclosure have been described with reference to the accompanying drawings, it should be understood that the methods, systems, and devices described above are merely exemplary embodiments or examples, and the scope of the invention is not limited by these embodiments or examples, but only by the granted claims and their equivalents. Various elements in the embodiments or examples may be omitted or replaced by their equivalents. Furthermore, the steps may be performed in a different order than that described in this disclosure. Further, various elements in the embodiments or examples may be combined in various ways. Importantly, as the technology evolves, many elements described herein can be replaced by equivalents that appear after this disclosure.
Claims
1. A method for generating training data, comprising: Obtain the first data containing the knowledge triple information; Based on the knowledge triple information, the first data is parsed to obtain the first knowledge triple set; The first set of knowledge triplets is filtered to obtain the second set of knowledge triplets; Obtain the second text data; The second text data is preprocessed to obtain multiple target text blocks; For each of the plurality of target text blocks, pattern matching is performed between the second knowledge triplet set and the target text block, including: Based on the second set of knowledge triples, a multimodal matching tree is constructed, wherein the multimodal matching tree includes a first multimodal matching tree and a second multimodal matching tree, and wherein constructing the multimodal matching tree based on the second set of knowledge triples includes: Based on the first entity of each knowledge triplet in the second knowledge triplet set, a first vocabulary is generated. A second vocabulary is generated based on the second entity of each knowledge triplet in the second knowledge triplet set. Based on the first vocabulary, construct the first multi-mode matching tree; and Based on the second vocabulary, construct the second multi-mode matching tree; and For each of the plurality of target text blocks, the multi-modal matching tree is matched against the target text block to determine the knowledge triples in the second knowledge triple set that match the target text block, including: For each of the plurality of target text blocks, the first multi-mode matching tree is matched with the target text block to determine the first entity in the second knowledge triplet set that matches the target text block; The second multi-mode matching tree is matched with the target text block to determine the second entity in the second knowledge triple set that matches the target text block; A configuration file is generated based on the second set of knowledge triples, wherein the configuration file includes a knowledge triple corresponding to each first entity, a knowledge triple corresponding to each relation, a knowledge triple corresponding to each second entity, and a slot value corresponding to each knowledge triple, wherein the slot value is the sum of the number of first entities, relations, and second entities in that knowledge triple; and Based on the configuration file, the first entity in the second knowledge triplet set that matches the target text block, and the second entity in the second knowledge triplet set that matches the target text block, determine the knowledge triplet in the second knowledge triplet set that matches the target text block; and Based on the pattern matching results, training data for the triplet information extraction model is generated.
2. The method according to claim 1, wherein, Each knowledge triple in the first knowledge triple set consists of three elements: at least one first entity, a relation, and at least one second entity having the relation with the at least one first entity. The step of filtering the first knowledge triple set to obtain the second knowledge triple set includes: Obtain preset rules, the preset rules including the expected character length of at least one of the three elements and / or the expected frequency of the at least one element in the first knowledge triplet set; Remove knowledge triples and / or duplicate knowledge triples from the first knowledge triple set that do not conform to the preset rules; and Based on the remaining knowledge triples in the first knowledge triple set, the second knowledge triple set is determined.
3. The method according to claim 2, wherein, The step of determining the second knowledge triplet set based on the remaining knowledge triplets in the first knowledge triplet set includes: Determine whether the first entity and the second entity in the remaining knowledge triples in the first knowledge triple set both have a type; and In response to determining that the first and second entities in each of the remaining knowledge triples both have a type, the remaining knowledge triples in the first knowledge triplet set are defined as the second knowledge triplet set; or In response to determining that there is a knowledge triplet with a missing entity type among the remaining knowledge triplets, the type corresponding to the missing entity is supplemented based on a preset concept library and the entity with the missing type, so as to obtain the second knowledge triplet set.
4. The method according to any one of claims 1-3, wherein, The second text data includes a first plurality of hierarchical text blocks and a second plurality of non-hierarchical text blocks, wherein the preprocessing of the second text data to obtain a plurality of target text blocks includes: Perform hierarchical parsing on the first plurality of text blocks in the second text data; and Remove abnormal characters and text blocks whose length does not meet the preset length from the first and second parsed text blocks to obtain the multiple target text blocks.
5. An apparatus for generating training data, comprising: The first acquisition module is configured to acquire first data containing knowledge triple information; The parsing module is configured to parse the first data based on the knowledge triple information to obtain a first knowledge triple set; The filtering module is configured to filter the first set of knowledge triples to obtain a second set of knowledge triples; The second acquisition module is configured to acquire the second text data; The processing module is configured to preprocess the second text data to obtain multiple target text blocks; A matching module is configured to perform pattern matching between the second knowledge triplet set and each of the plurality of target text blocks, wherein the matching module includes: A construction unit is configured to construct a multimodal matching tree based on the second set of knowledge triples, wherein the multimodal matching tree includes a first multimodal matching tree and a second multimodal matching tree, and wherein the construction unit includes: The first generation subunit is configured to generate a first vocabulary based on the first entity of each knowledge triplet in the second knowledge triplet set. The second generation subunit is configured to generate a second vocabulary based on the second entity of each knowledge triplet in the second knowledge triplet set. The first construction subunit is configured to construct the first multi-mode matching tree based on the first vocabulary; and The second construction subunit is configured to construct the second multi-mode matching tree based on the second vocabulary; and A matching unit is configured to match the multi-modal matching tree with each of the plurality of target text blocks to determine the knowledge triples in the second knowledge triple set that match the target text block, wherein the matching unit includes: The first matching subunit is configured to match the first multi-mode matching tree with each of the plurality of target text blocks to determine the first entity in the second knowledge triplet set that matches the target text block. The second matching subunit is configured to match the second multi-mode matching tree with the target text block to determine the second entity in the second knowledge triplet set that matches the target text block; The third generation subunit is configured to generate a configuration file based on the second set of knowledge triples. The configuration file includes a knowledge triple corresponding to each first entity, a knowledge triple corresponding to each relation, a knowledge triple corresponding to each second entity, and a slot value corresponding to each knowledge triple. The slot value is the sum of the number of first entities, relations, and second entities in that knowledge triple. The third determining subunit is configured to determine, based on the configuration file, a first entity in the second knowledge triplet set that matches the target text block, and a second entity in the second knowledge triplet set that matches the target text block, the knowledge triplet set itself; and The generation module is configured to generate training data for the triplet information extraction model based on the results of pattern matching.
6. The apparatus according to claim 5, wherein, Each knowledge triple in the first knowledge triple set consists of three elements: at least one first entity, a relation, and at least one second entity having the relation with the at least one first entity. The filtering module includes: The acquisition unit is configured to acquire preset rules, the preset rules including the expected character length of at least one of the three elements and / or the expected frequency of the at least one element appearing in the first knowledge triplet set; The first removal unit is configured to remove knowledge triples and / or duplicate knowledge triples from the first knowledge triple set that do not conform to the preset rules; and The determining unit is configured to determine the second knowledge triplet set based on the remaining knowledge triplets in the first knowledge triplet set.
7. The apparatus according to claim 6, wherein, The determining unit includes: The first determining subunit is configured to determine whether the first entity and the second entity in the remaining knowledge triples in the first knowledge triple set both have a type; and The second determining subunit is configured to, in response to determining that the first entity and the second entity in each of the remaining knowledge triplets both have a type, determine the remaining knowledge triplets in the first knowledge triplet set as the second knowledge triplet set; or The supplementary subunit is configured to, in response to determining that there is a knowledge triplet with a missing entity type in the remaining knowledge triplets, supplement the type corresponding to the entity based on a preset concept library and the entity with the missing type, so as to obtain the second knowledge triplet set.
8. The apparatus according to any one of claims 5-7, wherein, The second text data includes a first plurality of hierarchical text blocks and a second plurality of non-hierarchical text blocks, wherein the processing module includes: The parsing unit is configured to perform hierarchical parsing of the first plurality of text blocks in the second text data; and The second removal unit is configured to remove abnormal characters and text blocks whose length does not meet the preset length from the parsed first plurality of text blocks and the second plurality of text blocks, so as to obtain the plurality of target text blocks.
9. An electronic device, comprising: At least one processor; as well as A memory that is communicatively connected to the at least one processor; in The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-4.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-4.
11. A computer program product comprising a computer program, wherein, The computer program, when executed by a processor, implements the method of any one of claims 1-4.