A text recommendation method, apparatus, computer device, and storage medium
By analyzing the attribute information of candidate response texts and performing feature matching, the target response text is selected, which solves the problem of mismatch between answers and questions in neural network models and improves the accuracy of question-and-answer services.
Patent Information
- Application Number
- CN202110396686.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-13
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2041-04-13
AI Technical Summary
Neural network models suffer from overconfidence in question-answering service scenarios, leading to mismatches between recommended answers and questions and low accuracy.
By acquiring a set of candidate questions and answers, analyzing the attribute information of the candidate response texts, and performing feature matching with the target feature information, the target response texts are filtered out, generating a set of target questions and answers. When a query text to be processed is received, a matching response text is found from the set of target questions and answers for recommendation.
It improved the accuracy of recommendations, making the recommended response text more closely match the question and enhancing the user experience.
Smart Images

Figure CN113704422B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and more specifically to a text recommendation method, apparatus, computer device, and storage medium. Background Technology
[0002] In question-and-answer service scenarios, neural network models are typically used to predict the corresponding answers to questions and the matching rate of those answers, and then the answers are recommended to users based on the matching rate.
[0003] The inventors of this application have discovered that neural network models, such as answer extraction models, suffer from overconfidence, meaning that the answer extraction model predicts incorrect answers, but the prediction matching rate is very high, resulting in the recommended answers to users not matching the questions, i.e., the accuracy of the recommended answers is low. Summary of the Invention
[0004] This application provides a text recommendation method, apparatus, computer device, and storage medium, which can filter out response texts that are more closely matched to questions from candidate response texts and recommend more relevant response texts to users, thereby improving the accuracy of recommendations.
[0005] This application provides a text recommendation method, including:
[0006] Obtain a candidate question-and-answer set, which includes candidate question texts and candidate answer texts corresponding to the candidate question texts;
[0007] The candidate response text is analyzed to obtain its attribute information.
[0008] The attribute information is matched with the target feature information, and the target response text is selected from the candidate response texts based on the feature matching results;
[0009] Based on the target response text and the corresponding query text, a target question-and-answer set is generated;
[0010] When a query text to be processed is received, the system searches for a response text that matches the query text to be processed from the target question and answer set, and recommends the response text based on the query text to be processed.
[0011] Accordingly, embodiments of this application also provide a text recommendation device, comprising:
[0012] An acquisition unit is used to acquire a candidate question-and-answer set, the candidate question-and-answer set including candidate question texts and candidate answer texts corresponding to the candidate question texts;
[0013] An analysis unit is used to analyze the candidate response text to obtain attribute information of the candidate response text;
[0014] The filtering unit is used to perform feature matching between the attribute information and the target feature information, and filter the target response text from the candidate response text based on the feature matching result.
[0015] The generation unit is used to generate a target question-and-answer set based on the target response text and the corresponding query text.
[0016] The recommendation unit is used to, when receiving a query text to be processed, search for a response text that matches the query text to be processed from the target question and answer set, and recommend the response text based on the query text to be processed.
[0017] Accordingly, this application also provides a computer device including a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to execute any of the text recommendation methods provided in this application.
[0018] Accordingly, embodiments of this application also provide a storage medium for storing a computer program, which is loaded by a processor to execute any of the text recommendation methods provided in embodiments of this application.
[0019] This application embodiment obtains a candidate question-and-answer set, which includes candidate question texts and corresponding candidate answer texts; analyzes the candidate answer texts to obtain attribute information; performs feature matching between the attribute information and target feature information, and filters target answer texts based on the feature matching results; generates a target question-and-answer set based on the target answer texts and corresponding question texts; when a question text to be processed is received, it searches for answer texts that match the question text to be processed from the target question-and-answer set, and recommends answer texts based on the question text to be processed. This solution, by obtaining the attribute information of the candidate answer texts and matching the attribute information with target feature information, can filter out answer texts that are more closely matched to the question from the candidate answer texts, recommend more closely matched answer texts to the user, and improve the accuracy of recommendations. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1This is a scenario diagram of the text recommendation method provided in the embodiments of this application;
[0022] Figure 2 This is a flowchart of the text recommendation method provided in the embodiments of this application;
[0023] Figure 3 This is another flowchart of the text recommendation method provided in the embodiments of this application;
[0024] Figure 4 This is a partial tree structure diagram provided in the embodiments of this application;
[0025] Figure 5 This is another scenario diagram of the text recommendation method provided in the embodiments of this application;
[0026] Figure 6 This is a schematic diagram of the text recommendation device provided in the embodiments of this application;
[0027] Figure 7 This is a schematic diagram of the terminal structure provided in the embodiments of this application. Detailed Implementation
[0028] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0029] This application provides a text recommendation method, apparatus, computer device, and storage medium. The text recommendation apparatus can be integrated into a computer device, which may be a server or a terminal, etc.
[0030] The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can include mobile phones, wearable smart devices, tablets, laptops, personal computers (PCs), and in-vehicle computers, etc.
[0031] For example, such as Figure 1As shown, the computer device acquires a candidate question-and-answer set, which includes candidate question texts and corresponding candidate answer texts; analyzes the candidate answer texts to obtain their attribute information; performs feature matching between the attribute information and target feature information, and filters target answer texts based on the feature matching results; generates a target question-and-answer set based on the target answer texts and their corresponding question texts; when a question text to be processed is received, it searches for answer texts that match the question text in the target question-and-answer set, and recommends answer texts based on the question text. This solution, by acquiring the attribute information of candidate answer texts and matching them with target feature information, can filter out answer texts that are more closely matched to the question from the candidate answer texts, recommend more suitable answer texts to the user, and improve the accuracy of recommendations.
[0032] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the preferred order of the embodiments.
[0033] This embodiment will be described from the perspective of a response text recommendation device, which can be integrated into a computer device, such as a server. Figure 2 As shown, the specific process of this text recommendation method can be as follows:
[0034] 101. Obtain the candidate question and answer set, which includes candidate question texts and candidate answer texts corresponding to the candidate question texts.
[0035] Among them, the candidate query text can be text that needs to be answered, such as "Is A married?", "How old is B this year?", "What is the Chinese zodiac sign for 2019?", or other text containing keywords, such as "A is married", "B is how old", or "2019 is the Year of the Tiger", etc.
[0036] The candidate response text can be a text that answers the candidate query text. For example, if the candidate query text is "What is the Chinese zodiac sign for 2019?", the corresponding candidate response texts may include texts such as "pig", "tiger", "ox", "2019 is the year of the ox", "2019 is the year of the ox", "2019 is the year of the pig", and "2020 is the year of the tiger".
[0037] The candidate question and answer set can be a whole consisting of one or more defined candidate question texts and the corresponding candidate answer texts.
[0038] For example, it could be to obtain a set of candidate questions and answers from a database, or from other devices via network requests, Bluetooth, or other means; or it could be to obtain a set of candidate questions and answers from the network using technologies such as web crawling.
[0039] In addition to obtaining the candidate question-and-answer set through the methods described above, it can also be obtained through a neural network model. The parameters of the neural network model can be adjusted as needed to obtain more accurate answers, and these parameters can be adjusted at any time as required. That is, in one embodiment, before the step "obtaining the candidate question-and-answer set," it may also include:
[0040] Retrieve candidate query texts and their corresponding pending response texts;
[0041] By using a question-answering model, the candidate question text and the response text to be processed are vector-embedded to obtain the representation vector between the candidate question text and the candidate response information.
[0042] The response text is extracted from the representation vector to obtain candidate response texts corresponding to the response text to be processed;
[0043] A candidate question-and-answer set is generated based on the candidate response text and the corresponding candidate question text.
[0044] The text to be processed can be a text that includes candidate response texts. For example, if the candidate question is "What is 2019?" and the candidate response is "Pig", then the text to be processed could be "2019 is the Year of the Pig", or "2019 is the Year of the Pig in the Chinese lunar calendar. Therefore, people born in this year belong to the Pig zodiac sign", etc.
[0045] The question-answering model can be a pre-trained neural network model, such as a reading comprehension model, specifically a BERT-based reading comprehension model, an LSTM-based reading comprehension model, or other models capable of extracting answer segments.
[0046] The representation vector can be a vector obtained by mapping the candidate query text and the response text to be processed to real numbers.
[0047] For example, it can specifically obtain candidate query texts and corresponding response texts to be processed. A candidate query text can correspond to multiple response texts to be processed. The response texts to be processed and the corresponding candidate query texts are concatenated one by one through the question answering model. For example, it can obtain word sequences through classification mapping (segment embedding) and perform word embedding and position embedding mapping to real numbers to obtain the representation vector between the candidate query text and the candidate response information. Text fragments are extracted from the representation vector to obtain the candidate response text.
[0048] The obtained candidate response texts are mapped to the corresponding candidate question texts to obtain a set of candidate question and answer texts with a mapping relationship between the candidate question texts and the candidate response texts.
[0049] By extracting text fragments from the representation vector to obtain candidate response texts, the probability of each character in the response text being a response text can be predicted. Specifically, in one embodiment, the step "extracting response text from the representation vector to obtain candidate response texts corresponding to the response text to be processed" can be:
[0050] The question-answering model predicts the start probability of the position of each character in the representation vector as the candidate start position of the candidate response text, and the end probability of the position of each character as the candidate end position of the candidate response text.
[0051] The start position is determined from the candidate start positions based on the start probability, and the end position is determined from the candidate end positions based on the end probability;
[0052] Candidate response texts are determined from the pending response texts based on the start and end positions.
[0053] The candidate start position and candidate end position can be the position of each character in the text to be processed predicted by the question-answering model. For example, if the text to be processed is "2019 is the Year of the Pig", then the candidate start position / candidate end position of "2" is 1, the candidate start position / candidate end position of "0" is 2, and so on.
[0054] The start probability can be the probability predicted by the question-answering model that each character is the first character of the candidate response text. For example, if the response text to be processed is "2019 is the Year of the Pig", the probability predicted by the question-answering model that the candidate start position where "2" is located is the start position of the candidate response text might be 0.02, and the probability of the start position of "pig" might be 0.99.
[0055] The end probability can be the probability predicted by the question-answering model that each character is the last character of the candidate response text. For example, if the response text to be processed is "2019 is the Year of the Pig", the question-answering model predicts that the end probability of the candidate position where "2" is located is the beginning position of the candidate response text might be 0.02, and the end probability of "pig" might be 0.99.
[0056] The starting position can be the position of the first character of the candidate response text within the response text to be processed.
[0057] The end position can be the position of the last character of the candidate response text within the response text to be processed.
[0058] For example, specifically, the question-answering model can predict the start probability of each character position in the response text to be processed as the candidate start position of the candidate response text, and the end probability of each character position as the candidate end position of the candidate response text.
[0059] The first character of the candidate response text is determined based on the start probability of each character. For example, the start position of the candidate response text can be determined by the character with the highest start probability among multiple start probabilities.
[0060] The first character of the candidate response text is determined based on the end probability of each character. For example, the end position of the candidate response text can be determined by the character with the highest end probability among multiple end probabilities.
[0061] The start and end positions, as well as the characters in between, are determined as candidate response text.
[0062] 102. Analyze the candidate response texts to obtain their attribute information.
[0063] Among them, the attribute information can be the nature and characteristics of the candidate response text. For example, the attribute information of the candidate response text can be the number of characters in the candidate response text, the number of sentences contained in the candidate response text, or the candidate response text being the first sentence of the response text to be processed.
[0064] For example, specifically, the candidate response text can be analyzed based on the target feature information to obtain the attribute information of the candidate response text.
[0065] For example, if the target feature information could be that the candidate response text is the first sentence of the response text to be processed, then the position of the candidate response text within the response text to be processed can be determined based on the starting position of the candidate response text, and the obtained attribute information is the position of the candidate response text within the response text to be processed. Alternatively, the position of the candidate response text can be determined by finding the corresponding text within the response text to be processed.
[0066] In addition to obtaining attribute information based on target features, all attribute information required for matching candidate response texts with features can be obtained in advance based on possible feature matching of candidate response texts.
[0067] The attribute information of candidate response texts can also be obtained through neural network models. Neural network models can discover the latent features of candidate response texts, resulting in more accurate attribute information. Furthermore, the model parameters can be adjusted according to the accuracy requirements of the response texts in different application scenarios, thus adapting to the needs of various applications. Specifically, in one embodiment, the step "analyzing the candidate response texts to obtain their attribute information" can be:
[0068] The trained classification model extracts features from candidate response texts based on target feature information to obtain text features.
[0069] By analyzing the text features, the attribute information of the candidate response texts can be obtained.
[0070] The trained classification model can be a decision tree, support vector machine, or XGBoost model, among others.
[0071] Among them, text features can be characteristics of the candidate response text, such as features like commas and periods contained in the candidate response text, features like the start and end positions of the candidate response text, or the predicted probability of the candidate response text.
[0072] For example, specifically, the target feature information can be determined by training a classification model to identify the number of short sentences in the natural sentence containing the candidate response text (in the response text to be processed). Then, the position of the candidate response text in the response text to be processed can be determined. Punctuation marks such as commas, periods, question marks, and exclamation marks can be extracted from the natural sentence containing the candidate response text to obtain the text features of the candidate response text. The text features of the candidate response text can be analyzed. For example, the number of extracted punctuation marks can be statistically processed to obtain the number of punctuation marks. The attribute information of the candidate response text can be determined as the number of short sentences in the natural sentence containing the candidate response text, which is denoted as 'a'.
[0073] Different analysis methods are used for different text features, and the specific analysis method is determined according to the features.
[0074] 103. Perform feature matching between attribute information and target feature information, and filter target response text from candidate response texts based on the feature matching results.
[0075] The target response text can be either a text that answers a candidate query text or a text selected from candidate response texts.
[0076] The target feature information can be filtering condition information, or filtering condition information for selecting target response texts from candidate response texts. For example, the target feature information could be that the candidate response text is the first sentence of the response text to be processed, or the number of short sentences contained in the natural sentence (within the response text to be processed) of the candidate response text.
[0077] For example, specifically, the attribute information of the target response text and the candidate response text can be matched to obtain the matching results of the candidate response text with the target feature information. The matching candidate response text can be used as the target response text, or the non-matching candidate response text can be used as the target response text, or the matching result can be used as the first target response text and the matching result can be used as the second target response text.
[0078] To make the target response text obtained by the trained classification model more accurate, multiple feature matching operations can be performed on the candidate response texts. Specifically, in one embodiment, the step "matching attribute information with target feature information and filtering target response texts from candidate response texts based on the feature matching results" can be:
[0079] The current node is determined from the multi-layer node, and the attribute information is matched with the target feature information corresponding to the current node. Based on the feature matching result, the target response text is selected from the candidate response text.
[0080] The target response text and the corresponding candidate query text are used as the candidate question and answer set of the child nodes of the current node;
[0081] Take the aforementioned child node as the current node, return to perform the operation of matching the attribute information with the target feature information corresponding to the current node, until the current node is the target node, and take the candidate answer text in the candidate question and answer set of the obtained child node as the target answer text.
[0082] In this context, a node can be a feature matching connection point for attribute information, each branch represents a matching output, and the node can include the corresponding target feature information. The node can perform feature matching on the attribute information of the candidate response text based on the target feature information.
[0083] In this context, a child node can be a feature-matching connection point that connects the attribute information of the node; that is, it can be another connection point on a node branch. For example, if node A performs feature matching on the candidate response text, it outputs b branches, resulting in b matching results and b child nodes B.
[0084] The current node can be a node that performs feature matching.
[0085] The target node can be a leaf node, that is, a node that has only a parent node and no child nodes.
[0086] It's understandable that node A is the parent node of node B, and node B is the child node of node A. Parent and child nodes are relative; a parent node can also be a child node of another node, and a child node can also be the parent node of another node. Furthermore, a node and its child nodes can be nodes at different node levels.
[0087] For example, it can be done by determining the current node and its target feature information in a multi-layered node structure, matching the attribute information of the candidate response text with the target feature information, and then filtering the target response text from the candidate response text based on the feature matching results.
[0088] The set of candidate target response texts and corresponding candidate query texts is used as the candidate response texts of the current node's child nodes. This child node is then used as the current node. Feature matching is performed again on the new candidate response texts to filter the target response text from the new candidate response texts.
[0089] The process of using the target response text as a new candidate response text and filtering the target response text from the new candidate response text is iterated until a node is the target node. The candidate response text obtained from that node and the corresponding candidate query text are then used as the target response text.
[0090] Optionally, the target feature information of the current node can be determined by the training classification model, and the candidate response text can be analyzed according to the target feature information corresponding to the current node to obtain the attribute information corresponding to the target feature information.
[0091] To determine the target response text from candidate response texts using a trained classification model, the classification model needs to be trained beforehand. In one embodiment, the text recommendation method provided in this embodiment includes the following steps before:
[0092] The question-and-answer sample set is obtained through the initial classification model, and the nodes corresponding to the question-and-answer sample set and the target feature information corresponding to the nodes are determined.
[0093] A subset of question-and-answer samples is determined from the question-and-answer sample set based on the target feature information corresponding to the nodes;
[0094] The child nodes of the node are generated based on the question-and-answer sample subset, and the target feature information corresponding to the child nodes is determined based on the question-and-answer sample subset;
[0095] The question-and-answer sample subset is used as the question-and-answer sample set, and the child nodes are used as nodes. The process returns to determine the question-and-answer sample subset from the question-and-answer sample set based on the target feature information corresponding to the nodes, until the preset loop termination condition is met, and the trained classification model is obtained.
[0096] For example, it could involve obtaining a set of question-and-answer samples and generating corresponding nodes (hereinafter referred to as the first node for clarity) based on the set of question-and-answer samples, as well as determining target feature information. For example, the feature information in the preset feature information set includes priority, and one feature information is determined from the preset feature information set as the target feature information of the node based on the priority (e.g., obtaining the feature information with the highest priority).
[0097] Matching the question-and-answer sample set based on the target feature information yields two question-and-answer sample subsets—a first question-and-answer sample subset and a second question-and-answer sample subset. The first question-and-answer sample subset may match the target feature information, while the second question-and-answer sample subset may not match the target feature information.
[0098] Under the first node, child nodes are generated based on a subset of question-and-answer samples. Specifically, a first child node can be generated based on a first subset of question-and-answer samples, and a second child node can be generated based on a second subset of question-and-answer samples. Feature information (feature information different from the target feature information corresponding to the first node) is determined from preset feature information based on the first subset of question-and-answer samples and the second subset of question-and-answer samples, respectively, as the target feature information of the child node.
[0099] The first child node is taken as the first node, and the first question-and-answer sample subset is taken as the question-and-answer sample set. The question-and-answer sample subset is determined from the question-and-answer sample set (i.e., the first question-and-answer sample subset) based on the target feature information. The second child node is taken as the first node, and the second question-and-answer sample subset is taken as the question-and-answer sample set. The question-and-answer sample subset is determined from the question-and-answer sample set (i.e., the second question-and-answer sample subset) based on the target feature information.
[0100] Essentially, based on whether the response text samples in the target feature information corresponding to the first child node match, the first question-and-answer sample subset is divided into two subsets (matching and non-matching). Based on the obtained subsets, corresponding child nodes are generated (each subset corresponds to one node), and the target feature information corresponding to the generated child nodes is determined. The subsets are then divided based on the target feature information, that is, the question-and-answer sample set is iteratively divided based on the target feature information until a preset loop termination condition is met. For example, when the number of divisions reaches a preset number, it is determined that the preset loop termination condition is met, the loop ends, and the trained classification model is obtained.
[0101] In addition to obtaining target feature information according to a preset strategy, the target feature information can also be determined based on the influence of each feature information in the preset feature information set on the question-and-answer sample set, making the prediction process more reasonable and scientific, and the prediction results more accurate. Specifically, in one embodiment, the step "obtaining the question-and-answer sample set through an initial classification model, and determining the nodes corresponding to the question-and-answer sample set and the target feature information corresponding to the nodes" can be:
[0102] Obtain a question-and-answer sample set and a preset feature information set, the preset feature information set including multiple feature information;
[0103] Under the condition of feature information, the stable value of the question-and-answer sample set is calculated through the initial classification model;
[0104] The nodes are determined by an initial classification model, and the target feature information of the nodes is determined based on stable values.
[0105] The question-and-answer sample set can be a whole consisting of one or more question text samples and corresponding answer text samples.
[0106] The preset feature information set can be a set of multiple feature information sets. For example, the preset feature information set may include:
[0107] Feature 1: The response text is the first sentence of the response text to be processed.
[0108] Feature 2: The number of short sentences included in the natural sentence of the response text (in the response text to be processed) is less than 3.
[0109] Feature 3: Words in the candidate query text appear more than 5 times in the natural sentences of the response text (the response text to be processed)...
[0110] Understandably, the number of features in the preset feature information set can be adjusted as needed, and the feature information can also be flexibly set as required.
[0111] The stable value can be a measure of the uncertainty of the classification label carried by a response text sample taken from the question-and-answer sample set. For example, it can be conditional entropy, information entropy, and the Gini coefficient.
[0112] For example, it could involve obtaining a question-and-answer sample set and a preset feature information set, and calculating the stable value of the question-and-answer sample set under each feature information condition in the preset feature information set. This stable value could be the conditional entropy, that is, the conditional entropy of the question-and-answer sample set calculated under each feature information condition.
[0113] The initial classification model can generate a node and use the feature information corresponding to the conditional entropy with the smallest value among multiple conditional entropies as the target feature information of the node.
[0114] Alternatively, by calculating the information entropy of the question-and-answer sample set, the feature information that has the greatest impact on the information entropy of the question-and-answer sample set can be determined, and this feature information can be identified as the target feature information corresponding to the node. That is, in one embodiment, the step "calculating the stable value of the question-and-answer sample set under the feature conditions of the preset feature information set using an initial classification model" includes:
[0115] Based on the classification labels, the information entropy of the question-and-answer sample set is calculated using the initial classification model.
[0116] Calculate the conditional entropy of the question-and-answer sample set under the feature information conditions of the preset feature information set;
[0117] The stable value is determined based on information entropy and conditional entropy.
[0118] Information entropy can be a measure of the uncertainty of a question-and-answer sample set, while conditional entropy can be a measure of the uncertainty of a question-and-answer sample set under certain feature information conditions.
[0119] The response text sample may include a classification identifier, which can be a labeling information obtained by pre-marking whether the response text sample is the correct answer to the corresponding query text sample.
[0120] Identification information can be parameters, tags, or other methods that can distinguish categories.
[0121] For example, if the response text sample is the correct answer to the corresponding query text sample, the category identifier for the response text sample can be 0; if the response text sample is not the correct answer to the corresponding query text sample, the category identifier for the response text sample can be 1.
[0122] For example, it could be based on the classification identifier carried by the response text sample to calculate the number of query text samples and the corresponding response text samples, and count the number of response text samples that are correct answers to determine the frequency of response text samples being correct answers.
[0123] And count the number of incorrect answers in the response text samples to determine the frequency of incorrect answers in the response text samples.
[0124] According to the formula: Calculate the information entropy of the response text sample.
[0125] Where X represents all the response text samples included in the node, p i This represents the frequency of the response text sample in the i-th category. Since the classification identifier can determine whether the response text sample is a correct answer or not, in this embodiment, n is 2. If p i If p2 is the frequency of the correct answer, then p2 is the frequency of the incorrect answer.
[0126] According to the formula: Calculate the conditional entropy of the question-and-answer sample set under each feature information condition of the preset feature information set.
[0127] Where p(x) i ,y i ) represents the category identifier x i and feature information y i The co-occurrence frequency of candidate response text and feature information y. i Matches, and carries a category identifier of x. i The frequency.
[0128] According to the formula: Y = argmax Y {H(X)-H(X|Y)} determines the target feature information.
[0129] Where, argmax Y {*} represents taking the parameter Y that maximizes the value inside the parentheses.
[0130] The preset loop termination condition can have multiple conditions, such as exiting the loop when the ratio of correct answer text samples to incorrect answer text samples is greater than a preset threshold. In one embodiment, "satisfying the preset loop termination condition" can specifically be:
[0131] Calculate the ratio of the number of response text samples with the target classification label to the number of response text samples with the non-target classification label in the question-answer sample set;
[0132] If the ratio is greater than the preset threshold, the preset loop termination condition is met, and the loop ends.
[0133] The target classification identifier can be an identifier that indicates the correct answer to the corresponding query sample text in the response text sample.
[0134] For example, it can be calculated based on the classification identifier to determine the ratio between the number of correct answer text samples (assuming 40) and the number of incorrect answer text samples (assuming 8) (40 / 8 = 5). If the preset threshold is 4 (5 > 4), then the preset loop termination condition is met, and the loop is exited.
[0135] The preset loop condition can also be that the number of node layers reaches a preset number of layers, that is, in one embodiment, "satisfying the preset loop termination condition", which can specifically be:
[0136] Get the level number of the child node;
[0137] When the number of layers is greater than the preset number of layers, the preset loop termination condition is determined to be met.
[0138] The layer number can be the number of nodes in the path from the node corresponding to the node in the question-and-answer sample set (the question-and-answer sample set that has not been feature-matched) to a certain node (K). This number of nodes is the layer number of the node (K).
[0139] For example, it could be to obtain the layer number of the child node, and if the layer number is greater than the preset layer number, then it is determined that the preset loop termination condition is met.
[0140] The preset loop condition can also be that all the feature information in the preset feature information set is determined to be the target feature information of the node. That is, in one embodiment, after the step "generating child nodes of the node based on the question-and-answer sample subset, and determining the target feature information corresponding to the child nodes based on the question-and-answer sample subset", the following is executed:
[0141] The target feature information corresponding to the node in the preset feature information set is marked, as well as the target feature information corresponding to the child node is marked;
[0142] "Meets the preset loop termination condition", which can be:
[0143] If there are no unlabeled feature information in the preset feature information set, then the loop termination condition is satisfied.
[0144] For example, when determining the target feature information corresponding to a node, the feature information in the preset feature information set corresponding to the target feature information is marked; when determining the target feature information of a child node, the feature information in the preset feature information set corresponding to the target feature information of the child node is marked; when the target feature information of a child node is determined, the marked feature information in the preset feature information set is not acquired.
[0145] If all the feature information in the preset feature information set is marked, that is, all the feature information in the preset feature information set is determined as the target feature information of the node.
[0146] Optionally, if the path from the first node to the child node includes all the feature information in the preset feature information set, then the child node is not divided. That is, the node is determined based on the question-and-answer sample set. This node can be the root node, denoted as node A. The question-and-answer sample set is continuously divided based on the target feature information to obtain the child node B of node A, the child node C of node B, the child node D of node C, the child node E of node D, and so on. The target feature information corresponding to nodes A, B, C, and D are different feature information in the preset feature information. Assuming that when node N is determined, all the feature information in the preset feature information set is used by the nodes on the path from node A to node N to divide the question-and-answer sample set, then the determination of the target feature information of node N ends, and the question-and-answer samples are divided.
[0147] "Meeting the preset loop termination condition" can mean determining one of the three conditions above as the loop termination condition, or that meeting any one of the above conditions is sufficient to determine that the preset loop termination condition is met, or that two conditions are selected as the preset loop termination condition, and meeting just one of the conditions is sufficient to determine that the preset loop termination condition is met.
[0148] 104. Generate a target question and answer set based on the target response text and the corresponding question text.
[0149] The target question-and-answer set can be a whole consisting of candidate question texts and the target answer texts corresponding to the candidate question texts.
[0150] For example, a target question-and-answer set can be generated based on the target response text and the corresponding candidate question texts.
[0151] The target question-and-answer set can also be generated by establishing an index relationship between the target answer text and the candidate question text. That is, in one embodiment, the step "generating the target question-and-answer set based on the target answer text and the candidate question text corresponding to the target answer text" can specifically be:
[0152] An index relationship is established between the target response text and the corresponding candidate query texts to obtain the target question-and-answer set;
[0153] The step "When a query text to be processed is received, search for the response text that matches the query text in the target question-and-answer set, and recommend response text based on the query text" can specifically be:
[0154] When a query text to be processed is received, the response text that matches the query text to be processed is searched from the target question and answer set based on the index relationship.
[0155] Recommend response text based on the query text to be processed.
[0156] The index relationship can be a separate, physical storage structure that sorts the target response text in a database table, or it can be a list of logical pointers to the target response text and the corresponding candidate query samples pointing to the target response text.
[0157] The query text to be processed can be the text that the user inputs on the client and needs to get a reply, or it can be the text that the client or the server corresponding to the client obtains based on the voice information input by the user on the client and needs to get a reply.
[0158] For example, in a specific scenario, an index could be created in the database for question-answer pairs, such as the target response text and the candidate query texts corresponding to the target response text. When a client receives a query text to be processed, the corresponding candidate query text can be found based on the index, and the target response text corresponding to the candidate query text can be used as the response text that matches the query text to be processed and recommended to the client.
[0159] Based on the index relationship, the position of the reply text can be quickly located, improving the response speed of the query text to be processed.
[0160] 105. When a query text to be processed is received, search for the response text that matches the query text to be processed from the target question and answer set, and recommend response text based on the query text to be processed.
[0161] For example, when a pending query text is received from a client, the candidate query text corresponding to the pending query text is determined, and the target answer text corresponding to the target question and answer set is recommended to the client as the answer text for the pending question.
[0162] As described above, this embodiment of the application obtains a candidate question-and-answer set, which includes candidate question texts and corresponding candidate answer texts; analyzes the candidate answer texts to obtain their attribute information; performs feature matching between the attribute information and target feature information, and filters target answer texts from the candidate answer texts based on the feature matching results; generates a target question-and-answer set based on the target answer texts and their corresponding question texts; when a question text to be processed is received, it searches for answer texts that match the question text to be processed in the target question-and-answer set, and recommends answer texts based on the question text to be processed. This solution, by obtaining the attribute information of the candidate answer texts and matching the attribute information with target feature information, can filter out answer texts that are more closely matched to the question from the candidate answer texts, recommend more suitable answer texts to the user, and improve the accuracy of recommendations.
[0163] Based on the above embodiments, the following examples will provide further detailed explanations.
[0164] This embodiment will be described in detail using the example of integrating a response text recommendation device into a server, where the query text is a question, the response text is an answer fragment, and the response text to be processed is an answer document.
[0165] This application provides a text recommendation method, which can be executed by a server's processor, such as... Figure 3 As shown, the specific process of this text recommendation method can be as follows:
[0166] 201. Train the initial classification model to obtain the trained model.
[0167] 2011. Obtain a preset set of feature information and a set of question-and-answer samples.
[0168] The question-and-answer sample set may include question samples and corresponding answer fragment samples, as well as answer document samples including answer fragment samples.
[0169] In this embodiment, the preset feature information set may include the following feature information:
[0170] (1) Whether the answer fragment appears in the first short sentence of the answer document.
[0171] (2) The number of characters in the short sentence containing the answer fragment.
[0172] (3) The number of times the words in the question appear in the short sentence containing the answer.
[0173] (4) Whether the answer fragment appears in the first natural sentence of the answer document.
[0174] (5) The number of words in the natural sentence containing the answer segment.
[0175] (6) How many short sentences are contained in the natural sentence containing the answer segment.
[0176] (7) The number of times the words in the question appear in the natural sentence containing the answer fragment.
[0177] (8) The number of times the words in the question appear near the answer fragment (window size 20).
[0178] (9) The number of characters contained in the answer document.
[0179] (10) The number of short sentences in the answer document.
[0180] (11) The number of natural sentences in the answer document.
[0181] (12) The predicted probability of the answer fragment.
[0182] (13) The number of characters in the answer segment.
[0183] (14) The number of short sentences contained in the answer segment.
[0184] (15) Does the sentence containing the answer contain a negative word?
[0185] Understandably, the number of features in the preset feature set, the prediction probability, and other values can be adjusted according to the actual application scenario to obtain more accurate results.
[0186] For example, the server could obtain a preset set of feature information and a set of question-and-answer samples from a database, or obtain the preset set of feature information and the set of question-and-answer samples from other devices via network requests, Bluetooth, or other means.
[0187] The question-and-answer sample set can also be candidate answer samples extracted from the answer document samples by the server using a reading comprehension model based on an answer fragment extraction algorithm. The reading comprehension model can be, for example, a BERT-based reading comprehension model or an LSTM-based reading comprehension model.
[0188] The following explanation uses a BERT-based reading comprehension model as an example.
[0189] Suppose the problem sample consists of (x1, x2, ..., x M The ) indicates that the answer document sample containing answer fragment samples is composed of (y1, y2, ..., y N ) indicates that x i and y i This represents the i-th character in the question and paragraph.
[0190] The word sequence obtained by concatenating the question sample and the answer document sample is: [CLS]x1,…,x M [SEP]y1,…,y N [SEP], we use the following formula to calculate the representation of each word, and finally obtain the output matrix.
[0191] H = BERT([CLS], x1, ..., x M ,[SEP],y1,…,y N [SEP])
[0192] Where M and N represent the number of words in the question and paragraph, respectively, [CLS] and [SEP] represent special delimiters, and d represents the dimension of the hidden layer of the BERT reading comprehension model.
[0193] After obtaining the implicit representation matrix H of the BERT output, we predict the start and end positions of the answer fragment samples based on it.
[0194] Specifically, the probability p that the i-th character is predicted to be the starting position of the answer fragment sample. s (i=s a The probability p of the end position of the answer fragment sample. e (i=e a It can be calculated using the following formula:
[0195]
[0196] in, This represents the weights and bias parameters of the prediction layer in the reading comprehension model, s a and e a These represent the start and end positions of the answer, respectively, and softmax(*) is the normalization function. The loss function L of the reading comprehension model is defined by the following formula:
[0197]
[0198] in, This indicates an indicator function, meaning that the function's value is 1 only if the condition in parentheses is true, otherwise it is 0.
[0199] After the BERT reading comprehension model has finished training, the model's prediction results are obtained using the following formula:
[0200]
[0201] st1≤start≤end≤N
[0202] Where start represents the start position of the predicted answer fragment sample in the answer document sample, end represents the end position of the predicted answer fragment sample in the answer document sample, and argmax i {*} represents the parameter i that maximizes the value within the parentheses. Furthermore, the model's prediction result must ensure that the start index is less than the end index, and both the start and end positions must be within the answer document sample. The string between the start and end positions is the answer fragment sample extracted by the question-answering model. Its prediction probability is calculated using the following formula:
[0203]
[0204] Where exp(*) represents the exponential function, p s (start=s a ) and p e (end=e a ) represent the probabilities that the index positions start and end, obtained by the formula, are the beginning and end positions of the answer, respectively.
[0205] The reading comprehension model extracts answer fragment samples from the answer document samples and labels them as positive or negative samples. That is, it labels the answer fragment sample as the correct answer to the question sample (the answer fragment sample matches the standard answer exactly) or the answer fragment sample as the incorrect answer to the question sample (the answer fragment sample does not match the standard answer exactly).
[0206] The server obtains a question-and-answer sample set based on question samples, answer document samples, and answer fragment samples extracted from the answer document samples by the reading comprehension model.
[0207] 2012. The initial classification model generates corresponding nodes based on the question-and-answer sample set, and determines the target feature information of the nodes.
[0208] For example, the server can generate a node (root node) through an initial classification model, and determine the target feature information of the node from a preset feature information set based on the question and answer sample set.
[0209] For example, based on the classification identifier carried by the answer fragment samples, the number of question samples and the number of answer fragment samples corresponding to the question samples can be calculated, and the number of answer fragment samples that are correct answers can be counted to determine the frequency of answer fragment samples being correct answers.
[0210] And count the number of answer fragment samples that are not correct answers, and determine the frequency of answer fragment samples that are not correct answers.
[0211] According to the formula: Calculate the information entropy of the answer fragment sample.
[0212] Where X represents all answer fragment samples included in the node, p i This represents the frequency of answer fragment samples in the i-th category. Since the classification identifier can determine whether an answer fragment sample is a correct answer or not, in this embodiment, n is 2. If p i If p2 is the frequency of the correct answer, then p2 is the frequency of the incorrect answer.
[0213] According to the formula: Calculate the conditional entropy of the question-and-answer sample set under each feature information condition of the preset feature information set.
[0214] Where p(x) i ,y i ) represents the category identifier x i and feature information y i The co-occurrence frequency of candidate answer fragments and feature information y. i Matches, and carries a category identifier of x. i The frequency.
[0215] According to the formula: Y = argmax Y {H(X)-H(X|Y)} determines the target feature information.
[0216] Where, argmax Y {*} represents taking the parameter Y that maximizes the value inside the parentheses.
[0217] The feature information corresponding to the target feature information in the preset feature information set is marked.
[0218] 2013. Determine the first and second question-and-answer sample subsets from the question-and-answer sample set based on the target feature information.
[0219] For example, if the target feature information of a node is determined to be "(1) whether the answer fragment appears in the first short sentence of the answer document", the server determines the position of the answer fragment sample in the answer document sample in the question and answer sample set based on the target feature information. It can determine whether the answer fragment sample appears in the first short sentence of the answer document based on the position of the end position of the answer fragment sample and the position of the first punctuation mark (comma, period, question mark or exclamation mark) of the answer document.
[0220] The server uses an initial classification model to determine the first question-and-answer sample subset based on the answer fragment samples that appear in the first short sentence of the answer document; and to determine the second question-and-answer sample subset based on the answer fragment samples that do not appear in the first short sentence of the answer document.
[0221] 2014. Take the first subset of question and answer samples as the question and answer sample set, and return to step 2012 until the preset loop termination condition is met.
[0222] For example, the server can generate corresponding child nodes based on the first question-and-answer sample subset using an initial classification model, recursively determine the target feature information of the nodes, and continuously divide the question-and-answer sample set into two smaller subsets based on the target feature information.
[0223] When the newly generated node reaches the preset number of layers, or when the proportion of answer fragment samples in the question-and-answer sample subset corresponding to the node that exactly matches the standard answer reaches the preset threshold, or when all features in the preset feature information set are identified as target feature information by the nodes on the path from the root node to the node, the division of the question-and-answer text sample is stopped, that is, the splitting of the node to obtain child nodes is stopped.
[0224] 2015. Take the second subset of question and answer samples as the question and answer sample set, and return to step 2012 until the preset loop termination condition is met.
[0225] For example, the server can generate corresponding child nodes based on the first question-and-answer sample subset using an initial classification model, recursively determine the target feature information of the nodes, and continuously divide the question-and-answer sample set into two smaller subsets based on the target feature information.
[0226] When the newly generated node reaches the preset number of layers, or when the proportion of answer fragment samples in the question-and-answer sample subset corresponding to the node that exactly matches the standard answer reaches the preset threshold, or when all features in the preset feature information set are identified as target feature information by the nodes on the path from the root node to the node, the division of the question-and-answer text sample is stopped, that is, the splitting of the node to obtain child nodes is stopped.
[0227] Steps 2016, 2014, and 2015 end the loop, resulting in the trained classification model.
[0228] For example, specifically, the training classification model can be obtained when all nodes meet the preset loop termination condition and the splitting of child nodes ends.
[0229] In one embodiment, the partial structure of the decision tree structure obtained after training the model is as follows: Figure 4 As shown, the sample size is the number of answer fragment samples contained in the question-and-answer sample corresponding to the node; the sample ratio is the number of non-exact matching answers and the number of exact matching answers in the answer fragment sample. For example, the sample ratio [632, 404] means that there are 632 non-exact matching answers and 404 exact matching answers in the answer fragment sample.
[0230] from Figure 4 As shown at node B, although the reading comprehension model predicts a probability greater than 0.921, there are 100 non-exact matches. Therefore, relying solely on the reading comprehension model to predict the matching degree of answer segments is unreliable.
[0231] 202. Obtain the set of candidate questions and answers to be processed, and extract answer fragments from the answer documents through the question-and-answer model to obtain the set of candidate questions and answers.
[0232] The candidate question and answer set to be processed includes questions and corresponding answer documents.
[0233] The answer document can be a document that includes answer snippets.
[0234] For example, the server could retrieve the question and its corresponding answer document. A question could correspond to multiple answer documents, obtained through web crawling or pre-stored in a database. A question-answering model, such as one based on a reading comprehension model (specifically, a BERT-based model), could then concatenate the answer document and the corresponding question one by one. This could involve segment embedding to obtain a word sequence, followed by word embedding and position embedding mapping to real numbers, resulting in a representation vector between the question and the answer document.
[0235] The server uses a BERT-based reading comprehension model to predict the start probability of each character in the answer document as a candidate start position for a candidate answer segment, and the end probability of each character as a candidate end position for a candidate answer segment.
[0236] The first character of the candidate answer segment is determined based on the starting probability of each character. For example, the starting position of the candidate answer segment can be determined by the character with the highest starting probability among multiple starting probabilities.
[0237] The first character of the candidate answer segment is determined based on the end probability of each character. For example, the end position of the candidate answer segment can be determined by the character with the highest end probability among multiple end probabilities.
[0238] The server identifies the start and end positions, as well as the characters in between, as candidate answer segments. Text segment extraction is then performed on the representation vector to obtain these candidate answer segments.
[0239] The specific implementation process can refer to the relevant process in step 2011.
[0240] However, modern neural network models generally suffer from overconfidence. For example, a reading comprehension model might predict a fragment as an exact match with a high probability, even if the fragment is not an exact match. Simply judging the reasonableness of an answer based on the predicted probability is undoubtedly unreliable. This is especially true in applications like intelligent medical consultations where answer quality is paramount; presenting patients with misleading answers could have very serious consequences.
[0241] In this embodiment of the application, in addition to predicting the probability of candidate answer segments using a BERT-based reading comprehension model, a classification model is also used to further filter the candidate answer segments to obtain more accurate candidate answer segments.
[0242] For example, such as Figure 5 As shown, the candidate question-and-answer set is input into a neural network model (specifically, a reading comprehension model). The server uses the reading comprehension model to extract answer documents from the candidate question-and-answer set, obtaining candidate answer fragments and outputting the candidate question-and-answer set. Then, a trained classification model filters the target answer fragments from the candidate question-and-answer set to obtain the target question-and-answer set.
[0243] Index the target question and answer set. When a user enters a question to be processed in the client (the search engine), such as: What does 2019 belong to?
[0244] The server uses an index to find the corresponding answer fragment for the question in the database, such as "pig," and then returns the answer fragment to the user through the client.
[0245] 203. Determine the current node and its target feature information through the trained classification model.
[0246] For example, the trained classification model obtained after training the initial classification model can include a tree structure, which can be a decision tree structure. Based on the tree structure, a decision path is determined, and the target feature information corresponding to each node on the decision path is determined.
[0247] The server determines the current node, such as the root node, through the trained model, and determines the target feature information corresponding to that node.
[0248] Partial structure of decision tree as follows Figure 4 As shown, the target feature information of the root node (node A) is: the predicted probability of the answer fragment is <= 0.921.
[0249] The classification model after training can be a decision tree model because each step of the decision tree model is interpretable. Therefore, the specific reason why a candidate answer segment is judged as an exact match or an inexact match can be determined based on the output of the decision tree model. In other words, the decision tree model is interpretable.
[0250] 204. Extract features from candidate answer segments based on target feature information to obtain text features, thereby obtaining attribute information of the candidate answer segments.
[0251] For example, if the target feature information is "(2) the number of characters in the short sentence containing the answer fragment", then the server can determine the position of the candidate answer fragment in the answer document based on the starting position of the candidate answer fragment, and determine the short sentence containing the candidate answer fragment based on the punctuation marks.
[0252] Calculate the number of characters contained in the short sentence.
[0253] 205. Perform feature matching between the attribute information and the target feature information to obtain the first subset and the second subset.
[0254] For example, the server could specifically define candidate answer fragments whose short sentences contain fewer than 30 characters as the first subset, and candidate answer fragments whose short sentences contain 30 or more characters as the second subset.
[0255] 206. Take the first subset as the candidate question and answer set of the first child node of the current node, and return to execute step 204 until the first child node is the target node.
[0256] For example, specifically, the first subset can be used as the candidate question-answer set of the first child node of the current node, and a 204 error can be returned. That is, the first subset is recursively divided into smaller subsets according to the target feature information of the first node.
[0257] 207. Take the second subset as the candidate question and answer set of the second child node of the current node, and return to execute step 204 until the second child node is the target node.
[0258] For example, specifically, the second subset can be used as the candidate question-answer set of the second child node of the current node, and a 204 error can be returned. That is, the second subset is recursively divided into smaller subsets according to the target feature information of the second node.
[0259] like Figure 4 As shown, based on the target feature information of node A: the predicted probability of the answer fragment is <= 0.921, the candidate answer sample texts with a predicted probability greater than 0.921 based on the BERT reading comprehension model, along with the corresponding answer documents and questions, are determined as the first subset, and the candidate answer sample texts with a predicted probability less than 0.921, along with the corresponding answer documents and questions, are determined as the second subset.
[0260] The server determines that the node corresponding to the second subset is node B, and the target feature information corresponding to node B is: whether the answer fragment appears in the first short sentence; the node corresponding to the first subset is another child node of node A.
[0261] The candidate answer fragments that appear in the first sentence are divided into two subsets in the second subset, and the candidate answer fragments that do not appear in the first sentence are divided into two subsets.
[0262] The node corresponding to the candidate answer fragment that does not appear in the first short sentence set is identified as node C. The target feature information for node C is: the number of characters in the answer fragment is <= 3. The node corresponding to the candidate answer fragment that appears in the subset of the first short sentence is identified as node D. The target feature information for node D is: the number of characters in the answer fragment is <= 3.
[0263] Based on the target feature information of node C, the subset can be divided into two smaller subsets. The node corresponding to one subset is node E. As shown in the figure, node E is a leaf node. The questions, candidate answer fragments, and answer documents included in the set corresponding to node E are determined as the target question and answer set.
[0264] The loop ends when the first or second node is the target node, such as the root node.
[0265] 208. Index the candidate question and answer set of the target node. When a question to be processed is received from the client, find the answer fragment that matches the question to be processed according to the index, and recommend the answer fragment to the client.
[0266] For example, in a specific scenario, the server could create an index in the database that indexes the target answer fragment and the question-answer pair corresponding to the target answer fragment. When receiving a question from a client, the server could find the corresponding question based on the index and recommend the target answer fragment corresponding to the question as the matching answer fragment for the question to the client.
[0267] As can be seen from the above, this embodiment of the application trains an initial classification model to obtain a trained model; obtains a set of candidate questions and answers to be processed, and extracts answer fragments from the answer document using the question-and-answer model to obtain a set of candidate questions and answers; determines the current node and the target feature information of the current node using the trained classification model; extracts features from the candidate answer fragments based on the target feature information to obtain text features, thereby obtaining the attribute information of the candidate answer fragments; performs feature matching between the attribute information and the target feature information to obtain a first subset and a second subset; uses the first subset as the candidate question and answer set of the first child node of the current node, and returns to step 204 until the first child node is the target node; uses the second subset as the candidate question and answer set of the second child node of the current node, and returns to step 204 until the second child node is the target node; establishes an index for the candidate question and answer set of the target node, and when a question to be processed from a client is received, searches for an answer fragment that matches the question to be processed based on the index, and recommends the answer fragment to the client. This solution obtains attribute information from candidate answer fragments and matches them with target feature information. It can then filter out answer fragments that are more closely matched to the question and recommend more relevant answer fragments to the user, thereby improving the accuracy of the recommendation.
[0268] To facilitate better implementation of the text recommendation method provided in this application embodiment, a response text recommendation device is also provided in one embodiment. The meanings of the terms are the same as in the text recommendation method described above, and specific implementation details can be found in the description of the method embodiment.
[0269] The response text recommendation device can be specifically integrated into computer devices, such as... Figure 6 As shown, the response text recommendation device may include: an acquisition unit 301, an analysis unit 302, a filtering unit 303, a generation unit 304, and a recommendation unit 305, as detailed below:
[0270] Acquisition unit 301: used to acquire a candidate question and answer set, which includes candidate question texts and candidate answer texts corresponding to the candidate question texts.
[0271] For example, it could be to obtain a set of candidate questions and answers from a database, or to obtain a set of candidate questions and answers from other devices via network requests, Bluetooth, or other means.
[0272] Optionally, the response text recommendation device further includes an extraction unit, which is used to obtain a candidate question-and-answer set through a neural network model. Specifically, the extraction unit is used to:
[0273] Retrieve candidate query texts and their corresponding pending response texts;
[0274] By using a question-answering model, the candidate question text and the response text to be processed are vector-embedded to obtain the representation vector between the candidate question text and the candidate response information.
[0275] The response text is extracted from the representation vector to obtain candidate response texts corresponding to the response text to be processed;
[0276] A candidate question-and-answer set is generated based on the candidate response text and the corresponding candidate question text.
[0277] For example, it can specifically obtain candidate query texts and corresponding response texts to be processed. A candidate query text can correspond to multiple response texts to be processed. The response texts to be processed and the corresponding candidate query texts are concatenated one by one through the question answering model. For example, it can obtain word sequences through classification mapping (segment embedding) and perform word embedding and position embedding mapping to real numbers to obtain the representation vector between the candidate query text and the candidate response information. Text fragments are extracted from the representation vector to obtain the candidate response text.
[0278] The obtained candidate response texts are mapped to the corresponding candidate question texts to obtain a set of candidate question and answer texts with a mapping relationship between the candidate question texts and the candidate response texts.
[0279] Optionally, the extraction unit may further include a determination subunit, which is used to determine candidate response texts from the response text to be processed. Specifically, the determination subunit is used to:
[0280] The question-answering model predicts the start probability of the position of each character in the representation vector as the candidate start position of the candidate response text, and the end probability of the position of each character as the candidate end position of the candidate response text.
[0281] The start position is determined from the candidate start positions based on the start probability, and the end position is determined from the candidate end positions based on the end probability;
[0282] Candidate response texts are determined from the pending response texts based on the start and end positions.
[0283] For example, specifically, the question-answering model can predict the start probability of each character in the response text being the candidate start position of the candidate response text, and the end probability of each character being the candidate end position of the candidate response text.
[0284] The first character of the candidate response text is determined based on the start probability of each character. For example, the start position of the candidate response text can be determined by the character with the highest start probability among multiple start probabilities.
[0285] The first character of the candidate response text is determined based on the end probability of each character. For example, the end position of the candidate response text can be determined by the character with the highest end probability among multiple end probabilities.
[0286] The start and end positions, as well as the characters in between, are determined as candidate response text.
[0287] Analysis unit 302: Used to analyze candidate response texts to obtain attribute information of candidate response texts.
[0288] For example, the candidate response text can be analyzed based on the target feature information to obtain the attribute information of the candidate response text. For instance, if the target feature information is that the candidate response text is the first sentence of the response text to be processed, then the position of the candidate response text in the response text to be processed can be determined based on the starting position of the candidate response text, and the obtained attribute information is the position of the candidate response text in the response text to be processed.
[0289] Alternatively, the position of the candidate response text in the pending response text can be determined by finding the corresponding text in the pending response text based on the candidate response text.
[0290] In addition to obtaining attribute information based on target features, all attribute information required for matching candidate response texts with features can be obtained in advance based on possible feature matching of candidate response texts.
[0291] Analysis unit 302 may further include an acquisition subunit, which is used to acquire attribute information of candidate response text through a neural network model. Specifically, the acquisition subunit is used to:
[0292] The trained classification model extracts features from candidate response texts based on target feature information to obtain text features.
[0293] By analyzing the text features, the attribute information of the candidate response texts can be obtained.
[0294] For example, specifically, the target feature information can be determined by training a classification model to identify the number of short sentences in the natural sentence containing the candidate response text (in the response text to be processed). Then, the position of the candidate response text in the response text to be processed can be determined. Punctuation marks such as commas, periods, question marks, and exclamation marks can be extracted from the natural sentence containing the candidate response text to obtain the text features of the candidate response text. The text features of the candidate response text can be analyzed. For example, the number of extracted punctuation marks can be statistically processed to obtain the number of punctuation marks. The attribute information of the candidate response text can be determined as the number of short sentences in the natural sentence containing the candidate response text, which is denoted as 'a'.
[0295] Filtering unit 303: Used to perform feature matching between attribute information and target feature information, and filter target response text from candidate response text based on feature matching results.
[0296] For example, specifically, the attribute information of the target response text and the candidate response text can be matched to obtain the matching results of the candidate response text with the target feature information. The matching candidate response text can be used as the target response text, or the non-matching candidate response text can be used as the target response text, or the matching result can be used as the first target response text and the matching result can be used as the second target response text.
[0297] To further improve the accuracy of the target response text obtained by the trained classification model, the filtering unit 303 may optionally include a matching subunit for performing multiple feature matches on the candidate response text. Specifically, the matching subunit is used for:
[0298] The current node is determined from the multi-layer node, and the attribute information is matched with the target feature information corresponding to the current node. Based on the feature matching result, the target response text is selected from the candidate response text.
[0299] The target response text and the corresponding candidate query text are used as the candidate question and answer set of the child nodes of the current node;
[0300] Take the aforementioned child node as the current node, return to perform the operation of matching the attribute information with the target feature information corresponding to the current node, until the current node is the target node, and take the candidate answer text in the candidate question and answer set of the obtained child node as the target answer text.
[0301] For example, it can be done by determining the current node and its target feature information in a multi-layered node structure, matching the attribute information of the candidate response text with the target feature information, and then filtering the target response text from the candidate response text based on the feature matching results.
[0302] The set of candidate target response texts and corresponding candidate query texts is used as the candidate response texts of the current node's child nodes. This child node is then used as the current node. Feature matching is performed again on the new candidate response texts to filter the target response text from the new candidate response texts.
[0303] The process of using the target response text as a new candidate response text and filtering the target response text from the new candidate response text is iterated until a node is the target node. The candidate response text obtained from that node and the corresponding candidate query text are then used as the target response text.
[0304] Optionally, the target feature information of the current node can be determined by the training classification model, and the candidate response text can be analyzed according to the target feature information corresponding to the current node to obtain the attribute information corresponding to the target feature information.
[0305] To determine the target response text from candidate response texts using a trained classification model, the classification model needs to be trained beforehand. In one embodiment, the response text recommendation device provided in this embodiment further includes a training unit for training the classification model to obtain a trained classification model. Specifically, the trained classification model is used for:
[0306] The question-and-answer sample set is obtained through the initial classification model, and the nodes corresponding to the question-and-answer sample set and the target feature information corresponding to the nodes are determined.
[0307] A subset of question-and-answer samples is determined from the question-and-answer sample set based on the target feature information corresponding to the nodes;
[0308] The child nodes of the node are generated based on the question-and-answer sample subset, and the target feature information corresponding to the child nodes is determined based on the question-and-answer sample subset;
[0309] The question-and-answer sample subset is used as the question-and-answer sample set, and the child nodes are used as nodes. The process returns to determine the question-and-answer sample subset from the question-and-answer sample set based on the target feature information corresponding to the nodes, until the preset loop termination condition is met, and the trained classification model is obtained.
[0310] For example, it could involve obtaining a set of question-and-answer samples and generating corresponding nodes (hereinafter referred to as the first node for clarity) based on the set of question-and-answer samples, as well as determining target feature information. For example, the feature information in the preset feature information set includes priority, and one feature information is determined from the preset feature information set as the target feature information of the node based on the priority (e.g., obtaining the feature information with the highest priority).
[0311] Matching the question-and-answer sample set based on the target feature information yields two question-and-answer sample subsets—a first question-and-answer sample subset and a second question-and-answer sample subset. The first question-and-answer sample subset may match the target feature information, while the second question-and-answer sample subset may not match the target feature information.
[0312] Under the first node, child nodes are generated based on a subset of question-and-answer samples. Specifically, a first child node can be generated based on a first subset of question-and-answer samples, and a second child node can be generated based on a second subset of question-and-answer samples. Feature information (feature information different from the target feature information corresponding to the first node) is determined from preset feature information based on the first subset of question-and-answer samples and the second subset of question-and-answer samples, respectively, as the target feature information of the child node.
[0313] The first child node is taken as the first node, and the first question-and-answer sample subset is taken as the question-and-answer sample set. The question-and-answer sample subset is determined from the question-and-answer sample set (i.e., the first question-and-answer sample subset) based on the target feature information. The second child node is taken as the first node, and the second question-and-answer sample subset is taken as the question-and-answer sample set. The question-and-answer sample subset is determined from the question-and-answer sample set (i.e., the second question-and-answer sample subset) based on the target feature information.
[0314] Essentially, based on whether the response text samples in the target feature information corresponding to the first child node match, the first question-and-answer sample subset is divided into two subsets (matching and non-matching). Based on the obtained subsets, corresponding child nodes are generated (each subset corresponds to one node), and the target feature information corresponding to the generated child nodes is determined. The subsets are then divided based on the target feature information, that is, the question-and-answer sample set is iteratively divided based on the target feature information until a preset loop termination condition is met. For example, when the number of divisions reaches a preset number, it is determined that the preset loop termination condition is met, the loop ends, and the trained classification model is obtained.
[0315] In addition to acquiring target feature information according to a preset strategy, in one embodiment, the training unit may further include a feature determination subunit. The feature determination subunit is used to determine target feature information based on the influence of each feature in the preset feature information set on the generation of the question-answer sample set. Specifically, the feature determination subunit is used to:
[0316] Obtain a question-and-answer sample set and a preset feature information set, the preset feature information set including multiple feature information;
[0317] Under the condition of feature information, the stable value of the question-and-answer sample set is calculated through the initial classification model;
[0318] The nodes are determined by an initial classification model, and the target feature information of the nodes is determined based on stable values.
[0319] For example, it could involve obtaining a question-and-answer sample set and a preset feature information set, and calculating the stable value of the question-and-answer sample set under each feature information condition in the preset feature information set. This stable value could be the conditional entropy, that is, the conditional entropy of the question-and-answer sample set calculated under each feature information condition.
[0320] The initial classification model can generate a node and use the feature information corresponding to the conditional entropy with the smallest value among multiple conditional entropies as the target feature information of the node.
[0321] In one embodiment, the feature determination subunit may further include a calculation module. This calculation module is used to determine the feature information that has the greatest impact on the information entropy of the question-and-answer sample set by calculating the information entropy of the question-and-answer sample set, and then determine this feature information as the target feature information corresponding to the node. Specifically, the calculation module is used to:
[0322] Based on the classification labels, the information entropy of the question-and-answer sample set is calculated using the initial classification model.
[0323] Calculate the conditional entropy of the question-and-answer sample set under the feature information conditions of the preset feature information set;
[0324] The stable value is determined based on information entropy and conditional entropy.
[0325] For example, it could be based on the classification identifier carried by the response text sample to calculate the number of query text samples and the corresponding response text samples, and count the number of response text samples that are correct answers to determine the frequency of response text samples being correct answers.
[0326] And count the number of incorrect answers in the response text samples to determine the frequency of incorrect answers in the response text samples.
[0327] According to the formula: Calculate the information entropy of the response text sample.
[0328] According to the formula: Calculate the conditional entropy of the question-and-answer sample set under each feature information condition of the preset feature information set.
[0329] According to the formula: Y = argmax Y {H(X)-H(X|Y)} determines the target feature information.
[0330] The preset loop termination condition can have multiple conditions, such as exiting the loop when the ratio of correct answer text samples to incorrect answer text samples is greater than a preset threshold. In one embodiment, the training unit may further include a loop termination subunit, which is used to terminate the loop when the preset loop termination condition is met. Specifically, the loop termination subunit is used to:
[0331] Calculate the ratio of the number of response text samples with the target classification label to the number of response text samples with the non-target classification label in the question-answer sample set;
[0332] If the ratio is greater than the preset threshold, the preset loop termination condition is met, and the loop ends.
[0333] For example, it can be calculated based on the classification identifier to determine the ratio between the number of correct answer text samples (assuming 40) and the number of incorrect answer text samples (assuming 8) (40 / 8 = 5). If the preset threshold is 4 (5 > 4), then the preset loop termination condition is met, and the loop is exited.
[0334] Specifically, the loop termination subunit can also be used for:
[0335] Get the level number of the child node;
[0336] When the number of layers is greater than the preset number of layers, the preset loop termination condition is determined to be met.
[0337] For example, it could be to obtain the layer number of the child node, and if the layer number is greater than the preset layer number, then it is determined that the preset loop termination condition is met.
[0338] Specifically, the loop termination subunit can also be used for:
[0339] The target feature information corresponding to the node in the preset feature information set is marked, as well as the target feature information corresponding to the child node is marked;
[0340] If there are no unlabeled feature information in the preset feature information set, then the loop termination condition is satisfied.
[0341] For example, when determining the target feature information corresponding to a node, the feature information in the preset feature information set corresponding to the target feature information is marked; when determining the target feature information of a child node, the feature information in the preset feature information set corresponding to the target feature information of the child node is marked; when the target feature information of a child node is determined, the marked feature information in the preset feature information set is not acquired.
[0342] If all the feature information in the preset feature information set is marked, that is, all the feature information in the preset feature information set is determined as the target feature information of the node.
[0343] Optionally, if the path from the first node to the child node includes all the feature information in the preset feature information set, then the child node is not divided. That is, the node is determined based on the question-and-answer sample set. This node can be the root node, denoted as node A. The question-and-answer sample set is continuously divided based on the target feature information to obtain the child node B of node A, the child node C of node B, the child node D of node C, the child node E of node D, and so on. The target feature information corresponding to nodes A, B, C, and D are different feature information in the preset feature information. Assuming that when node N is determined, all the feature information in the preset feature information set is used by the nodes on the path from node A to node N to divide the question-and-answer sample set, then the determination of the target feature information of node N ends, and the question-and-answer samples are divided.
[0344] "Meeting the preset loop termination condition" can mean determining one of the three conditions above as the loop termination condition, or that meeting any one of the above conditions is sufficient to determine that the preset loop termination condition is met, or that two conditions are selected as the preset loop termination condition, and meeting just one of the conditions is sufficient to determine that the preset loop termination condition is met.
[0345] Generation unit 304: Used to generate a target question and answer set based on the target response text and the corresponding query text.
[0346] For example, a target question-and-answer set can be generated based on the target response text and the corresponding candidate question texts.
[0347] In one embodiment, the generation unit may further include an indexing subunit, which is used to establish an index relationship based on the target response text and candidate query texts to generate a target question-and-answer set. The recommendation unit may include a search subunit. Specifically, the indexing subunit may be used for:
[0348] An index relationship is established between the target response text and the corresponding candidate query texts to obtain the target question-and-answer set;
[0349] Finding subcells can be used for:
[0350] When a query text to be processed is received, the response text that matches the query text to be processed is searched from the target question and answer set based on the index relationship.
[0351] Recommend response text based on the query text to be processed.
[0352] For example, in a specific scenario, an index could be created in the database for question-answer pairs, such as the target response text and the candidate query texts corresponding to the target response text. When a client receives a query text to be processed, the corresponding candidate query text can be found based on the index, and the target response text corresponding to the candidate query text can be used as the response text that matches the query text to be processed and recommended to the client.
[0353] Recommendation unit 305: When a query text to be processed is received, it searches for a response text that matches the query text to be processed from the target question and answer set, and recommends a response text based on the query text to be processed.
[0354] For example, when a pending query text is received from a client, the candidate query text corresponding to the pending query text is determined, and the target answer text corresponding to the target question and answer set is recommended to the client as the answer text for the pending question.
[0355] As can be seen from the above, in this embodiment of the application, the acquisition unit 301 acquires a candidate question-and-answer set, which includes candidate question texts and corresponding candidate answer texts. The analysis unit 302 analyzes the candidate answer texts to obtain attribute information. The filtering unit 303 performs feature matching between the attribute information and target feature information, and filters target answer texts from the candidate answer texts based on the feature matching results. The generation unit 304 generates a target question-and-answer set based on the target answer texts and the corresponding question texts. Finally, when a client's pending question text is received, the recommendation unit 305 searches for answer texts that match the pending question texts from the target question-and-answer set and recommends answer texts based on the pending question texts. This solution, by acquiring the attribute information of the candidate answer texts and matching them with target feature information, can filter out answer texts that are more closely matched to the question from the candidate answer texts and recommend more closely matched answer texts to the user, thereby improving the accuracy of the recommendation.
[0356] This application also provides a computer device, which can be a terminal or a server, such as... Figure 7 As shown, it illustrates a structural schematic diagram of the computer device involved in the embodiments of this application, specifically:
[0357] The computer device may include components such as a processor 1001 with one or more processing cores, a memory 1002 with one or more computer-readable storage media, a power supply 1003, and an input unit 1004. Those skilled in the art will understand that... Figure 7 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0358] The processor 1001 is the control center of the computer device. It connects various parts of the computer device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the memory 1002, and by calling data stored in the memory 1002, thereby providing overall monitoring of the computer device. Optionally, the processor 1001 may include one or more processing cores; preferably, the processor 1001 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and computer programs, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1001.
[0359] The memory 1002 can be used to store software programs and modules. The processor 1001 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002. The memory 1002 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, computer programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 1002 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 1002 may also include a memory controller to provide the processor 1001 with access to the memory 1002.
[0360] The computer equipment also includes a power supply 1003 that supplies power to the various components. Preferably, the power supply 1003 can be logically connected to the processor 1001 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 1003 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0361] The computer device may also include an input unit 1004, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0362] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 1001 in the computer device loads the executable files corresponding to the processes of one or more computer programs into the memory 1002 according to the following instructions, and the processor 1001 runs the computer programs stored in the memory 1002 to realize various functions, as follows:
[0363] Obtain a candidate question-and-answer set, which includes candidate question texts and corresponding candidate answer texts.
[0364] Analyze the candidate response texts to obtain their attribute information;
[0365] The attribute information is matched with the target feature information, and the target response text is selected from the candidate response text based on the feature matching results;
[0366] Generate a target question-and-answer set based on the target response text and the corresponding question text.
[0367] When a query text to be processed is received, the system searches for a matching response text from the target question-and-answer set and recommends a response text based on the query text to be processed.
[0368] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0369] As described above, the computer device in this embodiment acquires a candidate question-and-answer set, which includes candidate question texts and corresponding candidate answer texts. It analyzes the candidate answer texts to obtain their attribute information. It performs feature matching between the attribute information and target feature information, and filters target answer texts from the candidate answer texts based on the feature matching results. It generates a target question-and-answer set based on the target answer texts and their corresponding question texts. When a question text to be processed is received, it searches the target question-and-answer set for answer texts that match the question text to be processed, and recommends answer texts based on the question text to be processed. This solution, by acquiring the attribute information of candidate answer texts and matching it with target feature information, can filter out answer texts that better match the question from the candidate answer texts, recommending more suitable answer texts to the user and improving the accuracy of the recommendation.
[0370] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium (also simply referred to as a storage medium). A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations of the above embodiments.
[0371] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by a computer program, or by a computer program controlling related hardware. The computer program can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0372] Therefore, embodiments of this application provide a storage medium storing a computer program that can be loaded by a processor to execute the steps in any of the text recommendation methods provided in embodiments of this application.
[0373] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0374] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0375] Since the computer program stored in the storage medium can execute the steps in any of the text recommendation methods provided in the embodiments of this application, the beneficial effects that any of the text recommendation methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0376] The foregoing has provided a detailed description of a text recommendation method, apparatus, computer device, and storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A text recommendation method, characterized in that, include: Obtain a candidate question-and-answer set, which includes candidate question texts and candidate answer texts corresponding to the candidate question texts; The candidate response text is extracted based on the target feature information by a trained classification model to obtain text features. The trained classification model includes multiple layers of nodes, and each node in the multiple layers of nodes stores the target feature information. The text features are analyzed to obtain the attribute information of the candidate response text, wherein the attribute information includes the number of characters in the candidate response text, the number of sentences contained in the candidate response text, and the position information of the candidate response text; The current node is determined from the multi-layer nodes, and the attribute information is matched with the target feature information corresponding to the current node. Based on the feature matching result, the target response text is filtered from the candidate response text. The target feature information includes the number of characters in the candidate response text, the number of sentences in the candidate response text, and the position information of the candidate response text as filtering conditions. The target response text and the corresponding candidate query text are used as the candidate question and answer set of the child nodes of the current node; Take the child node as the current node, return to perform the operation of matching the attribute information with the target feature information corresponding to the current node, until the current node is the target node, and take the candidate answer text in the candidate question and answer set of the obtained child node as the target answer text; Based on the target response text and the corresponding candidate query texts, a target question-and-answer set is generated; When a query text to be processed is received, the system searches for a response text that matches the query text to be processed from the target question and answer set, and recommends the response text based on the query text to be processed.
2. The method according to claim 1, characterized in that, The process of obtaining the candidate question-answer set includes: Obtain candidate query texts and corresponding response texts to be processed; The candidate query text and the response text to be processed are vector-embedded using a question-and-answer model to obtain a representation vector between the candidate query text and the candidate response information. The response text is extracted from the representation vector to obtain candidate response texts corresponding to the response text to be processed; A candidate question-and-answer set is generated based on the candidate response text and the corresponding candidate question text.
3. The method according to claim 2, characterized in that, The response text is extracted from the representation vector using a question-and-answer model to obtain candidate response texts corresponding to the response text to be processed, including: The question-answering model predicts the start probability of the position of each character in the representation vector as the candidate start position of the candidate response text, and the end probability of the position of each character as the candidate end position of the candidate response text. A start position is determined from the candidate start positions based on the start probability, and an end position is determined from the candidate end positions based on the end probability; Candidate response texts are determined from the response texts to be processed based on the start position and the end position.
4. The method according to claim 1, characterized in that, Before obtaining the candidate question-answer set, the method further includes: The question-and-answer sample set is obtained through an initial classification model, and the nodes corresponding to the question-and-answer sample set and the target feature information corresponding to the nodes are determined. A subset of question-and-answer samples is determined from the question-and-answer sample set based on the target feature information corresponding to the node; The child nodes of the node are generated based on the subset of question-and-answer samples, and the target feature information corresponding to the child nodes is determined based on the subset of question-and-answer samples. The subset of question-and-answer samples is used as the question-and-answer sample set, and the child node is used as the node. The process of determining the subset of question-and-answer samples from the question-and-answer sample set based on the target feature information corresponding to the node is repeated until the preset loop termination condition is met, and the trained classification model is obtained.
5. The method according to claim 4, characterized in that, The step of obtaining a question-and-answer sample set through an initial classification model, and determining the nodes corresponding to the question-and-answer sample set and the target feature information corresponding to the nodes, includes: Obtain a question-and-answer sample set and a preset feature information set, wherein the preset feature information set includes multiple feature information; Under the given feature information conditions, a stable value for the question-and-answer sample set is calculated using an initial classification model; The initial classification model generates nodes corresponding to the question-and-answer sample set, and the target feature information of the nodes is determined based on the stable value.
6. The method according to claim 5, characterized in that, The question-and-answer sample set includes multiple response text samples, each carrying a classification identifier. The step of calculating a stable value for the question-and-answer sample set using an initial classification model, under the given feature information, includes: The information entropy of the question-and-answer sample set is calculated based on the classification identifier using the initial classification model. Calculate the conditional entropy of the question-and-answer sample set under the feature information conditions of the preset feature information set; The stable value is determined based on the information entropy and the conditional entropy.
7. The method according to claim 4, characterized in that, The conditions for satisfying the preset loop termination condition include: Calculate the ratio of the number of response text samples with the target classification label to the number of response text samples with the non-target classification label in the question-and-answer sample set. If the ratio is greater than a preset threshold, then the preset loop termination condition is satisfied.
8. The method according to claim 4, characterized in that, The child node includes the level number of the child node, and the condition for satisfying the preset loop termination includes: Obtain the layer number of the child node; When the number of layers is greater than the preset number of layers, the loop termination condition is determined to be met.
9. The method according to claim 5, characterized in that, After generating child nodes of the node based on the question-and-answer sample subset, and determining the target feature information corresponding to the child nodes based on the question-and-answer sample subset, the method further includes: The target feature information corresponding to the node in the preset feature information set is marked, and the target feature information corresponding to the child node is also marked; The conditions for satisfying the preset loop termination condition include: If there is no unlabeled feature information in the preset feature information set, then the loop termination condition is satisfied.
10. The method according to any one of claims 4-9, characterized in that, The step of generating a target question-and-answer set based on the target response text and the corresponding candidate question text includes: An index relationship is established between the target response text and the corresponding candidate query texts to obtain the target question-and-answer set; When a query text to be processed is received, the step of searching for a matching response text from the target question-and-answer set and recommending the response text based on the query text to be processed includes: When a query text to be processed is received, the answer text that matches the query text to be processed is searched from the target question and answer set based on the index relationship. The response text is recommended based on the query text to be processed.
11. A text recommendation device, characterized in that, include: An acquisition unit is used to acquire a candidate question-and-answer set, the candidate question-and-answer set including candidate question texts and candidate answer texts corresponding to the candidate question texts; An analysis unit is used to analyze the candidate response text to obtain attribute information of the candidate response text, wherein the attribute information includes the number of characters in the candidate response text, the number of sentences contained in the candidate response text, and the position information of the candidate response text; A filtering unit is used to perform feature matching between the attribute information and the target feature information, and to filter the target response text from the candidate response text based on the feature matching result. The target feature information includes filtering condition information such as the number of characters in the candidate response text, the number of sentences contained in the candidate response text, and the position information of the candidate response text. The generation unit is used to generate a target question-and-answer set based on the target response text and the corresponding query text. The recommendation unit is used to, when receiving a query text to be processed, search for a response text that matches the query text to be processed from the target question and answer set, and recommend the response text based on the query text to be processed; The analysis unit includes an acquisition subunit, which is used for: The candidate response text is extracted based on the target feature information by a trained classification model to obtain text features; The text features are analyzed to obtain the attribute information of the candidate response text; The filtering unit includes a matching sub-unit, which is used for: The current node is determined from the multi-layer nodes, and the attribute information is matched with the target feature information corresponding to the current node. Based on the feature matching result, the target response text is filtered from the candidate response text. The target response text and the corresponding candidate query text are used as the candidate question and answer set of the child nodes of the current node; Take the child node as the current node, return to perform the operation of matching the attribute information with the target feature information corresponding to the current node, until the current node is the target node, and take the candidate response text in the candidate question and answer set of the obtained child node as the target response text.
12. A computer device, characterized in that, It includes a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to perform the text recommendation method according to any one of claims 1 to 10.
13. A storage medium, characterized in that, The storage medium is used to store a computer program, which is loaded by a processor to execute the text recommendation method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Question answering data processing method and device based on machine learning and computer device
CN109446302A
Multi-text analysis method and device
CN110929015A
Information acquisition method and device based on big data, equipment and storage medium
CN112052310A