Long text relation determination method and device based on external knowledge base and electronic equipment

By introducing information and entity type tags from external knowledge bases into triple extraction technology, the problem of entity type information being ignored in the existing technology is solved, and more accurate and comprehensive relationship extraction is achieved, enhancing the effect of natural language processing .

CN119312807AInactive Publication Date: 2025-01-14杭州峰景科技有限公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411835280.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-01-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing triple extraction technology ignores the entity's type information in the inter-entity relationship extraction task and cannot effectively utilize the information in the external knowledge graph, resulting in inaccurate relationship extraction results.

Method used

Using a long text relationship determination method based on the external knowledge base, the entity masking process and type marking are performed by obtaining pending text and external knowledge base, and encoding and relation type prediction are performed using BERT model and neural network to integrate the external knowledge base. triple map information.

Benefits of technology

It improves the accuracy and comprehensiveness of relationship extraction between entities, can effectively utilize information in the external knowledge base, avoids the neglect of entity type information, and enhances the accuracy of relational semantic coding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119312807A_ABST
    Figure CN119312807A_ABST
Patent Text Reader

Abstract

The invention provides a long text relation determination method and device based on an external knowledge base and electronic equipment, and relates to the field of natural language process.The method comprises the steps that any two first entities in a first text are processed, and first codes and second codes of the two first entities are obtained; processing two corresponding second entities in the second text to obtain a first output code and a second output code; splicing the first code and the second code with the first output code and the second output code to obtain a relation semantic code; and processing the relationship semantic codes, and determining a target relationship type between the two first entities. According to the method, the triple atlas of the external knowledge base is fused, the data structure of the first text is not damaged, the external triple atlas corresponding to each first entity is combined into a short sentence, and interactive learning of information of each triple atlas is effectively realized through the BERT model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and in particular, to a method, device and electronic device for determining long text relations based on an external knowledge base. Background Art

[0002] The current popularization of digitalization has brought the whole nation into an information age, with tens of thousands of pieces of information flowing into the Internet. Faced with this huge amount of information, it is very important to quickly and easily obtain valuable and meaningful data from it. Triple extraction technology can extract entities and the relationships between entities from these irregular plain text contents, thereby obtaining concise and accurate triples. It is of indispensable importance to the fields of natural language processing: such as human-computer dialogue, summary generation, recommendation systems, and the construction of large knowledge graphs.

[0003] In practical applications, the current triple extraction technology mostly uses pipeline extraction methods, which divides the triple extraction task into named entity recognition tasks and entity relationship extraction tasks. In the past, BIO or BIEOS annotation methods were used for named entity recognition tasks, but this annotation method cannot solve the problem of nested entities. The emergence of span annotation methods has solved this problem. For the task of extracting the relationship between entities, generally only the information contained in the entity in the current text is used, but the type information of the entity is ignored.

[0004] For the relationship extraction task, the relationships between entities are extracted based on the identified entities, but existing methods generally ignore the information about the entities in the existing knowledge graph. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a method, device and electronic device for determining long text relationships based on an external knowledge base, so as to solve the above-mentioned problems existing in the prior art. The text of the external knowledge base can be integrated without destroying the data structure of the text to be processed to obtain the relationship between entities in the text to be processed.

[0006] In a first aspect, a method for determining a long text relationship based on an external knowledge base is provided, and the method may include: Acquire a first text to be processed and a second text acquired based on an external knowledge base; the first text and the second text contain the same entity; Processing any two first entities in the first text to obtain first codes and second codes of the two first entities; Processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code; Concatenate the first code and the second code, and the first output code and the second output code to obtain a relational semantic code; The relationship semantic encoding is processed to determine a target relationship type between the two first entities.

[0007] In a possible implementation, any two first entities in the first text are processed to obtain first codes and second codes of the two first entities, including: Perform masking processing on any two first entities in the first text to obtain a third text; The trained first BERT model is used to extract feature codes of characters in the third text to obtain a first code and a second code.

[0008] In a possible implementation, masking is performed on any two first entities in the first text to obtain a third text, including: Obtaining multiple first entities of the first text; Form an entity pair by any two first entities among the plurality of first entities; For any entity pair, determine the head entity and the tail entity in the entity pair; Replacing the head entity and the tail entity with a head entity type tag and a tail entity type tag, respectively; Insert a head entity start tag and a head entity end tag before and after the head entity type tag respectively; and insert a tail entity start tag and a tail entity end tag before and after the tail entity type tag respectively, to obtain the third text.

[0009] In a possible implementation, processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code includes: The two second entities in the second text that are identical to the two first entities in the first text are processed by the trained second BERT model to obtain the first output code and the second output code.

[0010] In a possible implementation, processing the relationship semantic code to determine the target relationship type between the two first entities includes: Processing the relationship semantic coding through a fully connected network layer of a trained preset neural network with a softmax activation function to determine a coding relationship between the first coding and the second coding; Based on the encoded relationship, a target relationship type between the head entity and the tail entity is determined.

[0011] In a possible implementation, the loss function of the preset neural network during training is for:

[0012] in, Represents entity pair The label of the real relationship type; Represents the head entity, is the tail entity, The header entity type tag corresponding to the entity type of the header entity, The tail entity type tag corresponding to the entity type of the tail entity, Represents a set of entity types, and S is a set of entity pairs.

[0013] In a possible implementation, the third text It is expressed as:

[0014] in, represents the first entity, Indicates the header entity type tag, Indicates the end entity type tag, Indicates the start tag of the header entity. Indicates the end of the header entity. Indicates the start tag of the tail entity. Indicates the end of the entity tag.

[0015] In a second aspect, a long text relationship determination device based on an external knowledge base is provided, and the device may include: An acquisition unit, used for acquiring a first text to be processed and a second text acquired based on an external knowledge base; the first text and the second text contain the same entity; A processing unit, configured to process any two first entities in the first text to obtain first codes and second codes of the two first entities; and, processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code; a concatenation unit, configured to concatenate the first code and the second code, and the first output code and the second output code to obtain a relational semantic code; The processing unit is further used to process the relationship semantic coding to determine the target relationship type between the two first entities.

[0016] In a third aspect, an electronic device is provided, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement any method step described in the first aspect when executing the program stored in the memory.

[0017] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.

[0018] The present application provides a method for determining the relationship of a long text based on an external knowledge base, the method comprising: obtaining a first text to be processed and a second text obtained based on the external knowledge base; the first text and the second text have the same entity; processing any two first entities in the first text to obtain the first code and the second code of the two first entities; processing the two second entities in the second text that are the same as the two first entities in the first text to obtain the first output code and the second output code; splicing the first code and the second code, as well as the first output code and the second output code to obtain the relationship semantic code; processing the relationship semantic code to determine the target relationship type between the two first entities. The relationship determination method proposed in the present application not only integrates the triple map of the external knowledge base, but also does not destroy the data structure of the first text to be processed, selects to combine the triple map of the external knowledge base corresponding to each first entity into a short sentence, and encodes it through the BERT model. The BERT model of the present application can very effectively realize interactive learning of the information of each triple map; the relationship semantic coding integrates the information of all triple maps in the external knowledge base. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 A system architecture diagram for a method for determining long text relations based on an external knowledge base provided in an embodiment of the present application; Figure 2 A flowchart of a method for determining long text relations based on an external knowledge base provided in an embodiment of the present application; Figure 3A schematic diagram of a processing process of a method for determining long text relations based on an external knowledge base provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of a long text relationship determination device based on an external knowledge base provided in an embodiment of the present application; Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0022] The long text relationship determination method based on an external knowledge base provided in the embodiment of the present application can be applied to Figure 1 In the system architecture shown in Figure 1 As shown, the system may include: a server in the background of the enterprise and a terminal for the employees of the enterprise. The server may be a physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal may be a user equipment (UE) such as a mobile phone, smart phone, laptop, digital broadcast receiver, personal digital assistant (PDA), tablet computer (PAD), handheld device, vehicle-mounted device, wearable device, computing device or other processing device connected to a wireless modem, mobile station (MS), mobile terminal, etc. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in this application.

[0023] The terminal is used to obtain a first text to be processed and a second text obtained based on an external knowledge base, and send the first text and the second text to a server.

[0024] The server is used to obtain the first text and the second text to execute a long text relationship determination method based on an external knowledge base provided by the present application.

[0025] The current popularization of digitalization has brought the whole nation into an information age, with tens of thousands of pieces of information flowing into the Internet. Faced with this huge amount of information, it is very important to quickly and easily obtain valuable and meaningful data from it. Triple extraction technology can extract entities and the relationships between entities from these irregular plain text contents, thereby obtaining concise and accurate triples. It is of indispensable importance to the fields of natural language processing: such as human-computer dialogue, summary generation, recommendation systems, and the construction of large knowledge graphs.

[0026] In practical applications, the current triple extraction technology mostly uses pipeline extraction methods, which divides the triple extraction task into named entity recognition tasks and entity relationship extraction tasks. In the past, BIO or BIEOS annotation methods were used for named entity recognition tasks, but this annotation method cannot solve the problem of nested entities. The emergence of span annotation methods has solved this problem. For the task of extracting the relationship between entities, generally only the information contained in the entity in the current text is used, but the type information of the entity is ignored.

[0027] For the relationship extraction task, the relationships between entities are extracted based on the identified entities, but existing methods generally ignore the information about the entities in the existing knowledge graph.

[0028] Therefore, the present application provides a long text relationship determination method based on an external knowledge base, which adopts a span-based annotation method and integrates all the characters of the span at the same time; when performing the relationship extraction task between entities, a method of entity masking is proposed, that is, replacing the entity with an entity type tag and inserting corresponding tags before and after it, so as to eliminate the interference of the entity on the task.

[0029] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0030] Figure 2 The following is a flow chart of a method for determining long text relationships based on an external knowledge base provided in an embodiment of the present application. Figure 2 and Figure 3 As shown, the method may include: Step S210: Acquire a first text to be processed and a second text acquired based on an external knowledge base.

[0031] The same entity exists in the first text and the second text.

[0032] The process of obtaining the second text in the external knowledge base includes: The external knowledge base can select the largest open knowledge base (Wikidata knowledge base) to construct a small knowledge graph: Specifically, step S211, in the Wikidata knowledge base, for each object (Value), it can be divided into data value and entity class; entity class is further divided into three categories: data type, entity name, and relationship type. Therefore, the Wikidata knowledge base contains two categories: relationship triples (which can be understood as the subject, predicate, and object in the text content) and attribute triples (which can be understood as the object is not an entity, but a specific attribute value). For the Wikidata knowledge base, the most important are entity names and relationship types, which can be said to be the core elements of the knowledge base.

[0033] In the Wikidata knowledge base, for any entity, an id is given to the entity (Item), starting with Q, so that the entity is unique; For any property type / relationship type, give the property type / relationship type (Property) an id starting with P to ensure the uniqueness of the property type or relationship type; it can be understood that the property type / relationship type is the attribute of any entity or the relationship between any two entities.

[0034] For each entity, the entities corresponding to each attribute type / relationship type will be included in the Wikidata knowledge base.

[0035] Step S212: Use crawler technology to crawl the Property ID and value from the web pages of the Wikidata knowledge base and save them in a json format file.

[0036] Specifically, the internal format of the Wikidata knowledge base assigns an id starting with Q to each specific entity. However, in the attribute type or relationship type part, the attribute type or relationship type corresponding to each entity only displays its corresponding id, and does not specifically give the attribute value or relationship type. Therefore, if you want to get the relationship type of the triple, you must construct the specific value corresponding to the attribute type or relationship type id; Crawl all the information of the web page where the Property is located in the Wikidata knowledge base. Crawl the Property's id (number), label (label), description (description), and aliases (aliases) and store them in a json format file; Return the source code of the requested web page through the third-party Python library urlopen method; Use the third-party python library Beautifulsoup method to parse HTML into objects and convert them into string format for processing to capture important data of the corresponding web page; Use the third-party python library etree method to parse the HTML document object in string format and convert the string parameter into an Element object so that the required data can be found and extracted using the xpath() method.

[0037] Step S213: construct a small external knowledge base Science for the SciERC dataset.

[0038] Specifically, the triple map of the Wikidata knowledge base can be obtained by arranging the data results obtained in each part. This application conducts experiments on the public SciERC dataset, and it is necessary to construct a small external knowledge base for the dataset.

[0039] There are many types of relations in the Wikidata knowledge base. This application selects properties with the same or similar relation types as those in the SciERC dataset, and selects entities under the corresponding relation types to construct the Science small external knowledge base, referred to as the Science knowledge base. Finally, the number of entities and the number of relation types in the Science knowledge base are obtained; as shown in Table 1 below: Table 1-Statistical table of Science knowledge base

[0040] In summary, it can be understood that the first text is the text to be processed; the second text is the text with the same entity as the first text. The second text is based on the text with a triple graph in the external knowledge base; the second text can also be understood as the triple graph related to the first entity in the first text provided by the external knowledge base.

[0041] Step S220: Process any two first entities in the first text to obtain first codes and second codes of the two first entities.

[0042] Specifically, step S221, masking any two first entities in the first text to obtain a third text; Step S221 may include: first, processing the first text to obtain a plurality of first entities of the first text. It can be expressed as: ; The first entity.

[0043] It should be noted that entities and tags involved in this application are represented by vectors.

[0044] Form an entity pair by any two first entities among the plurality of first entities; For any entity pair, determine the head entity and the tail entity in the entity pair; this process can be understood as: determine any first entity in the entity pair as the head entity, the other as the tail entity, and determine the starting position of the head entity in the first text and end position ; Determine the starting position of the tail entity in the first text and end position ; The entity pair can be represented as: ,in, is the head entity, It is the tail entity. In this case, the entity pair uses the span to represent the first entity.

[0045] First Text It can be expressed as:

[0046] After that, replace the head entity and tail entity with the head entity type marker respectively and the end entity type tag ; Insert the head entity start tag and the head entity end tag before and after the head entity type tag respectively; and insert the tail entity start tag and the tail entity end tag before and after the tail entity type tag respectively, to obtain a third text. In this way, using entity types instead of entities can reduce the impact of semantic noise on relationship classification.

[0047] The third text It can be expressed as:

[0048] in, represents the first entity, Indicates the header entity type tag, Indicates the end entity type tag, Indicates the start tag of the header entity. Indicates the end of the header entity. Indicates the start tag of the tail entity. Indicates the end of the entity tag.

[0049] It should be noted that each token is represented using characters that are not defined in the vocabulary of the first BERT model.

[0050] Step S222: Using the trained first BERT model, extract feature codes from characters in the third text to obtain a first code and a second code.

[0051] Step S222 may specifically include: masking the new sentence after the first entity, that is, the third text Send it to the first BERT model, and output the sentence feature encoding of each character (token character) in the third text after integrating the global information, and use Indicates. Among them, The header entity type tag is included and the end entity type tag The features (feature vectors), that is, the first encoding and the second code .

[0052] Step S230: Process two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code.

[0053] Specifically, according to In this way, two second entities in the second text (Science) of the external knowledge base that are the same as the two first entities (head entity and tail entity) in the first text are used to construct two short sentences. Then, the second BERT model is used to encode the two constructed short sentences, thereby outputting the two encoded sentences and adding the [CLS] position of the two sentences to the BERT model. (the short sentence [CLS] position corresponding to the head entity) and (The short sentence [CLS] position corresponding to the tail entity) is used as the information of the external knowledge base, that is, the first output code and the second output code.

[0054] The [CLS] position can also be understood as a [CLS] tag, which is a special token that is placed at the beginning of each input sequence. The main function of this tag is to provide a fixed point for the entire input sequence, so that the model can learn the semantic information representing the entire sentence or paragraph at this position.

[0055] Step S240: Process the relational semantic code obtained by concatenating the first code and the second code, and the first output code and the second output code, to determine a target relation type between the two first entities.

[0056] Specifically, in step S241, the first code and the second code, as well as the first output code and the second output code are concatenated to obtain a relational semantic code.

[0057] The first output code and the second output code are compared with the entity The corresponding first code and the second code Splice to get the relational semantic encoding , It can be expressed as:

[0058] Combination Figure 3 As shown, the first text W = (In 1752, flagmaker Betsy Ross was born in Philadelphia), the first entity is masked to obtain the third text ; ; The third text is represented by a word vector. Then, the relational semantic encoding is determined by combining the first output encoding and the second output encoding determined by the second entity.

[0059] Step S242: Process the relationship semantic coding to determine the target relationship type between the two first entities.

[0060] The relational semantic coding is processed by using a fully connected network layer of a trained preset neural network with a softmax activation function to determine the coding relationship between the first coding and the second coding; Based on the encoding relationship, a target relationship type between a head entity corresponding to the first encoding and a tail entity corresponding to the second encoding is determined.

[0061] Specifically, it can be expressed as: Encoding the relationship semantics Input a preset neural network (feedforward neural network, which can also be understood as a relationship type classifier) ​​to predict the head and tail entities Type of relationship The probability distribution of , ; Among them, R is a set of pre-configured relationship types, and σ indicates that there is no relationship between the head entity and the tail entity of the entity pair.

[0062] In some embodiments, during the training process of the preset neural network, the relationship type labels of all entity pairs and the entity pair relationship type labels predicted by the model are used to construct a cross entropy loss function, and then the preset neural network is trained. The loss function during the training process is as follows:

[0063] in, Represents entity pair The label of the real relationship type; Represents the head entity, is the tail entity, The header entity type tag corresponding to the entity type of the header entity, The tail entity type tag corresponding to the entity type of the tail entity, Represents a set of entity types, and S is a set of entity pairs.

[0064] The present application provides a method for determining long text relationships based on an external knowledge base, the method comprising: obtaining a first text to be processed and a second text obtained based on an external knowledge base; the first text and the second text have the same entity; processing any two first entities in the first text to obtain a first code and a second code for the two first entities; processing two second entities in the second text that are the same as the two first entities in the first text to obtain a first output code and a second output code; splicing the first code and the second code, as well as the first output code and the second output code, to obtain a relationship semantic code; processing the relationship semantic code to determine the target relationship type between the two first entities. Not all entities in the prior art data set can find their corresponding external information in the external database. Therefore, when there is no external information for the head entity or the tail entity, the relationship result is determined according to the common entity relationship determination algorithm. The relationship extraction method proposed in this application not only integrates the triple graph of the external knowledge base, but also does not destroy the data structure of the first text to be processed. It chooses to combine the triple graph of the external knowledge base corresponding to each first entity into a short sentence. The BERT model of this application can very effectively realize interactive learning between the short sentences of each triple graph, and the relational semantic encoding integrates the information of all triple graphs in the external knowledge base.

[0065] Corresponding to the above method, the embodiment of the present application also provides a long text relationship determination device based on an external knowledge base, such as Figure 4 As shown, the device comprises: An acquisition unit 410 is used to acquire a first text to be processed and a second text acquired based on an external knowledge base; the first text and the second text contain the same entity; A processing unit 420 is used to process any two first entities in the first text to obtain first codes and second codes of the two first entities; and, processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code; A concatenation unit 430 is configured to concatenate the first code and the second code, and the first output code and the second output code to obtain a relational semantic code; The processing unit 420 is further configured to process the relationship semantic encoding to determine a target relationship type between the two first entities.

[0066] The functions of each functional unit of a long text relationship determination device based on an external knowledge base provided in the above-mentioned embodiment of the present application can be realized through the above-mentioned method steps. Therefore, the specific working process and beneficial effects of each unit in a long text relationship determination device based on an external knowledge base provided in the embodiment of the present application will not be repeated here.

[0067] The present application also provides an electronic device, such as Figure 5 As shown, it includes a processor 510 , a communication interface 520 , a memory 530 and a communication bus 540 , wherein the processor 510 , the communication interface 520 , and the memory 530 communicate with each other via the communication bus 540 .

[0068] A memory 530, for storing computer programs; The processor 510 is used to execute the program stored in the memory 530 to implement the following steps: Acquire a first text to be processed and a second text acquired based on an external knowledge base; the first text and the second text contain the same entity; Processing any two first entities in the first text to obtain first codes and second codes of the two first entities; Processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code; Concatenate the first code and the second code, and the first output code and the second output code to obtain a relational semantic code; The relationship semantic encoding is processed to determine a target relationship type between the two first entities.

[0069] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0070] The communication interface is used for communication between the above electronic device and other devices.

[0071] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0072] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0073] The implementation methods and beneficial effects of the components of the electronic device in the above embodiments to solve the problems can be seen in Figure 2 The various steps in the illustrated embodiment are implemented, therefore, the specific working process and beneficial effects of the electronic device provided by the embodiment of the present application are not repeated here.

[0074] In another embodiment provided in the present application, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer executes a long text relationship determination method based on an external knowledge base as described in any of the above embodiments.

[0075] In another embodiment provided by the present application, a computer program product including instructions is also provided. When the computer program product is executed on a computer, the computer executes a method for determining a long text relationship based on an external knowledge base as described in any one of the above embodiments.

[0076] Those skilled in the art will appreciate that the embodiments in the present application can be provided as methods, systems, or computer program products. Therefore, the embodiments in the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments in the present application can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0077] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0078] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0079] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0080] Unless otherwise defined, the technical terms or scientific terms used in this application should be understood by people with ordinary skills in the field to which the present invention belongs. "First", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect", "couple" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0081] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the present application embodiments are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application embodiments.

[0082] Obviously, those skilled in the art can make various changes and modifications to the embodiments in the present application without departing from the spirit and scope of the embodiments in the present application. Thus, if these modifications and variations of the embodiments in the present application are within the scope of the embodiments in the present application and their equivalents, the embodiments in the present application are also intended to include these modifications and variations.

Claims

1. A method for determining long text relations based on an external knowledge base, characterized in that: The method comprises: Acquire a first text to be processed and a second text acquired based on an external knowledge base; the first text and the second text contain the same entity; Processing any two first entities in the first text to obtain first codes and second codes of the two first entities; Processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code; Concatenate the first code and the second code, and the first output code and the second output code to obtain a relational semantic code; The relationship semantic encoding is processed to determine a target relationship type between the two first entities.

2. The method according to claim 1, characterized in that Processing any two first entities in the first text to obtain first codes and second codes of the two first entities includes: Perform masking processing on any two first entities in the first text to obtain a third text; The trained first BERT model is used to extract feature codes of characters in the third text to obtain a first code and a second code.

3. The method according to claim 2, characterized in that Performing masking processing on any two first entities in the first text to obtain a third text includes: Obtaining multiple first entities of the first text; Form an entity pair by any two first entities among the plurality of first entities; For any entity pair, determine the head entity and the tail entity in the entity pair; Replacing the head entity and the tail entity with a head entity type tag and a tail entity type tag, respectively; Insert a head entity start tag and a head entity end tag before and after the head entity type tag respectively; and insert a tail entity start tag and a tail entity end tag before and after the tail entity type tag respectively, to obtain the third text.

4. The method according to claim 1, characterized in that Processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code includes: The two second entities in the second text that are identical to the two first entities in the first text are processed by the trained second BERT model to obtain the first output code and the second output code.

5. The method according to claim 3, characterized in that Processing the relationship semantic code to determine a target relationship type between the two first entities includes: Processing the relationship semantic coding through a fully connected network layer of a trained preset neural network with a softmax activation function to determine a coding relationship between the first coding and the second coding; Based on the encoded relationship, a target relationship type between the head entity and the tail entity is determined.

6. The method according to claim 5, characterized in that The loss function of the preset neural network during training for: in, Represents entity pair The label of the real relationship type; Represents the head entity, is the tail entity, The header entity type tag corresponding to the entity type of the header entity, The tail entity type tag corresponding to the entity type of the tail entity, Represents a set of entity types, and S is a set of entity pairs.

7. The method according to claim 3, characterized in that The third text It is expressed as: in, represents the first entity, Indicates the header entity type tag, Indicates the end entity type tag, Indicates the start tag of the header entity. Indicates the end of the header entity. Indicates the start tag of the tail entity. Indicates the end of the entity tag.

8. A long text relationship determination device based on an external knowledge base, characterized in that: The device comprises: An acquisition unit, used for acquiring a first text to be processed and a second text acquired based on an external knowledge base; the first text and the second text contain the same entity; A processing unit, configured to process any two first entities in the first text to obtain first codes and second codes of the two first entities; and, processing two second entities in the second text that are identical to two first entities in the first text to obtain a first output code and a second output code; a concatenation unit, configured to concatenate the first code and the second code, and the first output code and the second output code to obtain a relational semantic code; The processing unit is further used to process the relationship semantic coding to determine the target relationship type between the two first entities.

9. An electronic device, characterized in that: The electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.

Citation Information

Patent Citations

  • Entity relationship extraction method and system, electronic device and storage medium

    CN113536795A

  • Relation extraction method and system based on entity replacement and suspension marking

    CN115935952A

  • Entity type fused BERT knowledge graph completion method and system

    CN116010622A

  • Knowledge graph-based junior high school mathematics knowledge point relation extraction method

    CN118709773A

  • Modular self-supervision for document-level relation extraction

    US20230019081A1