A semantic analysis method, device, electronic device and storage medium

By introducing a syntax-based two-layer encoder decoder model into the semantic analytical model, the natural language is directly vectorized and the abstract syntax tree operation sequence is generated, and the semantic analytical inaccuracy problem is solved in the existing technology due to the lack of obvious semantic correspondence relationships, and higher semantic analytical accuracy is achieved.

CN113486647BActive Publication Date: 2025-03-18CHINA CONSTRUCTION BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110744721.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-30
Publication Date
2025-03-18
Estimated Expiration
2041-06-30

AI Technical Summary

Technical Problem

The existing semantic analytical model constructs semantic correspondence by manually defining vocabulary or learning vocabulary from paired natural language and knowledge bases. However, the semantic correspondence constructed in this way is not obvious enough, resulting in inaccurate representation of the meaning of semantic analysis of natural language.

Method used

采用基于语法的双层编码器解码器模型(GCDL enc-dec model),通过第一层编码解码器对自然语言向量进行处理,得到编码向量和抽象概要树操作序列,接着利用第二层编码解码器对抽象概要树操作序列和编码向量进行处理,生成抽象语法树操作序列,并通过语法模型进行意义转换,得到自然语言的意义表示。

Benefits of technology

Improve the accuracy of natural language semantic analysis, avoid the problem of low accuracy due to the long generated operation sequence, and does not need to construct a vocabulary.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113486647B_ABST
    Figure CN113486647B_ABST
Patent Text Reader

Abstract

The present invention provides a semantic parsing method, device, electronic device and storage medium, wherein the target natural language vector obtained after vectorization processing is input into a pre-established GCDLenc-dec model; the target natural language vector is processed by the first layer codec of the GCDLenc-dec model to obtain a target coding vector, and the target coding vector is processed to obtain a target abstract summary tree operation sequence; the target abstract summary tree operation sequence and the target coding vector are processed by the second layer codec of the GCDLenc-dec model to obtain a target abstract syntax tree operation sequence; the target abstract syntax tree operation sequence is input into a conversion system to obtain a target abstract syntax tree, and the target abstract syntax tree is converted into meaning by using a syntax model to obtain a target natural language meaning representation. The present invention can improve the accuracy of semantic parsing of natural language.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and more specifically, to a semantic parsing method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of artificial intelligence, the use of artificial intelligence to build a semantic parsing system that understands natural language and enables communication between people and computers is becoming more and more widely used in academia and industry. The core component of the semantic parsing system is semantic parsing.

[0003] Existing semantic parsing models construct semantic correspondences by manually defining vocabularies or learning and obtaining vocabularies from paired natural languages ​​and knowledge bases, thereby achieving semantic parsing of natural semantics. However, the semantic correspondences constructed in this way are not obvious enough, resulting in inaccurate meaning representation obtained by semantic parsing of natural languages. Summary of the invention

[0004] The present invention provides a semantic parsing method, device, electronic device and storage medium, aiming at improving the accuracy of semantic parsing of natural language.

[0005] A first aspect of the present invention discloses a semantic parsing method, the method comprising:

[0006] Obtaining a target natural language, and inputting a target natural language vector obtained by vectorizing the target natural language into a pre-established GCDL enc-dec model, wherein the GCDL enc-dec model includes a first-layer codec and a second-layer codec obtained by training based on a training example, wherein the training example includes a natural language sample and a target meaning representation corresponding to the natural language sample;

[0007] Using the first layer codec to process the target natural language vector to obtain a target coding vector, and processing the target coding vector to obtain a target abstract summary tree operation sequence;

[0008] Processing the target abstract summary tree operation sequence and the target coding vector using the second layer codec to obtain a target abstract syntax tree operation sequence;

[0009] The target abstract syntax tree operation sequence is input into a conversion system to obtain a target abstract syntax tree, and a grammar model is used to perform meaning conversion on the target abstract syntax tree to obtain a meaning representation of the target natural language.

[0010] Optionally, the process of obtaining the first-layer codec and the second-layer codec based on training examples includes:

[0011] Acquire a training instance, wherein the training instance includes a natural language sample and a target meaning representation corresponding to the natural language sample;

[0012] Inputting the target meaning representation corresponding to the natural language sample into the grammar model to obtain an abstract syntax tree and an abstract summary tree;

[0013] Inputting the abstract syntax tree and the abstract summary tree into the conversion system, causing the conversion system to process the abstract syntax tree to obtain a first abstract syntax tree operation sequence, and to process the abstract summary tree to obtain a first abstract summary tree operation sequence;

[0014] Inputting the natural language sample vector obtained after vectorization processing of the natural language into the first layer codec to be trained to obtain a coding vector, and processing the coding vector to obtain a second abstract summary tree operation sequence;

[0015] Inputting the encoding vector and the second abstract summary tree operation sequence into the second layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence;

[0016] Inputting the second abstract syntax tree operation sequence into the conversion system to obtain an abstract syntax tree, and performing semantic parsing on the abstract syntax tree using the syntax model to obtain a meaning representation of the natural language sample;

[0017] Calculate using the first abstract syntax tree operation sequence, the first abstract summary tree operation sequence, the second abstract syntax tree operation sequence, and the second abstract syntax tree operation sequence to obtain a loss function;

[0018] The training goal is to make the meaning representation of the natural language sample approach the target meaning representation, and the parameters of the first layer codec to be trained and the second layer codec to be trained are adjusted by the loss function until the first layer codec to be trained and the second layer codec to be trained converge, so as to obtain the first layer codec and the second layer codec.

[0019] Optionally, the first-layer codec includes a sentence encoder and an abstract summary tree decoder, the natural language sample vector obtained after vectorization processing of the natural language is input into the first-layer codec to be trained to obtain a coding vector, and the coding vector is processed to obtain a second abstract summary tree operation sequence, including:

[0020] Inputting the natural language sample vector obtained after vectorization processing of the natural language into the sentence encoder to obtain an encoding vector;

[0021] The encoding vector is input into the abstract summary tree decoder, so that the abstract summary tree decoder processes the encoding vector to obtain a second abstract summary tree operation sequence.

[0022] Optionally, the second codec includes an abstract summary tree encoder and an abstract syntax tree decoder, and the step of inputting the encoding vector and the second abstract summary tree operation sequence into the second-layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence includes:

[0023] Inputting the second AST operation sequence into the AST encoder to obtain encoding information of the second AST operation sequence;

[0024] The encoding information of the second abstract summary tree operation sequence and the encoding vector are input into the abstract syntax tree decoder to obtain a second abstract syntax tree operation sequence.

[0025] Optionally, the using the first layer codec to process the target natural language vector to obtain a target encoding vector, and processing the target encoding vector to obtain a target abstract summary tree operation sequence includes:

[0026] Processing the target natural language vector using the sentence encoder to obtain a target encoding vector;

[0027] The target coding vector is processed by using the abstract summary tree decoder to obtain a target abstract summary tree operation sequence.

[0028] Optionally, the using the second layer codec to process the target abstract summary tree operation sequence and the target encoding vector to obtain a target abstract syntax tree operation sequence includes:

[0029] Processing a target abstract summary tree operation sequence using the abstract summary tree encoder to obtain encoding information of the target abstract summary tree operation sequence;

[0030] The encoding information of the target abstract summary tree operation sequence is processed by using the abstract syntax tree decoder to obtain a target abstract syntax tree operation sequence.

[0031] A second aspect of the present invention discloses a semantic parsing device, the device comprising:

[0032] A first acquisition unit is used to acquire a target natural language, and input a target natural language vector obtained by vectorizing the target natural language into a pre-established GCDL enc-dec model, wherein the GCDL enc-dec model includes a first-layer codec and a second-layer codec obtained by training based on a training example, and the training example includes a natural language sample and a target meaning representation corresponding to the natural language sample;

[0033] A first processing unit is used to process the target natural language vector using the first layer codec to obtain a target coding vector, and to process the target coding vector to obtain a target abstract summary tree operation sequence;

[0034] A second processing unit is used to process the target abstract summary tree operation sequence and the target coding vector by using the second layer codec to obtain a target abstract syntax tree operation sequence;

[0035] The first semantic parsing unit is used to input the target abstract syntax tree operation sequence into a conversion system to obtain a target abstract syntax tree, and perform meaning conversion on the target abstract syntax tree based on a grammar model to obtain a meaning representation of the target natural language.

[0036] Optionally, the process of obtaining the first-layer codec and the second-layer codec based on the training instance set includes:

[0037] A second acquisition unit is used to acquire a training instance, wherein the training instance includes a natural language sample and its corresponding target meaning representation;

[0038] A third processing unit, configured to input the target meaning representation corresponding to the natural language sample into the grammar model to obtain an abstract syntax tree and an abstract summary tree;

[0039] a conversion unit, configured to input the abstract syntax tree and the abstract summary tree into the conversion system, so that the conversion system processes the abstract syntax tree to obtain a first abstract syntax tree operation sequence, and processes the abstract summary tree to obtain a first abstract summary tree operation sequence;

[0040] a fourth processing unit, configured to input the natural language sample vector obtained after vectorization processing of the natural language into the first-layer codec to be trained to obtain a coding vector, and process the coding vector to obtain a second abstract summary tree operation sequence;

[0041] A fifth processing unit, configured to input the encoding vector and the second abstract summary tree operation sequence into a second-layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence;

[0042] A second semantic parsing unit, configured to input the second abstract syntax tree operation sequence into the conversion system to obtain a third abstract syntax tree, and perform semantic parsing on the third abstract syntax tree using the syntax model to obtain a meaning representation of the natural language sample;

[0043] a calculation unit, configured to calculate by using the first abstract syntax tree operation sequence, the first abstract summary tree operation sequence, the second abstract syntax tree operation sequence, and the second abstract syntax tree operation sequence to obtain a loss function;

[0044] A training unit is used for taking the meaning representation of the natural language sample approaching the target meaning representation as a training goal, adjusting the parameters of the first layer codec to be trained and the second layer codec to be trained by using the loss function, until the first layer codec to be trained and the second layer codec to be trained converge, so as to obtain the first layer codec and the second layer codec.

[0045] The third aspect of the present invention shows an electronic device, which includes a processor and a memory, wherein the memory is used to store program code and data for semantic parsing, and the processor is used to call the program instructions in the memory to execute a semantic parsing method as shown in the first aspect of the present invention.

[0046] A fourth aspect of the present invention shows a storage medium, which includes a storage program, wherein when the program is running, the device where the storage medium is located is controlled to execute a semantic parsing method as shown in the first aspect of the present invention.

[0047] The present invention provides a semantic parsing method, device, electronic device and storage medium, which obtain a target natural language vector by vectorizing the acquired target natural language, input the natural language vector into a pre-established GCDLenc-dec model, process the target natural language vector based on the first layer codec in the GCDL enc-dec model to obtain a target coding vector, and process the target coding vector to obtain a target abstract summary tree operation sequence, use the second layer codec in the GCDL enc-dec model to process the target abstract summary tree operation sequence and the target coding vector to obtain a target abstract syntax tree operation sequence, finally input the target abstract syntax tree operation sequence into a conversion system to obtain a target abstract syntax tree, and use a syntax model to perform semantic parsing on the target abstract syntax tree to obtain a meaning representation of the target natural language. The technical solution provided by the present invention directly uses the first-layer codec in the pre-established GCDL enc-dec model to process the target natural language vector obtained after vectorization processing of the target natural language, and obtains the corresponding coding vector and target abstract summary tree operation sequence, and then uses the second-layer codec in the GCDLenc-dec model to process the obtained coding vector and the target abstract summary tree operation sequence to obtain the target abstract syntax tree operation sequence, so that the corresponding meaning representation can be obtained by processing the obtained target abstract syntax tree operation sequence, without the need to construct a vocabulary, thereby improving the accuracy of semantic parsing of natural language. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0049] Figure 1 It is a structural diagram of an existing semantic parsing method;

[0050] Figure 2 It is a structural diagram of another existing semantic parsing method;

[0051] Figure 3 A structural diagram of a semantic parsing system provided by an embodiment of the present invention;

[0052] Figure 4 A schematic flow chart of a method for generating a GCDL enc-dec model provided in an embodiment of the present invention;

[0053] Figure 5A flowchart of a semantic parsing method provided by an embodiment of the present invention;

[0054] Figure 6 A schematic diagram of the structure of a semantic parsing device provided by an embodiment of the present invention;

[0055] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.

[0057] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0058] It should be noted that the concepts such as "first" and "second" mentioned in the disclosure of the present invention are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0059] It should be noted that the modifications of "one" and "plurality" mentioned in the disclosure of the present invention are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0060] Abstract Syntax Tree: Abstract Syntax Tree, AST is a tree representation of the grammatical structure of the source code. Each node in the tree represents the structure of part of the source code.

[0061] Transition system: It consists of a set of states and a set of transitions. The transition system is used to describe dynamic processes, and transitions represent the migration between states.

[0062] Syntax model: The built-in ast module in Python can be used to parse the code into an abstract syntax tree under the standard library. The abstract syntax tree defined by the standard library is further converted into an abstract syntax tree described by ASDL. The abstract syntax tree can also be converted back to a meaning representation.

[0063] From the above background technology, it can be seen that in the prior art, the existing semantic parsing model constructs semantic correspondence by manually defining a vocabulary list or learning and obtaining a vocabulary list from paired natural languages ​​and knowledge bases, thereby realizing semantic parsing of natural semantics. However, the semantic correspondence constructed in this way is not obvious enough, resulting in inaccurate meaning representation obtained by semantic parsing of natural language.

[0064] In order to avoid the problem of inaccurate meaning representation obtained by semantic parsing of natural language due to unclear semantic correspondence, in the prior art, semantic parsing of natural language is achieved through a seq2seq model based on an encoder-decoder architecture. Specifically, the natural language is split into words and input into a seq2seq model, so that the seq2seq model processes each input word in turn to generate corresponding meaning representations, such as Figure 1 As shown, however, the meaning generated in this way runs the risk of not being consistent with grammatical logic.

[0065] In order to solve this problem, in the prior art, natural language is split into words and input into a seq2seq model, so that the seq2seq model processes each input word in turn to generate a corresponding operation sequence, and then inputs the generated operation sequence into an abstract syntax tree for processing to obtain a corresponding meaning representation, such as Figure 2 Although the meaning representation generated in this way does not have the problem of not conforming to grammatical logic, the abstract syntax tree requires the input operation sequence to meet a certain length, which requires the seq2seq model to generate a longer operation sequence. If the operation sequence generated by the seq2seq model is too long, it will affect the accuracy of the generated operation sequence, resulting in a low accuracy rate of the final generated meaning representation.

[0066] Therefore, the present invention proposes a semantic parsing method, device, electronic device and storage medium, which directly uses the first layer of the pre-established grammar-based double-layer encoder-decoder model (Grammar Constrained Double Layer encoder-decodermodel, GCDL enc-dec model) to process the target natural language vector obtained after vectorization processing, and obtains the corresponding encoding vector and target abstract summary tree operation sequence, and then uses the second layer of the encoder-decoder in the GCDL enc-dec model to process the obtained encoding vector and target abstract summary tree operation sequence to obtain the target abstract syntax tree operation sequence, so that the corresponding meaning representation can be obtained by processing the obtained target abstract syntax tree operation sequence, and there is no need to construct a vocabulary, thereby improving the accuracy of semantic parsing of natural language. In addition, by splitting the generated abstract syntax tree operation sequence into two processes, it can effectively avoid the operation sequence generated by the existing seq2seq model from being too long, thereby improving the accuracy of the generated operation sequence, thereby improving the accuracy of the generated meaning representation.

[0067] See also Figure 3 , shows a schematic diagram of the structure of a semantic parsing system provided by an embodiment of the present invention, wherein the semantic parsing system includes: a pre-established GCDL enc-dec model 100, a conversion system 200 and a grammar model 300. The pre-established GCDL enc-dec model 100 includes a first-layer codec and a second-layer codec obtained by training based on a training instance set, the first-layer codec includes a sentence encoder and an abstract summary tree decoder, and the second codec includes an abstract summary tree encoder and an abstract syntax tree decoder.

[0068] See also Figure 4 , shows a flow chart of a method for generating a GCDL enc-dec model provided by an embodiment of the present invention, wherein the generating process of the GCDL enc-dec model specifically includes the following steps:

[0069] S401: Acquire a training instance, wherein the training instance includes a natural language sample and a target meaning representation corresponding to the natural language sample.

[0070] In the specific process of executing step S401, training instances including natural language samples and meaning representations corresponding to the natural language samples (for the sake of distinction, the meaning representations corresponding to the collected natural language samples are referred to as target meaning representations) may be collected.

[0071] It should be noted that multiple training instances can be collected. Regarding the specific number of training instances, the inventor can collect them according to his own needs, and the embodiments of the present application are not limited thereto.

[0072] S402: Input the target meaning representation corresponding to the natural language sample into the grammar model to obtain an abstract syntax tree and an abstract summary tree.

[0073] In the specific process of executing step S402, after obtaining the training instance, the target meaning representation corresponding to the natural language sample in the obtained training instance can be input into the grammar model, so that the grammar model processes the input target meaning representation based on the grammar algorithm to obtain an abstract syntax tree, and the leaf nodes of the obtained abstract syntax tree are removed to obtain an abstract summary tree.

[0074] S403: Inputting the abstract syntax tree and the abstract summary tree into the conversion system, so that the conversion system processes the abstract syntax tree to obtain a first abstract syntax tree operation sequence, and processes the abstract summary tree to obtain a first abstract summary tree operation sequence.

[0075] In the specific execution process of step S403, after the input target meaning representation is processed by the grammar model to obtain the abstract syntax tree and the abstract summary tree, the abstract syntax tree is converted into an abstract syntax tree operation sequence by the conversion system (for the sake of distinction, the abstract syntax tree operation sequence obtained by converting the abstract syntax tree is referred to as the first abstract syntax tree operation sequence), and the abstract summary tree is converted into an abstract summary tree operation sequence by the conversion system (for the sake of distinction, the abstract summary tree operation sequence obtained by converting the abstract summary tree is referred to as the first abstract summary tree operation sequence).

[0076] S404: Inputting the natural language sample vector obtained after vectorization processing of the natural language into the first layer codec to be trained to obtain a coding vector, and processing the coding vector to obtain a second abstract summary tree operation sequence.

[0077] In the specific process of executing step S404, after the training instance is obtained, the natural language sample in the obtained training instance can be vectorized to obtain a natural language sample vector, and the obtained natural language sample vector is input into the first-layer codec to be trained, so as to encode the natural language sample vector based on the sentence encoder (Natural Language Description encoder, NLD-encoder) in the first-layer codec to be trained to obtain a coding vector, and the obtained coding vector is decoded by using the abstract SKetch Tree decoder (Abstract SKetch Tree decoder, ASKT-decoder) in the first-layer codec to be trained to obtain an abstract synopsis tree operation sequence (for ease of distinction, the abstract synopsis tree operation sequence obtained by processing the coding vector using the abstract synopsis tree decoder is referred to as a second abstract synopsis tree operation sequence).

[0078] It should be noted that the method of using the AST decoder in the first-layer codec to be trained to decode the coding vector to obtain the second AST operation sequence can be seen in formula (1).

[0079]

[0080] Among them, X is the target natural language vector, S is the encoding vector, AS is the second abstract summary tree operation sequence, as t is the sequence of sub-operations obtained by processing the encoding vector at time t, as <t is the sequence of sub-operations obtained by processing the encoding vector before time t.

[0081] S405: Input the encoding vector and the second abstract summary tree operation sequence into the second layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence.

[0082] In the specific process of executing step S405, after the natural language sample vector is processed by the first-layer codec to be trained to obtain the code vector and the second abstract summary tree operation sequence, the obtained code vector and the second sampled summary tree operation sequence are input into the second-layer codec to be trained, so that the second sampled summary tree operation sequence is encoded by the Abstract SKetch Tree encoder (ASKT-encoder) of the second-layer codec to be trained to obtain the encoding information of the second abstract summary tree operation sequence, and the encoding information and the code vector of the second abstract summary tree operation sequence are decoded by the Abstract Syntax Tree decoder (AST-decoder) to obtain the abstract syntax tree operation sequence (for the convenience of distinction, the abstract syntax tree operation sequence obtained by decoding the encoding information and the code vector of the second abstract summary tree operation sequence is referred to as the second abstract syntax tree operation sequence).

[0083] It should be noted that the method of using the abstract syntax tree decoder to decode the encoding information and encoding vector of the second abstract summary tree operation sequence to obtain the second abstract syntax tree operation sequence can be seen in formula (2).

[0084]

[0085] Where X is the target natural language vector, S is the encoding vector, Y is the encoding information of the second abstract summary tree operation sequence, AY is the second abstract syntax tree operation sequence, and ay t is the sub-operation sequence obtained by processing the encoding information of the second abstract summary tree operation sequence at time t, ay <t is a sub-operation sequence obtained by processing the encoding information of the second abstract summary tree operation sequence before time t.

[0086] S406: Input the second abstract syntax tree operation sequence into the conversion system to obtain an abstract syntax tree, and perform meaning conversion on the abstract syntax tree using the syntax model to obtain a meaning representation of the natural language sample.

[0087] In the specific execution process of step S406, after the encoding vector and the second abstract summary tree operation sequence are processed by the second-layer encoder / decoder to be trained to obtain the second abstract syntax tree operation sequence, the second abstract syntax tree operation sequence is input into the conversion system so that the second abstract syntax tree operation sequence is converted into an abstract syntax tree by the conversion system, and the abstract syntax tree is converted into meaning by the syntax model to obtain the meaning representation of the natural language sample.

[0088] S407: Calculate using the first abstract syntax tree operation sequence, the first abstract summary tree operation sequence, the second abstract syntax tree operation sequence and the second abstract syntax tree operation sequence to obtain a loss function.

[0089] In the specific process of executing step S407, the first abstract syntax tree operation sequence and the second abstract syntax tree operation sequence are used to calculate the first loss function, the first abstract summary tree operation sequence and the second abstract syntax tree operation sequence are used to calculate the second loss function, and finally, the loss function of the GCDL enc-dec model is calculated based on the first loss function and the second loss function.

[0090] S408: Taking the meaning representation of natural language samples approaching the target meaning representation as the training goal, adjusting the parameters of the first-layer codec to be trained and the second-layer codec to be trained through the loss function until the first-layer codec to be trained and the second-layer codec to be trained converge, and obtaining the first-layer codec and the second-layer codec.

[0091] In the specific execution process of step S408, after calculating the loss function of the GCDL enc-dec model, the training goal is to make the meaning representation of natural language samples approach the target meaning representation, and the parameters of the sentence encoder, abstract summary tree decoder, abstract summary tree encoder and abstract syntax tree decoder are adjusted respectively through the loss function until the sentence encoder, abstract summary tree decoder, abstract summary tree encoder and abstract syntax tree decoder reach convergence to obtain the GCDLenc-dec model.

[0092] In an embodiment of the present application, the first layer encoder / decoder and the second layer encoder / decoder in the GCDL enc-dec model to be trained are trained using training examples to obtain a GCDL enc-dec model, so that when semantically parsing a natural language, the target natural language vector obtained after vectorization processing of the target natural language is directly processed using the first layer encoder / decoder in the GCDL enc-dec model to obtain the corresponding target encoding vector and target abstract summary tree operation sequence, and then the target encoding vector and the target abstract summary tree operation sequence are processed using the second layer encoder / decoder in the GCDL enc-dec model to obtain the target abstract syntax tree operation sequence, and the corresponding meaning representation can be obtained by processing the obtained target abstract syntax tree operation sequence, without the need to construct a vocabulary, thereby improving the accuracy of semantic parsing of natural language. In addition, by splitting the generated abstract syntax tree operation sequence into two processes, it is possible to effectively avoid the operation sequence generated by the existing seq2seq model from being too long, thereby improving the accuracy of the generated operation sequence, thereby improving the accuracy of the generated meaning representation.

[0093] See also Figure 5 , shows a flow chart of a semantic parsing method provided by an embodiment of the present invention, the semantic parsing method specifically comprises the following steps:

[0094] S501: Obtain a target natural language, and input the target natural language vector obtained after vectorization processing into a pre-established GCDL enc-dec model, wherein the GCDL enc-dec model includes a first-layer encoder-decoder and a second-layer encoder-decoder trained based on training examples, and the training examples include natural language samples and target meaning representations corresponding to the natural language samples.

[0095] In step S501, a GCDL enc-dec model is pre-established, wherein the GCDL enc-dec model includes a first-layer codec and a second-layer codec trained based on a training instance set, the first-layer codec includes a sentence encoder and an abstract summary tree decoder, the second codec includes an abstract summary tree encoder and an abstract syntax tree decoder, and the training instances include natural language samples and target meaning representations corresponding to the natural language samples.

[0096] It should be noted that the process of training the first-layer codec and the second-layer codec based on the training instance set can be seen in Figure 4 A method for generating a GCDL enc-dec model is disclosed and will not be described in detail here.

[0097] In the specific process of executing step S501, after the natural language to be semantically parsed is obtained (for the sake of distinction, the obtained natural language to be semantically parsed is referred to as the target natural language), the obtained target natural language is vectorized to obtain a target natural language vector, and the obtained target natural language vector is input into the pre-built GCDL enc-dec model.

[0098] S502: Utilize the first-layer codec to process the target natural language vector to obtain a target coding vector, and process the target coding vector to obtain a target abstract summary tree operation sequence.

[0099] In the specific execution process of step S502, after the obtained target natural language vector is input into the pre-built GCDL enc-dec model, the target natural language is encoded using the sentence encoder in the first-layer encoder-decoder in the GCDL enc-dec model to obtain the target encoding vector, and the target encoding vector is decoded using the abstract summary tree decoder in the first-layer encoder-decoder to obtain the target abstract summary tree operation sequence.

[0100] S503: Use the second-layer codec to process the target abstract summary tree operation sequence and the target coding vector to obtain a target abstract syntax tree operation sequence.

[0101] In the specific execution process of step S503, after the target natural language vector is processed by the first-layer codec to obtain the target coding vector and the target abstract summary tree operation sequence, the obtained target coding vector and the target sampling summary tree operation sequence are input into the second-layer codec, so that the target sampling summary tree operation sequence is encoded based on the abstract summary tree encoder of the second-layer codec to obtain the coding information of the target abstract summary tree operation sequence, and the coding information of the target abstract summary tree operation sequence and the target coding vector are decoded by the abstract syntax tree decoder to obtain the target abstract syntax tree operation sequence.

[0102] S504: Inputting the target abstract syntax tree operation sequence into the conversion system to obtain a target abstract syntax tree, and performing meaning conversion on the target abstract syntax tree using the grammar model to obtain a meaning representation of the target natural language.

[0103] In the specific execution process of step S504, after the target coding vector and the target abstract summary tree operation sequence are processed by the second-layer encoder-decoder to obtain the target abstract syntax tree operation sequence, the target abstract syntax tree operation sequence is input into the conversion system so that the target abstract syntax tree operation sequence is converted into a target abstract syntax tree by the conversion system, and the target abstract syntax tree is converted into meaning by using the syntax model to obtain the meaning representation of the target natural language.

[0104] The present invention provides a semantic parsing method, which performs vectorization processing on an acquired target natural language to obtain a target natural language vector, inputs the natural language vector into a pre-established GCDL enc-dec model, processes the target natural language vector based on a first-layer codec in the GCDL enc-dec model to obtain a target coding vector, processes the target coding vector to obtain a target abstract summary tree operation sequence, processes the target abstract summary tree operation sequence and the target coding vector using a second-layer codec in the GCDL enc-dec model to obtain a target abstract syntax tree operation sequence, finally inputs the target abstract syntax tree operation sequence into a conversion system to obtain a target abstract syntax tree, and performs semantic parsing on the target abstract syntax tree using a syntax model to obtain a meaning representation of the target natural language. The technical solution provided by the present invention directly uses the first layer codec in the pre-established GCDL enc-dec model to process the target natural language vector obtained after vectorization processing, and obtains the corresponding target coding vector and target abstract summary tree operation sequence, and then uses the second layer codec in the GCDL enc-dec model to process the obtained target coding vector and target abstract summary tree operation sequence to obtain the target abstract syntax tree operation sequence, so that the corresponding meaning representation can be obtained by processing the obtained target abstract syntax tree operation sequence, and there is no need to construct a vocabulary, thereby improving the accuracy of semantic parsing of natural language. In addition, by splitting the generated abstract syntax tree operation sequence into two processes, it can effectively avoid the operation sequence generated by the existing seq2seq model from being too long, thereby improving the accuracy of the generated operation sequence, thereby improving the accuracy of the generated meaning representation.

[0105] Based on the semantic parsing method disclosed in the embodiment of the present invention, the embodiment of the present invention also discloses a semantic parsing device, such as Figure 6 As shown, the semantic parsing device includes:

[0106] A first acquisition unit 61 is used to acquire a target natural language, and input a target natural language vector obtained by vectorizing the target natural language into a pre-established GCDL enc-dec model, wherein the GCDL enc-dec model includes a first-layer codec and a second-layer codec obtained by training based on a training example, and the training example includes a natural language sample and a target meaning representation corresponding to the natural language sample;

[0107] A first processing unit 62 is used to process the target natural language vector using the first layer codec to obtain a target coding vector, and to process the target coding vector to obtain a target abstract summary tree operation sequence;

[0108] A second processing unit 63 is used to process the target abstract summary tree operation sequence and the target coding vector using the second layer codec to obtain a target abstract syntax tree operation sequence;

[0109] The first semantic parsing unit 64 is used to input the target abstract syntax tree operation sequence into the conversion system to obtain a target abstract syntax tree, and perform meaning conversion on the target abstract syntax tree using a grammar model to obtain a meaning representation of a target natural language.

[0110] The specific principles and execution processes of each unit in the semantic parsing device disclosed in the above embodiment of the present invention are the same as the semantic parsing method disclosed in the above embodiment of the present invention. Please refer to the corresponding parts of the semantic parsing method disclosed in the above embodiment of the present invention, and will not be repeated here.

[0111] The present invention provides a semantic parsing device, which performs vectorization processing on an acquired target natural language to obtain a target natural language vector, inputs the natural language vector into a pre-established GCDL enc-dec model, processes the target natural language vector based on a first-layer codec in the GCDL enc-dec model to obtain a target coding vector, processes the target coding vector to obtain a target abstract summary tree operation sequence, processes the target abstract summary tree operation sequence and the target coding vector using a second-layer codec in the GCDL enc-dec model to obtain a target abstract syntax tree operation sequence, finally inputs the target abstract syntax tree operation sequence into a conversion system to obtain a target abstract syntax tree, and performs semantic parsing on the target abstract syntax tree using a syntax model to obtain a meaning representation of the target natural language. The technical solution provided by the present invention directly uses the first layer codec in the pre-established GCDL enc-dec model to process the target natural language vector obtained after vectorization processing, and obtains the corresponding target coding vector and target abstract summary tree operation sequence, and then uses the second layer codec in the GCDL enc-dec model to process the obtained target coding vector and target abstract summary tree operation sequence to obtain the target abstract syntax tree operation sequence, so that the corresponding meaning representation can be obtained by processing the obtained target abstract syntax tree operation sequence, and there is no need to construct a vocabulary, thereby improving the accuracy of semantic parsing of natural language. In addition, by splitting the generated abstract syntax tree operation sequence into two processes, it can effectively avoid the operation sequence generated by the existing seq2seq model from being too long, thereby improving the accuracy of the generated operation sequence, thereby improving the accuracy of the generated meaning representation.

[0112] Optionally, the process of training the first-layer codec and the second-layer codec based on the training instance set includes:

[0113] A second acquisition unit is used to acquire a training instance, wherein the training instance includes a natural language sample and a target meaning representation corresponding to the natural language sample;

[0114] A third processing unit is used to input the target meaning representation corresponding to the natural language sample into the grammar model to obtain an abstract syntax tree and an abstract summary tree;

[0115] a conversion unit, configured to input the abstract syntax tree and the abstract summary tree into a conversion system, so that the conversion system processes the abstract syntax tree to obtain a first abstract syntax tree operation sequence, and processes the abstract summary tree to obtain a first abstract summary tree operation sequence;

[0116] a fourth processing unit, configured to input the natural language sample vector obtained after vectorization processing of the natural language into the first-layer codec to be trained to obtain a coding vector, and process the coding vector to obtain a second abstract summary tree operation sequence;

[0117] A fifth processing unit, configured to input the encoding vector and the second abstract summary tree operation sequence into the second layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence;

[0118] A second semantic parsing unit is used to input the second abstract syntax tree operation sequence into the conversion system to obtain a third abstract syntax tree, and perform meaning conversion on the third abstract syntax tree using the grammar model to obtain a meaning representation of the natural language sample;

[0119] a calculation unit, configured to calculate by using the first abstract syntax tree operation sequence, the first abstract summary tree operation sequence, the second abstract syntax tree operation sequence, and the second abstract syntax tree operation sequence to obtain a loss function;

[0120] The training unit is used to take the meaning representation of the natural language sample approaching the target meaning representation as the training goal, and adjust the parameters of the first-layer codec to be trained and the second-layer codec to be trained through the loss function until the first-layer codec to be trained and the second-layer codec to be trained converge, so as to obtain the first-layer codec and the second-layer codec.

[0121] Optionally, the first layer encoder-decoder includes a sentence encoder and an abstract summary tree decoder, and the fourth processing unit includes:

[0122] A first encoding unit is used to input a natural language sample vector obtained after vectorization processing of the natural language into a sentence encoder to obtain an encoding vector;

[0123] The first decoding unit is used to input the coding vector into an abstract summary tree decoder, so that the abstract summary tree decoder processes the coding vector to obtain a second abstract summary tree operation sequence.

[0124] Optionally, the second codec includes an abstract summary tree encoder and an abstract syntax tree decoder, and the fifth processing unit includes:

[0125] A second encoding unit, configured to input the second AST operation sequence into an AST encoder to obtain encoding information of the second AST operation sequence;

[0126] The second decoding unit is used to input the encoding information and encoding vector of the second abstract summary tree operation sequence into an abstract syntax tree decoder to obtain a second abstract syntax tree operation sequence.

[0127] Optionally, the first processing unit includes:

[0128] A third encoding unit, used for processing the target natural language vector using a sentence encoder to obtain a target encoding vector;

[0129] The third decoding unit is used to process the target coding vector by using an abstract summary tree decoder to obtain a target abstract summary tree operation sequence.

[0130] Optionally, the second processing unit includes:

[0131] a fourth encoding unit, configured to process the target abstract summary tree operation sequence by using an abstract summary tree encoder to obtain encoding information of the target abstract summary tree operation sequence;

[0132] The fourth decoding unit is used to process the encoding information of the target abstract summary tree operation sequence by using the abstract syntax tree decoder to obtain the target abstract syntax tree operation sequence.

[0133] The present application embodiment provides an electronic device, such as Figure 7 As shown, the electronic device includes a processor 701 and a memory 702, the memory 702 is used to store program codes and data for semantic analysis, and the processor 701 is used to call program instructions in the memory to execute the steps shown in the semantic analysis method in the above embodiment.

[0134] An embodiment of the present application provides a storage medium, which includes a storage program, wherein when the program is running, the device where the storage medium is located is controlled to execute the semantic parsing method shown in the above embodiment.

[0135] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, in which 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 can 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.

[0136] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0137] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

[0138] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A semantic parsing method, characterized in that: The method comprises: Obtaining a target natural language, and inputting a target natural language vector obtained by vectorizing the target natural language into a pre-established GCDL enc-dec model, wherein the GCDL enc-dec model includes a first-layer codec and a second-layer codec obtained by training based on a training example, wherein the training example includes a natural language sample and a target meaning representation corresponding to the natural language sample; Using the first layer codec to process the target natural language vector to obtain a target coding vector, and processing the target coding vector to obtain a target abstract summary tree operation sequence; Processing the target abstract summary tree operation sequence and the target coding vector using the second layer codec to obtain a target abstract syntax tree operation sequence; The target abstract syntax tree operation sequence is input into a conversion system to obtain a target abstract syntax tree, and a grammar model is used to perform meaning conversion on the target abstract syntax tree to obtain a meaning representation of the target natural language.

2. The method according to claim 1, characterized in that The process of obtaining the first layer codec and the second layer codec based on the training examples includes: Acquire a training instance, wherein the training instance includes a natural language sample and a target meaning representation corresponding to the natural language sample; Inputting the target meaning representation corresponding to the natural language sample into the grammar model to obtain an abstract syntax tree and an abstract summary tree; Inputting the abstract syntax tree and the abstract summary tree into the conversion system, causing the conversion system to process the abstract syntax tree to obtain a first abstract syntax tree operation sequence, and to process the abstract summary tree to obtain a first abstract summary tree operation sequence; Inputting the natural language sample vector obtained after vectorization processing of the natural language into the first layer codec to be trained to obtain a coding vector, and processing the coding vector to obtain a second abstract summary tree operation sequence; Inputting the encoding vector and the second abstract summary tree operation sequence into the second layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence; Inputting the second abstract syntax tree operation sequence into the conversion system to obtain an abstract syntax tree, and performing semantic parsing on the abstract syntax tree using the syntax model to obtain a meaning representation of the natural language sample; Calculate using the first abstract syntax tree operation sequence, the first abstract summary tree operation sequence, the second abstract syntax tree operation sequence, and the second abstract syntax tree operation sequence to obtain a loss function; The training goal is to make the meaning representation of the natural language sample approach the target meaning representation, and the parameters of the first-layer codec to be trained and the second-layer codec to be trained are adjusted by the loss function until the first-layer codec to be trained and the second-layer codec to be trained converge, so as to obtain the first-layer codec and the second-layer codec.

3. The method according to claim 2, characterized in that The first-layer codec includes a sentence coder and an abstract summary tree decoder, the natural language sample vector obtained by vectorizing the natural language is input into the first-layer codec to be trained to obtain a coding vector, and the coding vector is processed to obtain a second abstract summary tree operation sequence, including: Inputting the natural language sample vector obtained after vectorization processing of the natural language into the sentence encoder to obtain an encoding vector; The encoding vector is input into the abstract summary tree decoder, so that the abstract summary tree decoder processes the encoding vector to obtain a second abstract summary tree operation sequence.

4. The method according to claim 3, characterized in that The second layer codec includes an abstract summary tree coder and an abstract syntax tree decoder, and the step of inputting the coding vector and the second abstract summary tree operation sequence into the second layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence includes: Inputting the second AST operation sequence into the AST encoder to obtain encoding information of the second AST operation sequence; The encoding information of the second abstract summary tree operation sequence and the encoding vector are input into the abstract syntax tree decoder to obtain a second abstract syntax tree operation sequence.

5. The method according to claim 3, characterized in that: The step of processing the target natural language vector using the first layer codec to obtain a target coding vector, and processing the target coding vector to obtain a target abstract summary tree operation sequence includes: Processing the target natural language vector using the sentence encoder to obtain a target encoding vector; The target coding vector is processed by using the abstract summary tree decoder to obtain a target abstract summary tree operation sequence.

6. The method according to claim 4, characterized in that The step of processing the target abstract summary tree operation sequence and the target coding vector by using the second layer codec to obtain a target abstract syntax tree operation sequence includes: Processing a target abstract summary tree operation sequence using the abstract summary tree encoder to obtain encoding information of the target abstract summary tree operation sequence; The encoding information of the target abstract summary tree operation sequence is processed by using the abstract syntax tree decoder to obtain a target abstract syntax tree operation sequence.

7. A semantic analysis device, characterized in that: The device comprises: A first acquisition unit is used to acquire a target natural language, and input a target natural language vector obtained by vectorizing the target natural language into a pre-established GCDL enc-dec model, wherein the GCDL enc-dec model includes a first-layer codec and a second-layer codec obtained by training based on a training example, and the training example includes a natural language sample and a target meaning representation corresponding to the natural language sample; A first processing unit is used to process the target natural language vector using the first layer codec to obtain a target coding vector, and to process the target coding vector to obtain a target abstract summary tree operation sequence; A second processing unit, configured to process the target abstract summary tree operation sequence and the target coding vector using the second layer codec to obtain a target abstract syntax tree operation sequence; The first semantic parsing unit is used to input the target abstract syntax tree operation sequence into a conversion system to obtain a target abstract syntax tree, and perform meaning conversion on the target abstract syntax tree based on a grammar model to obtain a meaning representation of the target natural language.

8. The device according to claim 7, characterized in that The process of obtaining the first-layer codec and the second-layer codec based on the training set of training examples includes: A second acquisition unit is used to acquire a training instance, wherein the training instance includes a natural language sample and its corresponding target meaning representation; A third processing unit, configured to input the target meaning representation corresponding to the natural language sample into the grammar model to obtain an abstract syntax tree and an abstract summary tree; a conversion unit, configured to input the abstract syntax tree and the abstract summary tree into the conversion system, so that the conversion system processes the abstract syntax tree to obtain a first abstract syntax tree operation sequence, and processes the abstract summary tree to obtain a first abstract summary tree operation sequence; a fourth processing unit, configured to input the natural language sample vector obtained after vectorization processing of the natural language into the first-layer codec to be trained to obtain a coding vector, and process the coding vector to obtain a second abstract summary tree operation sequence; A fifth processing unit, configured to input the encoding vector and the second abstract summary tree operation sequence into a second-layer codec to be trained for processing to obtain a second abstract syntax tree operation sequence; A second semantic parsing unit, configured to input the second abstract syntax tree operation sequence into the conversion system to obtain a third abstract syntax tree, and perform semantic parsing on the third abstract syntax tree using the syntax model to obtain a meaning representation of the natural language sample; a calculation unit, configured to calculate by using the first abstract syntax tree operation sequence, the first abstract summary tree operation sequence, the second abstract syntax tree operation sequence, and the second abstract syntax tree operation sequence to obtain a loss function; A training unit is used to take the meaning representation of the natural language sample approaching the target meaning representation as a training goal, and adjust the parameters of the first layer codec to be trained and the second layer codec to be trained through the loss function until the first layer codec to be trained and the second layer codec to be trained reach convergence, so as to obtain the first layer codec and the second layer codec.

9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory is used to store program code and data for semantic analysis, and the processor is used to call program instructions in the memory to execute a semantic analysis method as described in any one of claims 1-6.

10. A storage medium, characterized in that: The storage medium includes a storage program, wherein when the program is running, the device where the storage medium is located is controlled to execute a semantic parsing method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • System and method for multi-horizon time series forecasting with dynamic temporal context learning

    CN110866628A

  • Program understanding method and system based on abstract syntax tree

    CN112835585A