Method and system for text relation extraction

By using BERT encoding and multi-label classification technology, the relationship extraction of text is solved, and the problem of being unable to simultaneously achieve limited and open relationship extraction in the existing technology is achieved, and accurate and complete relationship representation and conflict resolution are achieved.

CN114385812BActive Publication Date: 2025-02-07AISPEECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111598713.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-24
Publication Date
2025-02-07
Estimated Expiration
2041-12-24

AI Technical Summary

Technical Problem

The relationship extraction method in the prior art cannot simultaneously realize the limited relationship extraction and open relationship extraction, and there are incomplete or conflicting relationship extraction problems.

Method used

BERT is used to encode the text, generate a matrix based on fragment arrangement, and classify each coordinate in the matrix multi-label to obtain a set of tags. By traversing the head, tail labels and entity labels in the tag collection, perform handshake label pairing to determine the triple that defines or open relationships.

Benefits of technology

The extraction of limited and open relationships is achieved simultaneously, reducing the loss of coded information, accurately representing multi-dimensional relationship triplets, and ensuring the accuracy of the relationship through a conflict resolution mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385812B_ABST
    Figure CN114385812B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method for text relation extraction. The method includes: encoding the text using BERT, replicating and upgrading the sequence dimension of the encoding result to obtain a matrix based on fragment arrangement; performing multi-label classification on the character string corresponding to each coordinate in the matrix to obtain a label set for each coordinate; traversing all head and tail labels and entity labels in the label set of each coordinate to perform handshake annotation pairing for relation extraction, and determining at least one triple of a restricted relationship or an open relationship to represent the relationship between entities in the text. The embodiment of the present invention also provides a text relation extraction system. The embodiment of the present invention utilizes a set label set and paired relationship extraction to achieve both restricted relationship extraction and open relationship extraction. It can reduce the loss of encoding information to a large extent and accurately represent non-conflicting multi-dimensional relationship triples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing, and in particular to a method and system for extracting relations from texts. Background Art

[0002] Relation extraction is a basic task in the field of natural language processing. It is widely present in the fields of text mining, information retrieval, intelligent question answering, etc., and plays a very important role.

[0003] For relation extraction, existing techniques use:

[0004] 1. A Chinese unsupervised open entity relationship extraction method based on dependency semantics performs Chinese word segmentation, named entity recognition, part-of-speech tagging and dependency syntax analysis on the text. Two entities are randomly selected from the named entity recognition to find the dependency path between them. Once the dependency path meets the predefined paradigm match, the relationship triples are further parsed.

[0005] 2. Use the neural network relationship extraction method to convolve each sentence and its related entities to obtain the sentence vector representation of the pair of entities, and then use the sentence-level attention mechanism to obtain the comprehensive sentence vector representation. The two are used as feature prediction relationships.

[0006] In the process of implementing the present invention, the inventors found that there are at least the following problems in the related art:

[0007] Since the frameworks adopted by the above methods are mostly based on pipeline model frameworks, it is impossible to realize restricted relationship extraction and open relationship extraction at the same time, and step-by-step extraction is required, and end-to-end extraction cannot be achieved. If the above two methods are not integrated, the extracted relationships may be incomplete or conflicting. Summary of the invention

[0008] In order to at least solve the problem of incomplete or conflicting relation extraction in the prior art. In a first aspect, an embodiment of the present invention provides a relation extraction method for text, comprising:

[0009] Use BERT to encode the text, replicate the sequence dimension of the encoding result, and obtain a matrix based on fragment arrangement;

[0010] Perform multi-label classification on the character string corresponding to each coordinate in the matrix to obtain a label set for each coordinate;

[0011] All head and tail tags and entity tags in the tag set of each coordinate are traversed to perform handshake annotation pairing for relationship extraction, and at least one triple of a restricted relationship or an open relationship is determined to represent the relationship between the entities in the text.

[0012] In a second aspect, an embodiment of the present invention provides a relationship extraction system for text, comprising:

[0013] A matrix determination program module is used to encode text using BERT, replicate and upgrade the sequence dimension of the encoding result, and obtain a matrix based on fragment arrangement;

[0014] A label classification program module is used to perform multi-label classification on the character string corresponding to each coordinate in the matrix to obtain a label set for each coordinate;

[0015] The annotation pairing program module is used to traverse all the head tags, tail tags and entity tags in the tag set of each coordinate to perform handshake annotation pairing for relationship extraction, and determine at least one triple of a restricted relationship or an open relationship to represent the relationship between the entities in the text.

[0016] According to a third aspect, an electronic device is provided, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the relationship extraction method for text according to any embodiment of the present invention.

[0017] In a fourth aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, characterized in that when the program is executed by a processor, the steps of the method for text relationship extraction of any embodiment of the present invention are implemented.

[0018] The beneficial effects of the embodiments of the present invention are: by using the set label set and the paired relationship extraction, both limited relationship extraction and open relationship extraction can be realized. The coding information loss can be reduced to a large extent, and multi-dimensional relationship triples can be accurately represented. After determining the multi-dimensional relationship triples, it is further determined whether there is a conflict between the triples, thereby further ensuring the accuracy of the extracted relationship. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 is a flow chart of a method for extracting textual relations provided by one embodiment of the present invention;

[0021] Figure 2is a matrix schematic diagram of a method for extracting textual relations provided by an embodiment of the present invention;

[0022] Figure 3 It is a schematic diagram of matrix annotation pairing of a method for text relationship extraction provided by an embodiment of the present invention;

[0023] Figure 4 It is an overall flow chart of a relation extraction method for text provided by one embodiment of the present invention;

[0024] Figure 5 is a structural schematic diagram of a text relationship extraction system provided by an embodiment of the present invention;

[0025] Figure 6 A schematic structural diagram of an embodiment of an electronic device for text relationship extraction provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] like Figure 1 FIG. 1 is a flowchart of a method for extracting textual relations provided by an embodiment of the present invention, comprising the following steps:

[0028] S11: Use BERT to encode the text, replicate the sequence dimension of the encoding result, and obtain a matrix based on fragment arrangement;

[0029] S12: performing multi-label classification on the character string corresponding to each coordinate in the matrix to obtain a label set for each coordinate;

[0030] S13: Traverse all the head and tail labels and entity labels in the label set of each coordinate to perform handshake annotation pairing for relationship extraction, and determine at least one triple of a restricted relationship or an open relationship to represent the relationship between the entities in the text.

[0031] In this embodiment, the method can be applied to the fields of text mining, information retrieval, intelligent question answering, etc., to extract relation triplets in the text to represent the relationship of the text. The text can be a conversation between users, a question input by a user, or an article.

[0032] For step S11, for the text X=[x 1 , x 2 , …, x n ], the output result after BERT encoding is H = [h 1 ,h 2 ,…,h n ]. Among them, BERT (Bidirectional Encoder Representations from Transformers), the Transformer model is a model based on the encoding-decoding structure.

[0033] The encoded output is copied and upgraded in the dimension of the sequence length to obtain matrix A and transposed matrix A. T , and the logits output matrix S with dimension n*n, as follows Figure 2 As shown in Figure 2, logits is the output of the final fully connected layer.

[0034] Each element S in the output matrix ij The formula is:

[0035]

[0036] in, is the vector concatenation operation, ⊙ is the vector dot multiplication operation, W 1 With W 2 is the weight matrix, b 1 With b 2 is the bias matrix. The dimension of the final matrix S is n×n×T, where T is the label set L all The number of .

[0037] For step S12, in the matrix S determined in step S11, since the label of each position in the matrix S is not unique, for a certain element s of the matrix S ij , there may be multiple labels, so s ij Do multi-label classification. ij The dimension is 1×T, that is, 01 binary classification is performed for all labels. ij The corresponding value of the tth label is 0, indicating s ij does not have a t label; vice versa. Therefore, the objective function is:

[0038]

[0039]

[0040] Among them, |D| is the number of training set data, n is the sentence length, T is the total number of labels, P ijt Indicates ij The probability that the tth label value is 1, y ijt Indicates ij The actual value (0 or 1) of the corresponding t label. In the prediction stage, by setting a threshold, for example, 0.5 is used as the threshold (the specific value can be adjusted according to the actual situation and is not limited here). ijt When the probability is greater than 0.5, it is considered that s ij L t Label.

[0041] The label set includes: subject entity label, object entity label, predicate entity label, first character label of two entities, last character label of two entities, first character label of subject-predicate entity, last character label of subject-predicate entity, first character label of object-predicate entity, last character label of object-predicate entity.

[0042] Specifically, the label set L all for:

[0043] Tag: time; Definition: time entity; Task: named entity recognition;

[0044] Tag: person; Definition: person entity; Task: named entity recognition;

[0045] Tag: subject; Definition: subject entity; Task: open relation extraction, restricted relation extraction;

[0046] Tag: object; Definition: object entity; Task: open relation extraction, restricted relation extraction;

[0047] Tag: nation_head2head; Definition: the head characters of two entities with ethnic relations; Task: limited relation extraction;

[0048] Tag: nation_tail2tail; Definition: the tail characters of two entities with ethnic relations; Task: limited relation extraction;

[0049] Tag: predicate; Definition: predicate entity; Task: open relation extraction;

[0050] Tag: subject_head2predicate_head; Definition: the head character of the subject-predicate entity with an open relation; Task: open relation extraction;

[0051] Label: subject_tail2predicate_tail; Interpretation: The tail character of the subject-predicate entity with an open relationship; Task: Open relationship extraction;

[0052] Label: object_head2predicate_head; Interpretation: The head character of the object-predicate entity with an open relationship; Task: Open relationship extraction;

[0053] Label: object_tail2predicate_tail; Interpretation: The tail character of the object-predicate entity with an open relationship; Task: Open relationship extraction;

[0054] In fact, the labels are not only the above content, but can also be added and adjusted based on actual needs. For example, in a sentence about family structure, there can be labels: Parent_head2head; Interpretation: The head characters of two entities with a parent-child relationship; Task: Defined relationship extraction; Label: Parent_tail2tail; Interpretation: The tail characters of two entities with a parent-child relationship; Task: Defined relationship extraction. That is to say, if there are other needs, more labels can be added, which will not be elaborated here. Taking the sentence "Yao loves playing basketball" as an example, the sequence dimension of the coding result is copied and upscaled to obtain a matrix based on segment permutation. Intuitively, the abscissa of the matrix from left to right is "Yao", "Mou", "loves", "plays", "basketball", "ball" in turn, and the ordinate from top to bottom is "Yao", "Mou", "loves", "plays", "basketball", "ball" in turn.

[0055] Multi-label classification can be performed through the strings corresponding to the matrix. For example, the matrix (0,1) expanded based on segment permutation. It indicates that the string with the starting position of 0 and the ending position of 1 (the abscissa corresponds to "Yao" and the ordinate corresponds to "Mou") corresponds to "Yao Mou", P ijt The probability corresponding to (Yao, Mou, person) is 0.9, which is higher than the preset 0.5, and the label is determined to be "person", that is, "Yao Mou" is a person entity. P ijt The probability corresponding to (Yao, Mou, time) is 0, which is lower than the preset 0.5, and it is concluded that "time" is not its label. In the same way, each label in the above example is judged separately. If multiple labels meet the requirements, the label set under the coordinates (0,1) can be obtained. The other coordinates are judged in the same way, which will not be elaborated here.

[0056] For step S13, taking a more complex text as an example, "Yao and his wife Ye attended together", through the above steps S11 and S12 for processing, the label set of each coordinate is obtained, such as Figure 3As shown, S: subject, subject entity; P: predicate, predicate entity; O: object, object entity; SH: subject_head2predicate_head, the head character of the subject-predicate entity with an open relationship; ST: subject_tail2predicate_tail, the tail character of the subject-predicate entity with an open relationship; OH: object_head2predicate_head, the head character of the object-predicate entity with an open relationship; OT: object_tail2predicate_tail, the tail character of the object-predicate entity with an open relationship.

[0057] Each element is in the form of (i, j, L), where i and j are the positions in the matrix, and L (L∈L all ) indicates that the position has an L label. Then, it is necessary to traverse all head and tail labels (including head and tail labels) and all entity labels to produce a clear triple.

[0058] Taking the more complex open relation extraction as an example, when the input text X contains the three elements of open relation extraction: (i s ,j s ,subject),(i p ,j p ,predicate),(i o ,j o ,object) (simply put, there will be a subject, predicate and object in a sentence), and satisfy the matrix position (i s ,i p ) has the label "subject_head2predicate_head", the matrix position (j s ,j p ) has the label "subject_tail2predicate_tail", the matrix position (i o ,i p ) has the label "object_head2predicate_head", the matrix position (j o ,j p ) has the label "object_tail2predicate_tail", and the triple can be obtained <X[i s :j s ],X[i p :j p ],X[i o :j o ]>. The above annotation method can be vividly called handshake annotation. For example, we get <Yao, wife, Ye>.

[0059] As an implementation manner, the triples of the restricted relations are determined by triples of preset relation types, and the triples of the open relations are determined by relation triples of non-restricted relations in the text.

[0060] In this embodiment, the extraction of limited relations is used to extract relation triplets of preset relation types. This type of text structure is relatively simple, and the label set is mainly "{REL}_head2head" and "{REL}_tail2tail", where REL represents a predefined relation type value. When the (i, j) position of the matrix expanded based on the fragment arrangement has "{REL}_head2head", it means that an entity (named entity or subject entity) with i as the starting position and another entity (named entity or object entity) with j as the starting position have a REL relationship, and "{REL}_tail2tail" is used to indicate the end position, with the same meaning. Since the named entity recognition task cannot cover all entity types, the subjects and objects of some relation triplets do not have strong named entity labels, so new "subject" and "object" labels are added. Taking the matrix of the text "Yao, Han nationality" as an example, the matrix (0,1) position (the horizontal axis corresponds to "Yao", the vertical axis corresponds to "some") based on the fragment arrangement has the label "person", the matrix (3,4) position (the horizontal axis corresponds to "Han", the vertical axis corresponds to "ethnicity") has the label "object", the matrix (0,3) position (the horizontal axis corresponds to "Yao", the vertical axis corresponds to "min") has the label "nation_head2head", and the matrix (1,4) position (the horizontal axis corresponds to "some", the vertical axis corresponds to "ethnicity") has the label "nation_tail2tail". At this time, it can be uniquely determined that the person entity "Yao" and the object entity "Han nationality" have a "nationality" relationship, that is, the triple <Yao, nationality, Han nationality> is obtained.

[0061] Open relation extraction: used to extract unrestricted relation triplets that appear in the text. This type of text structure is relatively complex. The label set is mainly "subject_head2predicate_head", "subject_tail2predicate_tail", "object_head2predicate_head", and "object_tail2predicate_tail", and the task will additionally identify the predicate entity "predicate" (simply put, a sentence may have a subject-predicate and object-predicate structure, which is more in line with the discourse structure that users say in daily life). When the (i, j) position of the matrix expanded based on the fragment arrangement has "subject_head2predicate_head", it means that a subject entity with i as the starting position and another predicate entity with j as the starting position belong to the same set of open relations, and the other labels have the same meaning. Taking the text "It Takes Two is a game published by EA" as an example, the matrix determined has the label "subject" at position (1,4) (the horizontal axis corresponds to "double", the vertical axis corresponds to "row"), the label "object" at position (10,11) (the horizontal axis corresponds to "E", the vertical axis corresponds to "A"), the label "predicate" at position (12,13) ​​(the horizontal axis corresponds to "hair", the vertical axis corresponds to "row"), the label "subject_head2predicate_head" at position (1,12) (the horizontal axis corresponds to "double", the vertical axis corresponds to "hair"), the label "subject_tail2predicate_tail" at position (4,13) (the horizontal axis corresponds to "row", the vertical axis corresponds to "row"), the label "subject_tail2predicate_tail" at position (10,12) (the horizontal axis corresponds to "E", the vertical axis corresponds to "hair"), the label "object_head2predicate_head" at position (11,13) (the horizontal axis corresponds to "A", the vertical axis corresponds to "row"), the label "object_tail2predicate_tail". At this time, it can be uniquely determined that the subject entity "two people in a trip" and the object entity "EA" have an open relationship "issue", that is, the triple <two people in a trip, issue, EA> is obtained.

[0062] It can be seen from this implementation that by using the set label set and paired relationship extraction, both limited relationship extraction and open relationship extraction can be achieved, which can greatly reduce the loss of coding information and accurately represent multi-dimensional relationship triples.

[0063] As an implementation manner, after determining at least one triple of a restricted relationship or an open relationship, the method further includes:

[0064] When there are entity relationship conflicts among multiple triples, determine the average score of the sum of all label probabilities in the multiple triples, and delete the triple with the lowest score in the multiple triples to resolve the entity relationship conflicts.

[0065] In this embodiment, when the above steps determine a set of triples, it is not only necessary to correctly identify the subject, predicate, and object (for restrictive relationship extraction, the subject and object are mainly considered), but also to identify the corresponding labels for the boundaries of each entity. Therefore, define the final score of a triple as the average of the sum of the probabilities of all label elements that determine this triple:

[0066]

[0067] Among them, N represents the number of all elements that determine this triple (for example, generally 4 for restrictive relationship extraction and generally 7 for open relationship extraction, so that better results can be obtained), and p(i, j, L) represents the corresponding probability score of a certain element. This score can be used to balance the accuracy and recall rate of the output triples, and can also be used to solve the triple conflict problem. Taking the text "The president a of country A meets the president b of country B" as an example. If the original result identifies the triples <country A, president, a>, <country B, president, b>, and <country A, president, b>. At this time, there are obvious conflicts in the triples. Calculate the scores of each triple through the above formula and sort them, and剔除 the triple <country A, president, b> with conflicting relationships and a lower score. Thus, the problem of entity relationship conflicts is solved. Generally speaking, the overall framework of this method is as Figure 4 shown.

[0068] It can be seen from this embodiment that after determining the multi-dimensional relationship triples, further judge whether there are conflicts among the triples, so as to further ensure the accuracy of the extracted relationships.

[0069] As Figure 5 shown is a schematic structural diagram of a relationship extraction system for text provided by an embodiment of the present invention. This system can execute the relationship extraction method for text described in any of the above embodiments and is configured in a terminal.

[0070] A relationship extraction system 10 for text provided in this embodiment includes: a matrix determination program module 11, a label classification program module 12, and a marking pairing program module 13.

[0071] Among them, the matrix determination program module 11 is used to encode the text using BERT, copy and upgrade the sequence dimension of the encoding result, and obtain a matrix based on fragment arrangement; the label classification program module 12 is used to perform multi-label classification on the character string corresponding to each coordinate in the matrix to obtain the label set of each coordinate; the annotation pairing program module 13 is used to traverse all the head and tail labels and entity labels in the label set of each coordinate to perform handshake annotation pairing for relationship extraction, and determine at least one triple of a restricted relationship or an open relationship to represent the relationship between the entities in the text.

[0072] Furthermore, the system further comprises: a conflict resolution program module, configured to:

[0073] When entity relationship conflicts exist in multiple triples, the average scores of all tag probabilities and in the multiple triples are determined, and the triple with the lowest score in the multiple triples is deleted to resolve the entity relationship conflicts.

[0074] The embodiment of the present invention further provides a non-volatile computer storage medium, the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the relationship extraction method for text in any of the above method embodiments;

[0075] As an implementation mode, the non-volatile computer storage medium of the present invention stores computer executable instructions, and the computer executable instructions are configured as follows:

[0076] Use BERT to encode the text, replicate the sequence dimension of the encoding result, and obtain a matrix based on fragment arrangement;

[0077] Perform multi-label classification on the character string corresponding to each coordinate in the matrix to obtain a label set for each coordinate;

[0078] Traverse all the head and tail tags and entity tags in the tag set of each coordinate to perform handshake annotation pairing for relationship extraction, and determine at least one triple of a restricted relationship or an open relationship to represent the relationship between the entities in the text.

[0079] As a non-volatile computer-readable storage medium, it can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the method in the embodiment of the present invention. One or more program instructions are stored in the non-volatile computer-readable storage medium, and when executed by the processor, the relationship extraction method for text in any of the above method embodiments is executed.

[0080] Figure 6 is a schematic diagram of the hardware structure of an electronic device for a text relationship extraction method provided by another embodiment of the present application, such as Figure 6 As shown, the device includes:

[0081] One or more processors 610 and memory 620, Figure 6 A processor 610 is taken as an example. The apparatus for extracting text relations may further include: an input device 630 and an output device 640.

[0082] The processor 610, the memory 620, the input device 630 and the output device 640 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.

[0083] The memory 620, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the text relationship extraction method in the embodiment of the present application. The processor 610 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 620, that is, the text relationship extraction method in the above method embodiment is implemented.

[0084] The memory 620 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data, etc. In addition, the memory 620 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 620 may optionally include a memory remotely arranged relative to the processor 610, and these remote memories may be connected to the mobile device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0085] The input device 630 can receive input digital or character information. The output device 640 can include a display device such as a display screen.

[0086] The one or more modules are stored in the memory 620, and when executed by the one or more processors 610, the relationship extraction method for text in any of the above method embodiments is executed.

[0087] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.

[0088] The non-volatile computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the device, etc. In addition, the non-volatile computer-readable storage medium may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the non-volatile computer-readable storage medium may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0089] An embodiment of the present invention also provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the relationship extraction method for text of any embodiment of the present invention.

[0090] The electronic device of the embodiment of the present application exists in various forms, including but not limited to:

[0091] (1) Mobile communication equipment: This type of equipment is characterized by having mobile communication functions and its main purpose is to provide voice and data communications. This type of terminal includes: smart phones, multimedia phones, functional phones, and low-end phones.

[0092] (2) Ultra-mobile personal computer devices: These devices fall into the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access features. These terminals include: PDAs, MIDs, and UMPC devices, such as tablet computers.

[0093] (3) Portable entertainment devices: These devices can display and play multimedia content. They include audio and video players, handheld game consoles, e-books, smart toys, and portable car navigation devices.

[0094] (4) Other electronic devices with data processing functions.

[0095] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include" and "comprise" include not only those elements, but also other elements not explicitly listed, or also include elements inherent to such processes, methods, articles or equipment. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or equipment that includes the elements.

[0096] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for extracting relations from text, comprising: Use BERT to encode the text, replicate the encoding result in the dimension of sequence length, and obtain a matrix based on fragment arrangement; Perform multi-label classification on the character string corresponding to each coordinate in the matrix to obtain a label set for each coordinate; Traversing all head and tail labels and entity labels in the label set of each coordinate to perform handshake annotation for relationship extraction, determining at least one triple of a restricted relationship or an open relationship to represent the relationship between entities in the text, and when there is an entity relationship conflict in multiple triples, determining the average score of the sum of all label probabilities in the multiple triples, and deleting the triple with the lowest score in the multiple triples to resolve the entity relationship conflict.

2. The method according to claim 1, wherein: The triples of the restricted relations are determined by triples of preset relation types, and the triples of the open relations are determined by relation triples of non-restricted relations in the text.

3. The method according to claim 1, wherein: The tag set includes: a subject entity tag, an object entity tag, a predicate entity tag, a subject-predicate entity first character tag, a subject-predicate entity last character tag, an object-predicate entity first character tag, and an object-predicate entity last character tag.

4. A relation extraction system for text, comprising: The matrix determination program module is used to encode the text using BERT, replicate and upgrade the encoding result in the dimension of sequence length, and obtain a matrix based on fragment arrangement; A label classification program module is used to perform multi-label classification on the character string corresponding to each coordinate in the matrix to obtain a label set for each coordinate; The annotation pairing program module is used to traverse all the head tags, tail tags and entity tags in the tag set of each coordinate to perform handshake annotation to extract relationships, determine at least one triple of a restricted relationship or an open relationship, and use it to represent the relationship between the entities in the text. When there is an entity relationship conflict in multiple triples, determine the average score of the sum of all label probabilities in the multiple triples, and delete the triple with the lowest score in the multiple triples to resolve the entity relationship conflict.

5. The system according to claim 4, wherein: The triples of the restricted relations are determined by triples of preset relation types, and the triples of the open relations are determined by relation triples of non-restricted relations in the text.

6. The system according to claim 4, wherein: The tag set includes: a subject entity tag, an object entity tag, a predicate entity tag, a subject-predicate entity first character tag, a subject-predicate entity last character tag, an object-predicate entity first character tag, and an object-predicate entity last character tag.

7. An electronic device, comprising: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps of the method described in any one of claims 1 to 3.

8. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 3 are implemented.