CN111324699A - Semantic matching method and device, electronic equipment and storage medium - Google Patents

Semantic matching method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111324699A
CN111324699A CN202010105193.2A CN202010105193A CN111324699A CN 111324699 A CN111324699 A CN 111324699A CN 202010105193 A CN202010105193 A CN 202010105193A CN 111324699 A CN111324699 A CN 111324699A
Authority
CN
China
Prior art keywords
words
sentences
association information
target
language model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010105193.2A
Other languages
Chinese (zh)
Inventor
赵文
张开旭
刘洪�
陈守志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Tencent Technology Co Ltd
Original Assignee
Guangzhou Tencent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Tencent Technology Co Ltd filed Critical Guangzhou Tencent Technology Co Ltd
Priority to CN202010105193.2A priority Critical patent/CN111324699A/en
Publication of CN111324699A publication Critical patent/CN111324699A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Animal Behavior & Ethology (AREA)
  • Machine Translation (AREA)

Abstract

The application provides a semantic matching method, a semantic matching device, electronic equipment and a storage medium, and belongs to the technical field of natural language processing. The method comprises the following steps: constructing a target graph based on the dependency relationship of the words in the at least two sentences to be matched in the sentences, wherein one node of the target graph is used for representing one word in the at least two sentences, and the edges of the target graph are used for representing that the dependency relationship exists between the words represented by the nodes connected by the edges or the words do not belong to the same sentence; replacing a mask matrix in a language model with an adjacency matrix of the target graph, the mask matrix being used to make the partial values involved in the calculation useless; and determining the semantic relation between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model. By the technical scheme, the relation between semantic structures is enhanced, and the accuracy of semantic matching is improved.

Description

Semantic matching method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of natural language processing technologies, and in particular, to a semantic matching method, an apparatus, an electronic device, and a storage medium.
Background
With the advent of large-scale data sets and the development of deep learning, many approaches to solve semantic matching problems have emerged. Semantic matching refers to judging semantic relations between sentences, such as similar relations or contradictory relations, the core of semantic matching is word sense understanding and structural semantic understanding, the word sense understanding refers to accurately mastering meanings of words in context, the structural semantic understanding refers to understanding relations between semantic components, and the semantic components refer to components of a semantic structure. Because semantic matching is widely applied to scenes such as searching, question answering, content recommendation and the like, whether the result of semantic matching is accurate or not is very important.
In the related art, the sentences to be matched are usually encoded into vectors by an encoder, and the semantic relationship between the sentences is obtained by comparing the distances between the vectors. The encoder may be an LSTM (Long Short-term memory network) based encoder, or a CNN (Convolutional Neural network) based encoder, etc.
In the semantic matching process, the meanings of the words of the sentences in the context are understood from the perspective of the sentences, the relation between semantic components is ignored, namely the understanding of structural semantics is ignored, and the accuracy of the semantic matching result is not high.
Disclosure of Invention
The embodiment of the application provides a semantic matching method and device, electronic equipment and a storage medium, which enhance the relation between semantic components and improve the accuracy of semantic matching. The technical scheme is as follows:
in one aspect, a method for semantic matching is provided, where the method includes:
constructing a target graph based on the dependency relationship of the words in the at least two sentences to be matched in the sentences, wherein one node of the target graph is used for representing one word in the at least two sentences, and the edges of the target graph are used for representing that the dependency relationship exists between the words represented by the nodes connected by the edges or the words do not belong to the same sentence;
replacing a mask matrix in a language model with an adjacency matrix of the target graph, the mask matrix being used to make the partial values involved in the calculation useless;
and determining the semantic relation between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model.
In one aspect, a semantic matching apparatus is provided, the apparatus including:
the system comprises a construction module, a matching module and a matching module, wherein the construction module is used for constructing a target graph based on the dependency relationship of terms in the at least two statements to be matched, one node of the target graph is used for representing one term in the at least two statements, and the edge of the target graph is used for representing that the dependency relationship exists between the terms represented by the nodes connected by the edge or does not belong to the same statement;
a replacement module, configured to replace a mask matrix in a language model with an adjacency matrix of the target graph, where the mask matrix is used to disable partial values involved in the calculation;
and the determining module is used for determining the semantic relation between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model.
In an optional implementation manner, the constructing module is further configured to perform dependency syntax analysis on at least two sentences to be matched, respectively, to obtain at least two dependency syntax trees, where one dependency syntax tree is used to represent a dependency relationship between words in one sentence; and in response to the dependency relationship between two words in the at least two sentences or the two words do not belong to the same sentence, constructing an edge between two nodes for representing the two words to obtain a target graph.
In an optional implementation manner, the determining module is further configured to input statement vectors corresponding to the at least two statements into the replaced language model; determining a similarity degree between words in the at least two sentences based on a coding layer of the language model; determining a semantic relationship between the at least two statements based on a decoding layer of the language model.
In an optional implementation manner, the determining module is further configured to, in the coding layer, adjust, according to the adjacency matrix, first association information between words that satisfy a target condition to second association information, where a degree of association between words represented by the second association information is greater than the first association information; and determining the similarity degree between the words in the at least two sentences according to the second association information.
In an alternative implementation, the first associated information and the second associated information are represented in numerical form; the determining module is further configured to use the element values of the adjacency matrix as relationship enhancement parameters, where a value of the relationship enhancement parameter is 1 or 0, 1 indicates that the target condition is satisfied between words, and 0 indicates that the target condition is not satisfied between words; acquiring target parameters, and inputting the target parameters into an activation function, wherein the target parameters are parameters optimized along with the training of the language model, and the activation function is used for ensuring the association degree between forward enhancement words; and adjusting the first association information between the words according to the product of the relationship enhancement parameter and the activation function to obtain the second association information.
In an alternative implementation, the target condition is any one of:
words belonging to different sentences;
words belonging to the same sentence and having a dependency relationship.
In an optional implementation manner, the determining module is further configured to, for any word, use second association information between the word and other words in the two sentences as an element in an attention matrix corresponding to the word; determining a degree of similarity between the word and the other words according to the attention matrix and the value vectors of the other words.
In an optional implementation manner, the determining module is further configured to decode, at the decoding layer, an output result of the encoding layer according to the adjacency matrix; and determining the semantic relation between the at least two sentences according to the output result of the decoding layer.
In one aspect, an electronic device is provided, and the electronic device includes a processor and a memory, where the memory is configured to store at least one piece of program code, and the at least one piece of program code is loaded and executed by the processor to implement the operations performed in the method for semantic matching in the embodiments of the present application.
In one aspect, a storage medium is provided, where at least one program code is stored in the storage medium, and the at least one program code is used to execute the method for semantic matching in the embodiment of the present application.
The technical scheme provided by the embodiment of the application has the following beneficial effects:
in the embodiment of the application, the target graph is constructed according to the dependency relationship among the words in the sentences, edges are used for representing the dependency relationship among the words in the graph and the words do not belong to the same sentence, and the adjacency matrix of the target graph is used for replacing a mask matrix in the language model, so that the relationship among semantic structures is enhanced, and the accuracy of semantic matching is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a block diagram of a semantic matching system provided according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for semantic matching according to an embodiment of the present application;
FIG. 3 is a diagram of a dependency syntax tree provided in accordance with an embodiment of the present application;
FIG. 4 is a schematic diagram of a target graph provided in accordance with an embodiment of the present application;
FIG. 5 is a flow chart of another method for semantic matching provided according to an embodiment of the present application;
FIG. 6 is a block diagram of an apparatus for semantic matching according to an embodiment of the present application;
fig. 7 is a block diagram of a terminal according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a server provided according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The embodiment of the application provides a semantic matching method, which can be applied to scenes such as searching, question answering, translation, content recommendation and the like, for example, when a commodity name is searched in a searching scene, the semantic matching method provided by the embodiment of the application can determine the corresponding information of the commodity name in a database, and then extracts the corresponding information from the database for display; or when a certain question is detected in a question-answering scene, the semantic matching method provided by the embodiment of the application can match the question with other stored questions, and when similar questions exist, the answers of the similar questions are displayed; or when the translation scene translates the content to be translated into the target language, the semantic matching method provided by the embodiment of the application can determine the content of the target language with the same semantic as the content to be translated; or when the content recommendation scene recommends according to the input content, the semantic matching method provided by the embodiment of the application can determine the recommended content related to the input content.
The following briefly introduces the main steps of the semantic matching method provided in the embodiment of the present application: firstly, constructing a target graph based on the dependency relationship of the words in the at least two sentences to be matched in the sentences, wherein one node of the target graph is used for representing one word in the at least two sentences, and the edge of the target graph is used for representing that the dependency relationship exists between the words represented by the nodes connected by the edge or does not belong to the same sentence. Then, a mask matrix in the language model is replaced with an adjacency matrix of the target graph, the mask matrix being used to make the partial values involved in the calculation useless. And finally, determining the semantic relation between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model. According to the semantic matching method, the target graph is constructed based on the dependency relationship among the words in the sentence, and the adjacent matrix of the target graph is used for replacing the mask matrix in the language model, so that the relationship among semantic structures is enhanced, and the semantic matching accuracy is improved.
Fig. 1 is a block diagram of a semantic matching system 100 provided according to an embodiment of the present application. The semantic matching system 100 includes: a terminal 110 and a semantic matching platform 120.
The terminal 110 is connected to the semantic matching platform 110 through a wireless network or a wired network. The terminal 110 may be at least one of a smartphone, a game console, a desktop computer, a tablet computer, an e-book reader, an MP3 player, an MP4 player, and a laptop portable computer. The terminal 110 is installed and operated with an application program supporting semantic matching. The application program may be one of applications such as question answering, search, translation or information. Illustratively, the terminal 110 is a terminal used by a user, and an application running in the terminal 110 has a user account logged therein.
The semantic matching platform 120 includes at least one of a server, a plurality of servers, a cloud computing platform, and a virtualization center. The semantic matching platform 120 is used to provide background services for applications that support semantic matching. Optionally, the semantic matching platform 120 undertakes primary semantic matching work, and the terminal 110 undertakes secondary semantic matching work; or, the semantic matching platform 120 undertakes the secondary semantic matching work, and the terminal 110 undertakes the primary semantic matching work; alternatively, the semantic matching platform 120 or the terminal 110 may respectively undertake the semantic matching work separately.
Optionally, the semantic matching platform 120 includes: the system comprises an access server, a semantic matching server and a database. The access server is used for providing the terminal 110 with access service. The semantic matching server is used for providing background services related to semantic matching. The semantic matching server can be one or more. When there are multiple semantic matching servers, there are at least two semantic matching servers for providing different services, and/or there are at least two semantic matching servers for providing the same service, for example, providing the same service in a load balancing manner, which is not limited in the embodiments of the present application. The semantic matching server can be provided with a language model. In the embodiment of the application, the language model is a model constructed based on a multi-head attention mechanism.
The terminal 110 may be generally referred to as one of a plurality of terminals, and the embodiment is only illustrated by the terminal 110.
Those skilled in the art will appreciate that the number of terminals described above may be greater or fewer. For example, the number of the terminals may be only one, or several tens or hundreds of the terminals, or a larger number, and in this case, the semantic matching system further includes other terminals. The number of terminals and the type of the device are not limited in the embodiments of the present application.
Fig. 2 is a flowchart of a semantic matching method provided according to an embodiment of the present application, as shown in fig. 2. The electronic device may be provided as a terminal, and may also be provided as a server, which is described in this embodiment by taking the application to the terminal as an example. The semantic matching method comprises the following steps:
201. and the terminal respectively carries out dependency syntax analysis on at least two sentences to be matched to obtain at least two dependency syntax trees, wherein one dependency syntax tree is used for expressing the dependency relationship among the words in one sentence.
In this embodiment of the application, for at least two sentences to be matched, the terminal may perform word segmentation on each sentence, and for any sentence, the terminal may analyze, according to a preset language rule, a dependency relationship between a plurality of words included in the sentence, and construct, according to the dependency relationship, a dependency syntax tree corresponding to the sentence. Optionally, the terminal may further perform dependency parsing on the at least two statements respectively by using a dependency parsing tool, and obtain a dependency syntax tree corresponding to each statement, so as to obtain at least two dependency syntax trees. The at least two sentences may be chinese sentences, english sentences, or sentences in other languages, which is not limited in the embodiments of the present application. The dependency parsing tool may be a tool constructed based on a statistical method, a tool constructed based on deep learning, or a tool constructed based on some rule, which is not limited in the embodiment of the present application.
For example, taking the case that the terminal performs dependency syntax analysis on two chinese sentences to be matched, respectively, as shown in fig. 3, fig. 3 is a schematic diagram of a dependency syntax tree according to an embodiment of the present application. In FIG. 3, two dependency syntax trees are included, one for each Chinese statement. In the dependency syntax tree corresponding to the sentence "he says a large real word", three words of "he", "he" and "large real word" all have dependency relationship with "say", and the word of "one sentence" has dependency relationship with "large real word". In the dependency syntax tree corresponding to the sentence "she once has lie", the four words "she", "once", "having" and "lying" all have a dependency relationship with "say".
In an optional implementation manner, in obtaining the at least two dependency syntax trees, in response to the dependency syntax tree including a compound word, the terminal may further perform word segmentation on the compound word to obtain at least two words, and retain dependency relationships before and after word segmentation. The compound word is obtained by compounding at least two words according to a certain grammatical rule, for example, the compound word 'beauty' is obtained by compounding two words of 'beauty' and 'human', and for example, the compound word 'football' is obtained by compounding two words of 'foot' and 'ball'. The terminal can make the words in the dependency syntax tree become the minimum word unit by further segmenting the compound words, so that the words can be conveniently represented in a vector form.
For example, the "big real word" in fig. 3 is a compound word, and two words, namely the "big" word and the "real word" word are obtained after word segmentation, and if the original dependency relationship is kept unchanged, both the words have a dependency relationship with the "say", and both the words have a dependency relationship with the "say". For another example, some english words include a prefix or a suffix, and the terminal may separate the prefix or the suffix of a word by word segmentation to obtain the prefix or the suffix and another word.
202. And the terminal constructs an edge between two nodes for representing the two words in response to the fact that the two words in the at least two sentences have dependency relations or do not belong to the same sentence, so as to obtain an object graph, wherein one node of the object graph is used for representing one word in the at least two sentences.
In this embodiment, after obtaining the at least two dependency syntax trees, the terminal may construct a target graph based on the at least two dependency syntax trees, where a node in the target graph is used to represent a term, and an edge in the target graph is used to represent that there is a dependency relationship between terms represented by nodes connected by the edge or that the terms do not belong to the same sentence. In the above technical process, that is, for any term in any statement, in the target graph, the node corresponding to the term is connected to the node corresponding to each term in other statements through an edge, and the node corresponding to the term is connected to the nodes corresponding to other terms having a dependency relationship in the same statement through an edge.
For example, referring to fig. 4, fig. 4 is a schematic diagram of a target map provided according to an embodiment of the present application. In fig. 4, continuing with the example of the dependency syntax tree corresponding to the two chinese sentences shown in fig. 3, 11 words included in the two chinese sentences are taken as 11 nodes in the target graph, where the 11 words include two words of "large" and "real" resulting from the word segmentation of "large real word". For any word in the 11 words, such as "he", because there is a dependency relationship between "he" and the word "say" in the same sentence, an edge is constructed between the node corresponding to "he" and the node corresponding to "say", and because "he" does not belong to the same sentence as the five words of "she", "ever", "say", "has", and "lies", an edge is constructed between the node corresponding to "he" and the node corresponding to the five words.
203. The terminal replaces the mask matrix in the language model with the adjacent matrix of the target graph, and the mask matrix is used for making the part values participating in the calculation useless.
In this embodiment, the terminal may determine the semantic relationship between the at least two sentences through a language model, and the language model may be composed of multiple layers of transformers (a model for natural language processing), and the transformers are mainly based on an encoder-decoder structure and an attention mechanism. The language model comprises a mask matrix, and some data participating in calculation can be masked by the mask matrix, so that the influence of the part of values on parameter updating is eliminated, namely the part of values do not influence the result of parameter updating no matter taking any value. The adjacency matrix of the target graph is used for representing the adjacent relation between the nodes in the target graph, that is, the elements in the adjacency matrix are used for representing that two terms have dependency relationship or do not belong to the same statement, and not only reflects the relation of the terms between the statements, but also reflects the relation of the terms in the statement. The mask matrix is replaced by the adjacency matrix of the target graph, so that on one hand, certain data can be continuously covered, on the other hand, the relation between words can be enhanced according to the adjacency matrix, the relation between semantic components is deepened, and the understanding of structural semantics is enhanced.
204. And the terminal determines the semantic relation between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model.
In this embodiment of the application, the terminal may input the statement vectors corresponding to the at least two statements into the replaced language model, and determine the semantic relationship between the at least two statements according to the output result of the replaced language model. Accordingly, this step can be realized by sub-step 2041 to 2043:
2041. and the terminal inputs the sentence vectors corresponding to the at least two sentences into the replaced language model.
The terminal can connect the at least two sentences together to form a target sentence, and combines word vectors corresponding to all the words in the target sentence into the sentence vector; the terminal can also obtain word vectors corresponding to words in each of the at least two sentences, and combine the obtained word vectors into the sentence vectors. The terminal can convert the words in the at least two sentences into corresponding word vectors based on an embedding algorithm.
2042. And the terminal determines the similarity degree between the words in the at least two sentences based on the coding layer of the language model.
The language model may be constructed based on multiple layers of transformers, the structure of which simply includes an encoding component including at least one encoder and a decoding component including the same number of decoders as the encoders. The layer at which the coding components are located may be referred to as the coding layer of the language model. Among other things, the encoder may include two sublayers: the encoder receives at least one vector as input, transfers the received vector to the self-attention layer, transmits an output result of the self-attention layer to the feedforward neural network, and finally sends the output of the feedforward neural network to the next encoder.
In the self-attention layer, the terminal calculates the self-attention of each word through the word vector based on a self-attention mechanism, and the step of calculating the self-attention of each word through the word vector may be as follows: in the first step, for each word vector in the input sentence vector, a Query vector, a Key vector, and a Value vector are created. The vectors can be obtained by multiplying the word vectors by corresponding weight matrixes respectively, wherein the dimension number of the weight matrixes is smaller than that of the word vectors. E.g., the number of dimensions of the weight matrix is 64, while the number of dimensions of the word vector and the vector of the input/output of the encoder is 512. By reducing the dimensionality of the vector, the fixation in dimensionality can be maintained while performing the attention moment matrix calculation. And secondly, calculating the association information between each word, wherein the association information is used for expressing the association degree between the words and can be expressed in a numerical form. And for the Query vector of any word, calculating the dot product of the Query vector of the word and the Key vectors of other words to obtain the association information between the word and other words. And thirdly, dividing the associated information by the square root of the dimensionality of the Key vector to ensure that the updating process is more stable. Fourthly, the calculation result is normalized, for example by means of logistic regression, so that the result after normalization is added up to 1. And fifthly, multiplying the Value vector of each word by the result of the standardization processing respectively. And sixthly, adding the multiplication results obtained in the fifth step to obtain the self attention of one word, wherein the self attention is used for expressing the similarity degree of the word and other words.
For example, by qi、kiAnd viA Query vector, a Key vector, and a Value vector, respectively, for word i. The degree of association between words can be normalized by formula (1), and the second to fourth steps are realized. The above-described fifth step and sixth step are then realized by formula (2).
Figure BDA0002388310030000091
Wherein, αijRepresenting the association information between words i and j, exp () representing an exponential function with a natural constant e as the base, qiA Query vector representing the word i,
Figure BDA0002388310030000092
a Key vector representing a word j, T representing a transpose, L representing a total number of words in at least two statements, L being a positive integer, L representing a wordIs detected.
Figure BDA0002388310030000093
Wherein o isiSelf-attention, α, to the word iijRepresenting association information between word i and word j, vjThe Value vector representing the word j.
In an alternative implementation, the second to sixth steps can be simplified to a matrix calculation, as shown in formula (3).
Figure BDA0002388310030000101
Wherein, O represents a matrix with elements of similarity between words, softmax () represents a logistic regression function, Q represents a matrix formed by Query vectors of words, K represents a matrix formed by Key vectors of words, T represents transposition, dkRepresenting the degree of dimension, V represents a matrix of Value vectors for each word.
In an optional implementation manner, when the terminal calculates the degree of association between each word in the coding layer, the terminal may adjust association information between the words, where the association information is used to indicate the degree of association between the words. The corresponding steps can be as follows: the terminal may adjust first correlation information between words satisfying the target condition to second correlation information according to the adjacency matrix of the target graph, where a degree of correlation between words represented by the second correlation information is greater than the first correlation information, and the terminal determines a degree of similarity between words in the at least two sentences according to the second correlation information. The target condition may be a word belonging to a different statement or a word belonging to the same statement and having a dependency relationship. By adjusting the association information between the words, the association degree between the words can be enhanced, thereby enhancing the relationship between semantic structures.
In an alternative implementation manner, the first associated information and the second associated information may be represented in a numerical form, so that the terminal may adjust the associated information between the words through a target parameter optimized along with the training of the language model. The corresponding steps can be as follows: the terminal can take the element value of the adjacency matrix as a relationship enhancement parameter, the value of the relationship enhancement parameter is 1 or 0, 1 represents that the target condition is satisfied between words, and 0 represents that the target condition is not satisfied between words. The terminal obtains a target parameter, inputs the target parameter into an activation function, the target parameter is a parameter optimized along with the training of the language model, and the activation function is used for ensuring the association degree between forward enhancement words. The terminal can adjust the first associated information between the words according to the product of the relationship enhancement parameter and the activation function to obtain second associated information. Through the characteristics of the adjacency matrix, terms satisfying the target condition can be indirectly represented based on the values of the elements in the adjacency matrix, that is, nodes corresponding to terms having dependency relationships or not belonging to the same sentence are connected by edges, and terms corresponding to the nodes connected by the edges are the terms satisfying the target condition. Whether the target conditions are met between the words is represented by the values of the elements in the adjacency matrix, so that the incidence relation between the words is adjusted, the judgment process is saved, and the calculation efficiency is improved.
For example, before the adjustment, the first correlation information may be calculated by the above formula (1). After the adjustment, the second correlation information may be calculated by formula (4).
Figure BDA0002388310030000111
Wherein, αijRepresenting the association information between words i and j, exp () representing an exponential function with a natural constant e as the base, qiA Query vector representing the word i,
Figure BDA0002388310030000112
key vector representing word j, T representing transpose, γijRepresents the enhancement coefficient of the relationship corresponding to word i and word j, i.e. the corresponding element value in the adjacency matrix, σ () represents the activation function, and λ represents the target parameter.
In an alternative implementation manner, the terminal may obtain an attention matrix corresponding to each word, and determine the similarity degree between the words based on the attention matrix. Correspondingly, the step of determining, by the terminal, the similarity degree between the words in the at least two sentences according to the second association information may be: for any word, the terminal may use the second association information between the other words in the two words as elements in the attention matrix corresponding to the word, and determine the similarity between the word and the other words according to the attention matrix and the value vectors of the other words. By adopting the mode of multiplying the matrix and the vector to calculate, the time required by calculation can be shortened to a certain extent, and the calculation efficiency is improved.
When two or more encoders are included in the encoding module, the encoders are stacked, the input of the bottommost encoder is the above statement vector, and the output of the bottommost encoder is the input of the encoder located adjacent to and above the bottommost encoder. That is, for any encoder in the encoding assembly except for the bottommost encoder and the topmost encoder, the input to the encoder is the output of the encoder that is adjacent to and below the encoder position, and the output of the encoder is the input to the encoder that is adjacent to and above the encoder position. By optionally including two or more encoders, the final output of the encoders, i.e., the input to the decoder, is made more accurate.
2043. The terminal determines a semantic relationship between at least two sentences based on a decoding layer of the language model.
After obtaining the output result of the coding layer, the terminal inputs the output result to a decoding component, where the layer where the decoding component is located may be referred to as a decoding layer of the language model. In the decoding layer, the terminal may decode an output result of the coding layer according to the adjacency matrix, and may determine a semantic relationship between the at least two sentences according to the output result of the decoding layer. Therein, the decoder may comprise three sub-layers: a self-attention layer, a codec attention layer, and a feed-forward neural network. The adjacency matrix may disable the partial values involved in the computation at the self-attention layer of the decoder, so that the self-attention layer only focuses on the earlier positions in the output sequence.
For example, if the output result corresponding to each word in one sentence corresponds to the output result corresponding to each word in another sentence, the two sentences are considered to be similar; otherwise, if none or only part of the two semantics are corresponding, the two semantics are considered dissimilar.
It should be noted that the steps described in the above step 201 to step 204 are optional implementations of the semantic matching method provided in the present application, and the flow of the implementation may also be shown in fig. 5, where fig. 5 is another flow chart of the semantic matching method provided according to an embodiment of the present application, and exemplarily shows a processing process of a terminal on two statements. In fig. 5, first, dependency syntax analysis is performed on each of sentence 1 and sentence 2 to obtain two dependency syntax trees. The two dependency syntax trees are then merged into one target graph. And then calculating an adjacency matrix corresponding to the target graph, and replacing the mask matrix of the language model with the adjacency matrix. And finally, outputting the semantic relation between the statement 1 and the statement 2 based on the replaced language model. The semantic relationship may be contradictory, similar, unrelated, or the like.
In other optional implementation schemes, the terminal may further form the at least two sentences into a word set respectively, where one sentence corresponds to one word set, construct, for any sentence, a graph corresponding to the sentence according to the dependency relationship among the words, and determine an edge set corresponding to the graph. Whether the word satisfies the target relationship is determined based on the set of edges. For example, taking sentence a and sentence B as examples, the words contained in sentence a form set S1The words contained in statement B form a set S2。G1Graph G representing correspondence of sentence A1Node in (1) represents S1Element (ii) E1Represents G1A corresponding set of edges. Similarly, G2Graph G representing correspondence of sentence A2Node in (1) represents S2Element (ii) E2Represents G2A corresponding set of edges. For any two words tiAnd tj,<ti,tj>Representing a slave word tiStarting from tjIf the directed edge exists in E1Or E2If t is equal to t, it means that there is a dependency relationship between the two wordsiAnd tjDo not appear at S at the same time1Or S2In (1), it means that the two words belong to different sentences. The relationship enhancement coefficient can be expressed by equation (5).
Figure BDA0002388310030000121
Wherein, γijRepresents the enhancement coefficient of the relationship between the word i and the word j, if represents the target condition, else represents the other condition, tiRepresenting the words i, tjRepresenting words j, SmRepresents the set m, SnRepresenting a set n.
In the embodiment of the application, the target graph is constructed according to the dependency relationship among the words in the sentences, edges are used for representing the dependency relationship among the words in the graph and the words do not belong to the same sentence, and the adjacency matrix of the target graph is used for replacing a mask matrix in the language model, so that the relationship among semantic structures is enhanced, and the accuracy of semantic matching is improved.
Fig. 6 is a block diagram of an apparatus for semantic matching according to an embodiment of the present application. The device is used for executing the steps when the method for semantic matching is executed, and referring to the figure, the device comprises the following steps: a construction module 601, a replacement module 602, and a determination module 603.
A constructing module 601, configured to construct a target graph based on dependency relationships of terms in the at least two statements to be matched, where one node of the target graph is used to represent one term in the at least two statements, and an edge of the target graph is used to represent that there is a dependency relationship between terms represented by nodes connected by the edge or that the terms do not belong to the same statement;
a replacing module 602, configured to replace a mask matrix in the language model with an adjacency matrix of the target graph, where the mask matrix is used to disable the partial values involved in the calculation;
a determining module 603, configured to determine a semantic relationship between at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model.
In an optional implementation manner, the constructing module 601 is further configured to perform dependency syntax analysis on at least two sentences to be matched, respectively, to obtain at least two dependency syntax trees, where one dependency syntax tree is used to represent a dependency relationship between words in one sentence; and in response to the fact that two terms in the at least two statements have dependency relationships or do not belong to the same statement, constructing an edge between two nodes for representing the two terms to obtain the target graph.
In an optional implementation manner, the determining module 603 is further configured to input statement vectors corresponding to at least two statements into the replaced language model; determining the similarity degree between words in at least two sentences based on a coding layer of a language model; based on a decoding layer of the language model, a semantic relationship between at least two statements is determined.
In an optional implementation manner, the determining module 603 is further configured to, in the encoding layer, adjust first association information between words that satisfy the target condition to second association information according to the adjacency matrix, where a degree of association between words represented by the second association information is greater than the first association information; and determining the similarity degree between the words in the at least two sentences according to the second association information.
In an alternative implementation manner, the first associated information and the second associated information are represented in a numerical form; the determining module 603 is further configured to use the element values of the adjacency matrix as relationship enhancement parameters, where a value of the relationship enhancement parameter is 1 or 0, 1 indicates that the target condition is satisfied between the words, and 0 indicates that the target condition is not satisfied between the words; acquiring target parameters, inputting the target parameters into an activation function, wherein the target parameters are parameters optimized along with the training of a language model, and the activation function is used for ensuring the association degree between forward enhancement words; and adjusting the first association information between the words according to the product of the relationship enhancement parameter and the activation function to obtain second association information.
In an alternative implementation, the target condition is any one of:
words belonging to different sentences;
words belonging to the same sentence and having a dependency relationship.
In an optional implementation manner, the determining module 603 is further configured to, for any word, use second association information between the word and other words in the two sentences as an element in an attention matrix corresponding to the word; and determining the similarity degree between the words and other words according to the attention matrix and the value vectors of other words.
In an optional implementation manner, the determining module 603 is further configured to decode, at the decoding layer, an output result of the encoding layer according to the adjacency matrix; and determining the semantic relation between at least two sentences according to the output result of the decoding layer.
In the embodiment of the application, the target graph is constructed according to the dependency relationship among the words in the sentences, edges are used for representing the dependency relationship among the words in the graph and the words do not belong to the same sentence, and the adjacency matrix of the target graph is used for replacing a mask matrix in the language model, so that the relationship among semantic structures is enhanced, and the accuracy of semantic matching is improved.
It should be noted that: in the semantic matching device provided in the above embodiment, when running an application program, only the division of the above functional modules is used for illustration, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the above described functions. In addition, the semantic matching device provided in the above embodiments and the semantic matching method embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments, and are not described herein again.
In the embodiment of the present application, the electronic device may be provided as a terminal or a server, and when the electronic device is provided as a terminal, the terminal may implement the operation performed by the semantic matching method; when the semantic matching method is provided as a server, the server can realize the operation executed by the semantic matching method, the server can receive at least two sentences to be matched sent by the terminal, the server determines the semantic relation between the at least two sentences based on a semantic matching platform, and the semantic relation is returned to the terminal; the operations performed by the above semantic matching method may also be implemented by the interaction of the server and the terminal.
The electronic device may be provided as a terminal, and fig. 7 is a block diagram of a terminal 700 according to an embodiment of the present disclosure. Fig. 7 is a block diagram illustrating a terminal 700 according to an exemplary embodiment of the present invention. The terminal 700 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group audio Layer III, motion Picture Experts compression standard audio Layer 3), an MP4 player (Moving Picture Experts Group audio Layer IV, motion Picture Experts compression standard audio Layer 4), a notebook computer, or a desktop computer. Terminal 700 may also be referred to by other names such as user equipment, portable terminal, laptop terminal, desktop terminal, and so on.
In general, terminal 700 includes: a processor 701 and a memory 702.
The processor 701 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on. The processor 701 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 701 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 701 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 701 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 702 may include one or more computer-readable storage media, which may be non-transitory. Memory 702 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 702 is used to store at least one instruction for execution by processor 701 to implement the method of semantic matching provided by the method embodiments herein.
In some embodiments, the terminal 700 may further optionally include: a peripheral interface 703 and at least one peripheral. The processor 701, the memory 702, and the peripheral interface 703 may be connected by buses or signal lines. Various peripheral devices may be connected to peripheral interface 703 via a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 704, a display screen 705, a camera assembly 706, an audio circuit 707, a positioning component 708, and a power source 709.
The peripheral interface 703 may be used to connect at least one peripheral related to I/O (Input/Output) to the processor 701 and the memory 702. In some embodiments, processor 701, memory 702, and peripheral interface 703 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 701, the memory 702, and the peripheral interface 703 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
The Radio Frequency circuit 704 is used for receiving and transmitting RF (Radio Frequency) signals, also called electromagnetic signals. The radio frequency circuitry 704 communicates with communication networks and other communication devices via electromagnetic signals. The rf circuit 704 converts an electrical signal into an electromagnetic signal to transmit, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 704 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so forth. The radio frequency circuitry 704 may communicate with other terminals via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: metropolitan area networks, various generation mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the radio frequency circuit 704 may also include NFC (Near Field Communication) related circuits, which are not limited in this application.
The display screen 705 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display screen 705 is a touch display screen, the display screen 705 also has the ability to capture touch signals on or over the surface of the display screen 705. The touch signal may be input to the processor 701 as a control signal for processing. At this point, the display 705 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the display 705 may be one, providing the front panel of the terminal 700; in other embodiments, the display 705 can be at least two, respectively disposed on different surfaces of the terminal 700 or in a folded design; in still other embodiments, the display 705 may be a flexible display disposed on a curved surface or on a folded surface of the terminal 700. Even more, the display 705 may be arranged in a non-rectangular irregular pattern, i.e. a shaped screen. The Display 705 may be made of LCD (liquid crystal Display), OLED (Organic Light-Emitting Diode), or the like.
The camera assembly 706 is used to capture images or video. Optionally, camera assembly 706 includes a front camera and a rear camera. Generally, a front camera is disposed at a front panel of the terminal, and a rear camera is disposed at a rear surface of the terminal. In some embodiments, the number of the rear cameras is at least two, and each rear camera is any one of a main camera, a depth-of-field camera, a wide-angle camera and a telephoto camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize panoramic shooting and VR (Virtual Reality) shooting functions or other fusion shooting functions. In some embodiments, camera assembly 706 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp, and can be used for light compensation at different color temperatures.
The audio circuitry 707 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 701 for processing or inputting the electric signals to the radio frequency circuit 704 to realize voice communication. For the purpose of stereo sound collection or noise reduction, a plurality of microphones may be provided at different portions of the terminal 700. The microphone may also be an array microphone or an omni-directional pick-up microphone. The speaker is used to convert electrical signals from the processor 701 or the radio frequency circuit 704 into sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, the audio circuitry 707 may also include a headphone jack.
The positioning component 708 is used to locate the current geographic position of the terminal 700 to implement navigation or LBS (location based Service). The positioning component 708 may be a positioning component based on the GPS (global positioning System) in the united states, the beidou System in china, the graves System in russia, or the galileo System in the european union.
Power supply 709 is provided to supply power to various components of terminal 700. The power source 709 may be alternating current, direct current, disposable batteries, or rechargeable batteries. When power source 709 includes a rechargeable battery, the rechargeable battery may support wired or wireless charging. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, terminal 700 also includes one or more sensors 710. The one or more sensors 710 include, but are not limited to: acceleration sensor 711, gyro sensor 712, pressure sensor 713, fingerprint sensor 714, optical sensor 715, and proximity sensor 716.
The acceleration sensor 711 can detect the magnitude of acceleration in three coordinate axes of a coordinate system established with the terminal 700. For example, the acceleration sensor 711 may be used to detect components of the gravitational acceleration in three coordinate axes. The processor 701 may control the display screen 705 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 711. The acceleration sensor 711 may also be used for acquisition of motion data of a game or a user.
The gyro sensor 712 may detect a body direction and a rotation angle of the terminal 700, and the gyro sensor 712 may cooperate with the acceleration sensor 711 to acquire a 3D motion of the terminal 700 by the user. From the data collected by the gyro sensor 712, the processor 701 may implement the following functions: motion sensing (such as changing the UI according to a user's tilting operation), image stabilization at the time of photographing, game control, and inertial navigation.
Pressure sensors 713 may be disposed on a side frame of terminal 700 and/or underneath display 705. When the pressure sensor 713 is disposed on a side frame of the terminal 700, a user's grip signal on the terminal 700 may be detected, and the processor 701 performs right-left hand recognition or shortcut operation according to the grip signal collected by the pressure sensor 713. When the pressure sensor 713 is disposed at a lower layer of the display screen 705, the processor 701 controls the operability control on the UI interface according to the pressure operation of the user on the display screen 705. The operability control comprises at least one of a button control, a scroll bar control, an icon control and a menu control.
The fingerprint sensor 714 is used for collecting a fingerprint of a user, and the processor 701 identifies the identity of the user according to the fingerprint collected by the fingerprint sensor 714, or the fingerprint sensor 714 identifies the identity of the user according to the collected fingerprint. When the user identity is identified as a trusted identity, the processor 701 authorizes the user to perform relevant sensitive operations, including unlocking a screen, viewing encrypted information, downloading software, paying, changing settings, and the like. The fingerprint sensor 714 may be disposed on the front, back, or side of the terminal 700. When a physical button or a vendor Logo is provided on the terminal 700, the fingerprint sensor 714 may be integrated with the physical button or the vendor Logo.
The optical sensor 715 is used to collect the ambient light intensity. In one embodiment, the processor 701 may control the display brightness of the display screen 705 based on the ambient light intensity collected by the optical sensor 715. Specifically, when the ambient light intensity is high, the display brightness of the display screen 705 is increased; when the ambient light intensity is low, the display brightness of the display screen 705 is adjusted down. In another embodiment, processor 701 may also dynamically adjust the shooting parameters of camera assembly 706 based on the ambient light intensity collected by optical sensor 715.
A proximity sensor 716, also referred to as a distance sensor, is typically disposed on a front panel of the terminal 700. The proximity sensor 716 is used to collect the distance between the user and the front surface of the terminal 700. In one embodiment, when the proximity sensor 716 detects that the distance between the user and the front surface of the terminal 700 gradually decreases, the processor 701 controls the display 705 to switch from the bright screen state to the dark screen state; when the proximity sensor 716 detects that the distance between the user and the front surface of the terminal 700 is gradually increased, the processor 701 controls the display 705 to switch from the breath-screen state to the bright-screen state.
Those skilled in the art will appreciate that the configuration shown in fig. 7 is not intended to be limiting of terminal 700 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
The electronic device may be provided as a server, and fig. 8 is a schematic structural diagram of a server provided in an embodiment of the present application, where the server 800 may generate a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 801 and one or more memories 802, where the memories 802 store at least one instruction, and the at least one instruction is loaded and executed by the processors 801 to implement the semantic matching method provided by each method embodiment. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input/output interface, so as to perform input/output, and the server may also include other components for implementing the functions of the device, which are not described herein again.
The embodiment of the present application also provides a computer-readable storage medium, which is applied to an electronic device, and the computer-readable storage medium stores at least one program code, where the at least one program code is used for being executed by a processor and implementing the operations performed by the electronic device in the semantic matching method in the embodiment of the present application.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only exemplary of the present application and should not be taken as limiting, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (15)

1. A method of semantic matching, the method comprising:
constructing a target graph based on the dependency relationship of the words in the at least two sentences to be matched in the sentences, wherein one node of the target graph is used for representing one word in the at least two sentences, and the edges of the target graph are used for representing that the dependency relationship exists between the words represented by the nodes connected by the edges or the words do not belong to the same sentence;
replacing a mask matrix in a language model with an adjacency matrix of the target graph, the mask matrix being used to make the partial values involved in the calculation useless;
and determining the semantic relation between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model.
2. The method according to claim 1, wherein constructing a target graph based on dependencies between words in at least two sentences to be matched comprises:
performing dependency syntax analysis on at least two sentences to be matched respectively to obtain at least two dependency syntax trees, wherein one dependency syntax tree is used for representing the dependency relationship among words in one sentence;
and in response to the dependency relationship between two words in the at least two sentences or the two words do not belong to the same sentence, constructing an edge between two nodes for representing the two words to obtain a target graph.
3. The method according to claim 1, wherein the determining the semantic relationship between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model comprises:
inputting statement vectors corresponding to the at least two statements into the replaced language model;
determining a similarity degree between words in the at least two sentences based on a coding layer of the language model;
determining a semantic relationship between the at least two statements based on a decoding layer of the language model.
4. The method of claim 3, wherein determining the degree of similarity between words in the at least two sentences based on the coding layer of the language model comprises:
in the coding layer, according to the adjacency matrix, adjusting first association information among the words meeting target conditions to second association information, wherein the association degree among the words represented by the second association information is greater than the first association information;
and determining the similarity degree between the words in the at least two sentences according to the second association information.
5. The method according to claim 4, wherein the first and second association information are represented in numerical form;
the adjusting, according to the adjacency matrix, first association information between words that satisfy a target condition to second association information includes:
taking the element value of the adjacency matrix as a relation enhancement parameter, wherein the value of the relation enhancement parameter is 1 or 0, 1 represents that the target condition is met among the words, and 0 represents that the target condition is not met among the words;
acquiring target parameters, and inputting the target parameters into an activation function, wherein the target parameters are parameters optimized along with the training of the language model, and the activation function is used for ensuring the association degree between forward enhancement words;
and adjusting the first association information between the words according to the product of the relationship enhancement parameter and the activation function to obtain the second association information.
6. The method according to any one of claims 4 or 5, wherein the target condition is any one of:
words belonging to different sentences;
words belonging to the same sentence and having a dependency relationship.
7. The method according to any one of claims 4 or 5, wherein the determining the similarity between words in the at least two sentences according to the second association information comprises:
for any word, taking second association information between the word and other words in the two sentences as an element in an attention matrix corresponding to the word;
determining a degree of similarity between the word and the other words according to the attention matrix and the value vectors of the other words.
8. The method of claim 3, wherein determining the semantic relationship between the at least two statements based on a decoding layer of the language model comprises:
decoding the output result of the coding layer at the decoding layer according to the adjacent matrix;
and determining the semantic relation between the at least two sentences according to the output result of the decoding layer.
9. A semantic matching apparatus, the apparatus comprising:
the system comprises a construction module, a matching module and a matching module, wherein the construction module is used for constructing a target graph based on the dependency relationship of terms in the at least two statements to be matched, one node of the target graph is used for representing one term in the at least two statements, and the edge of the target graph is used for representing that the dependency relationship exists between the terms represented by the nodes connected by the edge or does not belong to the same statement;
a replacement module, configured to replace a mask matrix in a language model with an adjacency matrix of the target graph, where the mask matrix is used to disable partial values involved in the calculation;
and the determining module is used for determining the semantic relation between the at least two sentences based on the sentence vectors corresponding to the at least two sentences and the replaced language model.
10. The apparatus according to claim 9, wherein the constructing module is further configured to perform dependency syntax analysis on at least two sentences to be matched, respectively, to obtain at least two dependency syntax trees, where one dependency syntax tree is used to represent a dependency relationship between words in one sentence; and in response to the dependency relationship between two words in the at least two sentences or the two words do not belong to the same sentence, constructing an edge between two nodes for representing the two words to obtain a target graph.
11. The apparatus according to claim 9, wherein the determining module is further configured to input statement vectors corresponding to the at least two statements into the replaced language model; determining a similarity degree between words in the at least two sentences based on a coding layer of the language model; determining a semantic relationship between the at least two statements based on a decoding layer of the language model.
12. The apparatus according to claim 11, wherein the determining module is further configured to, in the coding layer, adjust first association information between words that satisfy a target condition to second association information according to the adjacency matrix, where a degree of association between words indicated by the second association information is greater than the first association information; and determining the similarity degree between the words in the at least two sentences according to the second association information.
13. The apparatus of claim 12, wherein the first association information and the second association information are represented in numerical form; the determining module is further configured to use the element values of the adjacency matrix as relationship enhancement parameters, where a value of the relationship enhancement parameter is 1 or 0, 1 indicates that the target condition is satisfied between words, and 0 indicates that the target condition is not satisfied between words; acquiring target parameters, and inputting the target parameters into an activation function, wherein the target parameters are parameters optimized along with the training of the language model, and the activation function is used for ensuring the association degree between forward enhancement words; and adjusting the first association information between the words according to the product of the relationship enhancement parameter and the activation function to obtain the second association information.
14. An electronic device, comprising a processor and a memory, wherein the memory is configured to store at least one piece of program code, and wherein the at least one piece of program code is loaded by the processor and executes the method for semantic matching according to any one of claims 1 to 8.
15. A storage medium for storing at least one piece of program code for performing the method of semantic matching according to any one of claims 1 to 8.
CN202010105193.2A 2020-02-20 2020-02-20 Semantic matching method and device, electronic equipment and storage medium Pending CN111324699A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010105193.2A CN111324699A (en) 2020-02-20 2020-02-20 Semantic matching method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010105193.2A CN111324699A (en) 2020-02-20 2020-02-20 Semantic matching method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111324699A true CN111324699A (en) 2020-06-23

Family

ID=71171154

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010105193.2A Pending CN111324699A (en) 2020-02-20 2020-02-20 Semantic matching method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111324699A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112269884A (en) * 2020-11-13 2021-01-26 北京百度网讯科技有限公司 Information extraction method, device, equipment and storage medium
CN113254473A (en) * 2021-07-05 2021-08-13 中国气象局公共气象服务中心(国家预警信息发布中心) Method and device for acquiring weather service knowledge
CN114417838A (en) * 2022-04-01 2022-04-29 北京语言大学 Method for extracting synonym block pairs based on transformer model
CN114444472A (en) * 2022-04-02 2022-05-06 北京百度网讯科技有限公司 Text processing method and device, electronic equipment and storage medium
CN114492457A (en) * 2022-02-16 2022-05-13 平安科技(深圳)有限公司 Semantic recognition method and device, electronic equipment and storage medium
CN114548115A (en) * 2022-02-23 2022-05-27 北京三快在线科技有限公司 Method and device for explaining compound nouns and electronic equipment

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112269884A (en) * 2020-11-13 2021-01-26 北京百度网讯科技有限公司 Information extraction method, device, equipment and storage medium
CN112269884B (en) * 2020-11-13 2024-03-05 北京百度网讯科技有限公司 Information extraction method, device, equipment and storage medium
CN113254473A (en) * 2021-07-05 2021-08-13 中国气象局公共气象服务中心(国家预警信息发布中心) Method and device for acquiring weather service knowledge
CN113254473B (en) * 2021-07-05 2021-09-24 中国气象局公共气象服务中心(国家预警信息发布中心) Method and device for acquiring weather service knowledge
CN114492457A (en) * 2022-02-16 2022-05-13 平安科技(深圳)有限公司 Semantic recognition method and device, electronic equipment and storage medium
CN114492457B (en) * 2022-02-16 2023-07-07 平安科技(深圳)有限公司 Semantic recognition method, semantic recognition device, electronic equipment and storage medium
CN114548115A (en) * 2022-02-23 2022-05-27 北京三快在线科技有限公司 Method and device for explaining compound nouns and electronic equipment
CN114548115B (en) * 2022-02-23 2023-01-06 北京三快在线科技有限公司 Method and device for explaining compound nouns and electronic equipment
CN114417838A (en) * 2022-04-01 2022-04-29 北京语言大学 Method for extracting synonym block pairs based on transformer model
CN114444472A (en) * 2022-04-02 2022-05-06 北京百度网讯科技有限公司 Text processing method and device, electronic equipment and storage medium
CN114444472B (en) * 2022-04-02 2022-07-12 北京百度网讯科技有限公司 Text processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110097019B (en) Character recognition method, character recognition device, computer equipment and storage medium
CN110134804B (en) Image retrieval method, device and storage medium
CN111324699A (en) Semantic matching method and device, electronic equipment and storage medium
CN110750992B (en) Named entity recognition method, named entity recognition device, electronic equipment and named entity recognition medium
CN110807325B (en) Predicate identification method, predicate identification device and storage medium
CN110162604B (en) Statement generation method, device, equipment and storage medium
CN110147533B (en) Encoding method, apparatus, device and storage medium
CN111581958A (en) Conversation state determining method and device, computer equipment and storage medium
CN114281956A (en) Text processing method and device, computer equipment and storage medium
CN110555102A (en) media title recognition method, device and storage medium
WO2020151685A1 (en) Coding method, device, apparatus, and storage medium
CN113763931B (en) Waveform feature extraction method, waveform feature extraction device, computer equipment and storage medium
CN110990549B (en) Method, device, electronic equipment and storage medium for obtaining answer
CN110837557B (en) Abstract generation method, device, equipment and medium
CN112287070A (en) Method and device for determining upper and lower position relation of words, computer equipment and medium
CN113836946B (en) Method, device, terminal and storage medium for training scoring model
CN113032560B (en) Sentence classification model training method, sentence processing method and equipment
CN114328815A (en) Text mapping model processing method and device, computer equipment and storage medium
CN111310701B (en) Gesture recognition method, device, equipment and storage medium
CN111640432B (en) Voice control method, voice control device, electronic equipment and storage medium
CN113822084A (en) Statement translation method and device, computer equipment and storage medium
CN110096707B (en) Method, device and equipment for generating natural language and readable storage medium
CN112487162A (en) Method, device and equipment for determining text semantic information and storage medium
CN114154520A (en) Training method of machine translation model, machine translation method, device and equipment
CN111782767A (en) Question answering method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40023575

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination