Alternating sequence generation model training method, method for extracting graphs from text

CN113487024BActive Publication Date: 2024-12-10任立椋
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202110725279.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-29
Publication Date
2024-12-10
Estimated Expiration
2041-06-29

Smart Images

  • Figure CN113487024B_ABST
    Figure CN113487024B_ABST
Patent Text Reader

Abstract

The present invention discloses a training method for an alternating sequence generation model, comprising: obtaining a training sample pair from a sample library, the training sample pair comprising a paired training text and a training information graph, the training information graph comprising a plurality of nodes and at least one edge connecting two of the plurality of nodes; generating a training alternating sequence comprising node information and edge information according to the training information graph; and training an alternating sequence generation model according to the training text and the training alternating sequence. When extracting an information graph from a text through a model, the graph is not directly modeled, but the problem of extracting a graph from a text is converted into the problem of extracting an alternating sequence from a text, so that the alternating sequence generation model obtained by the method of this embodiment has only linear time and space complexity when used for graph extraction, and the time and space efficiency is significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to an alternating sequence generation model training method, a method for extracting graphs from text, an electronic device, and a computer-readable storage medium. Background Art

[0002] Existing methods for extracting graphs from text usually use a neural network to encode a text, and then use a pairwise scoring method to generate graph edges; or use a multi-dimensional recurrent neural network to generate a graph connection table; or use a method to generate a node-edge-node triple sequence of the graph to extract the graph from the text. At the same time, some technologies will represent the nodes of the graph as specific text or words.

[0003] These techniques usually have high time and space complexity (greater than linear complexity), or fail to accurately extract nodes containing uncommon / unseen words, or ignore the dependencies between graph elements (edges and nodes), resulting in low accuracy and precision of graph extraction;

[0004] Because the pairwise scoring method needs to traverse all possible text pairs, it will have a high time complexity; and the method using a multi-dimensional recurrent neural network needs to store the implicit representation of the entire graph connection table, so it will have a high space complexity. Representing graph nodes as specific words or text will cause the node classifier to be unable to accurately estimate the probability distribution of uncommon / unseen words, and thus unable to accurately extract these words as graph nodes, which will also affect the overall accuracy and precision of graph extraction. The pairwise scoring method treats each edge as an independent element and classifies them separately, which ignores the dependency between edges. The triple sequence generation method classifies edges and nodes independently when generating triples, which ignores the dependency between edges and nodes. These neglects of dependency will affect the overall accuracy and precision of graph extraction.

[0005] In general, when using the existing technologies, the inventors found that these solutions have high time complexity or space complexity, while the comprehensive accuracy and precision of graph extraction are low, making it difficult to apply them to actual industrial-level usage scenarios of large-scale long texts. Summary of the invention

[0006] Embodiments of the present invention provide an alternating sequence generation model training method, a method for extracting a graph from a text, an electronic device, and a computer-readable storage medium, which are used to solve at least one of the above-mentioned technical problems.

[0007] In a first aspect, an embodiment of the present invention provides an alternating sequence generation model training method, comprising:

[0008] Acquire a training sample pair from a sample library, wherein the training sample pair includes a paired training text and a training information graph, wherein the training information graph includes a plurality of nodes and at least one edge connecting two of the plurality of nodes;

[0009] Generate a training alternating sequence including node information and edge information according to the training information graph;

[0010] An alternating sequence generation model is trained according to the training text and the training alternating sequence.

[0011] In some embodiments, generating a training alternating sequence including node information and edge information according to the training information graph includes: using a preset traversal algorithm to traverse the training information graph to generate a training alternating sequence including node information and edge information.

[0012] In some embodiments, the training alternating sequence includes node information and edge information that are spaced apart from each other.

[0013] In some embodiments, the node information includes node type information, and the edge information includes actual edge type information and virtual edge type information.

[0014] In some embodiments, the training information graph includes spans of addresses as input text fragments and types as representations of abstract concepts, wherein the types may be spans of length 1 of a vocabulary of node type information, actual edge type information, and virtual edge type information.

[0015] In some embodiments, training an alternating sequence generation model according to the training text and the training alternating sequence includes: processing the output distribution of the alternating sequence generation model using an alternating mask to obtain an alternating sequence consisting of mutually spaced node information and edge information.

[0016] In a second aspect, an embodiment of the present invention provides a method for extracting a graph from a text, comprising:

[0017] Input the text to be extracted into the alternating sequence generation model trained by the aforementioned method to obtain the target alternating sequence;

[0018] A target information graph is generated according to the target alternating sequence.

[0019] In some embodiments, generating a target information graph according to the target alternating sequence comprises:

[0020] The target alternating sequence is processed according to a preset traversal algorithm used to train the alternating sequence generation model to generate a target information graph.

[0021] In a third aspect, an embodiment of the present invention provides a storage medium, in which one or more programs including execution instructions are stored, and the execution instructions can be read and executed by an electronic device (including but not limited to a computer, a server, or a network device, etc.) to execute any of the above-mentioned methods for extracting images from text of the present invention.

[0022] In a fourth 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 execute any one of the above-mentioned methods for extracting images from text of the present invention.

[0023] In a fifth aspect, an embodiment of the present invention further provides a computer program product, comprising a computer program stored on a storage medium, wherein the computer program comprises program instructions, and when the program instructions are executed by a computer, the computer executes any one of the above-mentioned methods for extracting images from text.

[0024] In this embodiment, when extracting an information graph from a text through a model, the graph is not directly modeled. Instead, the problem of extracting a graph from a text is converted into the problem of extracting an alternating sequence from a text. As a result, the alternating sequence generation model obtained by the method of this embodiment has only linear time and space complexity when used for graph extraction, and the time and space efficiency is significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0026] Figure 1 A flowchart of an embodiment of the alternating sequence generation model training method of the present invention;

[0027] Figure 2 A flowchart of an embodiment of a method for extracting a graph from a text according to the present invention;

[0028] Figure 3 A schematic diagram of an embodiment of an alternating sequence of information multiplex graphs of the present invention;

[0029] Figure 4 is a schematic diagram of an embodiment of an encoder architecture of the present invention;

[0030] Figure 5A schematic diagram of an embodiment of an alternating sequence of knowledge graphs in the ACE05 dataset of the present invention;

[0031] Figure 6 is a schematic diagram of an embodiment of a hybrid span decoder of the present invention;

[0032] Figure 7 It is a schematic diagram of BFS traversal embedding of alternating sequence of the present invention;

[0033] Figure 8 This is a schematic diagram of the distribution of the remaining errors on the ACE05 test set of the present invention;

[0034] Fig. 9 Schematic diagram of the structure of the converter with a hybrid attention layer in the present invention;

[0035] Fig.10 It is a schematic structural diagram of an embodiment of an electronic device of the present invention. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the technical scheme 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 in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. It should be noted that the embodiments in this application and the features in the embodiments can be combined with each other without conflict.

[0037] The present invention may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0038] When using existing technologies, the inventors found that these solutions have high time complexity or space complexity, and the comprehensive accuracy and precision of graph extraction are low, making it difficult to apply them to actual industrial-level usage scenarios of large-scale long texts. Therefore, the inventors proposed a solution with both high performance and high efficiency to adapt to existing industrial-level application scenarios.

[0039] like Figure 1 As shown, an embodiment of the present invention provides an alternating sequence generation model training method, comprising:

[0040] S11. Acquire a training sample pair from a sample library, wherein the training sample pair includes a paired training text and a training information graph, wherein the training information graph includes a plurality of nodes and at least one edge connecting two of the plurality of nodes.

[0041] For example, the training information graph can be viewed as a heterogeneous multigraph (Li et al., 2014; Shi et al., 2017) G = (V, E), where V is a set of nodes (usually representing spans in the input documents (t s , t e ), E is a multiset of edges with node type mapping function φ: V → Q and edge type mapping function ψ: E → R. It is assumed that node types and edge types are extracted from a finite vocabulary. Node types can be used to represent entity types (PER, ORG, etc.), while edge types can represent relationships between nodes (PHYS, OGR-AFF, etc.).

[0042] S12. Generate a training alternating sequence including node information and edge information according to the training information graph.

[0043] In this embodiment, the space of heterogeneous multigraph G is not directly modeled, but a sequence space S is constructed from G to π Mappings π =f s (G,π).f s Depends on the (given) ordering π of nodes and their edges in G, constructed by a graph traversal algorithm such as breadth-first search (BFS) or depth-first search (DFS) and an internal ordering of node and edge types.

[0044] In some embodiments, the node information includes node type information, and the edge information includes actual edge type information and virtual edge type information.

[0045] This application assumes that the sequence s π Elements of i π is obtained from a finite set of node representations V (defined below), a set of node types Q, a set of edge types R, and a set of “virtual” edge types U, s i π ∈V∪Q∪R∪U. The virtual edge type U = {[SOS], [EOS], [SEP]} does not represent an edge in G, but is used to control the generation of sequences, indicating the start / end of sequences and the separation of levels in the graph.

[0046] Exemplarily, the training alternating sequence includes node information and edge information that are spaced apart from each other. π =s0π ,…s n π , with an alternating structure, where s0 π ,s2 π ,s4 π ,…represents node V, s1 π ,s3 π ,s5 π ,… represent real or virtual edges. In the case of BFS, this application exploits the fact that BFS visits nodes layer by layer (i.e., in order p i ,c i1 ,…,c ik ,p j , where c ik is the parent node p i The kth child node of ik Connection, p j May or may not be equivalent to p i One of the child nodes of ), this application turns it into a sequence,

[0047] s π =p i ,ψ(e i1 ), c i1 , ...,

[0048] ψ(e ik ), c ik ,[SEP],p j ,...

[0049] Among them, the present application uses a special edge type [SEP] to describe the hierarchy in the graph. The specific name of the special edge type can be arbitrary, including but not limited to the [SEP] mentioned in this article. In the case of DFS, the [SEP] type appears immediately after the leaf node. If the present application knows which type of graph traversal algorithm (BFS or DFS) the alternating sequence is based on, this representation allows the present application to unambiguously restore the original information graph.

[0050] S13. Training an alternating sequence generation model according to the training text and the training alternating sequence.

[0051] In this embodiment, when extracting an information graph from a text through a model, the graph is not directly modeled. Instead, the problem of extracting a graph from a text is converted into the problem of extracting an alternating sequence from a text. As a result, the alternating sequence generation model obtained by the method of this embodiment has only linear time and space complexity when used for graph extraction, and the time and space efficiency is significantly improved.

[0052] In some embodiments, step S20 generates a training alternating sequence including node information and edge information according to the training information graph, including: using a preset traversal algorithm to traverse the training information graph to generate a training alternating sequence including node information and edge information. The preset traversal algorithm may be a breadth-first search (BFS) algorithm or a depth-first search (DFS) algorithm, which is not limited in the present application.

[0053] In some embodiments, the training information graph includes spans of addresses as input text fragments and types as representations of abstract concepts, wherein the types may be spans of length 1 of a vocabulary of node type information, actual edge type information, and virtual edge type information.

[0054] The representation of nodes and edges of alternating sequences relies on the observation that there are only two kinds of objects in the information graph: spans (as addresses of input text fragments) and types (as representations of abstract concepts). Since we can regard types as special spans of length 1 based on the vocabulary of all types (Q∪R∪U), we define these ordered sets consisting of text spans and type spans of length 1 as mixed spans. The indices in the ordered sets can be reversibly mapped back to types or text spans according to their sizes. Through the joint indexing of spans and types, the task of generating an information graph is therefore transformed into generating an alternating sequence of mixed spans.

[0055] In some embodiments, training an alternating sequence generation model according to the training text and the training alternating sequence includes: processing the output distribution of the alternating sequence generation model using an alternating mask to obtain an alternating sequence consisting of mutually spaced node information and edge information.

[0056] Exemplarily, the alternating sequence generation model is a neural decoder that is forced to generate alternating sequences only by decoding spans and types in a mixed manner, for each decoding step, the decoder of the present application has only linear space and time complexity with respect to the length of the input sequence, and due to its nature as a sequential decision process, it can capture the interdependence between referents and types.

[0057] like Figure 2 FIG. 1 is a flow chart of an embodiment of a method for extracting a graph from a text according to the present invention, and the embodiment includes:

[0058] S21, inputting the text to be extracted into the alternating sequence generation model trained by the aforementioned alternating sequence generation model training method to obtain a target alternating sequence;

[0059] S22. Generate a target information graph according to the target alternating sequence.

[0060] In this embodiment, when extracting information graphs from text through the model, the graphs are not modeled directly. Instead, the problem of extracting graphs from text is transformed into the problem of extracting alternating sequences from text. As a result, graph extraction from text has only linear time and space complexity, and the time and space efficiency are significantly improved.

[0061] In some embodiments, generating a target information graph according to the target alternating sequence comprises:

[0062] The target alternating sequence is processed according to a preset traversal algorithm used to train the alternating sequence generation model to generate a target information graph.

[0063] In order to more clearly introduce the technical solution of the present invention and to more directly prove the real-time performance and the benefits of the present invention over the prior art, the technical background, technical solution and experiments of the present invention will be introduced in more detail below.

[0064] summary

[0065] Text-to-Graph extraction aims to automatically extract information graphs consisting of references (or entities) and types from natural language text. Existing methods, such as table completion and pairwise scoring, show impressive performance on various information extraction tasks, but they are difficult to scale to datasets with longer input texts due to their second-order space / time complexity with respect to the input length. In this work, we propose a Hybrid SPan Generator (HySPA) to map information graphs into alternating sequences of node and edge types, and directly generate such sequences through a hybrid span decoder that can recurrently decode spans and types in linear time and space complexity. Extensive experiments on the ACE05 dataset show that our method also significantly outperforms existing methods on the joint entity and relation extraction task.

[0066] 1. Introduction

[0067] Information extraction (IE) can be viewed as a text-to-graph extraction task, which aims to extract an information graph consisting of references (or entities) and types from unstructured text (Li et al., 2014; Shi et al., 2017), where the nodes of the graph are references or entity types and the edges are relation types representing the relationships between nodes. Typical approaches to graph extraction are to decompose the extraction process into subtasks, such as named entity recognition (NER) (Florian et al., 2006, 2010) and relation extraction (RE) (Sun et al., 2011; Jiang and Zhai, 2007), and perform them separately (Chan and Roth, 2011) or jointly (Li and Ji, 2014; Eberts and Ulges, 2019).

[0068] Recent joint IE models (Wadden et al., 2019; Wang and Lu, 2020; Lin et al., 2020) have shown impressive performance on various IE tasks as they can mitigate error propagation and exploit interdependencies between tasks. Previous works often use pairwise scoring techniques to identify the types of relations between entities. However, this approach is computationally inefficient as it requires enumerating all possible entity pairs in a document, and due to the sparsity of relations between entities, the relation types are null values ​​in most cases. In addition, pairwise scoring techniques evaluate each relation type independently and therefore fail to capture the interrelationships between relation types of different referent pairs.

[0069] Another approach is to treat the joint information extraction task as a table filling problem (Zhang et al., 2017; Wang and Lu, 2020) and use a multi-dimensional recurrent neural network to generate a two-dimensional table (Graves et al., 2007). This can capture the interrelationships between entities and relations, but the space complexity grows quadratically with respect to the length of the input text, making this approach impractical for long sequences.

[0070] Some attempts, e.g., Seq2RDF (Liu et al., 2018) and IMoJIE (Kolluru et al., 2020), leverage the power of Seq2seq models (Cho et al., 2014) to capture the interrelationships between reference and type with first-order complexity, but they all use a pre-defined vocabulary for reference prediction, which depends heavily on the distribution of target words and cannot handle unseen out-of-vocabulary words.

[0071] To solve these problems, this application proposes a first-order method to reversibly map the target graph into an alternating sequence of nodes and edges, and applies a mixed span generator that directly learns to generate such an alternating sequence. The main contributions of this application are three-fold:

[0072] This application proposes a general technique to perform a reversible mapping between information graphs and alternating sequences (assuming a given graph traversal algorithm). Generating the alternating sequence is equivalent to generating the original information graph.

[0073] We propose a new neural decoder that is forced to generate alternating sequences by only decoding spans and types in a mixed manner. For each decoding step, our decoder has only linear space and time complexity with respect to the length of the input sequence, and due to its nature as a sequential decision process, it can capture the interdependencies between referents and types.

[0074] We conduct extensive experiments on the Automatic Content Extraction (ACE) dataset, which demonstrates that our model achieves state-of-the-art performance on the joint entity and relation extraction task aimed at extracting a knowledge graph from a piece of unstructured text.

[0075] 2. Model the infographic as an alternating sequence

[0076] Information graphs can be viewed as heterogeneous multigraphs (Li et al., 2014; Shi et al., 2017) G = (V, E), where V is a set of nodes (usually representing spans in the input documents (t s , t e )), E is a multiset of edges with node type mapping function φ: V→Q and edge type mapping function ψ: E→R. It is assumed that the node and edge types are extracted from a finite vocabulary. Node types can be used, for example, to represent entity types (PER, ORG, etc.), while edge types can represent relationships between nodes (PHYS, ORG-AFF, etc.). In this work, the present application represents node types as separate nodes that are connected to their node v by special edge types.

[0077] Representing information graphs as sequences: This application does not directly model the space of heterogeneous multigraphs G, but constructs a space from G to sequence S. π Mappings π =f s (G,π).f s It depends on a (given) ordering π of nodes and their edges in G, constructed by a graph traversal algorithm such as breadth-first search (BFS) or depth-first search (DFS) and an internal ordering of node and edge types. This application assumes that the resulting sequence s π Elements of iπ is obtained from a finite set consisting of node representation V, node type Q, edge type (real edge type) R, and "virtual" edge type U: s i π ∈V∪Q∪R∪U. The virtual edge type U = {[SOS], [EOS], [SEP]} does not represent an edge in G, but is used to control the generation of sequences, indicating the start / end of sequences and the division of levels in the graph.

[0078] This application further assumes that s π =s0 π ,…s n π , indicating that the graph has an alternating structure, where s0 π ,s2 π ,s4 π ,…represents node V, s1 π ,s3 π ,s5 π ,… represent real or virtual edges. In the case of BFS, this application uses it layer by layer, i.e. in order p i ,c i1 ,…,c ik ,p j The fact of visiting a node (where c ik is the parent node p i The kth child node of ik Connection, p j May or may not be equal to p i One of the child nodes of s π becomes a sequence,

[0079] s π =p i ,ψ(e i1 ), c i1 , ...,

[0080] ψ(e ik ), c ik ,[SEP],p j ,...

[0081] Among them, we use special edge types [SEP] to describe the hierarchy in the graph. This representation allows us to unambiguously recover the original graph if we know which type of graph traversal (BFS or DFS) is assumed. Algorithm 1 (which we use to convert graphs in training data into sequences) shows how an alternating sequence can be constructed using BFS traversal for a given graph. Figure 3 An alternating sequence of information multigraphs is shown. Length |s π |The size of the graph is O(|sπ a linear constraint of O(|V| + |E|) (which is also the complexity of typical graph traversal algorithms such as BFS / DFS).

[0082] Figure 3 : This application represents a directed multigraph as an alternating sequence of nodes (A, B, C, D, E) and edges (1, 2, 3, 4, [S]). Here, the graph is traversed by breadth - first search (BFS) in ascending order of node and edge types. "[s]" or [SEP] is a virtual edge type representing the end of each BFS level.

[0083]

[0084] Node and edge representation: The node and edge representation of this application (explained below) depends on the observation that there are only two types of objects in an information graph: spans (as addresses of input text segments) and types (as representations of abstract concepts). Since this application can consider types as special spans of length 1 based on the vocabulary of all types (Q ∪ R ∪ U), this application only needs O(nm+|Q ∪ R ∪ U|) indices to explicitly represent the concatenation - based span - type vocabulary and the representation of the input text, where n is the maximum input length, m is the maximum span length, and m << n. This application defines these ordered sets consisting of text spans and type spans of length 1 as hybrid spans. These indices can be reversibly mapped back to types or text spans according to their sizes (the details of this mapping are explained in Section 3.2). By the joint indexing of spans and types, the task of generating an information graph is thus transformed into generating an alternating sequence of hybrid spans.

[0085] Generating sequences: This application models the distribution p(s π ) with a sequence generator h with parameter θ (|s| is the length of s π ):

[0086]

[0087]

[0088] This application will discuss in the following sections how to force the sequence generator h to generate sequences only in the space S π because this application does not want h to assign non - zero probabilities to arbitrary sequences that do not have corresponding graphs.

[0089] 3. HySPA: Generation of Hybrid Spans for Alternating Sequences

[0090] In order to directly generate a target sequence (which alternates between nodes representing spans in the input and sets of node / edge types that depend on the extraction task of this application), this application first constructs a hybrid representation H, which is a concatenation of hidden representations from edge types, node types, and input text. This representation serves as both the context space and the output space of the decoder of this application. Then this application reversibly maps the indexes of both the spans and types of the input text to hybrid spans based on the representation H. Finally, the hybrid spans automatically generated by the hybrid span decoder are used to form the alternating sequence y π ∈S π By converting the graph extraction task into a sequence generation task, this application can easily use beam search decoding to reduce the exposure bias that may occur in the sequence decision process (Wiseman and Rush, 2016) to find a globally better graph representation.

[0091] High-level overview of HySPA: The HySPA model takes as input a piece of text (e.g., a sentence or paragraph) and predefined node and edge types, and outputs an alternating sequence representation of the information graph. This application enforces alternation in the generation of this sequence by applying an alternation mask to the output probabilities. The detailed architecture is described in the following subsections.

[0092] 3.1 Text and Type Encoders

[0093] Figure 4 shows the encoder architecture of the proposed model, where the symbol ⊕ is the concatenation operator, k is the index of the word vector in H0, and l e =|R|+|U|. The colored table on the right shows the meta-type assignments for different blocks of the concatenated word vectors from H0. For the node type set Q, edge type set R, and virtual edge type U, the application arranges the type list v as the concatenation of the label names of the edge type, virtual edge type, and node type, i.e.

[0094]

[0095]

[0096]

[0097]

[0098] in, represents the concatenation operator between two lists, are lists of type names in the sets R, U, and Q respectively (e.g. ). Note that the concatenation order between the type name lists can be arbitrary as long as it is consistent throughout the model. Then, as in the embedding part of the table-sequence encoder (Wang and Lu, 2020), for each type v i This application uses contextual word embeddings from pre-trained language models, GloVe embeddings (Pennington et al., 2014), and feature embeddings to embed type label symbols. GloVe’s full name is Global Vectors for Word Representation, which is a word representation tool based on count-based & overall statistics.

[0099]

[0100]

[0101]

[0102]

[0103]

[0104] Among them, l p =|R|+|U|+|Q| is the number of various types, W0∈R de×dm is the weight matrix of the linear projection layer, d e =d c +d g +d k is the total embedding dimension, d m is the size of the hidden layer of the model in this application. In this application, each type v i After embedding the context of the tags ∈v, this application takes the average of these tag vectors as v i , and freeze its updates during training. See Appendix A for more details.

[0105] This embedding pipeline is also used to embed words in the input text x. Different from the type embedding approach, this application represents words as contextual embeddings of the first subtoken from a pre-trained language model (LM, e.g. BERT (Devlin et al., 2018)) and fine-tunes the language model in an end-to-end manner.

[0106] In order to obtain the type embedding E v and text embedding E xAfter that, this application concatenates them along the sequence length dimension to form the hybrid representation H0. Since H0 is a concatenation of word vectors from four different types of tokens (i.e., edge types, virtual edge types, node types, and text), meta-type embeddings are applied to indicate this type difference between the vector blocks from the representation H0 (as Figure 4 shown). The final context representation H is obtained by element-wise addition of the meta-type embeddings and H0,

[0107]

[0108]

[0109]

[0110] where l h = l p + |x| is the height of the hybrid representation matrix H of this application.

[0111] 3.2, Reversible Mapping between Span&Types and Hybrid Spans

[0112] Given a span in the text, t = (t s , t e ) ∈ N 2 , t s < t e , this application converts the span t to an index k in the representation H through the mapping g k , k ≥ l p ,

[0113] k = g k (t s , t e ) = t s m + t e - t s - 1 + l p ∈ N,

[0114] where m is the maximum length of the span, l p = |R| + |U| + |Q|. This application keeps the type indices in the graph unchanged because they are less than l p and k ≥ l p . Since for an information graph, the maximum span length m of a reference is usually much smaller than the length of the text, i.e., m << n, this application can reduce the maximum magnitude of k from O(n 2 ) to O(nm) by only considering spans with lengths less than m, thus maintaining the linear space complexity of the decoder of this application with respect to the input text length n. Figure 5A specific example of the alternating sequence of the knowledge graph in the ACE05 dataset of this application is shown, and the alternating sequence representation (middle) example of the knowledge graph (bottom) from the ACE05 training set is shown, in which: He was captured in Baghdad late Monday night. Where A1 represents Algorithm 1, and this application takes m=16 and l in this example p = 19. "19" in the alternating sequence is the index of the span (0,1) of "he", "83" is the index of the span (4,5) of "Baghdad", and "10" is the dummy edge type [SEP]. The input text (top) of this graph is "He was arrested in Baghdad late Monday night".

[0115] Due to t s ,t e , k are all natural numbers. This application can construct an inverse mapping g t , convert the index k in H back to t = (t s ,t e ),

[0116]

[0117] t e =g t (k) = gt s (k)+max(0,kl p )mod m,

[0118] in, is the integer floor function, and mod is the modulus operator. Note that g t (k) can be applied directly to the indices in the type segment of H and keep their values ​​unchanged, i.e.,

[0119]

[0120] With this feature, this application can easily map g t Incorporated into the decoder of this application to convert the alternating sequence y π Map back to spans in the hybrid representation H.

[0121] 3.3 Mixed Span Decoder

[0122] Figure 6 The general model architecture of the hybrid span decoder of the present invention is shown. The decoder of the present invention takes the context representation H as input and cyclically decodes the alternating sequence y given a sequence start marker π N is the number of decoder layers before the softmax function. Represents the concatenation operator, H yN is the sequence y from the last decoder layer π The hybrid span decoder of this application can be understood as an autoregressive model that operates in the closed context space and output space defined by H.

[0123] Attention-based hybrid span encoding: Given an alternating sequence y π and the mapping g t (Section 3.2), the decoder of this application first converts y π Each index in is mapped to a span, (t si , t ei ) = g t (y i π ), based on the representation H, and then transforming the span of the attention mask M0 to allow the model to learn to represent the span as a weighted sum of the context word representation fragments referenced by the span,

[0124]

[0125]

[0126]

[0127]

[0128] in, It is the beginning of the sequence marker [CLS] |y π | times repeated hidden representation, text segment from H, H y This is the final representation of the mixture in this application with a span of y π W1, W2, b1, b2 are learnable parameters, t si ,t ei are the start and end positions of the span that this application is encoding. Note that for type spans of length 1, the result of the softmax calculation will always be 1, which results in its span representation being exactly the embedding vector that this application wants.

[0129] Traversal Embedding: To distinguish the mixed spans of different positions in yπ, a simple approach is to add a sinusoidal positional embedding to Hy (Vaswani et al., 2017). However, this approach treats alternating sequences as normal sequences and ignores the underlying graph structure it encodes. To alleviate this problem, this application proposes a novel traversal embedding method that captures traversal level information, parent-child information, and intra-level connection information as an alternative to the original positional embedding. The traversal embedding of this application can encode BFS or DFS traversal patterns. As an example, this application assumes BFS traversal here.

[0130] Figure 7 : Example of BFS traversal embedding of alternating sequence, [“him”, type, PER, [SEP], “Baghdad”, type, GPE, PHYS, “him”]. The BFS traversal embedding of this application is the point-wise sum of the layer embedding L, the parent-child embedding P, and the tree embedding T of a given alternating sequence y,

[0131] TravEmbed(y)=L(y)+P(y)+T(y)∈R |y|×dm

[0132] where layer embedding assigns the same embedding vector L to each position of BFS traversal level i i , and fill in the values ​​of the embedding vector according to the non-parametric sinusoidal positional embedding, because we want our embeddings to be extrapolated to sequences longer than any sequence in the training set. Parent-child embeddings assign different randomly initialized embedding vectors to the positions of parent and child nodes in a BFS traversal level to help the model distinguish between the two types of nodes. In order to encode the intra-layer connection information, our insight is that the connection between each node in the BFS layer can be viewed as a tree of depth 3, where the first depth takes the parent node, the second depth is filled with edge types, and the third depth consists of the child nodes corresponding to each edge type. Our tree embedding is then formed by encoding the position information of the depth 3 tree using the tree position embedding (Shiv and Quirk, 2019) at each BFS level. Figure 7 A concrete example of how these embeddings work for a given alternating sequence is shown. The obtained traversal embeddings are then added pointwise to the alternating sequence H y The hidden representation of is used to inject the traversal information of the graph structure.

[0133] The inner block is constructed by transforming the mixed representation H and the target sequence representation H y The input text representation of the slice H text , we apply an N-layer transformer structure with hybrid attention (He et al., 2018) to allow our model to utilize attention from different layers when decoding edges or nodes of alternating sequences. Note that our hybrid span decoder is perpendicular to the actual choice of neural structure of the internal block. We choose the design of hybrid attention transformer (He et al., 2018) because its hierarchical coordination properties are empirically more suitable for our heterogeneous decoding of two different types of sequence elements. The detailed structure of the internal block is explained in Appendix E.

[0134] Hybrid span decoding: For the hybrid span decoding module, the present application first cuts out the alternating sequence y from the output of the N-layer internal block π The hidden representation of y N。Then for each hidden representation h yi N ∈H y N , 0 ≤ i ≤ |y π |, this application uses two different linear layers to obtain the start position representation s yi and the end position representation e yi ,

[0135]

[0136]

[0137] where W5, W6 ∈ R dm×dm and b5, b6 ∈ R dm are learnable parameters. Then this application calculates the scores of the target spans of the type segment and the text segment of H respectively, and concatenates them together before the final softmax operator to jointly estimate the probabilities of text spans and type spans,

[0138]

[0139]

[0140]

[0141]

[0142]

[0143]

[0144]

[0145] where, h i is the score vector of the possible spans in the type segment of H, and t i is the score vector of the possible spans in the text segment of H. Since the span length of the type span is always 1, this application only needs an element-wise addition calculation between the start position score h si and the end position score h ei to calculate h i . The entries of t i contain the scores of the text spans, t si,j +t ei,k ; k - j < m, calculated with the help of an unfolding function that takes the vector t ei ∈R nConverted to a stack of n sliding windows of size m, maximum span length, and stride 1. Alternating mask m a ∈R lp ,m a ′∈R n Defined as:

[0146]

[0147]

[0148] Among them, l e =|R|+|U| is the total number of edge types. Thus, although the present application has a joint model of node and edge types, the output distribution is enforced by the alternating mask to produce alternating decodings of node and edge types, which is the main reason why the present application calls this decoder a mixed span decoder.

[0149] 4. Experiment

[0150] 4.1 Experimental Setup

[0151] This application tests the model of this application on the ACE 2005 dataset distributed by LDC3, which includes 14,500 sentences, 38,000 entities (with 7 types) and 7,100 relations (with 6 types). These datasets are from the general news field. For details, see Appendix C.

[0152] Following previous work, this application uses F1 as the evaluation metric for NER and RE. For the NER task, a prediction is marked as correct when both the type and boundary span match the gold entity. For the RE task, a prediction is correct when both the relation type and boundary of the two entities are correct.

[0153] 4.2 Implementation Details

[0154] When training our model, we applied a cross entropy loss with a label smoothing factor of 0.1. We trained our model with 2048 labels per batch (approximately 28 batches) and used the AdamW optimizer (Loshchilov and Hutter, 2018) for 25,000 iterations with a learning rate of 2e -4, weight decay is 0.01, and warm-up is performed 2000 times using the inverse square root scheduler. Following the TabSeq model (Wang and Lu, 2020), this application uses RoBERTa-large (Liu et al.) or ALBERT-xxlarge-v1 (Lan et al., 2020) as a pre-trained language model during training and slows down its learning rate by 0.1 times. When ALBERT-xxlarge-v1 has a drop rate of 0.1, the hidden drop rate of RoBERTalarge reaches 0.2. The drop rate of the mixed span decoder of this application during training is also 0.1. This application sets the maximum span length, m=16, and the hidden size of the model of this application, d m = 256, and the number of decoder blocks, N = 12. Although theoretically beam search should help us reduce exposure bias, we did not observe any performance gain during the grid search of beam size and length penalty on the validation set (detailed grid search settings are in Appendix A). Therefore, we set the normal beam size to 1 and the length penalty to 1, and leave this theoretical-experimental contradiction for future research. Our models were built using the FAIRseq toolkit (Ott et al., 2019) for efficient distributed training, and all experiments were performed on two NVIDIA TITAN X GPUs.

[0155]

[0156] Table 1: Joint NER and RE F1 scores of the IE model on the ACE05 test set. The complexity of the entity and relation decoding parts of the model is calculated (n is the length of the input text). The performance of the TabSeq model reported here is based on the same ALBERT-xxlarge (Lan et al., 2020) pre-trained language model as in this application.

[0157]

[0158] Table 2: Ablation study on the ACE05 test set. "-Traversal-embedding": This application removes the traversal embedding and uses the sinusoidal position embedding instead. The following ablation is based on the model after this ablation. "-Masking": This application removes the alternating mask from the mixed span decoder. "--BFS": This application uses DFS instead of BFS as traversal. "-Mixedattention": This application removes the mixed attention layer and uses the standard transformer encoder-decoder structure. "-Span-attention": This application removes the span attention in the span encoding module and instead averages the words in the span.

[0159] 4.3 Results

[0160] Table 1 compares our model with previous state-of-the-art results on the ACE05 test set. Compared to the previous SOTA, TabSeq (Wang and Lu, 2020) using the ALBERT pre-trained language model, our model using ALBERT achieves significantly better performance in both NER and RE scores, while maintaining a linear space complexity that is an order of magnitude smaller than TabSeq. Compared to all previous joint IE models, our model is the first joint model with both linear space and time complexity, and thus has the best scalability for large-scale real-world applications.

[0161] 4.4 Ablation study

[0162] To demonstrate the effectiveness of our method, we conducted ablation experiments on the ACE05 dataset. As shown in Table 2, after we remove the traversal embedding, the RE F1 score drops significantly, indicating that our traversal embedding can help encode the graph structure and improve relationship prediction. In addition, if the alternation masking is abandoned, both the NER F1 and RE F1 scores drop significantly, which proves the importance of enforcing the alternation pattern. We can observe that the mixed attention layer contributes significantly to relationship extraction. This is because layer-by-layer coordination can help the decoder to decompose source features and utilize different layer features between entity and relationship prediction. We can also observe that the performance of DFS traversal is worse than BFS. We suspect that this is because due to the nature of the knowledge graph, the resulting alternation sequence from DFS is usually longer than the alternation sequence from BFS, which increases the difficulty of learning.

[0163] 4.5 Error Analysis

[0164] After analyzing the 80 remaining errors, this application categorizes and discusses the following common cases: Figure 8 (Figure 2) shows the distribution of residual errors on the ACE05 test set. These may require additional features and strategies to address.

[0165] Insufficient context: In many examples, the answer entity is a pronoun, which cannot be accurately typed given the limited context: in “This application notes that they say they do not want to use the word destroyed, in fact, they say let others do it”, it is difficult to correctly classify this application as an organization. This can be mitigated by using the entire document as input, leveraging cross-sentence context.

[0166] Uncommon Words: The rare word problem is that words in the test set rarely appear in the training set and usually do not appear in the dictionary. In the sentence "The base also has Navy FA-18 and Navy Heriers", the term "Heriers" (a vehicle that the model incorrectly classifies as a person) neither appears in the training set nor is it well understood by the pre-trained language model; in this case, the model can only rely on subword-level representations.

[0167] Requires background knowledge: Often the entities mentioned in a sentence are difficult to infer from the context, but are easily identified by consulting a knowledge base: In “Airbus should have sounded a stronger alarm”, our model incorrectly predicts that Airbus is a vehicle, whereas Airbus here refers to the European aerospace company. Our system also split the United Nations Security Council into two entities, the United Nations and the Security Council, producing a non-existent relation triple (Security Council, part of the United Nations). Such errors can be avoided by consulting a knowledge base such as DBpedia (Bizer et al., 2009) or performing entity linking.

[0168] Inherent ambiguity: Many examples are inherently ambiguous, e.g. the European Union can be classified as either an organization or a political entity, while some entities (e.g., a military base) can be both a location and an organization or facility.

[0169] 5. Related Work

[0170] NER is often done jointly with RE to reduce error propagation and learn mutual relations between tasks. One approach is to consider the joint task as a square table filling problem (Miwa and Sasaki, 2014; Gupta et al., 2016; Wang and Lu, 2020), where the i-th column or row represents the i-th token. The table has a diagonal indicating the sequential tags of entities and other entries as relations between pairs of tags. Another line of work performs RE after NER. In the work of Miwa and Bansal (2016), the authors used BiLSTM (Graves et al., 2013) for NER, and thus used a dependency graph-based Tree-LSTM (Tai et al., 2015) for RE. Wadden et al. (2019) and Luan et al. (2019), on the other hand, adopt the approach of building a dynamic text span graph to detect entities and relations. Extending Wadden et al. (2019), Lin et al. (2020) introduced ONEIE, which further combines global features based on cross-subtask and instance constraints, aiming to extract IE results as graphs. Note that the difference between our model and ONEIE (Lin et al., 2020) is that our model automatically captures global relations through autoregressive generation, while ONEIE uses feature engineering templates; in addition, ONEIE requires pairwise classification for relation extraction, while our method effectively generates existing relations and entities.

[0171] Although several Seq2Seq based models have been proposed (Zhang et al., 2020; Zeng et al., 2018, 2020; Wei et al., 2019; Zhang et al., 2019) to generate triplets (i.e., node-edge-node), our model is fundamentally different from them in that: (1) it generates a BFS / DFS traversal of the target graph, which captures the dependencies between nodes and edges and has a shorter target sequence, and (2) we model nodes. Since the spans in text are independent of vocabulary, even if the node tag is an uncommon word or an unseen word, we can still generate spans for it based on contextual information.

[0172] 6. Conclusion

[0173] In this work, we propose the Hybrid Span Generation (HySPA) model, the first end-to-end text-to-graph extraction model with linear space and time complexity in the graph decoding stage. In addition to scalability, the model achieves state-of-the-art performance on the ACE05 joint entity and relation extraction task. Given the flexibility of the structure of our hybrid span generator, there are still rich research directions in the future, such as incorporating external knowledge for hybrid span generation, applying more effective sparse self-attention, and developing better search methods to find more globally reasonable graphs represented by alternating sequences.

[0174] In some embodiments, another method is provided in which the mixed attention layer is removed and the standard Transformer encoder-decoder structure is used. This version has a simpler structure but performs worse than the version using the mixed attention layer.

[0175] In some embodiments, another method is provided, in which DFS traversal is used instead of BFS traversal to construct an alternating sequence representation of the graph, and this version also uses DFS traversal embedding (see Appendix D for details) instead of BFS traversal embedding. The graph extraction accuracy of this version is inferior to that of BFS traversal.

[0176] In some embodiments, another method is provided in which the words in the span are averaged to encode the span instead of performing attention-based span encoding. This version of the model structure is simpler and has fewer model parameters, but the graph extraction accuracy is inferior to attention-based span encoding.

[0177] Appendix A: Hyperparameters

[0178] We use 100-dimensional GloVe word embeddings trained on 6B tokens as initialization and freeze their updates during training. Feature embeddings are encoded with 30-dimensional LSTM, and GloVe embeddings of out-of-vocabulary tokens are replaced with randomly initialized vectors, following Wang and Lu (2020). We use gradient clipping of 0.25 during training. The number of heads of our hybrid attention is set to 8. The beam size and length penalty are determined by grid search on the validation set of the ACE05 dataset, with beam sizes ranging from 1 to 7 with a step size of 1 and length penalties from 0.7 to 1.2 with a step size of 0.1. We choose the best beam size and length penalty based on the metric of the relation extraction F1 score.

[0179] Appendix B: Training Details

[0180] The model used in this application uses the ALBERT-xxlarge pre-trained language model with 236 million parameters. On average, the best model used in this application using ALBERT-xxlarge can be distributed trained on two NVIDIA TITAN X GPUs for 20 hours.

[0181] Appendix C: Data

[0182] The Automatic Content Extraction (ACE) 2005 dataset contains English, Arabic, and Chinese training data used for the 2005 Automatic Content Extraction (ACE) technical evaluation, providing entity, relation, and event annotations. This application follows Vaden et al. (2019) for preprocessing and data splitting. The preprocessed data contains 7100 relations, 38k entities, and 145k sentences. The split contains 10051 training samples, 2424 development samples, and 2050 test samples.

[0183] Appendix D: DFS traversal embedding

[0184] Since the parent-child information is already included in the intra-layer connections of the DFS traversal, this application only has the sum of the layer embedding and the connection embedding of the DFS traversal embedding. Similar to BFS embedding, DFS layer embedding assigns the same embedding vector Li to each position at DFS traversal layer i, but the values ​​of the embedding vectors are randomly initialized instead of being filled with non-parametric sinusoidal position embeddings because there is no information between the traversal levels of proximity DFS. However, for elements in the DFS level, this application does have clear distance information, that is, for DFS level D = [A, B, C, ..., [sep]], the distance from A to the element [A, B, C, ..., [sep]] is [0, 1, 2; 3, ..., |D|-1]. This application encodes this distance information using sinusoidal position embedding, which becomes the connection embedding of this application, capturing the intra-layer connection information.

[0185] Appendix E: Transformers with Hybrid Attention Layers

[0186] This application first extracts the hidden representation of the input text from the mixed representation H and denotes it as H text , then the input text represents H text and hybrid span coding H y The output of is fed into a stack of N hybrid attention / feedforward blocks with Fig. 9 The structure shown.

[0187] Since generating node and edge types may require features from different layers, this paper uses hybrid attention (He et al., 2018), which allows our model to be more efficient in text segments, H text When encoding the target, features from different attention layers are used, Hy ,

[0188]

[0189]

[0190] Where n = |x| is the length of the input text, l m =|x|+|yπ| is the total length of the source feature and the target feature. text and the target feature H y The concatenation of is denoted as H0, and the source / target embedding (He et al., 2018) is added to H0 before the first layer of hybrid attention to allow the model to distinguish features from the source sequence and the target sequence. The hybrid attention layer is combined with the feedforward layer to form the decoder block:

[0191]

[0192]

[0193] Where W q,k,v , b q,k,v , W3∈R dm×4dm , W4∈R 4dm×dm , b3, b4 are learnable parameters, and LayerNorm is a layer normalization layer (Ba et al., 2016). The decoder blocks are stacked N times to obtain the final hidden representation H N , and output the final representation H of the target sequence N y The time complexity of hybrid attention in encoding source features is O(n 2 ), but due to the causal masking of the target features, the present application can cache the hidden representation of this part when generating the target tag, thereby keeping the time complexity of each decoding step O(n).

[0194] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of combined actions, but those skilled in the art should be aware that the present invention is not limited by the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention. In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0195] In some embodiments, an embodiment of the present invention provides a non-volatile computer-readable storage medium, in which one or more programs including execution instructions are stored. The execution instructions can be read and executed by an electronic device (including but not limited to a computer, a server, or a network device, etc.) to execute any of the above-mentioned methods for extracting images from text of the present invention.

[0196] In some embodiments, an embodiment of the present invention further provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes any one of the above-mentioned methods for extracting images from text.

[0197] In some embodiments, 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 to enable the at least one processor to execute a method for extracting images from text.

[0198] In some embodiments, an embodiment of the present invention further provides a storage medium having a computer program stored thereon, wherein the program implements a method for extracting a graph from a text when executed by a processor.

[0199] Fig.10 is a schematic diagram of the hardware structure of an electronic device for executing a method for extracting a graph from a text provided by another embodiment of the present application, such as Fig.10 As shown, the device includes:

[0200] One or more processors 1010 and memory 1020, Fig.10 A processor 1010 is taken as an example.

[0201] The device for executing the method of extracting graphs from text may further include: an input device 1030 and an output device 1040 .

[0202] The processor 1010, the memory 1020, the input device 1030 and the output device 1040 may be connected via a bus or other means. Fig.10 The example of connecting through bus is taken in the following.

[0203] The memory 1020, 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 method for extracting a graph from a text in the embodiment of the present application. The processor 1010 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 1020, that is, the method for extracting a graph from a text in the above method embodiment is implemented.

[0204] The memory 1020 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the device for extracting a graph from a text, etc. In addition, the memory 1020 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 1020 may optionally include a memory remotely arranged relative to the processor 1010, and these remote memories may be connected to the device for extracting a graph from a text 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.

[0205] The input device 1030 may receive input digital or character information and generate signals related to user settings and function control of the device for extracting images from text. The output device 1040 may include a display device such as a display screen.

[0206] The one or more modules are stored in the memory 1020, and when executed by the one or more processors 1010, the method of extracting a graph from a text in any of the above method embodiments is performed.

[0207] 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.

[0208] The electronic devices of the embodiments of the present application exist in various forms, including but not limited to:

[0209] (1) Mobile communication devices: These devices are characterized by their mobile communication functions and their main purpose is to provide voice and data communications. These terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.

[0210] (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: PDA, MID and UMPC devices, such as iPad.

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

[0212] (4) Other electronic devices with data interaction functions.

[0213] 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 shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0214] 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 general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology 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.

[0215] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application 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 application.

Claims

1. A method for training an alternating sequence generation model, comprising: Acquire a training sample pair from a sample library, wherein the training sample pair includes a paired training text and a training information graph, wherein the training information graph includes a plurality of nodes and at least one edge connecting two of the plurality of nodes; Generate a training alternating sequence including node information and edge information according to the training information graph; Training an alternating sequence generation model according to the training text and the training alternating sequence; The alternating sequence generation model is a mixed span decoder, which is N The output of the internal block of the layer is cut out in alternating sequence y π Hidden representation of H y N , then for each hidden representation h yi N ∈ H y N , 0≤ i ≤| y π |, using two different linear layers to obtain the starting position representation s yi and end position e yi , in, m is the maximum span length, d m is the size of the hidden layer, W 5, W 6∈ R dm×dm and b5, b6∈ R dm is a learnable parameter, and then jointly estimates the probability of text span and type span: in, lp is the number of various types of node type sets, edge type sets, and virtual edge type sets, H types For input type representation, H text For input text representation, n is the maximum input length of the input text, h i yes H The score vector of the span in the type segment, and t i yes H The score vector of the spans in the text segment, alternating mask m a ∈ R lp , m a ´∈ R n Defined as: in, l e =| R | + | U | is the total number of edge types.

2. The method according to claim 1, characterized in that The step of generating a training alternating sequence including node information and edge information according to the training information graph comprises: The training information graph is traversed using a preset traversal algorithm to generate a training alternating sequence including node information and edge information.

3. The method according to claim 1 or 2, characterized in that: The training alternating sequence includes node information and edge information that are spaced apart from each other.

4. The method according to claim 3, characterized in that The node information includes node type information, and the edge information includes actual edge type information and virtual edge type information.

5. The method according to claim 4, characterized in that The training information graph includes text spans as addresses of input text fragments and types as representations of abstract concepts, wherein the types are spans of a length of 1 for a vocabulary of node type information, actual edge type information, and virtual edge type information.

6. The method according to claim 3, characterized in that: Training an alternating sequence generation model according to the training text and the training alternating sequence includes: The output distribution of the alternating sequence generation model is processed using an alternating mask to obtain an alternating sequence consisting of mutually spaced node information and edge information.

7. A method for extracting a graph from text, comprising: Inputting the text to be extracted into the alternating sequence generation model trained by the method described in any one of claims 1 to 6 to obtain a target alternating sequence; A target information graph is generated according to the target alternating sequence.

8. The method according to claim 7, characterized in that Generating a target information graph according to the target alternating sequence comprises: The target alternating sequence is processed according to a preset traversal algorithm used to train the alternating sequence generation model to generate a target information graph.

9. 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 7-8.

10. A computer-readable 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 7 to 8 are implemented.

Citation Information

Patent Citations

  • Word graph rescoring method and system for deep learning language models

    CN108415898A

  • Text analysis model training method and device and text analysis method and device

    CN111008266A

  • Data processing method, device and equipment and storage medium

    CN112149400A

  • Sequence labeling method and system, computer readable storage medium and computer equipment

    CN112270181A

  • Method, system and computer readable record medium for refining web document using text pattern extraction

    JP2012018667A