Text matching method, device, equipment and storage medium

By using constraint generation rules and a tree-structured text matching model in the intelligent customer service system, the problem of low matching efficiency caused by too many pre-stored statements is solved, and efficient matching of text sequences is achieved.

CN117290555BActive Publication Date: 2025-09-23MASHANG CONSUMER FINANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210698963.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-20
Publication Date
2025-09-23
Estimated Expiration
2042-06-20

AI Technical Summary

Technical Problem

In existing intelligent customer service systems, the excessive number of pre-stored statements leads to low text matching efficiency, which affects user experience.

Method used

A text matching model that uses constraint generation rules stores pre-stored text sequences through a tree structure diagram, and generates the prediction range of the current character based on the prediction result of the previous character and the constraint conditions, narrowing the prediction range of each character to improve matching efficiency.

Benefits of technology

When there are a large number of pre-stored text sequences, the matching efficiency of text sequences is significantly improved, the amount of calculation is reduced, and the response speed of the intelligent customer service system is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117290555B_ABST
    Figure CN117290555B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a text matching method and device, which include: obtaining a text sequence to be matched; generating a predicted string formed by prediction results of multiple characters based on the text sequence through a text matching model configured with constraint generation rules, wherein the predicted string is the matching result of the text sequence in multiple pre-stored text sequences; the constraint generation rules include: the constraint condition of the first character in the predicted string is a preset starting constraint condition, and the constraint condition of each character in the predicted string except the first character is generated according to the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is obtained by the text matching model based on the constraint condition of the previous character and the text sequence prediction; the tree structure diagram is used to represent multiple pre-stored text sequences stored according to the tree structure, thereby improving the matching efficiency of the text sequence.
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, apparatus, device and storage medium. Background Art

[0002] With the development of electronic technology, the use of intelligent customer service is becoming increasingly common. Compared with human customer service, intelligent customer service offers the significant advantage of saving manpower. However, users' demands for efficiency and accuracy are increasing, creating unprecedented challenges. During the operation of intelligent customer service, the excessive number of pre-stored sentences leads to inefficient text matching, resulting in a poor customer experience. Summary of the Invention

[0003] The embodiments of the present application provide a text matching method and apparatus to improve the matching efficiency of text sequences.

[0004] In a first aspect, an embodiment of the present application provides a text matching method, comprising:

[0005] Get the text sequence to be matched;

[0006] generating, based on the text sequence, a predicted character string formed by prediction results of a plurality of characters using a text matching model configured with constraint generation rules, wherein the predicted character string is a matching result of the text sequence in a plurality of pre-stored text sequences;

[0007] The constraint condition generation rules include:

[0008] The constraint condition for the first character in the predicted string is a preset starting constraint condition, and the constraint condition for each character in the predicted string except the first character is generated based on the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is obtained by the text matching model based on the constraint condition of the previous character and the text sequence prediction; the tree structure diagram is used to represent the multiple pre-stored text sequences stored in a tree structure.

[0009] In a second aspect, an embodiment of the present application provides another text matching method, including:

[0010] Get the text sequence to be matched;

[0011] Predicting the first character according to the text sequence and the starting constraint of the first character of the sequence to be predicted to obtain a prediction result of the first character;

[0012] The step of generating each character except the first character in the sequence to be predicted corresponding to the text sequence includes:

[0013] Generate a constraint condition for predicting the current character based on a prediction result of a previous character of the current character and a preset tree structure diagram; the tree structure diagram is used to represent a plurality of pre-stored text sequences stored in a tree structure;

[0014] Predicting the current character according to the text sequence and the constraints of the current character to obtain a prediction result of the current character;

[0015] The predicted target text sequence is used as the matching result of the text sequence in the multiple pre-stored text sequences; the target text sequence is composed of the prediction results of each character in the sequence to be predicted.

[0016] In a third aspect, an embodiment of the present application provides a text matching device, comprising:

[0017] A first acquisition module is used to acquire a text sequence to be matched;

[0018] A generation module is used to generate a predicted string formed by prediction results of multiple characters based on the text sequence through a text matching model configured with constraint generation rules, wherein the predicted string is the matching result of the text sequence in multiple pre-stored text sequences; the constraint generation rules include: the constraint of the first character in the predicted string is a preset starting constraint, and the constraint of each character in the predicted string except the first character is generated according to the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is predicted by the text matching model based on the constraint of the previous character and the text sequence; the tree structure diagram is used to represent the multiple pre-stored text sequences stored in a tree structure.

[0019] In a fourth aspect, an embodiment of the present application provides another text matching device, comprising:

[0020] A first acquisition module is used to acquire a text sequence to be matched;

[0021] A generation module is used to generate a predicted string formed by prediction results of multiple characters based on the text sequence through a text matching model configured with constraint generation rules, wherein the predicted string is the matching result of the text sequence in multiple pre-stored text sequences; the constraint generation rules include: the constraint of the first character in the predicted string is a preset starting constraint, and the constraint of each character in the predicted string except the first character is generated according to the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is predicted by the text matching model based on the constraint of the previous character and the text sequence; the tree structure diagram is used to represent the multiple pre-stored text sequences stored in a tree structure.

[0022] In a fifth aspect, an embodiment of the present application provides a text matching device, comprising: a processor; and a memory configured to store computer-executable instructions, wherein the computer-executable instructions, when executed, cause the processor to execute the text matching method described in the first aspect and the text matching method described in the second aspect.

[0023] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, implement the text matching method described in the first aspect and the text matching method described in the second aspect.

[0024] It can be seen that in an embodiment of the present application, first, a text sequence to be matched is obtained; a text matching model configured with constraint generation rules is used to generate a predicted string formed by prediction results of multiple characters based on the text sequence, and the predicted string is a matching result of the text sequence in multiple pre-stored text sequences; the constraint generation rules include: the constraint of the first character in the predicted string is a preset starting constraint, and the constraint of each character in the predicted string except the first character is generated according to the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is predicted by the text matching model based on the constraint of the previous character and the text sequence; the tree structure diagram is used to represent multiple pre-stored text sequences stored according to the tree structure. In this way, in the character prediction process of the text matching model, the constraint conditions of the current character can be generated based on the prediction results of the previous character and the tree structure diagram. The number of branch nodes adjacent to each node in the tree structure diagram is limited, so the prediction range of the current character predicted using the constraint conditions and the text sequence is significantly narrowed. Therefore, each character in the predicted string is predicted within a very small prediction range determined based on the previous character, thereby improving the matching efficiency of the text sequence when the number of pre-stored text sequences is large. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments described in this specification. Those skilled in the art can also derive other drawings based on these drawings without inventive work.

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

[0027] Figure 2 A tree structure diagram of a text matching method provided in an embodiment of the present application;

[0028] Figure 3 A schematic diagram of a text matching model in a text matching method provided in an embodiment of the present application;

[0029] Figure 4 A flowchart of another text matching method provided in an embodiment of the present application;

[0030] Figure 5 A schematic diagram of a text matching device provided in an embodiment of the present application;

[0031] Figure 6 A schematic diagram of another text matching device provided in an embodiment of the present application;

[0032] Figure 7 A schematic diagram of the structure of a text matching device provided in an embodiment of the present application; DETAILED DESCRIPTION

[0033] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0034] In practical applications, the number of pre-stored text sequences may be very large. In order to determine the matching results of the text sequence to be matched in the massive pre-stored text sequences, it is often necessary to calculate the similarity between the text sequence to be matched and each pre-stored text sequence separately, and sort them according to the similarity. This process is labor-intensive and inefficient.

[0035] In view of this, in order to improve the efficiency of text matching, this embodiment provides a text matching method, which obtains a text sequence to be matched; generates a predicted string formed by the prediction results of multiple characters based on the text sequence through a text matching model configured with a constraint generation rule, and the predicted string is the matching result of the text sequence in multiple pre-stored text sequences; the constraint generation rule includes: the constraint of the first character in the predicted string is a preset starting constraint, and the constraint of each character in the predicted string except the first character is generated according to the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is predicted by the text matching model based on the constraint of the previous character and the text sequence; the tree structure diagram is used to represent the multiple pre-stored text sequences stored in a tree structure. In this way, when the number of pre-stored text sequences is large, the constraint of each character can be generated in combination with the tree structure diagram, thereby greatly narrowing the prediction range of each character and improving the matching efficiency of the text sequence.

[0036] Figure 1 A text matching method processing flow chart provided in the embodiment of the present application. Figure 1 The text matching method provided in this embodiment specifically includes steps S102 to S104.

[0037] Step S102: Obtain a text sequence to be matched.

[0038] Methods for obtaining the text sequence to be matched include: receiving user input, collecting user information, reading historical data, etc.

[0039] A text sequence can be a string consisting of multiple characters.

[0040] For example, the text sequence to be matched can be the sequence x1x2...x entered by the user in the text input box. m , where m is a natural number greater than 0, x i The i-th character in the sequence entered by the user.

[0041] For example, user A and user B have a natural conversation in voice form through an electronic device. The electronic device can collect A's natural conversation and extract target voice data from it, and convert the target voice data into a text sequence to be matched.

[0042] For example, the electronic device reads the text sequence to be matched from the historical data according to a preset reading rule.

[0043] For example, the electronic device traverses a plurality of pre-configured text sequences to be processed, and during the traversal process, determines each traversed text sequence to be processed as a text sequence to be matched.

[0044] The text matching method provided in this embodiment can be applied to scenarios such as intelligent customer service scenarios, document retrieval scenarios, and other scenarios that require text matching, which will not be elaborated here.

[0045] Taking the intelligent customer service scenario as an example, the text sequence to be matched can be a question input by the user in the form of voice or text. For example: The user dials the customer service phone and asks "How to redeem points". In this sequence, x1 = "Ru", x2 = "He", x3 = "Dui", x4 = "Huan", x5 = "Ji", x6 = "Fen". The text sequences in other scenarios are similar to those in the intelligent customer service scenario, which will not be elaborated here.

[0046] Step S104, based on the text sequence, a text matching model configured with a constraint condition generation rule generates a prediction string formed by prediction results of multiple characters. The prediction string is the matching result of the text sequence in multiple pre-stored text sequences; the constraint condition generation rule includes: the constraint condition for the first character in the prediction string is a preset start constraint condition, and the constraint condition for each character except the first character in the prediction string is generated according to the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is predicted by the text matching model based on the constraint condition of the previous character and the text sequence; the tree structure diagram is used to represent multiple pre-stored text sequences stored according to the tree structure.

[0047] Next, taking the intelligent customer service scenario as an example, combined with Figure 2 Specifically illustrate the tree structure diagram and pre-stored text sequences. Figure 2 This is the tree structure diagram in a text matching method provided in an embodiment of the present application.

[0048] The use of the FAQ (Frequently Asked Questions) dialogue system in the intelligent customer service scenario is very common. After a customer of the FAQ dialogue system inputs a question on the FAQ dialogue system, the background will recognize the semantic information of the text and return an answer. The algorithm logic behind the FAQ dialogue system is usually as follows: First, collect business data and user log data, and maintain a FAQ question and answer library. The question and answer pairs in the question and answer library are stored in the form of "question-answer"; then, expand the standard questions in the question and answer pairs to expand multiple similar questions for semantic matching; when the user's question is input, the FAQ dialogue system will first perform a rough recall and query the question list (similar question list) with the highest text matching degree with the question in the FAQ library; then use a large model with higher accuracy for fine sorting. If the similarity between the question input by the user and any pre-stored question in the similar question list is greater than the preset similarity threshold, the relevant answer to the pre-stored question will be returned to the customer.

[0049] For example, in an intelligent customer service scenario, the pre-stored text sequence may be a preset question-answer pair. In a specific implementation, it may be assumed that the question-answer library in the FAQ dialogue system has 10 preset question-answer pairs as follows:

[0050] (1) How to redeem points—ans1

[0051] (2) How to check points—ans2

[0052] (3) Points Recharge—ans3

[0053] (4) Points expiration time—ans4

[0054] (5) How to deal with the expiration of points—ans5

[0055] (6) How to apply for a bank card—ans6

[0056] (7) How to unlock a bank card—ans7

[0057] (8) Lost bank card—ans8

[0058] (9) Retrieve bank card password—ans9

[0059] (10) What to do if you forget your bank card?—ans10

[0060] Each preset question-and-answer pair includes, but is not limited to, a question, an answer, and an interval identifier. For example, in the first preset question-and-answer pair, "How to redeem points—ans1," the question is "How to redeem points," the interval identifier is "—," and the answer is "ans1." ans1 through ans10 are the answers to the corresponding questions. The interval identifier can also be represented by the string "END," a preset character, or a preset string.

[0061] In the text matching method provided in this embodiment, the 10 preset question-answer pairs can be stored in a tree structure as follows: Figure 2 The tree structure diagram shown.

[0062] like Figure 2 As shown, START is the root node of the tree structure diagram, and the root node has two adjacent tree branches. The tree structure diagram includes multiple nodes, each of which corresponds to a character or a string.

[0063] In the specific implementation, in the first tree structure diagram, each node corresponds to a character; in the second tree structure diagram, each node corresponds to a string; in the third tree structure diagram, each node in a part of the nodes corresponds to a character, and each node in another part of the nodes corresponds to a string, such as Figure 2 As shown. The tree structure diagram applied to the text matching method can be one of the above-mentioned first tree structure diagram, second tree structure diagram, and third tree structure diagram.

[0064] If the tree structure diagram applied to the text matching method is the above-mentioned first tree structure diagram, the predicted string y1y2...y output by the text matching model n In, y i can be a character, i can be any natural number from 1 to n, and n can be a natural number greater than 0.

[0065] If the text matching method adopts the first tree structure diagram, the prediction result of each character can be a character.

[0066] If the tree structure diagram applied to the text matching method is the above-mentioned second tree structure diagram, the predicted string y1y2...y output by the text matching model n In, y i can be a string, i can be any natural number from 1 to n, and n can be a natural number greater than 0.

[0067] If the text matching method adopts the second tree structure diagram, the prediction result of each character can be a string.

[0068] If the tree structure diagram applied to the text matching method is the above-mentioned third tree structure diagram, as Figure 2 shown, the predicted string y1y2...y output by the text matching model n In, y i can be a character, such as "product", y i can also be a string, such as "END", i can be any natural number from 1 to n, and n can be a natural number greater than 0. If the text matching method adopts the third tree structure diagram, the prediction result of each character can be a character or a string.

[0069] For any specified node, there is a connection relationship between the specified node and at least one adjacent node below, and the arrow direction of the connection relationship points from the specified node to the adjacent node below, then the adjacent node below can be determined as the tree branch adjacent to the specified node. The same applies to the tree branch adjacent to the specified character.

[0070] Exemplarily, the node where the character "product" is located is node 1, the node where the character "points" is located is node 2, the node where the character "such as" is located is node 3, the node where the character "charge" is located is node 4, and the node where the character "arrive" is located is node 5. Then, the tree-like branch adjacent to node 1 can be node 2, and the tree-like branches adjacent to node 2 can be node 3, node 4, and node 5.

[0071] In Figure 2 , the tree-like branches adjacent to "product" include the node where "points" is located; the tree-like branches adjacent to "points" include the nodes where "such as", "charge", and "arrive" are located; the tree-like branches adjacent to "such as" include the node where "how" is located; the tree-like branches adjacent to "how" include "redeem" and "check"; the tree-like branches adjacent to "redeem" include the node where "exchange" is located; the tree-like branches adjacent to "exchange" include the node where "END" is located; the branches adjacent to "END" include the node where "ans1" is located. Then, the first preset Q&A pair "How to redeem points for END ans1" is stored in the tree structure diagram in the above manner.

[0072] In Figure 2 , the tree-like branches adjacent to "product" include the node where "points" is located; the tree-like branches adjacent to "points" include the nodes where "such as", "charge", and "arrive" are located; the tree-like branches adjacent to "such as" include the node where "how" is located; the tree-like branches adjacent to "how" include "redeem" and "check"; the tree-like branches adjacent to "check" include the node where "inquire" is located; the tree-like branches adjacent to "inquire" include the node where "END" is located; the branches adjacent to "END" include the node where "ans2" is located. Then, the second preset Q&A pair "How to query points for END ans2" is stored in the tree structure diagram in the above manner.

[0073] As Figure 2 shown, the first preset Q&A pair "How to redeem points for END ans1" and the second preset Q&A pair "How to query points for END ans2" share the nodes of "product", "points", "such as", and "how" in the tree structure diagram.

[0074] The way of storing other preset Q&A pairs in the tree structure diagram is similar to that of the aforementioned first preset Q&A pair and the second preset Q&A pair, which will not be elaborated here.

[0075] The tree structure diagram is used to represent multiple pre-stored text sequences stored in a tree structure. By making similar pre-stored text sequences share a part of the nodes, for example, the nodes corresponding to "product", "points", "such as", and "how" are commonly used in "How to redeem points for END an1" and "How to query points for END ans2", a part of the storage space is saved. Then, through the tree structure diagram, a smaller storage space can be used to store a larger number of pre-stored text sequences.

[0076] The text matching model includes a character prediction sub-model. The character prediction sub-model can be a text generation model, such as a VAE model and a seq2seq model.

[0077] In this embodiment, the "matching" may be that the text sequence to be matched semantically matches one of the multiple pre-stored text sequences. For example, the text sequence to be matched is "I want to ask how to redeem points", which semantically matches a pre-stored text sequence "How to redeem points".

[0078] In this embodiment, the "matching" may also be that the text sequence to be matched semantically matches a part of one of the multiple pre-stored text sequences. For example, the text sequence to be matched is "I want to ask how to redeem points", which semantically matches a part "How to redeem points" of a pre-stored text sequence "How to redeem points ENDans1".

[0079] Specifically, taking the intelligent customer service scenario as an example, a tree structure diagram stores multiple preset question-and-answer pairs. Each preset question-and-answer pair includes, but is not limited to, a question part, a separator identifier, and an answer part. For example, "How to apply for a bank card ENDans6", where "How to apply for a bank card" is the question part, "END" is the separator identifier, and "ans6" is the answer part. Through a text matching model configured with a constraint condition generation rule, based on the user's input question "How to apply for a bank card", a prediction string "How to apply for a bank card END" is generated. The prediction string is composed of the prediction results of multiple characters. The prediction string is the matching result of the user's input question "How to apply for a bank card" among multiple preset question-and-answer pairs. The user's input question "How to apply for a bank card" semantically matches the question part "How to apply for a bank card" of a preset question-and-answer pair "How to apply for a bank card ENDans6".

[0080] In the case of generating the prediction string "How to apply for a bank card END", the matching preset question-and-answer pair "How to apply for a bank card ENDans6" can be determined according to the prediction string, and the "an6" after the separator identifier in the matching preset question-and-answer pair can be fed back to the user who asks the question. Refer to Figure 2 , among the 1o preset question-and-answer pairs stored in the tree structure diagram, the first character is either "silver" or "points", and there is no other possibility. Then, the constraint condition of the first character of the prediction string, that is, the start constraint condition, can be set as follows: when predicting the first character, the probability that the character prediction sub-model may predict other characters except the two characters "points" and "silver" is set to 0. In this way, the value of the first character y1 predicted by the character prediction sub-model can only be one of "points" and "silver".

[0081] The constraint conditions for each character in the predicted string, except the first character y1, are generated based on the prediction result of the previous character and a preset tree structure diagram.

[0082] For example, the constraint condition for the second character y2 is generated based on the prediction result "product" of the first character and the tree structure diagram. Since in the Figure 2 tree structure diagram as shown, the tree branches adjacent to "product" only include the node where "division" is located, the constraint condition for the second character y2 can be set such that, on the premise that y1 is "product", the probability that the character prediction sub-model may predict other characters except "division" is set to 0. In this way, the value of the second character y2 predicted by the character prediction sub-model can only be "division".

[0083] Another example is that the constraint condition for the third character y3 is generated based on the prediction result "division" of the second character and the tree structure diagram. Since in the Figure 2 tree structure diagram as shown, the tree branches adjacent to "division" include the nodes where "such as", "fill", and "arrive" are located, the constraint condition for the third character y3 can be set such that, on the premise that the value of y1 is "product" and the value of y2 is "division", the probability that the character prediction sub-model may predict other characters except "such as", "fill", and "arrive" is set to 0. In this way, the value of the third character y3 predicted by the model can only be one of "such as", "fill", and "arrive".

[0084] And so on, the prediction result of each character in the predicted string is output through the character prediction sub-model until the prediction result of a character is the interval identifier, for example, "?". At this time, the predicted string "y1 y2... y n ?" output by the character prediction sub-model corresponds to one of the multiple preset text sequences stored in the tree structure diagram. For example, the predicted string output by the character prediction sub-model is "Bank card lost?", which matches "Bank card lost? ans8" among the multiple preset text sequences stored in the tree structure diagram.

[0085] It should be noted that to generate the prediction result of each character, the complete text sequence is required. That is, the character prediction sub-model predicts y1 based on x1x2...x m and the preset starting constraint conditions, and the text matching model predicts y2 based on x1x2...x m and the constraint condition of y2... The text matching model predicts y m based on x1x2...x n and the constraint condition of y n , and so on.

[0086] Next, it can be combined with Figure 3To illustrate the text matching model. Figure 3 A schematic diagram of a text matching model in a text matching method provided in an embodiment of the present application.

[0087] like Figure 3 As shown, the input value of the text matching model can be a text sequence x1x2...x m , the output value can be y1y2……y n END. Figure 3 It includes two embedding layers, which are used to vectorize the input values. Figure 3 The embedding layer in the left half can be the second embedding layer, which is used to embed the text sequence to be matched x1x2...x m Vectorization, in Figure 3 The embedding layer in the right half can be the first embedding layer, which is used to vectorize the prediction results of each character and then prepare data for generating the constraints of the next character. Figure 3 The word "predicted" in the prediction can be understood as the character prediction sub-model outputting the prediction results for each character in the prediction string. Figure 3 START in is used to indicate the preset starting constraints.

[0088] Optionally, the text matching model includes a second embedding layer; the second embedding layer is connected to the character prediction sub-model; based on the text sequence and the text matching model configured with constraint generation rules, a predicted character string formed by the prediction results of multiple characters is generated, including: vectorizing the text sequence through the second embedding layer to output a text vector sequence; performing character prediction processing on the text vector sequence through the character prediction sub-model to obtain a predicted character string corresponding to the text sequence.

[0089] like Figure 3 As shown, the text matching model includes a second embedding layer, namely Figure 3 The embedding layer on the left, the input value of the second embedding layer is the text sequence x1x2...x m , the output value is the vectorized text sequence. The second embedding layer is connected to the predicted character sub-model, so that the output result of the second embedding layer is input into the predicted character sub-model.

[0090] Through the second embedding layer, the text sequence x1x2...x m Perform vectorization processing to obtain a text vector sequence; input the text vector sequence into a character prediction model to perform character prediction processing to generate a predicted character string corresponding to the text sequence.

[0091] Optionally, the text matching model includes a character prediction sub-model; the text matching model configured with a constraint condition generation rule generates a prediction string formed by prediction results of multiple characters based on a text sequence, including: performing character prediction processing on the first character of the prediction string based on the text sequence according to the starting constraint condition through the character prediction sub-model to obtain the prediction result of the first character; and the generation steps of other characters except the first character in the prediction string include: generating the constraint condition of the current character according to the prediction result of the previous character of the current character; and obtaining the prediction result of the current character according to the text sequence, the constraint condition of the current character, and the character prediction sub-model.

[0092] Input the text sequence and the starting constraint condition into the character prediction sub-model to perform character prediction processing on the first character based on the text sequence according to the starting constraint condition, and obtain the prediction result of the first character in the prediction string.

[0093] Exemplarily, the text sequence x1x2...x m = "How to redeem points", that is, x1 = "怎", x2 = "么", x3 = "兑", x4 = "换", x5 = "积", x6 = "分". The preset starting constraint condition is that when predicting the first character, the probabilities of the text matching model predicting other characters except the two characters "积" and "银" are set to 0. Then, when the character prediction sub-model is configured with this starting constraint condition, according to the text sequence "How to redeem points", the probability of predicting the first character y1 = "积" is 90%, and the probability of y1 = "银" is 10%. Then, it is determined that the prediction result of y1 is "积".

[0094] In specific implementation, a prediction end condition can be preset. For example, when it is detected that the prediction result of an output character is an interval identifier, it can be determined that the complete prediction string has been output, and the constraint condition of the next character is no longer generated. The prediction string formed by the prediction results of each generated character is used as the output result of the text matching model to end the text matching process. In this case, it can be understood that the interval identifier "?" is the prediction result of the last character of the prediction string output by the text matching model.

[0095] The other characters except the first character in the prediction string are generated through the following two steps:

[0096] The first step is: generating the constraint condition of the current character according to the prediction result of the previous character of the current character.

[0097] Exemplarily, in the case where the prediction result of the previous character y1 is "product", the constraint condition of the current character y2 can be generated according to the prediction result "product" of y1 and the tree structure diagram; similarly, in the case where the prediction result of the previous character y2 is "division", the constraint condition of the current character y3 can be generated according to the prediction result "product" of y1, the prediction result "division" of y2, and the tree structure diagram... In the case where the prediction result of the previous character y n+1 is obtained, when it is detected that y n+1 = "?", and the preset prediction end condition is satisfied, the text matching process is ended. At this time, the predicted string obtained is "How to redeem points?".

[0098] The second step is: According to the text sequence, the constraint condition of the current character, and the character prediction sub-model, obtain the prediction result of the current character.

[0099] It should be noted that the text sequence only needs to be input into the character prediction sub-model once. During the process of character prediction processing for each character by the character prediction sub-model, this text sequence will be called once. For each character other than the first character, the constraint condition of the current character is input into the character prediction sub-model, and the character prediction sub-model calls the text sequence to perform character prediction processing on the current character based on the text sequence according to the constraint condition of the current character, so as to obtain the prediction result of the current character.

[0100] Exemplarily, the constraint condition of the current character y2 can be that on the premise that y1 is "product", the probability that the character prediction sub-model may predict other characters except "division" is set to 0, then the prediction result of y2 is "division"; the constraint condition of the current character y3 can be that on the premise that y1 is "product" and y2 is "division", the probability that the character prediction sub-model may predict other characters except "such as", "charge", "arrive" is set to 0. The character prediction sub-model predicts the third character y3 based on the text sequence according to the constraint condition of the current character y3, and obtains that the probability of the third character y3 being "such as" is 85%, the probability of the third character y3 being "charge" is 5%, and the probability of the third character y3 being "arrive" is 10%. Furthermore, it can be determined that the prediction result of y3 is "such as"... The constraint condition of the current character y n can be that the probability that the character prediction sub-model predicts characters or strings other than "END" is set to 0, then the prediction result of the current character y n is the string "END", which satisfies the prediction end condition, and no longer continues to generate the constraint condition of the next character, nor predicts the next character. The string formed by the prediction results of each currently generated character is determined as the predicted string, that is, the matching result of the text sequence in multiple pre-stored text sequences.

[0101] Optionally, the text matching model includes a first embedding layer and a constraint generation module configured with constraint generation rules; the character prediction sub-model, the first embedding layer and the constraint generation module are connected in series; based on the prediction result of the previous character of the current character, the constraint of the current character is generated, including: vectorizing the prediction result of the previous character obtained by the character prediction sub-model through the first embedding layer to obtain the prediction result vector of the previous character; generating the constraint of the current character according to the constraint generation rule based on the prediction result of the previous character through the constraint generation module.

[0102] like Figure 3 As shown, the text matching model includes the first embedding layer, i.e. Figure 3 The embedding layer on the right side of the figure takes as input the predicted result for each character, for example, the predicted result for y1, the predicted result for y2, and so on. n The prediction result is output as a prediction result vector for each character. The character prediction sub-model, the first embedding layer, and the constraint generation module are sequentially connected in series, and the constraint generation module is connected to the character prediction sub-model, so that the predicted character sub-model outputs the prediction result of the current character to the second embedding layer, the second embedding layer outputs the prediction result vector of the current character to the constraint generation module, and the constraint generation module outputs the constraint of the next character to the predicted character sub-model.

[0103] For characters other than the first character, the prediction result of the previous character y1 is vectorized through the first embedding layer to obtain the prediction result vector of the previous character y1, and the prediction result vector of the previous character y1 is input into the constraint generation module to generate the constraint of the current character y2. The constraint generation module inputs the constraint of the current character y2 into the character prediction sub-model, so that the character prediction sub-model performs character prediction processing based on the text sequence according to the constraint of the current character y2, obtains the prediction result of y2 and outputs it to the first embedding layer; the prediction result of the previous character y2 is vectorized through the first embedding layer to obtain the prediction result vector of the previous character y2, and the prediction result vector of the previous character y2 is input into the constraint generation module to generate the constraint of the current character y3. The constraint generation module inputs the constraint of the current character y3 into the character prediction sub-model, so that the character prediction sub-model performs character prediction processing based on the text sequence according to the constraint of the current character y3, obtains the prediction result of y3 and outputs it to the first embedding layer, and so on.

[0104] Optionally, based on the prediction result of the previous character, the constraint condition generation module generates the constraint condition of the current character according to the constraint condition generation rule, including: the constraint condition generation module queries in the tree structure diagram for the target character corresponding to the prediction result vector of the previous character and the branch characters corresponding to at least one tree branch adjacent to the target character; according to the at least one branch character, the constraint condition of the current character is generated.

[0105] According to the at least one branch character, generating the constraint condition of the current character may be to set the prediction results of the characters other than the at least one branch character to 0, so that the prediction result of the current character is one of the at least one branch character.

[0106] Specifically, as Figure 2 shown, if the prediction result of the previous character is "product", then the constraint condition generation module queries in the tree structure diagram to obtain the target character "product" corresponding to the prediction result vector of "product" and the branch character "division" corresponding to one tree branch adjacent to the target character "product". According to the branch character "division", the constraint condition of the current character is generated: on the premise that the previous character is "product", the probabilities of the text matching model possibly predicting other characters except "division" are set to 0.

[0107] For another example, if the prediction result of the previous character is "division", then the constraint condition generation module queries in the tree structure diagram to obtain the target character "division" corresponding to the prediction result vector of "division" and the branch characters "such as", "fill", and "arrive" corresponding to three tree branches adjacent to the target character "division". According to the above three branch characters, the constraint condition of the current character is generated: on the premise that y1 is "product" and y2 is "division", the probabilities of the text matching model possibly predicting other characters except "such as", "fill", and "arrive" are set to 0.

[0108] Optionally, the constraint condition of the current character includes at least one optional character; according to the text sequence, the constraint condition of the current character, and the character prediction sub-model, obtaining the prediction result of the current character includes: the character prediction sub-model determines at least one to-be-processed prediction result of the current character from at least one optional character according to the text sequence, and generates the prediction probability of each to-be-processed prediction result; the prediction probability of the to-be-processed prediction result is greater than zero; among the at least one to-be-processed prediction results, the to-be-processed prediction result with the highest prediction probability is determined as the prediction result of the current character.

[0109] If the tree structure diagram is the first tree structure diagram, the constraint condition of the current character may include one optional character or may include multiple optional characters.

[0110] If the tree structure diagram is the second tree structure diagram, the constraint condition of the current character may include an optional string or multiple optional strings.

[0111] If the tree structure diagram is the third tree structure diagram, the constraint condition of the current character may include an optional character, an optional string, multiple optional characters, multiple optional strings, at least one optional character and at least one optional string.

[0112] The function of the constraint condition is to preset the prediction probability of each character other than the optional character to 0. Among the at least one pending prediction result with a prediction probability greater than 0 generated by the character prediction sub-model, each character corresponding to the pending prediction result must be one of the optional characters.

[0113] If the number of pending prediction results is greater than one, the pending prediction result with the highest prediction probability is determined as the prediction result of the current character.

[0114] For example, the text sequence is "我想知道怎么查询积分" (I want to know how to query the points). In the constraint condition of the first character, the optional characters include "积" (points) and "银" (silver). Then the character prediction sub-model generates two pending prediction results for the first character: x1 "积" (points) and x2 "银" (silver). The prediction probability of x1 is 90%, and the prediction probability of x2 is 10%. Then x1 is determined as the prediction result of the first character.

[0115] Optionally, the text sequence is a dialogue text; the multiple pre-stored text sequences are multiple preset question-and-answer pairs; an interval identifier is set between the question part and the answer part of each preset question-and-answer pair; after the text matching model configured with the constraint condition generation rule generates a prediction string formed by the prediction results of multiple characters based on the text sequence, that is, after step S104 is executed, the text matching method further includes: determining the character position of the interval identifier in the prediction string; according to the character position of the interval identifier, determining the character or string after the interval identifier as the response information of the dialogue text and outputting it.

[0116] In another embodiment, the prediction end condition preset by the text matching model may be: when it is detected that the prediction result of a character output by the character prediction sub-model is an end identifier, it can be determined that the complete prediction string has been output, and the constraint condition for the next character is no longer generated. The prediction string formed by the prediction results of each character that has been generated is used as the output result of the text matching model, and the text matching process is ended. The end identifier is another symbol different from the interval identifier, which is used to determine the end of the matching process, such as ".". Exemplarily, a prediction string may include a question part, an interval identifier, an answer part, and an end identifier, and the question part is located before the interval identifier, the answer part is located after the interval identifier, and the end identifier is located after the answer part. In this case, the end identifier "." is the prediction result of the last character of the prediction string output by the text matching model.

[0117] For example, the predicted string "y1 y2..." output by the character prediction sub-model corresponds to one of the multiple preset text sequences stored in the tree structure diagram. For example, the predicted string "Bank card lost? ans8." output by the character prediction sub-model matches "Bank card lost? ans8." in the multiple preset text sequences stored in the tree structure diagram.

[0118] The conversation text may be text data of a conversation between at least two participants.

[0119] The conversation text may be conversation text data input by a user, conversation text data collected by an electronic device, conversation text data read from historical data, and so on.

[0120] In a specific implementation, in an intelligent customer service scenario, a text sequence can be a question input by a user; multiple pre-stored text sequences can be multiple preset question-answer pairs. A separator, such as a "?", is set between the question and answer parts of each preset question-answer pair.

[0121] A text matching model configured with constraint generation rules generates a prediction string formed by prediction results of multiple characters based on the text sequence. This can be done by inputting a question input by the user, for example, "How do I apply for a bank card?" into the text matching model configured with constraint generation rules, and generating a prediction string based on the question, for example, "How do I apply for a bank card? ans6", which is used as the matching result of the question input by the user "How do I apply for a bank card" in multiple preset question and answer pairs.

[0122] After generating a prediction string, for example, "How to apply for a bank card? ans6", the character position of the interval identifier "?" can be determined. For example, y1 = "bank", y2 = "card" ... y8 = "?", y9 = "a" ... y 12 = "6". Furthermore, according to the character position y8 of the interval identifier, the string "ans6" after the interval identifier is determined as the response information of the question and output.

[0123] In the Figure 1 illustrated embodiment, first, a text sequence to be matched is obtained; then, a text matching model configured with a constraint condition generation rule generates a prediction string formed by prediction results of multiple characters based on the text sequence. The prediction string is the matching result of the text sequence in multiple pre-stored text sequences; the constraint condition generation rule includes: the constraint condition for the first character in the prediction string is a preset start constraint condition, and the constraint condition for each character except the first character in the prediction string is generated according to the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is predicted by the text matching model based on the constraint condition of the previous character and the text sequence; the tree structure diagram is used to represent multiple pre-stored text sequences stored in a tree structure. In this way, in the character prediction process of the text matching model, based on the prediction result of the previous character and the tree structure diagram, the constraint condition of the current character can be generated. Since the number of adjacent branch nodes of each node in the tree structure diagram is limited, the prediction range of the current character predicted using this constraint condition and the text sequence is significantly reduced. Therefore, each character in the prediction string is predicted within a very small prediction range determined based on the previous character, thereby improving the matching efficiency of the text sequence when the number of pre-stored text sequences is large.

[0124] Due to a similar technical concept, the embodiment of the present application also provides another text matching method. Figure 4 This is a processing flowchart of another text matching method provided by the embodiment of the present application.

[0125] Step S402, obtain a text sequence to be matched.

[0126] The obtaining methods of the text sequence to be matched include: receiving user input, collecting user information, reading historical data, and so on.

[0127] The text sequence can be a string composed of multiple characters.

[0128] For example, the text sequence to be matched can be the sequence x1x2...x m input by the user in the text input box, where m is a natural number greater than 0, and x<00> i is the i-th character in the sequence input by the user.

[0129] For example, user A and user B have a natural conversation in voice form through an electronic device. The electronic device can collect the natural conversation of A and extract the target voice data from it, and convert the target voice data into a text sequence to be matched.

[0130] For example, the electronic device reads the text sequence to be matched from historical data according to a preset reading rule.

[0131] For example, the electronic device traverses multiple pre - processed text sequences configured in advance. During the traversal process, each traversed pre - processed text sequence is determined as the text sequence to be matched.

[0132] The text matching method provided in this embodiment can be applied to intelligent customer service scenarios, file retrieval scenarios, and other scenarios that require text matching, which will not be elaborated here. <000|0337>Taking the intelligent customer service scenario as an example, the text sequence to be matched can be a question input by the user in voice form or text form, such as: How to redeem points. In this sequence, x1 = "How", x2 = "to", x3 = "redeem", x4 = "points", x5 = "points", x6 = "points". The text sequences in other scenarios are similar to those in the intelligent customer service scenario, which will not be elaborated here.

[0134] Step S404: Predict the first character according to the starting constraint condition of the first character of the text sequence and the sequence to be predicted; the generation step of each character except the first character in the sequence to be predicted corresponding to the text sequence includes: generating the constraint condition for predicting the current character according to the prediction result of the previous character of the current character and a preset tree - shaped structure diagram; the tree - shaped structure diagram is used to represent multiple pre - stored text sequences stored in a tree - shaped structure; predict the current character according to the text sequence and the constraint condition of the current character to obtain the prediction result of the current character; use the predicted target text sequence as the matching result of the text sequence in multiple pre - stored text sequences; the target text sequence is composed of the prediction results of each character in the sequence to be predicted.

[0135] The sequence to be predicted is a string variable with an unknown number of characters and unknown character values for each character. Each character in the target text sequence is respectively the prediction result of each character in the sequence to be predicted.

[0136] o>Exemplarily, the text sequence x1x2...x m = "How to redeem points", that is, x| = "How", x2 = "to", x3 = "redeem", x4 = "points", x5 = "points", x6 = "points", and the sequence to be predicted z1z2……z nThe starting constraint condition of the first character z1 is that when predicting the first character z1, the probabilities of predicting other characters except the two characters "积" and "银" are set to 0. According to the text sequence "怎么兑换积分", the probability of predicting z1 = "积" is 90%, and the probability of z1 = "银" is 10%. Then, it is determined that the prediction result of z1 is "积". Therefore, the first character of the target text sequence is "积".

[0137] The tree structure diagram and the pre-stored text sequence can be referred to Figure 1 the corresponding parts in the embodiments of the described text matching method.

[0138] For example, the constraint condition of z2 is generated according to the prediction result "积" of z1 and the tree structure diagram. Since in the tree structure diagram as Figure 2 shown, the tree branches adjacent to "积" only include the node where "分" is located, the constraint condition of the second character z2 can be set as follows: on the premise that z1 is "积", the probabilities of predicting other characters except "分" are set to 0. In this way, the value of the second character z2 can only be "分".

[0139] Another example is that the constraint condition of the third character z3 is generated according to the prediction result "分" of the second character and the tree structure diagram. Since in the tree structure diagram as Figure 2 shown, the tree branches adjacent to "分" include the nodes where "如", "充", and "到" are located, the constraint condition of the third character z3 can be set as follows: on the premise that the value of z1 is "积" and the value of z2 is "分", the probabilities of predicting other characters except "如", "充", and "到" are set to 0. In this way, the value of the third character z3 can only be one of "如", "充", and "到".

[0140] Optionally, generating the constraint condition for predicting the current character according to the prediction result of the previous character of the current character and the preset tree structure diagram includes: querying the target character corresponding to the prediction result of the previous character and at least one branch character corresponding to the tree branch adjacent to the target character in the tree structure diagram; generating the constraint condition for predicting the current character according to at least one branch character.

[0141] Specifically, as Figure 2 shown, if the previous character is "积", then query the target character "积" corresponding to "积" and the branch character "分" corresponding to one of the tree branches adjacent to the target character "积" in the tree structure diagram. According to this branch character "分", generate the constraint condition of the current character: on the premise that the previous character is "积", the probabilities of predicting other characters except "分" are set to 0.

[0142] For another example, if the previous character is "fen", query the target character "fen" corresponding to "fen" and the three tree branches adjacent to the target character "fen" in the tree structure diagram, namely, the branch characters "ru", "chong", and "dao" corresponding to the three branches. According to the above three branch characters, generate the constraint condition for the current character: on the premise that z1 is "ji" and z2 is "fen", set the probability of predicting other characters except "ru", "chong", and "dao" to 0.

[0143] Optionally, according to the text sequence and the constraint condition of the current character, predict the current character to obtain the prediction result of the current character, including: determining at least one pending prediction result of the current character according to the text sequence and the constraint condition of the current character; the prediction probability of the pending prediction result is greater than zero; among at least one pending prediction result, determine the pending prediction result with the highest prediction probability as the prediction result of the current character.

[0144] Obtain at least one pending prediction result of the current character according to the text sequence to be matched and the constraint condition of the current character. For example, the constraint condition of the current character is that on the premise that z1 is "ji" and z2 is "fen", set the probability of predicting other characters except "ru", "chong", and "dao" to 0. Then, according to the text sequence, the probability that the third character z3 is "ru" is 85%, the probability that z3 is "chong" is 5%, and the probability that z3 is "dao" is 10%. Furthermore, the prediction result of z3 can be determined as "ru".

[0145] Take the predicted target text sequence as the matching result of the text sequence in the multiple pre-stored text sequences.

[0146] For example, for "How to redeem points?", where z1 = "ji"; z2 = "fen"; z3 = "ru"; z4 = "he"; z5 = "dui"; z6 = "huan"; z7 = "?". The predicted target text sequence "How to redeem points?" corresponds to a pre-stored text sequence in multiple pre-stored text sequences, such as: "How to redeem points? ans1". Take the predicted target text sequence "How to redeem points?" as the matching result of the text sequence "How to redeem points" in multiple pre-stored text sequences.

[0147] Since the text matching method provided in this embodiment is similar to the technical concept of the foregoing method embodiment, it is written relatively simply, and the relevant content can be referred to the foregoing method embodiment.

[0148] [[ID=IS]]An embodiment of a text matching device provided in this specification is as follows:

[0149] In the embodiment as Figure 1 shown, a text matching method is provided. Correspondingly, a text matching device is also provided, which will be described below with reference to the accompanying drawings.

[0150] Figure 5 Schematic diagram of a text matching device provided in an embodiment of the present application. This embodiment provides a text matching device, including:

[0151] A first acquisition module 501 is used to acquire a text sequence to be matched;

[0152] A generation module 502 is used to generate a predicted string formed by prediction results of multiple characters based on a text sequence through a text matching model configured with constraint generation rules, where the predicted string is the matching result of the text sequence in multiple pre-stored text sequences; the constraint generation rules include: the constraint of the first character in the predicted string is a preset starting constraint, and the constraint of each character in the predicted string except the first character is generated based on the prediction result of the previous character and a preset tree structure diagram; the prediction result of the previous character is predicted by the text matching model based on the constraint of the previous character and the text sequence; the tree structure diagram is used to represent multiple pre-stored text sequences stored according to the tree structure.

[0153] Optionally, the text matching model includes a character prediction sub-model; a generation module 502 includes: a prediction sub-module, which is used to perform character prediction processing based on the text sequence and the starting constraints through the character prediction sub-model to obtain a prediction result for the first character in the predicted string; and the generation steps of each character other than the first character in the predicted string include: generating the constraints of the current character based on the prediction result of the previous character of the current character; and obtaining the prediction result of the current character based on the text sequence, the constraints of the current character and the character prediction sub-model.

[0154] Optionally, the text matching model includes a first embedding layer and a constraint generation module configured with constraint generation rules; the prediction submodule includes: a vectorization unit for vectorizing the prediction result of the previous character obtained by the character prediction submodel through the first embedding layer to obtain the prediction result vector of the previous character; a generation unit for generating the constraint of the current character according to the constraint generation rules based on the prediction result of the previous character through the constraint generation module.

[0155] Optionally, the generation unit is specifically used to: query the target character corresponding to the prediction result vector of the previous character and the branch character corresponding to at least one tree branch adjacent to the target character in the tree structure diagram through the constraint condition generation module; and generate the constraint condition of the current character based on at least one branch character.

[0156] Optionally, the constraints of the current character include at least one optional character; the prediction submodule is specifically used to: determine at least one pending prediction result of the current character in at least one optional character according to the text sequence through a character prediction submodel, and generate a prediction probability for each pending prediction result; the prediction probability of the pending prediction result is greater than zero; and among at least one pending prediction result, determine the pending prediction result with the highest prediction probability as the prediction result of the current character.

[0157] Optionally, the text matching model includes a second embedding layer; the second embedding layer is connected to the character prediction sub-model; the generation module 502 is specifically used to: vectorize the text sequence through the second embedding layer and output a text vector sequence; perform character prediction processing on the text vector sequence through the character prediction sub-model to obtain a predicted character string corresponding to the text sequence.

[0158] Optionally, the text sequence is a dialogue text; the multiple pre-stored text sequences are multiple preset question-answer pairs; a spacing identifier is set between the question part and the answer part of each preset question-answer pair; the text matching device also includes: a determination module, used to determine the character position of the spacing identifier in the predicted character string; an output module, used to determine the character or character string after the spacing identifier as the response information of the dialogue text according to the character position of the spacing identifier and output it.

[0159] Another text matching device embodiment provided in this specification is as follows:

[0160] In such Figure 4 In the illustrated embodiment, a text matching method is provided, and correspondingly, a text matching device is also provided, which will be described below with reference to the accompanying drawings.

[0161] Figure 6 A schematic diagram of another text matching device provided in an embodiment of the present application.

[0162] Since the device embodiment corresponds to the method embodiment, the description is relatively simple. For the relevant parts, please refer to the corresponding description of the method embodiment provided above. The device embodiment described below is only illustrative.

[0163] This embodiment provides a text matching device, including:

[0164] The second acquisition module 601 is used to acquire a text sequence to be matched;

[0165] Prediction module 602 is used to predict the first character based on the text sequence and the starting constraints of the first character of the sequence to be predicted, and obtain a prediction result for the first character; the steps for generating each character in the sequence to be predicted corresponding to the text sequence except the first character include: generating constraints for predicting the current character based on the prediction result of the previous character of the current character and a preset tree structure diagram; the tree structure diagram is used to represent multiple pre-stored text sequences stored in a tree structure; predicting the current character based on the text sequence and the constraints of the current character, and obtaining a prediction result for the current character; using the predicted target text sequence as the matching result of the text sequence in the multiple pre-stored text sequences; the target text sequence is composed of the prediction results of each character in the sequence to be predicted.

[0166] Optionally, the prediction module 602 is specifically used to: query the target character corresponding to the prediction result of the previous character and the branch character corresponding to at least one tree branch adjacent to the target character in the tree structure diagram; and generate a constraint condition for predicting the current character based on the at least one branch character.

[0167] Optionally, the prediction module 602 is specifically used to: determine at least one pending prediction result of the current character based on the text sequence and the constraints of the current character; the prediction probability of the pending prediction result is greater than zero; and among the at least one pending prediction result, determine the pending prediction result with the highest prediction probability as the prediction result of the current character.

[0168] An embodiment of a text matching device provided in this specification is as follows:

[0169] Corresponding to the above Figure 1 A text matching method described above Figure 4 The text matching method described above is based on the same technical concept. The embodiment of the present application also provides a text matching device, which is used to perform the above Figure 1 The provided text matching method, or the text matching device is used to perform the above Figure 4 The text matching method provided, Figure 7 A structural diagram of a text matching device provided in an embodiment of the present application.

[0170] This embodiment provides a text matching device, including:

[0171] like Figure 7As shown, the text matching device may have relatively large differences due to different configurations or performances, and may include one or more processors 701 and memory 702, and the memory 702 may store one or more storage applications or data. Among them, the memory 702 can be a temporary storage or a permanent storage. The application stored in the memory 702 may include one or more modules (not shown in the figure), and each module may include a series of computer-executable instructions in the text matching device. Furthermore, the processor 701 can be configured to communicate with the memory 702 and execute a series of computer-executable instructions in the memory 702 on the text matching device. The text matching device may also include one or more power supplies 703, one or more wired or wireless network interfaces 704, one or more input / output interfaces 705, one or more keyboards 706, etc.

[0172] In a specific embodiment, a text matching device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the text matching device, and the one or more programs are configured to be executed by one or more processors, including computer-executable instructions for performing the following:

[0173] Get the text sequence to be matched;

[0174] Generate a predicted string consisting of prediction results of multiple characters based on a text sequence by using a text matching model configured with constraint generation rules, where the predicted string is a matching result of the text sequence in multiple pre-stored text sequences;

[0175] Constraint generation rules include:

[0176] The constraint conditions for the first character in the predicted string are the preset starting constraints, and the constraints for each character in the predicted string except the first character are generated based on the prediction result of the previous character and the preset tree structure diagram; the prediction result of the previous character is obtained by the text matching model based on the constraint conditions of the previous character and the text sequence prediction; the tree structure diagram is used to represent multiple pre-stored text sequences stored according to the tree structure.

[0177] In another specific embodiment, a text matching device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the text matching device, and the one or more programs are configured to be executed by one or more processors, including computer-executable instructions for performing the following:

[0178] Get the text sequence to be matched;

[0179] According to the starting constraints of the first character of the text sequence and the sequence to be predicted, the first character is predicted to obtain the prediction result of the first character;

[0180] The steps for generating each character except the first character in the sequence to be predicted corresponding to the text sequence include:

[0181] Generate constraints for predicting the current character based on the prediction result of the previous character of the current character and a preset tree structure diagram; the tree structure diagram is used to represent multiple pre-stored text sequences stored in a tree structure;

[0182] According to the text sequence and the constraints of the current character, the current character is predicted to obtain the prediction result of the current character;

[0183] The predicted target text sequence is used as the matching result of the text sequence in multiple pre-stored text sequences; the target text sequence is composed of the prediction results of each character in the sequence to be predicted.

[0184] Corresponding to the above Figure 1 A text matching method described above Figure 4 A text matching method is described. Based on the same technical concept, an embodiment of the present application also provides a computer-readable storage medium.

[0185] In a specific embodiment, a computer-readable storage medium is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the following process is implemented:

[0186] Get the text sequence to be matched;

[0187] Generate a predicted string consisting of prediction results of multiple characters based on a text sequence by using a text matching model configured with constraint generation rules, where the predicted string is a matching result of the text sequence in multiple pre-stored text sequences;

[0188] Constraint generation rules include:

[0189] The constraint conditions for the first character in the predicted string are the preset starting constraints, and the constraints for each character in the predicted string except the first character are generated based on the prediction result of the previous character and the preset tree structure diagram; the prediction result of the previous character is obtained by the text matching model based on the constraint conditions of the previous character and the text sequence prediction; the tree structure diagram is used to represent multiple pre-stored text sequences stored according to the tree structure.

[0190] In another specific embodiment, a computer-readable storage medium is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the following process is implemented:

[0191] Get the text sequence to be matched;

[0192] According to the starting constraints of the first character of the text sequence and the sequence to be predicted, the first character is predicted to obtain the prediction result of the first character;

[0193] The steps for generating each character except the first character in the sequence to be predicted corresponding to the text sequence include:

[0194] Generate constraints for predicting the current character based on the prediction result of the previous character of the current character and a preset tree structure diagram; the tree structure diagram is used to represent multiple pre-stored text sequences stored in a tree structure;

[0195] According to the text sequence and the constraints of the current character, the current character is predicted to obtain the prediction result of the current character;

[0196] The predicted target text sequence is used as the matching result of the text sequence in multiple pre-stored text sequences; the target text sequence is composed of the prediction results of each character in the sequence to be predicted.

[0197] It should be noted that the embodiment of the computer-readable storage medium in this specification and the embodiment of the text matching method in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding method mentioned above, and the repeated parts will not be repeated.

[0198] It should be noted that the embodiment of the computer-readable storage medium in this specification and the embodiment of the text matching method in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding method mentioned above, and the repeated parts will not be repeated.

[0199] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0200] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the embodiments of the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0201] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable text matching device to produce a machine, so that the instructions executed by the processor of the computer or other programmable text matching device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0202] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable text matching device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, the instruction device being implemented in the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0203] These computer program instructions may also be loaded onto a computer or other programmable text matching device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide for implementing the process described in the flow. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0204] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0205] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0206] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0207] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

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

[0209] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.

[0210] The foregoing description is merely an example of the present invention and is not intended to limit the present invention. Persons skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims herein.

Claims

1. A text matching method, characterized in that: include: Get the text sequence to be matched; generating, based on the text sequence, a predicted character string formed by prediction results of a plurality of characters using a text matching model configured with constraint generation rules, wherein the predicted character string is a matching result of the text sequence in a plurality of pre-stored text sequences; The constraint condition generation rules include: The constraint condition for the first character in the predicted string is a preset starting constraint condition, and the constraint condition for each character in the predicted string except the first character includes setting the prediction probability of characters or strings other than branch characters in a preset tree structure diagram to zero; the branch character corresponding to each character is determined by searching the tree structure diagram for a target character corresponding to a prediction result of a previous character and a branch character corresponding to at least one tree branch adjacent to the target character; the prediction result of the previous character is obtained by the text matching model based on the constraint condition of the previous character and the text sequence prediction; The tree structure diagram is used to represent the multiple pre-stored text sequences stored according to the tree structure.

2. The method according to claim 1, characterized in that The text matching model includes a character prediction sub-model; the text matching model configured with constraint condition generation rules generates a predicted character string formed by prediction results of multiple characters based on the text sequence, including: Performing character prediction processing based on the text sequence and the starting constraint condition by the character prediction sub-model to obtain a prediction result for the first character in the predicted character string; Furthermore, the step of generating each character other than the first character in the predicted character string includes: Generate a constraint condition for the current character based on a prediction result of a previous character of the current character; A prediction result of the current character is obtained according to the text sequence, the constraint condition of the current character and the character prediction sub-model.

3. The method according to claim 2, characterized in that The text matching model includes a first embedding layer and a constraint generation module configured with the constraint generation rule; the character prediction sub-model, the first embedding layer and the constraint generation module are connected in series; The step of generating the constraint condition of the current character based on the prediction result of the previous character of the current character includes: Vectorizing the prediction result of the previous character obtained by the character prediction sub-model through the first embedding layer to obtain a prediction result vector of the previous character; The constraint condition generation module generates the constraint condition of the current character based on the prediction result of the previous character and according to the constraint condition generation rule.

4. The method according to claim 2, characterized in that The constraint condition of the current character includes at least one optional character; and obtaining a prediction result of the current character according to the text sequence, the constraint condition of the current character, and the character prediction sub-model includes: Determining, by the character prediction sub-model, at least one to-be-processed prediction result of the current character among the at least one optional character according to the text sequence, and generating a prediction probability for each of the to-be-processed prediction results; wherein the prediction probability of the to-be-processed prediction result is greater than zero; Among the at least one prediction result to be processed, the prediction result to be processed with the highest prediction probability is determined as the prediction result of the current character.

5. The method according to claim 2, characterized in that The text matching model includes a second embedding layer; the second embedding layer is connected to the character prediction sub-model; the text matching model configured with constraint condition generation rules generates a predicted string formed by prediction results of multiple characters based on the text sequence, including: Performing vectorization processing on the text sequence through the second embedding layer and outputting a text vector sequence; The text vector sequence is subjected to character prediction processing by the character prediction sub-model to obtain a predicted character string corresponding to the text sequence.

6. The method according to any one of claims 1 to 5, characterized in that The text sequence is a dialogue text; the plurality of pre-stored text sequences are a plurality of preset question-answer pairs; a spacer identifier is provided between the question portion and the answer portion of each of the preset question-answer pairs; after the text matching model configured with constraint condition generation rules generates a predicted character string formed by prediction results of a plurality of characters based on the text sequence, the method further includes: In the predicted character string, determining a character position of the space identifier; According to the character position of the interval identifier, the characters or character strings following the interval identifier are determined as response information of the dialogue text and output.

7. A text matching method, characterized in that: include: Get the text sequence to be matched; Predicting the first character according to the text sequence and the starting constraint of the first character of the sequence to be predicted to obtain a prediction result of the first character; The step of generating each character except the first character in the sequence to be predicted corresponding to the text sequence includes: Searching a preset tree structure diagram for a target character corresponding to a prediction result of a character preceding a current character and a branch character corresponding to at least one tree branch adjacent to the target character; the tree structure diagram is used to represent a plurality of pre-stored text sequences stored in a tree structure; generating a constraint condition for predicting the current character based on at least one of the branch characters; the constraint condition comprising setting the prediction probability of characters or character strings other than the branch characters in the tree structure diagram to zero; Predicting the current character according to the text sequence and the constraints of the current character to obtain a prediction result of the current character; The predicted target text sequence is used as the matching result of the text sequence in the multiple pre-stored text sequences; the target text sequence is composed of the prediction results of each character in the sequence to be predicted.

8. The method according to claim 7, characterized in that The step of predicting the current character based on the text sequence and the constraint condition of the current character to obtain a prediction result of the current character includes: Determining at least one to-be-processed prediction result of the current character according to the text sequence and the constraint conditions of the current character; wherein the prediction probability of the to-be-processed prediction result is greater than zero; Among the at least one prediction result to be processed, the prediction result to be processed with the highest prediction probability is determined as the prediction result of the current character.

9. A text matching device, characterized in that: include: A first acquisition module is used to acquire a text sequence to be matched; a generating module configured to generate a predicted string formed by prediction results of a plurality of characters based on the text sequence by using a text matching model configured with constraint condition generation rules, wherein the predicted string is a matching result of the text sequence in a plurality of pre-stored text sequences; The constraint condition generation rule includes: the constraint condition of the first character in the predicted string is a preset starting constraint condition; the constraint condition of each character in the predicted string except the first character includes setting the prediction probability of characters or strings other than branch characters in a preset tree structure diagram to zero; the branch character corresponding to each character is determined by searching the tree structure diagram for a target character corresponding to the prediction result of the previous character and a branch character corresponding to at least one tree branch adjacent to the target character; the prediction result of the previous character is obtained by the text matching model based on the constraint condition of the previous character and the text sequence prediction; The tree structure diagram is used to represent the multiple pre-stored text sequences stored in a tree structure.

10. A text matching device, characterized in that: include: The second acquisition module is used to obtain the text sequence to be matched; A prediction module, configured to predict the first character of the text sequence and a starting constraint of the first character of the sequence to be predicted, and obtain a prediction result of the first character; The step of generating each character except the first character in the sequence to be predicted corresponding to the text sequence includes: searching a preset tree structure diagram for a target character corresponding to the prediction result of the previous character of the current character and a branch character corresponding to at least one tree branch adjacent to the target character; the tree structure diagram is used to represent multiple pre-stored text sequences stored in a tree structure; based on at least one of the branch characters, a constraint condition for predicting the current character is generated; the constraint condition includes setting the prediction probability of characters or character strings other than the branch characters in the tree structure diagram to zero; predicting the current character according to the text sequence and the constraint condition of the current character to obtain a prediction result of the current character; using the predicted target text sequence as the matching result of the text sequence in the multiple pre-stored text sequences; the target text sequence is composed of the prediction result of each character in the sequence to be predicted.

11. A text matching device, characterized in that: The device comprises: A processor; and a memory configured to store computer-executable instructions, which, when executed, cause the processor to perform the text matching method according to any one of claims 1 to 8.

12. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the text matching method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Intelligent dialogue method and apparatus, and storage medium

    US20220129448A1

  • Information processing method and apparatus, electronic device, and storage medium

    WO2022111347A1