Text matching method, device, equipment and storage medium

By combining the first vector output from the pre-trained model and the second vector determined by the vocabulary dependence relationship in the text to be matched, a more accurate target vector is formed, which solves the problem of low text matching accuracy in the prior art and achieves higher text matching accuracy.

CN113297354BActive Publication Date: 2025-03-07WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110669568.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-16
Publication Date
2025-03-07
Estimated Expiration
2041-06-16

AI Technical Summary

Technical Problem

In the prior art, when text matching, the CLS flag bit vector output by the pretrained model is used as the target vector, resulting in a lower accuracy of text matching.

Method used

By obtaining the text to be matched and inputting it into the pre-trained model, a first vector representation is obtained. At the same time, based on the dependence between the words in the text to be matched, a second vector representation is determined, and a target vector representation is determined in combination with the two to improve the accuracy of text description.

Benefits of technology

By considering the dependencies between vocabulary in the text to be matched, the accuracy of the vector representation used to describe the text to be matched is improved, thereby improving the accuracy of the text matching results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113297354B_ABST
    Figure CN113297354B_ABST
Patent Text Reader

Abstract

The present application discloses a text matching method, apparatus, device and storage medium, the method comprising: when performing text matching, first inputting the text to be matched into a pre-trained model to obtain a first vector representation corresponding to the text to be matched, and determining a second vector representation corresponding to the text to be matched based on the dependency relationship between words in the text to be matched, and then combining the first vector and the second vector representation to jointly determine a target vector representation corresponding to the text to be matched, fully considering the dependency relationship between words in the text to be matched, and improving the accuracy of the vector representation used to describe the text to be matched; thus, determining the matching result of the text to be matched based on the target vector representation with higher accuracy, and improving the accuracy of the text matching result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a text matching method, device, equipment and storage medium. Background Art

[0002] Text matching has been widely used in more and more fields, such as intelligent question answering or text.

[0003] In the prior art, when performing text matching, a CLS flag is first added to the first position of the text to be matched, and the added text to be matched is input into a pre-trained model, and the vector of the last layer of CLS flags in the output result of the pre-trained model is determined as a target vector for describing the text to be matched, and then the similarity between the target vector and the vector corresponding to the pre-stored text is calculated, so as to determine whether the text to be matched matches the text in the database based on the similarity.

[0004] However, using the existing matching method to determine the vector of the last layer of CLS flag in the output result of the pre-training model as the target vector for describing the text to be matched will result in low accuracy of text matching. Summary of the invention

[0005] The main purpose of this application is to provide a text matching method, apparatus, device and storage medium, aiming to improve the accuracy of text matching.

[0006] To achieve the above object, the present application provides a text matching method, which includes:

[0007] Get the text to be matched.

[0008] The text to be matched is input into a pre-trained model to obtain a first vector representation corresponding to the text to be matched, and a second vector representation corresponding to the text to be matched is determined based on the dependency relationship between words in the text to be matched.

[0009] A target vector representation corresponding to the to-be-matched text is determined according to the first vector representation and the second vector representation.

[0010] According to the target vector representation, a matching result of the text to be matched is determined.

[0011] In a possible implementation, determining the second vector representation corresponding to the text to be matched according to the dependency relationship between the words in the text to be matched includes:

[0012] The text to be matched is input into a pre-trained dependency syntactic analysis model to obtain dependency relations between words in the text to be matched.

[0013] At least one core word in the text to be matched is determined according to the dependency relationship between the words in the text to be matched.

[0014] The second vector representation is determined according to the vector representation corresponding to each core word in the at least one core word.

[0015] In a possible implementation, the number of the core words is at least two, and determining the second vector representation according to the vector representation corresponding to each core word in the at least one core word includes:

[0016] Perform weighted averaging on the vector representations corresponding to the core words; and determine the weighted averaging result as the second vector representation.

[0017] In a possible implementation, determining a target vector representation corresponding to the to-be-matched text according to the first vector representation and the second vector representation includes:

[0018] The first vector representation and the second vector representation are concatenated to obtain a concatenated vector representation.

[0019] The vector representation after the concatenation process is determined as the target vector representation.

[0020] In a possible implementation, inputting the to-be-matched text into a pre-trained model to obtain a first vector representation corresponding to the to-be-matched text includes:

[0021] The text to be matched is input into the pre-trained model to obtain an output result corresponding to the text to be matched.

[0022] The vectors of the last two layers in the output result are weighted averaged to obtain the first vector representation.

[0023] In a possible implementation, determining the matching result of the to-be-matched text according to the target vector representation includes:

[0024] The cosine similarity between the target vector representation and a preset vector representation corresponding to the preset text is determined.

[0025] The matching result of the text to be matched is determined according to the cosine similarity; wherein the matching result includes that the text to be matched matches the preset text; or, the text to be matched does not match the preset text.

[0026] In a possible implementation, the method further includes:

[0027] If the matching result is that the text to be matched matches the preset text, response information corresponding to the preset text is determined.

[0028] The response information is output.

[0029] The present application also provides a text matching device, which may include:

[0030] The acquisition unit is used to acquire the text to be matched.

[0031] A processing unit is used to input the text to be matched into a pre-trained model to obtain a first vector representation corresponding to the text to be matched, and determine a second vector representation corresponding to the text to be matched based on the dependency relationship between words in the text to be matched.

[0032] A determination unit is used to determine a target vector representation corresponding to the text to be matched according to the first vector representation and the second vector representation, and to determine a matching result of the text to be matched according to the target vector representation.

[0033] The present application also provides an electronic device, comprising: a memory, a processor, and a text matching program stored in the memory and executable on the processor, wherein the text matching program, when executed by the processor, implements the steps of the text matching method as described in any possible implementation of the first aspect above.

[0034] The present application also provides a computer-readable storage medium, on which a text matching program is stored. When the text matching program is executed by a processor, the steps of the text matching method described in any possible implementation of the first aspect are implemented.

[0035] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the text matching method described in any possible implementation manner of the first aspect above.

[0036] In the present application, when performing text matching, the text to be matched is first input into the pre-trained model to obtain the first vector representation corresponding to the text to be matched, and the second vector representation corresponding to the text to be matched is determined based on the dependency relationship between the words in the text to be matched, and then the first vector and the second vector representation are combined to jointly determine the target vector representation corresponding to the text to be matched, which fully takes into account the dependency relationship between the words in the text to be matched and improves the accuracy of the vector representation used to describe the text to be matched; in this way, the matching result of the text to be matched is determined based on the target vector representation with higher accuracy, thereby improving the accuracy of the text matching result. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A schematic diagram of a framework of an application scenario provided in an embodiment of the present application;

[0038] Figure 2 A flowchart of a text matching method provided in an embodiment of the present application;

[0039] Figure 3 A flowchart of a method for determining a second vector representation corresponding to a text to be matched provided in an embodiment of the present application;

[0040] Figure 4 A structural schematic diagram of a text matching device provided in an embodiment of the present application;

[0041] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0042] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0043] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0044] The text matching method provided by the embodiment of the present application can be applied to intelligent voice question-and-answer scenarios and text matching scenarios. Taking the application to intelligent voice question-and-answer scenarios as an example, for example, a user inputs "Hello, what will the weather be like tomorrow?" to a smart device. If the smart device has sufficient computing power, after collecting the voice information input by the user, the voice information can be converted into text information first, and the text information is used as a matching basis to search for preset text information matching the voice information from the question-and-answer library. If it is determined through text matching that the preset text information "What will the weather be like tomorrow" exists in the question-and-answer library, the response message corresponding to the preset text information, that is, the answer corresponding to the preset text information "What will the weather be like tomorrow" is "The weather will be sunny tomorrow, suitable for outdoor activities", and the answer "The weather will be sunny tomorrow, suitable for outdoor activities" is output to the user to complete this voice question-and-answer operation.

[0045] It is understandable that if the computing power of the smart device is weak, after converting the voice information into text information, the text information can be used as a matching basis and sent to an electronic device for performing text matching operations, such as a terminal or a server. For example, see Figure 1 As shown, Figure 1A framework diagram of an application scenario provided for an embodiment of the present application, in which the electronic device searches for preset text information matching the voice information from a question and answer library. If, through text matching, it is determined that the preset text information "What's the weather like tomorrow?" exists in the question and answer library, the answer "Tomorrow's weather will be sunny and suitable for outdoor activities" corresponding to the preset text information "What's the weather like tomorrow?" is sent to the smart device, so that the smart device outputs the answer "Tomorrow's weather will be sunny and suitable for outdoor activities" to the user, thereby completing the voice question and answer operation.

[0046] Combined with the above description, it can be seen that if the voice question-and-answer operation is to be completed accurately, the accuracy of text matching needs to be improved. Only when the corresponding preset text is accurately matched can the answer corresponding to the preset text be output, so that the voice question-and-answer operation can be completed accurately. However, in the prior art, when performing text matching, a CLS flag is first added to the first position of the text to be matched, and the added text to be matched is input into the pre-trained model, and then the vector of the last layer of CLS flags in the output result of the pre-trained model is determined as the target vector used to describe the text to be matched, which will result in a low accuracy of text matching.

[0047] In order to improve the accuracy of text matching, the dependency relationship between words in the text to be matched is taken into account, so that the text to be matched can be described more accurately. Therefore, when determining the target vector used to describe the text to be matched, the target vector used to describe the text to be matched can be determined based on the vector representation corresponding to the text to be matched obtained through the pre-trained model, combined with the dependency relationship between words in the text to be matched, thereby improving the accuracy of the vector representation used to describe the text to be matched. In this way, the matching result of the text to be matched is determined based on the target vector representation with higher accuracy, which can effectively improve the accuracy of the text matching result.

[0048] Based on the above technical concept, the embodiment of the present application provides a text matching method. The text matching method provided by the present application will be described in detail below through specific embodiments. It is understandable that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0049] Figure 2 This is a flowchart of a text matching method provided in an embodiment of the present application. The text matching method can be executed by software and / or hardware devices. For example, the hardware device can be a text matching device, and the text matching device can be a terminal or a server. For example, see Figure 2 As shown, the text matching method may include:

[0050] S201, obtaining text to be matched.

[0051] For example, the text to be matched can be "Hello, what's the weather like tomorrow?" or "Service A is not only easy to operate, but also the money arrives quickly." It can be set according to actual needs. In the embodiment of the present application, the text to be matched will be "Service A is not only easy to operate, but also the money arrives quickly" as an example for explanation, but it does not mean that the embodiment of the present application is limited to this.

[0052] For example, when obtaining the text to be matched, if in the intelligent voice question-answering scenario, the voice to be matched can be collected first, and the voice to be matched can be converted into the corresponding text to be matched; or, the text to be matched obtained by converting the voice to be matched sent by the collection device can be directly received, so as to obtain the text to be matched. If in the text scenario, the text to be matched input by the user can be directly received, so as to obtain the text to be matched. The specific settings can be made according to actual needs. Here, the embodiment of the present application does not make specific restrictions on the method of obtaining the text to be matched.

[0053] After obtaining the text to be matched, the following S202 may be executed:

[0054] S202: Input the text to be matched into the pre-trained model to obtain a first vector representation corresponding to the text to be matched, and determine a second vector representation corresponding to the text to be matched based on the dependency relationship between words in the text to be matched.

[0055] For example, the dependency relations between words may include 15 kinds of dependency relations, such as subject-verb (SBV), verb-object (VOB), in which the object is a direct object, indirect-object (IOB), in which the object is an indirect object, fronting-object (FOB), double (DBL), attribute (ATT), adverbial (ADV), complement (CMP), coordinate (COO), preposition-object (POB), left adjunct (LAD), right adjunct (RAD), independent structure (IS), and head (HED).

[0056] Taking the text to be matched as "Business A is not only easy to operate, but also has fast payment" as an example, the dependency relationship between the words in the text to be matched can be shown in the following Table 1:

[0057] Table 1

[0058]

[0059]

[0060] From Table 1, it can be seen that the text to be matched "A business is not only simple to operate, but also fast to arrive" includes 7 words and one punctuation mark, and the 7 words are "A business", "not only", "operation", "simple", "but also", "arrival", and "fast", among which, there is a SBV relationship between "A business" and "simple", an ADV relationship between "not only" and "simple", an ADV relationship between "operation" and "simple", and an ADV relationship between "simple". "Simple" is the core word, represented by 0, and there is a WP relationship between the punctuation mark "," and "simple", an ADV relationship between "but also" and "fast", an ADV relationship between "arrival" and "fast", and a COO relationship between "fast" and "simple".

[0061] For example, when determining the first vector representation corresponding to the text to be matched through a pre-trained model, in a possible implementation method, you can refer to the relevant description of the prior art, you can first add a CLS flag to the first position of the text to be matched, and input the added text to be matched into the pre-trained model, and determine the vector of the last layer of CLS flag in the output result of the pre-trained model as the first vector representation used to describe the text to be matched, thereby obtaining the first vector representation of the text to be matched.

[0062] In another possible implementation, in order to further improve the accuracy of the first vector representation obtained, there is no need to first add a CLS flag to the first position of the text to be matched. Instead, the text to be matched can be directly input into the pre-trained model to obtain the output result corresponding to the text to be matched; then the vectors of the last two layers in the output result are weighted averaged, and the weighted average result is determined as the first vector representation used to describe the text to be matched. In this way, the first vector representation of the text to be matched is determined by the vectors of the last two layers in the output result, which can improve the accuracy of the first vector representation obtained.

[0063] After respectively obtaining the first vector representation corresponding to the to-be-matched text and the second vector representation corresponding to the to-be-matched text, the target vector representation corresponding to the to-be-matched text can be determined by combining the first vector and the second vector representation, that is, executing the following S203:

[0064] S203: Determine a target vector representation corresponding to the text to be matched according to the first vector representation and the second vector representation.

[0065] It can be understood that in the embodiment of the present application, it is precisely because the dependency relationship between the words in the text to be matched is taken into account. Therefore, on the basis of the first vector representation, the target vector representation corresponding to the text to be matched is determined in combination with the second vector representation, so that the accuracy of the target vector representation can be improved; so that when the matching result of the text to be matched is subsequently determined according to the target vector representation with higher accuracy, the accuracy of the text matching result can be further improved.

[0066] S204: Determine the matching result of the text to be matched according to the target vector representation.

[0067] For example, when determining the matching result of the text to be matched based on the target vector representation, the cosine similarity between the target vector representation and the preset vector representation corresponding to the preset text can be first determined; and the matching result of the text to be matched is determined based on the cosine similarity; wherein the matching result includes that the text to be matched matches the preset text; or, the text to be matched does not match the preset text.

[0068] It should be noted that, in the embodiment of the present application, when determining the cosine similarity between the target vector representation and the preset vector representation corresponding to the preset text, the preset vector representation corresponding to the preset text can be determined and stored in advance, so that after determining the target vector representation corresponding to the text to be matched, the cosine similarity between the target vector representation and the preset vector representation corresponding to the preset text can be directly determined, which can improve the efficiency of text matching. Of course, if the efficiency of text matching is not considered, the preset text can be determined and stored in advance, and when determining the target vector representation corresponding to the text to be matched, the preset vector representation corresponding to the preset text is determined at the same time, and then the cosine similarity between the target vector representation and the preset vector representation corresponding to the preset text is determined.

[0069] It can be understood that in the embodiment of the present application, when determining the preset vector representation corresponding to the preset text, the determination method is similar to the method for determining the target vector representation corresponding to the text to be matched in the embodiment of the present application. The preset text can be first input into the pre-trained model to obtain the first vector representation corresponding to the preset text, and the second vector representation corresponding to the preset text is determined based on the dependency relationship between the words in the preset text. The first vector and the second vector representation are then combined to jointly determine the target vector representation corresponding to the preset text. Please refer to the relevant description of the method for determining the target vector representation corresponding to the text to be matched, which will not be repeated here.

[0070] It can be seen that in an embodiment of the present application, when performing text matching, the text to be matched is first input into the pre-trained model to obtain a first vector representation corresponding to the text to be matched, and based on the dependency relationship between the words in the text to be matched, a second vector representation corresponding to the text to be matched is determined, and then the first vector and the second vector representation are combined to jointly determine the target vector representation corresponding to the text to be matched, which fully takes into account the dependency relationship between the words in the text to be matched and improves the accuracy of the vector representation used to describe the text to be matched; in this way, the matching result of the text to be matched is determined based on the target vector representation with higher accuracy, thereby improving the accuracy of the text matching result.

[0071] Combined with the above Figure 2 In order to facilitate understanding of how to determine the second vector representation corresponding to the to-be-matched text according to the dependency relationship between the words in the to-be-matched text in the above S203, the following will be described. Figure 3 The illustrated embodiment describes in detail how to determine the second vector representation corresponding to the text to be matched based on the dependency relationship between words in the text to be matched.

[0072] Figure 3 A flowchart of a method for determining a second vector representation corresponding to a text to be matched provided in an embodiment of the present application, the method for determining a second vector representation corresponding to a text to be matched can be executed by software and / or hardware devices, for example, the hardware device can also be a text matching device. For example, see Figure 3 As shown, the method for determining the second vector representation corresponding to the text to be matched may include:

[0073] S301: Input the text to be matched into a pre-trained dependency syntactic analysis model to obtain the dependency relationship between words in the text to be matched.

[0074] Among them, the dependency syntactic analysis model is mainly used to determine and analyze the dependency relationship between words. The input of the dependency syntactic analysis model is text, and the output is the dependency relationship between words in the text.

[0075] For example, when pre-training a dependency syntactic analysis model, a large number of training sample data sets need to be obtained. Since public text data sets are easy to obtain, a part of the public text data sets can be obtained as training sample data. In addition, in order to improve the accuracy of the dependency syntactic analysis model, on the basis of the public text data sets, text data sets in the subsequent use field of the dependency syntactic analysis model can be further obtained as training sample data. This can further improve the accuracy of the dependency syntactic analysis model.

[0076] After obtaining a large number of training sample data sets, each sample data in the training sample data sets can be segmented and POS tagged. For example, when performing word segmentation and POS tagging, a self-training model or open source tools, such as the jieba tool, can be used to perform word segmentation and POS tagging on each sample data. Taking the sample data "simple operation" as an example, after word segmentation and POS tagging, the sample data "operation (v) simple (a)" is obtained, where v represents a verb and a represents an adjective.

[0077] Then the processed training sample data set is annotated. For example, the annotation standard of the Language Technology Platform (LTP) can be referred to for annotation to obtain the annotated training sample data set. The annotated training sample data set includes the dependency relationship between the words in each training sample data set. Taking a certain training sample data in the training sample data set as "A business is not only simple to operate, but also fast to arrive", the dependency relationship between the words in the training sample data set can be seen in Table 1 above, where "A business" and "simple" have an SBV relationship, "not only" and "simple" have an ADV relationship, "operation" and "simple" have an ADV relationship, "simple" is the core word, represented by 0, the punctuation mark "," has a WP relationship with "simple", "and" and "fast" have an ADV relationship, "arrival" and "fast" have an ADV relationship, and "fast" and "simple" have a COO relationship.

[0078] After obtaining the labeled training sample data set, the labeled training sample data set can be used to train the dependency syntactic analysis model. The dependency syntactic analysis model can adopt the structure of Transformer-multilayer perceptron-double affine transformation network, and the training process is as follows:

[0079] a) In the labeled training sample data set, each word included in each training sample data is vectorized to obtain the vector representation of each word. The vector representation of each word is composed of a word vector, a part-of-speech vector and a position vector; that is; Among them, Ew represents the word vector of the vocabulary, which can be obtained by models such as word2vec, Glove, ELMO, and bert. Et represents the part-of-speech vector of the vocabulary, which is randomly initialized during training. Ep represents the position vector of the vocabulary, which is obtained by sine and cosine functions. Represents the concatenation operation between vectors.

[0080] b) Input the vectorized training sample data into the Transformer model for feature extraction, which is also vectorized in essence;

[0081] c) Input the output of the Transformer model into two multi-layer perceptron networks respectively. The two multi-layer perceptron networks will output two different vector representations Rh and Rd. Each word vector in Rh is a vector representation of the head in a pair of dependency relationships, and each word vector in Rd is a vector representation of the dependent in a pair of dependency relationships.

[0082] d) Inputting two different vector representations Rh and Rd into the double affine transformation network layer, obtaining the score matrix S through double affine transformation, and then predicting the dependency relationship between the words in the training sample data through the maximum spanning tree algorithm;

[0083] e) Compare the predicted labels of the dependency relationships between words in the training sample data with the true labels of the dependency relationships between words in the training sample data, calculate the error between the two labels, and update the parameters of the model through the back propagation algorithm until the dependency syntactic analysis model converges, and the result is a trained dependency syntactic analysis model.

[0084] In this way, after the dependency syntactic analysis model is trained, the text to be matched can be directly input into the pre-trained dependency syntactic analysis model during the text matching process to obtain the dependency relationship between the words in the text to be matched. After determining the dependency relationship between the words in the text to be matched, it is possible to accurately determine which words in the text to be matched are core words and which words are non-core words based on the dependency relationship between the words. In view of the fact that core words can usually describe the content of the text to be matched more accurately, while non-core words have less influence on the text to be matched, it is necessary to determine at least one core word in the text to be matched based on the dependency relationship between the words in the text to be matched, that is, to execute the following S302:

[0085] S302: Determine at least one core word in the text to be matched according to the dependency relationship between the words in the text to be matched.

[0086] In combination with the relevant description in the above S202, continuing to take the to-be-matched text "A business is not only simple to operate, but also arrives quickly" as an example, the dependency relationships between the words in the to-be-matched text include: there is a SBV relationship between "A business" and "simple", there is an ADV relationship between "not only" and "simple", there is an ADV relationship between "operation" and "simple", "simple" is the core word, represented by 0, there is a WP relationship between the punctuation mark "," and "simple", there is an ADV relationship between "and" and "fast", there is an ADV relationship between "arrival" and "fast", and there is a COO relationship between "fast" and "simple".

[0087] According to the dependency relationship between these eight words, it can be determined that the five words "A business", "operation", "simple", "arrival" and "fast" in the text to be matched are core words, and the two words "not only" and "but also" are non-core words.

[0088] It can be seen that the five core words "A business", "operation", "simple", "account arrival" and "fast" can accurately describe the content of the text to be matched, while the non-core words "not only" and "but also" have little influence on the matching text. Therefore, the second vector representation corresponding to the text to be matched can be determined according to the vector representation corresponding to the core words, that is, the following S303 is executed:

[0089] S303: Determine a second vector representation according to the vector representation corresponding to each core word in at least one core word.

[0090] For example, when determining the second vector representation according to the vector representation corresponding to each core word in at least one core word, two cases may be included:

[0091] In one case, when the number of core words is one, the vector representation corresponding to the core word can be directly determined as the second vector representation corresponding to the text to be matched.

[0092] In another case, when the number of core words is at least two, the vector representations corresponding to the core words can be comprehensively considered to jointly determine the second vector representation corresponding to the text to be matched. The specific process is: the vector representations corresponding to the core words can be weighted averaged first, and the weighted average result can be determined as the second vector representation corresponding to the text to be matched.

[0093] It can be seen that in an embodiment of the present application, when determining the second vector representation corresponding to the text to be matched based on the dependency relationship between the words in the text to be matched, the text to be matched can be first input into a pre-trained dependency syntactic analysis model to obtain the dependency relationship between the words in the text to be matched; given that the core words in the text can usually describe the content of the text to be matched more accurately, while the non-core words have less influence on the text to be matched, therefore, based on the dependency relationship between the words in the text to be matched, at least one core word in the text to be matched can be determined; and based on the vector representation corresponding to each core word in at least one core word, the second vector representation can be determined, which can improve the accuracy of the second vector representation.

[0094] After determining the second vector representation corresponding to the text to be matched based on the dependency relationship between the words in the text to be matched, the target vector representation corresponding to the text to be matched can be determined based on the first vector representation corresponding to the text to be matched and the second vector representation. For example, when determining the target vector representation corresponding to the text to be matched based on the first vector representation and the second vector representation, the first vector representation and the second vector representation can be concatenated to obtain the concatenated vector representation; and the concatenated vector representation can be determined as the target vector representation.

[0095] For example, when the first vector representation and the second vector representation are spliced ​​together, the first vector representation can be used as the first half of the splicing, and the second vector representation can be used as the second half of the splicing, spliced ​​behind the first vector representation; the second vector representation can also be used as the first half of the splicing, and the first vector representation can be used as the second half of the splicing, spliced ​​behind the second vector representation, so that the vector representation after the splicing process is determined as the target vector representation. In this way, when the matching result of the text to be matched is determined according to the target vector representation, the accuracy of the vector representation used to describe the text to be matched is improved; in this way, the matching result of the text to be matched is determined according to the target vector representation with higher accuracy, thereby improving the accuracy of the text matching result.

[0096] Based on any of the above embodiments, after determining the matching result of the text to be matched, if the matching result is that the text to be matched matches the preset text, response information corresponding to the preset text can be further determined; and the corresponding response information can be output.

[0097] Taking the application in intelligent voice question and answer scenario as an example, the user inputs "Hello, how is the weather tomorrow?" to the smart device. If the smart device has sufficient computing power, after collecting the voice information input by the user, the voice information can be first converted into text to be matched to determine whether there is a preset text matching the text to be matched in the question and answer library. If it is determined through text matching that the preset text "How is the weather tomorrow" exists in the question and answer library, the response message corresponding to the preset text, that is, the answer corresponding to the preset text information "How is the weather tomorrow" "Tomorrow the weather will be sunny, suitable for outdoor activities" is output to the user to complete this voice question and answer operation.

[0098] Figure 4 A structural diagram of a text matching device 40 provided in an embodiment of the present application is provided. For example, see Figure 4 As shown, the text matching device 40 may include:

[0099] The acquisition unit 401 is used to acquire the text to be matched.

[0100] The processing unit 402 is used to input the text to be matched into the pre-trained model to obtain a first vector representation corresponding to the text to be matched, and determine a second vector representation corresponding to the text to be matched based on the dependency relationship between words in the text to be matched.

[0101] The determination unit 403 is used to determine a target vector representation corresponding to the text to be matched according to the first vector representation and the second vector representation, and determine a matching result of the text to be matched according to the target vector representation.

[0102] Optionally, the processing unit 402 is specifically used to input the text to be matched into a pre-trained dependency syntactic analysis model to obtain the dependency relationship between words in the text to be matched; determine at least one core word in the text to be matched based on the dependency relationship between words in the text to be matched; and determine a second vector representation based on the vector representation corresponding to each core word in the at least one core word.

[0103] Optionally, the number of core words is at least two, and the processing unit 402 is specifically configured to perform weighted averaging on the vector representations corresponding to the core words; and determine the weighted averaging result as the second vector representation.

[0104] Optionally, the determination unit 403 is specifically configured to perform concatenation processing on the first vector representation and the second vector representation to obtain a concatenated vector representation; and determine the concatenated vector representation as the target vector representation.

[0105] Optionally, the processing unit 402 is specifically used to input the text to be matched into the pre-trained model to obtain an output result corresponding to the text to be matched; and perform weighted averaging on the vectors of the last two layers in the output result to obtain a first vector representation.

[0106] Optionally, the determination unit 403 is specifically used to determine the cosine similarity between the target vector representation and the preset vector representation corresponding to the preset text; determine the matching result of the text to be matched based on the cosine similarity; wherein the matching result includes that the text to be matched matches the preset text; or, the text to be matched does not match the preset text.

[0107] Optionally, the text matching device 40 further includes an output unit 404 .

[0108] The determination unit 403 is further configured to determine response information corresponding to the preset text if the matching result is that the to-be-matched text matches the preset text.

[0109] The output unit 404 is used to output response information.

[0110] The text matching device 40 provided in the embodiment of the present application can execute the technical solution of the text matching method in any of the above-mentioned embodiments. Its implementation principle and beneficial effects are similar to the implementation principle and beneficial effects of the text matching method. Please refer to the implementation principle and beneficial effects of the text matching method, and no further details will be given here.

[0111] Figure 5 This is a schematic diagram of the structure of an electronic device 50 provided in an embodiment of the present application, for example, see Figure 5 As shown, the electronic device may include: a memory 501, a processor 502, and a model parameter determination program stored in the memory 501 and executable on the processor 502, wherein the model parameter determination program, when executed by the processor 502, implements the steps of the model parameter determination method as described in any of the foregoing embodiments.

[0112] Optionally, the memory 501 may be independent or integrated with the processor 502 .

[0113] The electronic device 50 shown in the embodiment of the present application can execute the technical solution of the text matching method in any of the above-mentioned embodiments. Its implementation principle and beneficial effects are similar to the implementation principle and beneficial effects of the text matching method. Please refer to the implementation principle and beneficial effects of the text matching method, and no further details will be given here.

[0114] An embodiment of the present application also provides a computer-readable storage medium, on which a text matching program is stored. When the text matching program is executed by a processor, the steps of the text matching method described in any of the above embodiments are implemented. The implementation principle and beneficial effects are similar to those of the text matching method. Please refer to the implementation principle and beneficial effects of the text matching method, which will not be repeated here.

[0115] An embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the technical solution of the text matching method in any of the above embodiments. Its implementation principle and beneficial effects are similar to those of the text matching method. Please refer to the implementation principle and beneficial effects of the text matching method, and no further details will be given here.

[0116] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed.

[0117] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present application.

[0118] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0119] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0120] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0121] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.

[0122] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0123] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0125] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A text matching method, characterized in that: include: Get the text to be matched; Inputting the text to be matched into a pre-trained model to obtain a first vector representation corresponding to the text to be matched, and determining a second vector representation corresponding to the text to be matched according to the dependency relationship between words in the text to be matched; Determine a target vector representation corresponding to the to-be-matched text according to the first vector representation and the second vector representation; Determining a matching result of the text to be matched according to the target vector representation; Determining the second vector representation corresponding to the text to be matched according to the dependency relationship between the words in the text to be matched includes: Inputting the text to be matched into a pre-trained dependency syntactic analysis model to obtain dependency relations between words in the text to be matched; Determining at least one core word in the text to be matched according to the dependency relationship between the words in the text to be matched; Determine the second vector representation according to the vector representation corresponding to each core word in the at least one core word; The determining the second vector representation according to the vector representation corresponding to each core word in the at least one core word includes: When the number of the core words is one, determining the vector representation corresponding to the core words as the second vector representation corresponding to the text to be matched; When the number of the core words is at least two, weighted averaging is performed on the vector representations corresponding to the core words, and the weighted averaging result is determined as the second vector representation.

2. The method according to claim 1, characterized in that The step of determining a target vector representation corresponding to the to-be-matched text according to the first vector representation and the second vector representation includes: Performing concatenation processing on the first vector representation and the second vector representation to obtain a concatenated vector representation; The vector representation after the concatenation process is determined as the target vector representation.

3. The method according to claim 1, characterized in that The step of inputting the text to be matched into a pre-trained model to obtain a first vector representation corresponding to the text to be matched includes: Input the text to be matched into the pre-trained model to obtain an output result corresponding to the text to be matched; The vectors of the last two layers in the output result are weighted averaged to obtain the first vector representation.

4. The method according to claim 1, characterized in that: The step of determining the matching result of the text to be matched according to the target vector representation includes: Determining the cosine similarity between the target vector representation and a preset vector representation corresponding to the preset text; The matching result of the text to be matched is determined according to the cosine similarity; wherein the matching result includes that the text to be matched matches the preset text; or, the text to be matched does not match the preset text.

5. The method according to claim 4, characterized in that The method further comprises: If the matching result is that the text to be matched matches the preset text, determining response information corresponding to the preset text; The response information is output.

6. A text matching device, characterized in that: include: An acquisition unit, used to acquire the text to be matched; A processing unit, used for inputting the text to be matched into a pre-trained model to obtain a first vector representation corresponding to the text to be matched, and determining a second vector representation corresponding to the text to be matched according to the dependency relationship between words in the text to be matched; A determination unit, configured to determine a target vector representation corresponding to the text to be matched according to the first vector representation and the second vector representation, and determine a matching result of the text to be matched according to the target vector representation; The processing unit is specifically used to input the text to be matched into a pre-trained dependency syntactic analysis model to obtain the dependency relationship between the words in the text to be matched; determine at least one core word in the text to be matched according to the dependency relationship between the words in the text to be matched; determine the second vector representation according to the vector representation corresponding to each core word in the at least one core word; The processing unit is specifically used to, when the number of the core words is one, determine the vector representation corresponding to the core words as the second vector representation corresponding to the text to be matched; when the number of the core words is at least two, perform weighted averaging on the vector representations corresponding to the core words, and determine the weighted average result as the second vector representation.

7. An electronic device, characterized in that: The electronic device comprises: a memory, a processor, and a text matching program stored in the memory and executable on the processor, wherein the text matching program implements the steps of the text matching method according to any one of claims 1 to 5 when executed by the processor.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a text matching program, and when the text matching program is executed by a processor, the steps of the text matching method according to any one of claims 1 to 5 are implemented.

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the text matching method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Data matching method, device and equipment and storage medium

    CN109710744A