Problem-solving method, device, storage medium, and electronic device
By obtaining the similar probability of similar questions and target questions, splicing them form splicing questions and calculating the probability matrix, the problem of low accuracy in problem solving in online course learning is solved, more efficient problem-solving methods are achieved, and students' learning experience is improved.
Patent Information
- Application Number
- CN202111513818.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-12-10
AI Technical Summary
In the existing online course study, students lack dedicated explanations when answering questions, resulting in low accuracy in problem solving. Existing problem-solving methods such as template matching and neural network methods cannot effectively utilize similar question relationships, which limits the performance of AI problem-solving.
By obtaining the similar probability of similar questions and target questions, splicing them form splicing questions, and calculating the expression probability matrix and joint probability matrix, determining the expression of the target questions, and improving the accuracy of understanding the problem.
Improve the accuracy of problem-solving, reduce teachers' educational time costs, stimulate students' interest and enthusiasm in learning, and improve students' learning effectiveness.
Smart Images

Figure CN116341516B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a problem-solving method, device, storage medium, and electronic device. Background Art
[0002] Students' education issues are receiving more and more attention from all parties. In recent years, due to the epidemic, online course learning has become an indispensable part of building a learning society. However, due to issues such as labor costs, students often do not have dedicated personnel to explain at any time when answering questions. Therefore, it is necessary to use relevant applications in mobile terminals to solve exercises that students do not know. These applications can automatically obtain the characteristics of the exercises and generate the final solution expression for the exercises. Summary of the Invention
[0003] In order to solve the above problems, the embodiments of the present application provide a problem-solving method, device, storage medium and electronic device to improve the accuracy of problem-solving.
[0004] In a first aspect, an embodiment of the present application provides a problem-solving method, the method comprising:
[0005] Obtain a target topic, obtain at least one similar topic corresponding to the target topic, and a similarity probability between each similar topic and the target topic;
[0006] Each of the similar questions is spliced with the target question to obtain a spliced question, and an expression probability matrix corresponding to each of the spliced questions is calculated, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character;
[0007] Calculating a joint probability matrix based on each of the similarity probabilities and each of the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters;
[0008] An expression of the target question is determined based on the joint probability matrix.
[0009] In a second aspect, an embodiment of the present application provides a problem-solving device, the device comprising:
[0010] An information acquisition module is used to acquire a target topic, acquire at least one similar topic corresponding to the target topic, and a similarity probability between each similar topic and the target topic;
[0011] A first calculation module is used to respectively splice each of the similar questions with the target question to obtain spliced questions, and calculate an expression probability matrix corresponding to each of the spliced questions, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character;
[0012] A second calculation module is configured to calculate a joint probability matrix based on each of the similarity probabilities and each of the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters;
[0013] An expression determination module is used to determine the expression of the target question based on the joint probability matrix.
[0014] In a third aspect, an embodiment of the present application provides a computer storage medium, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps of the above-mentioned first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps of the above-mentioned first aspect.
[0016] The beneficial effects of the technical solutions provided by some embodiments of the present application include at least:
[0017] In an embodiment of the present application, by obtaining a target topic, obtaining at least one similar topic corresponding to the target topic and the similarity probability between each similar topic and the target topic, each similar topic is spliced with the target topic to obtain a spliced topic, and calculating the expression probability matrix corresponding to each spliced topic, each row in the expression probability matrix is an expression probability vector corresponding to each preset character, and a joint probability matrix is calculated based on each similarity probability and each expression probability matrix, each row in the joint probability matrix is a joint probability vector corresponding to each preset character, and the expression of the target topic is determined based on the joint probability matrix. The user only needs to input the target topic, calculate the similarity between the topics in the corpus and the target topic, obtain at least one similar topic and the corresponding similarity probability, splice the similar topics with the target topic to obtain a spliced topic, and calculate the expression probability matrix of each spliced topic, calculate the joint probability matrix through the similarity probability and the expression probability matrix, and thus determine the expression of the target topic according to the joint probability matrix, thereby improving the accuracy of solving the problem. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 A system architecture diagram of a problem-solving system provided in an embodiment of the present application;
[0020] Figure 2 A flowchart of a problem-solving method provided in an embodiment of the present application;
[0021] Figure 3 A flowchart of a problem-solving method provided in an embodiment of the present application;
[0022] Figure 4 A flowchart of a problem-solving method provided in an embodiment of the present application;
[0023] Figure 5 A schematic structural diagram of a problem-solving device provided in an embodiment of the present application;
[0024] Figure 6 A schematic structural diagram of a problem-solving device provided in an embodiment of the present application;
[0025] Figure 7 A schematic structural diagram of a problem-solving device provided in an embodiment of the present application;
[0026] Figure 8 A schematic structural diagram of a problem-solving device provided in an embodiment of the present application;
[0027] Figure 9 A schematic structural diagram of a problem-solving device provided in an embodiment of the present application;
[0028] Figure 10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.
[0030] In the following introduction, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The following introduction provides multiple embodiments of the present application. Different embodiments can be replaced or combined, so the present application can also be considered to include all possible combinations of the same and / or different embodiments described. Therefore, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then the present application should also be considered to include embodiments containing one or more of all other possible combinations of A, B, C, and D, even though the embodiment may not be clearly described in the following text.
[0031] The following description provides examples and does not limit the scope, applicability, or examples set forth in the claims. Changes may be made to the function and arrangement of the elements described without departing from the scope of the present application. Various examples may appropriately omit, replace, or add various processes or components. For example, the described method may be performed in an order different from the order described, and various steps may be added, omitted, or combined. In addition, features described in some examples may be combined in other examples.
[0032] In recent years, due to the epidemic, online course learning has become an indispensable part of building a learning society. How to reduce the burden on teachers in teaching and students in learning has also become an important topic. It is hoped that AI problem-solving technology can be used to reduce the time cost of teachers' education, while reducing the learning burden of students and stimulating students' learning interest and enthusiasm. Most of the existing problem-solving methods use template matching or neural network-based sequence generation methods. The template matching method retrieves similar questions and brings the expressions of similar questions into the original question as templates to obtain the answer to the question. However, because it is impossible to traverse the templates of all questions, the problem-solving effect of this method is poor. The neural network-based sequence generation method takes the original question as input and obtains the problem expression after a sequence-to-sequence neural network model. However, this method can only learn the internal logical relationship of the question through the neural network model itself, ignoring the relationship between the original question and similar questions. This limits the performance of AI problem-solving to a certain extent, and the accuracy of solving the original problem is not high enough.
[0033] Based on this, an embodiment of the present application provides a method for solving a problem, which obtains a target question, obtains at least one similar question corresponding to the target question, and the similarity probability between each similar question and the target question, respectively splices each similar question with the target question to obtain a spliced question, and calculates the expression probability matrix corresponding to each spliced question, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character, calculates a joint probability matrix based on each similarity probability and each expression probability matrix, wherein each row in the joint probability matrix is a joint probability vector corresponding to each preset character, and determines the expression of the target question based on the joint probability matrix. The user only needs to input the target question, calculate the similarity between the questions in the corpus and the target question, obtain at least one similar question and the corresponding similarity probability, splice the similar question with the target question to obtain a spliced question, and calculate the expression probability matrix of each spliced question, calculate the joint probability matrix through the similarity probability and the expression probability matrix, thereby determining the expression of the target question according to the joint probability matrix, and improving the accuracy of solving the problem.
[0034] See Figure 1 , is a schematic diagram of the architecture of a problem-solving system provided in an embodiment of the present application.
[0035] The system includes a user terminal, which may include but is not limited to a smart phone, a smart interactive tablet, a personal computer, a desktop computer, a tablet computer, a PDA, a laptop computer, an all-in-one computer, a vehicle-mounted multimedia device, etc. By obtaining a target topic, at least one candidate topic in the corpus is vectorized to obtain a candidate topic vector corresponding to each candidate topic, and the target topic is vectorized to obtain a target topic vector corresponding to the target topic, and the cosine similarity between each candidate topic and the target topic is calculated to obtain a first similarity probability corresponding to each candidate topic and the target topic, and each first similarity probability is sorted, and N similar topics are determined from the candidate topics based on each sorted first similarity probability, and the first feature vectors corresponding to the N similar topics are obtained through a text feature extractor, and the second feature vector of the target topic is obtained, and each first feature vector is vector-inner-producted with the second feature vector, and each result after the vector inner product is normalized to obtain a second similarity probability of the N similar topics with the target topic, and each second similarity probability is sorted, and K similar topics are determined from the N similar topics based on each sorted second similarity probability. The second similarity probabilities of K similar questions and the target question are respectively spliced with the target question to obtain K spliced questions, and each spliced question is traversed in turn to obtain the expression probability vector of each character in the preset characters corresponding to the currently traversed target spliced question, and each expression vector is arranged in rows to generate an expression probability matrix corresponding to the target spliced question. Until the traversal is completed, the expression probability matrix of each spliced question is obtained, and the second similarity probabilities of the K similar questions are multiplied by the corresponding expression probability matrix to obtain the result matrices corresponding to the K similar questions, and the expression probability vectors corresponding to the corresponding rows in each result matrix are added to obtain the joint probability vector of the corresponding row, and the joint probabilities are combined to obtain the joint probability matrix, and the maximum joint probability in the joint probability vector of each row of the joint probability matrix and the target character corresponding to the maximum joint probability are determined, and the target characters are combined to obtain the expression of the target question.
[0036] The cosine similarity between the target question entered by the user and the candidate questions in the corpus is calculated to determine similar questions and similarity probabilities. The similar questions and the target question are concatenated to calculate the expression probability matrix. The joint probability matrix is calculated based on the similarity probability and the expression probability matrix. The expression of the target question is determined through the joint probability matrix, thereby completing the solution to the target question and improving the accuracy of the solution.
[0037] See Figure 2 , provides a flowchart of a problem-solving method for the embodiment of this application. Figure 2 As shown, the problem-solving method may include the following steps:
[0038] S101, obtaining a target topic, obtaining at least one similar topic corresponding to the target topic, and a similarity probability between each similar topic and the target topic.
[0039] In one embodiment, the target question input by the user is word-vectorized, and the word vector of the target question is mean-pooled to obtain the target question vector. At the same time, all the candidate questions in the corpus are word-vectorized, and the word vector of each candidate question is mean-pooled to obtain the candidate question vector corresponding to each candidate question. The target question vector is respectively calculated with the cosine similarity of each candidate question vector, and at least one candidate question with high similarity is taken as a similar question, as well as the similarity probability of each similar question with high similarity to the target question.
[0040] The target question is any type of question that the user needs to solve.
[0041] Methods for word vectorization of target questions and candidate questions may include, but are not limited to, using Word2vec or GloVe algorithms to train the prediction library to obtain a vector representation of each word.
[0042] Word2vec is a related model used to generate word vectors. These models are shallow, two-layer neural networks trained to reconstruct linguistic text. The network is represented by words and is required to guess the adjacent positions of the input words. Under the bag-of-words model in Word2vec, the order of words is unimportant. After training, the Word2vec model maps each word to a vector that represents the relationship between words. This vector serves as the hidden layer of the neural network.
[0043] GloVe, short for Global Vectors for Word Representation, is a word representation tool based on count-based and overall statistics. It represents a word as a vector composed of real numbers. These vectors capture semantic properties between words, such as similarity and analogy. By performing operations on these vectors, such as Euclidean distance or cosine similarity, we can calculate the semantic similarity between two words.
[0044] Cosine similarity measures the similarity between two vectors by measuring the cosine of the angle between them. The cosine of a 0-degree angle is 1, while the cosine of any other angle is no greater than 1; and its minimum value is -1. Therefore, the cosine of the angle between two vectors determines whether the two vectors point in roughly the same direction. When two vectors have the same direction, the cosine similarity value is 1; when the angle between the two vectors is 90°, the cosine similarity value is 0; when the two vectors point in completely opposite directions, the cosine similarity value is -1. This result is independent of the length of the vector and is only related to the direction in which the vector points. Cosine similarity is usually used in positive space, so the value given is between -1 and 1.
[0045] S102, respectively concatenating the similar questions with the target question to obtain concatenated questions, and calculating an expression probability matrix corresponding to each concatenated question, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character.
[0046] In one embodiment, similar questions selected from the candidate questions based on similarity are respectively spliced with the target question to obtain corresponding spliced questions, and the expression generator generates an expression probability matrix corresponding to each spliced question.
[0047] The splicing methods of similar topics and target topics may include but are not limited to similar topics before the target topic, similar topics after the target topic, similar topics interspersed between target topics, target topics interspersed between similar topics, etc.
[0048] For example, the target question is "The riverside park originally had 20 boats, with a daily income of 360 yuan. Based on this calculation, now that 15 boats have been added, how much more yuan can be earned every day?"
[0049] One of the similar questions is "There used to be 3 cruise ships in Dipu Port, with a daily income of 225 yuan. Based on this calculation, there are now 14 cruise ships. How much yuan can be earned every day?"
[0050] The spliced questions can be "Dipu Port originally had 3 cruise ships, with a daily income of 225 yuan. According to this calculation, there are now 14 cruise ships. How much yuan can be earned every day? Riverside Park originally had 20 boats, with a daily income of 360 yuan. According to this calculation, 15 more boats have been added. How much more yuan can be earned every day?" or "Riverside Park originally had 20 boats, with a daily income of 360 yuan. According to this calculation, 15 more boats have been added. How much more yuan can be earned every day? Dipu Port originally had 3 cruise ships, with a daily income of 225 yuan. According to this calculation, there are now 14 cruise ships. How much yuan can be earned every day?" and so on.
[0051] Each row in the expression probability matrix represents an expression probability vector formed by the generation probability of each pre-set character corresponding to each splicing question in the expression generator.
[0052] For example, the splicing question is input into the expression generator, and the expression forms an expression probability matrix according to the splicing question.
[0053] If the characters preset in the expression generator are +, 8, 3, 6, *, and one of the splicing questions is input into the expression generator, the expression generator generates expression probability vectors [0.18, 0.22, 0.35, 0.05, 0.2], [0.29, 0.21, 0.17, 0.23, 0.1], [0.16, 0.24, 0.08, 0.25, 0.27] based on the content of the splicing question. Then the generated expression probability matrix is:
[0054]
[0055] Each column represents the generation probability of each preset character in the expression generator in the expression of the splicing question. For example, the first column is the generation probability of the character "1" when the splicing question generates each character of the expression. Each row in the expression probability matrix is an expression probability vector formed by the generation probability of each character of the expression corresponding to the splicing question in the expression generator. For example, the first row in the above matrix is the generation probability of each preset character in the expression generator when the splicing question generates the first character of the expression. The generation probabilities of the characters "+", 8, 3, 6, *" are 0.18, 0.22, 0.35, 0.05, and 0.2 respectively.
[0056] The example of 5 preset characters in the expression generator is used here for illustration, which does not limit the number of preset characters in the expression generator in this solution. Based on the technical concept of the present invention, any preset number of characters that a person skilled in the art has not thought of without creative work should fall within the scope of protection of this solution.
[0057] S103: Calculate a joint probability matrix based on the similarity probabilities and the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters.
[0058] In one embodiment, after splicing at least one similar question with the target question, at least one corresponding expression probability matrix will be generated. There are as many similar probabilities and expression probability matrices as there are similar questions. Each similar probability is multiplied with each row of the expression probability matrix generated after splicing the corresponding similar question with the target question, and then the corresponding rows in each multiplied probability matrix are added to obtain a joint probability vector of the corresponding rows. The joint probability vector is arranged according to the corresponding rows of the expression probability vector to obtain a joint probability matrix.
[0059] For example, if three similar questions are selected, with similarity probabilities of 0.5, 0.2, and 0.3 respectively, the expression probability matrices generated by concatenating the similar questions with the target question are:
[0060]
[0061] Multiplying the similarity probability with the probability matrix of each expression respectively obtains the corresponding probability matrix expressed as:
[0062]
[0063] The joint probability vector is expressed as follows: the first row of the joint probability vector is [0.09, 0.11, 0.175, 0.025, 0.1] + [0.056, 0.024, 0.03, 0.05, 0.04] + [0.054, 0.036, 0.075, 0.045, 0.09] = [0.2, 0.17, 0.28, 0.12, 0.23], and the second row of the joint probability vector is [0.145, 0.105, 0.85, 0.115, 0.085, 0.115, 0.05] + [0.038 , 0.042, 0.054, 0.026, 0.04]+[0.057, 0.063, 0.081, 0.039, 0.06]=[0.24, 0.21, 0.22, 0.18, 0.15], the third row joint probability vector is [0.08, 0.12, 0.04, 0.125, 0.135]+[0.038, 0.064, 0.016, 0.05, 0.034]+[0.108, 0.072, 0.054, 0.015, 0.051]=[0.22, 0.26, 0.11, 0.19, 0.22], and the final joint probability matrix is:
[0064]
[0065] S104: Determine an expression of the target question based on the joint probability matrix.
[0066] In one embodiment, the character corresponding to the maximum joint probability in each row of the joint probability vector of the joint probability matrix is used as the target character, and all target characters are arranged in the order of the rows of the joint matrix to form an expression of the target question.
[0067] Among them, each target character in the expression of the target question is a preset character in the expression builder.
[0068] For example, the character corresponding to the maximum joint probability determined in the first row of the joint probability vector in the joint probability matrix is the first character of the expression of the target question. For example, the joint matrix formed in step S103 is:
[0069]
[0070] If the preset characters in the expression generator are "+, 8, 3, 6, *", then according to the maximum joint probability of each row in the joint matrix, the target character corresponding to the maximum joint probability of 0.28 in the first row is "3", the target character corresponding to the maximum joint probability of 0.24 in the second row is "+", and the target character corresponding to the maximum joint probability of 0.26 in the third row is "8". Therefore, the expression of the target question is expressed as "3+8".
[0071] In an embodiment of the present application, a user inputs a target question to be solved, and a cosine similarity calculation is performed on the target question and all questions in the corpus to obtain at least one similar question and the similarity probability between the similar question and the target question. Each similar question selected is concatenated with the target question to obtain a concatenated question. An expression generator generates an expression probability matrix corresponding to each concatenated question, multiplies each similar probability by the corresponding expression probability matrix, and then adds the corresponding rows in each probability matrix after multiplication to obtain a joint probability vector. The joint probability vector is arranged according to the corresponding rows of the expression probability vector to obtain a joint probability matrix. The maximum joint probability value is determined in each row of the joint probability vector of the joint probability matrix. The preset character corresponding to the maximum joint probability value is used as the target character. Finally, all target characters are combined to obtain the expression of the target question. In the problem-solving process, the problem-solving template of similar questions can be used as a reference, and the similarity probability of similar questions is multiplied by the corresponding expression probability matrix to obtain the joint probability. The more similar the questions are, the more reference value they have for solving the target question. The expression of the target question is determined according to the joint probability of each preset character in the joint probability matrix, thereby improving the accuracy of problem-solving.
[0072] See Figure 3 , provides a flowchart of a problem-solving method for the embodiment of this application. Figure 3 As shown, the problem-solving method may include the following steps:
[0073] S201, vectorizing at least one candidate topic in a corpus to obtain a candidate topic vector corresponding to each candidate topic, and vectorizing the target topic to obtain a target topic vector corresponding to the target topic.
[0074] In one embodiment, a vectorization algorithm is used to train a corpus to obtain a vector representation of each word of at least one candidate topic in the corpus, and then the word vectors of each candidate topic are mean-pooled to obtain a candidate topic vector corresponding to each candidate topic. At the same time, the corpus vectorizes the target topic, also by vectorizing each word and then mean-pooling the word vectors to obtain a target topic vector corresponding to the target topic.
[0075] The vectorization algorithm may include but is not limited to Word2vec, GloVe, etc.
[0076] Word2vec is a family of related models used to generate word embeddings. These models are shallow, two-layer neural networks trained to reconstruct linguistic text. The network is represented by words and is required to guess the adjacent positions of the input words. Under the bag-of-words model in Word2vec, word order is unimportant. After training, the Word2vec model can be used to map each word to a vector, which can be used to represent the relationships between words.
[0077] GloVe stands for Global Vectors for Word Representation. It is a word representation tool based on count-based and overall statistics. It can express a word as a vector composed of real numbers. These vectors capture some semantic characteristics between words, such as similarity and analogy. We can calculate the semantic similarity between two words by performing operations on vectors, such as Euclidean distance or cosine similarity.
[0078] S202, respectively calculating the cosine similarity between each of the candidate question vectors and the target question vector, and obtaining first similarity probabilities corresponding to each of the candidate questions and the target question.
[0079] In one embodiment, after vectorizing each candidate question and target question in the corpus, the similarity between each candidate question and the target question is calculated using cosine similarity to obtain a first similarity probability between each candidate question and the target question. Cosine similarity uses the cosine value of the angle between each candidate question vector and the target question vector to determine the similarity between the two vectors. The closer the cosine value of the angle between the two vectors is to 1, the smaller the angle is, indicating a higher similarity between the candidate question and the target question.
[0080] Cosine similarity measures the similarity between two vectors by measuring the cosine of the angle between them. The cosine of a 0-degree angle is 1, while the cosine of any other angle is no greater than 1; and its minimum value is -1. Therefore, the cosine of the angle between two vectors determines whether the two vectors point in roughly the same direction. When two vectors have the same direction, the cosine similarity value is 1; when the angle between the two vectors is 90°, the cosine similarity value is 0; when the two vectors point in completely opposite directions, the cosine similarity value is -1. This result is independent of the length of the vector and is only related to the direction in which the vector points. Cosine similarity is usually used in positive space, so the value given is between -1 and 1.
[0081] S203: Determine N similar questions from the candidate questions based on the first similarity probabilities, where N is a positive integer and greater than or equal to 1.
[0082] In one embodiment, the first similarity probabilities corresponding to the candidate questions and the target question are sorted, and N candidate questions corresponding to higher first similarity probabilities are determined as N similar questions, where N is a positive integer and greater than or equal to 1.
[0083] The sorting method of the first similarity probability may include but is not limited to sorting from large to small or from small to large.
[0084] S204: Obtain first feature vectors corresponding to the N similar topics respectively through a text feature extractor, and obtain a second feature vector of the target topic.
[0085] In one embodiment, N similar topics with high similarity to the target topic are screened out from the candidate topics in the corpus and input into the text feature extractor to obtain the first feature vector corresponding to each similar topic. There are N first feature vectors, and the target topic is input into the text feature extractor to obtain the second feature vector corresponding to the target topic.
[0086] The first eigenvector and the second eigenvector are both eigenvectors of the entire sentence.
[0087] Text feature extractors may include but are not limited to neural network models such as Textcnn, Textrcnn, and Bert.
[0088] TextCNN, the first layer is the input M×Q word vector matrix, the dimension of the word vector is Q, and there are M words in total; the second layer is the convolution layer, with a total of 6 convolution kernels. The input layer is convolved with 6 convolution kernels respectively, and then activated by the activation function. Each convolution kernel obtains the corresponding feature maps; the third layer is the pooling layer, which uses 1-max pooling to extract the maximum value of each feature map, and then cascades to obtain a 6-dimensional feature representation; the fourth layer is the output layer, which uses the softmax activation function for classification, and regularization (12-regularization) can be performed at this layer.
[0089] Textrcnn, the text here can be a sentence, a document (short text, several sentences) or a chapter (long text), so the length of each text is different. When classifying text, we generally specify a fixed input sequence / text length: this length can be the length of the longest text / sequence, in which case all other texts / sequences must be padded to reach this length; this length can also be the average of the lengths of all texts / sequences in the training set, in which case texts / sequences that are too long need to be truncated, and texts that are too short need to be padded. In short, in order to make all texts / sequences in the training set the same length, this length can be any other reasonable value in addition to the settings mentioned above. During testing, the same processing is also required for the texts / sequences in the test set; assuming that the length of all texts / sequences in the training set is uniformly n, we need to segment the text and use word embedding to obtain a vector representation of a fixed dimension for each word. For each input text / sequence, we can input the vector representation of a word in the text at each time step of the RNN, calculate the hidden state at the current time step, and then use it as the output of the current time step and pass it to the next time step and use it together with the word vector of the next word as the RNN unit input, and then calculate the hidden state of the RNN at the next time step, and repeat this... until every word in the input text is processed. Since the length of the input text is n, it takes n time steps.
[0090] Bert, which stands for Bidirectional Encoder Representation from Transformers, is a pre-trained language representation model. It emphasizes that instead of using traditional unidirectional language models or shallowly concatenating two unidirectional language models for pre-training as in the past, it adopts a new masked language model (MLM) to generate deep bidirectional language representations. When the Bert paper was published, it mentioned achieving new state-of-the-art results in 11 NLP (Natural Language Processing) tasks. It used MLM to pre-train bidirectional Transformers to generate deep bidirectional language representations. After pre-training, it only required adding an additional output layer for fine-tuning to achieve state-of-the-art performance in a variety of downstream tasks. During this process, no task-specific structural modifications to Bert were required.
[0091] In this invention, the network parameters of the aforementioned model can be dynamically adjusted based on the expression generation results. Therefore, during the model training process, the vector representation of each question changes dynamically. The biggest difference between this method and unsupervised retrieval methods is that the parameters can be dynamically adjusted during model training to learn better vector representations.
[0092] It should be noted that the text feature extractor can also be a convolutional neural network (CNN), a recurrent neural network (RNN), a transformer model, etc., and this solution does not make specific limitations.
[0093] S205 , performing inner product of each of the first eigenvectors with the second eigenvector, and normalizing each result of the inner product to obtain a second similarity probability between each of the N similar questions and the target question.
[0094] In one embodiment, the first eigenvectors corresponding to the N similar questions are respectively inner-producted with the second eigenvector of the target question using a vector inner product formula, and the results of the N vector inner products are normalized to obtain the second similarity probabilities between the N similar questions and the target question.
[0095] Among them, the vector inner product formula can be , where x is the second eigenvector corresponding to the target question, z is the first eigenvector corresponding to one of the similar questions, and f(x, z) is the vector inner product result corresponding to one of the similar questions.
[0096] Normalization converts data into decimals between 0 and 1. This was primarily proposed for easier data processing. Mapping data to the range of 0 to 1 makes processing more efficient and convenient. It also converts dimensional expressions into dimensionless ones, facilitating comparison and weighting of indicators of different units or magnitudes. Normalization is a method for simplifying calculations by transforming dimensional expressions into dimensionless ones, becoming scalar quantities.
[0097] The normalization method can be:
[0098] Where f(x, z) is the vector inner product result corresponding to one of the similar questions, Z i represents the i-th candidate similar exercise, and P(z|x) represents the normalization of the result after the inner product calculation, thereby obtaining the second similarity probability corresponding to the target question of the N similar questions.
[0099] S206, based on each of the second similarity probabilities, determine K similar questions among the N similar questions and the second similarity probabilities between the K similar questions and the target question, where K is a positive integer and K is greater than or equal to 1, N is a positive integer and N is greater than or equal to 1, and K is less than or equal to N.
[0100] In one embodiment, the second similarity probabilities are sorted, and K similar topics corresponding to higher second similarity probabilities and second similarity probabilities corresponding to the K similar topics are determined from the N second similarity probabilities.
[0101] Where K and N are both positive integers and both greater than or equal to 1, and K is less than or equal to N.
[0102] The sorting manner of the second similarity probabilities may include, but is not limited to, sorting from large to small or from small to large.
[0103] S207 , respectively concatenating the similar questions with the target question to obtain concatenated questions, and calculating an expression probability matrix corresponding to each concatenated question, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character.
[0104] The specific implementation of this step can refer to step S102 and will not be described in detail here.
[0105] S208 , calculating a joint probability matrix based on each of the similarity probabilities and each of the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters.
[0106] The specific implementation of this step can refer to step S103 and will not be described in detail here.
[0107] S209: Determine the expression of the target question based on the joint probability matrix.
[0108] The specific implementation of this step can refer to step S104 and will not be described in detail here.
[0109] In an embodiment of the present application, at least one candidate topic in the corpus is vectorized to obtain a candidate topic vector corresponding to each candidate topic, and the target topic is vectorized to obtain a target topic vector corresponding to the target topic, and the cosine similarity of each candidate topic vector and the target topic vector is calculated respectively to obtain the first similarity probability corresponding to each candidate topic and the target topic, and N similar topics are determined in the candidate topics based on each first similarity probability, and the first feature vectors corresponding to the N similar topics are obtained by a text feature extractor, and the second feature vector corresponding to the target topic is obtained, and the vector inner product is performed on each first feature vector and the second feature vector, and the vector inner product is performed on each first feature vector and the second feature vector, and the vector inner product is performed on each first feature vector and the second feature vector, and the vector inner product is performed on each first feature vector and the second feature vector, and the vector inner product is performed on each first feature vector and the second feature vector, and the vector inner product is performed on each first feature vector and the second feature vector, and the vector inner product is performed on each first feature vector and the second feature vector, and the vector inner product is performed on each first feature vector and the target topic ... cosine similarity of each candidate topic vector and the target topic The product result is normalized to obtain the second similarity probability of the N similar questions and the target question respectively. Based on the second similarity probabilities, K similar questions and the second similarity probabilities of the K similar questions and the target question respectively are determined among the N similar questions. The K similar questions are spliced with the target question respectively to obtain K spliced questions, and the K expression probability matrices corresponding to the K spliced questions are calculated. The joint probability matrix is calculated based on the second similarity probabilities and the expression probability matrices, and then the expression corresponding to the target question is determined based on the joint probability matrix, where N is a positive integer and N is greater than or equal to 1, K is a positive integer and K is greater than or equal to 1, and K is less than or equal to N. By calculating the cosine similarity between the target question and the candidate questions in the corpus for initial screening, N similar questions are obtained. Then, the similarity probability between the N similar questions and the target question is calculated through vector inner product, and K similar questions that are more similar to the target question are further obtained. The K similar questions are spliced with the target question to calculate the expression probability matrix, and then the K similar probabilities are respectively combined with the K expression probability matrix to calculate the joint probability matrix. The target characters of the target question are determined from the joint probability matrix, and the target characters are combined to obtain the expression of the target question. The similar questions obtained through two screenings are more instructive for solving the target question, which improves the accuracy of solving the target question.
[0110] See Figure 4 , provides a flowchart of a problem-solving method for the embodiment of this application. Figure 4 As shown, the problem-solving method may include the following steps:
[0111] S301: Obtain a target topic, obtain at least one similar topic corresponding to the target topic, and a similarity probability between each similar topic and the target topic.
[0112] The specific implementation of this step can refer to step S101 and will not be described in detail here.
[0113] S302: Each of the similar questions is combined with the target question to obtain a combined question.
[0114] In one embodiment, each similar topic is concatenated with the target topic to obtain a concatenated topic.
[0115] The splicing methods of similar topics and target topics may include but are not limited to similar topics before the target topic, similar topics after the target topic, similar topics interspersed between target topics, target topics interspersed between similar topics, etc.
[0116] For example, the target question is "The riverside park originally had 20 boats, with a daily income of 360 yuan. Based on this calculation, now that 15 boats have been added, how much more yuan can be earned every day?"
[0117] One of the similar questions is "There used to be 3 cruise ships in Dipu Port, with a daily income of 225 yuan. Based on this calculation, there are now 14 cruise ships. How much yuan can be earned every day?"
[0118] The spliced questions can be "Dipu Port originally had 3 cruise ships, with a daily income of 225 yuan. According to this calculation, there are now 14 cruise ships. How much yuan can be earned every day? Riverside Park originally had 20 boats, with a daily income of 360 yuan. According to this calculation, 15 more boats have been added. How much more yuan can be earned every day?" or "Riverside Park originally had 20 boats, with a daily income of 360 yuan. According to this calculation, 15 more boats have been added. How much more yuan can be earned every day? Dipu Port originally had 3 cruise ships, with a daily income of 225 yuan. According to this calculation, there are now 14 cruise ships. How much yuan can be earned every day?" and so on.
[0119] S303: traverse the splicing questions in sequence, and obtain the expression probability vector of each character in the preset characters corresponding to the currently traversed target splicing question.
[0120] In one embodiment, K similar questions are spliced with the target question respectively to obtain K spliced questions. For each spliced question, a corresponding expression probability matrix will be generated through an expression generator. The K spliced questions are input into the expression generator. The expression generator traverses the K expressions and generates a corresponding expression probability matrix according to the spliced questions. Each row in the expression probability matrix is an expression probability vector composed of the generation probability corresponding to the preset characters in the expression generator. The number of expression probability vectors is determined by the expression generator. In the process of generating a spliced question, the expression generator automatically determines the dimension of the expression probability matrix according to the spliced question.
[0121] Among them, the maximum dimension of expression probability is 64 dimensions. When the expression generator traverses a splicing question to generate an expression probability vector, if the end identifier is detected, the generation of the expression probability vector will be stopped.
[0122] For example, when the expression generator generates an expression probability vector for one of the splicing questions, when generating the fourth row of expression probability vector, the end identifier is detected, which means that the expression corresponding to the current splicing question is 3 characters, and the expression probability matrix of the splicing question is composed of three rows of expression probability vectors.
[0123] It should be noted that the expression generator can be replaced with other text generation models, such as a keyword-based automatic text generation model, an RNN model for automatic text generation, etc. This solution does not make specific limitations.
[0124] S304, arranging the expression probability vectors in rows to generate an expression probability matrix corresponding to the target splicing question; until the traversal is completed.
[0125] In one embodiment, after the expression is traversed for each splicing question to generate an expression probability vector, the expression probability vectors corresponding to each splicing question are arranged in rows to generate an expression probability matrix corresponding to the corresponding target splicing question. The expression probability matrix is generated for each of the K splicing questions.
[0126] For example, for a splicing question, the corresponding expression probability vectors generated in the expression generator are: the first expression probability vector generated is [0.15, 0.32, 0.13, 0.23, 0.17], the second expression probability vector generated is [0.25, 0.22, 0.15, 0.16, 0.22], and the third expression probability vector generated is [0.2, 0.33, 0.14, 0.16, 0.17]. When generating the fourth expression probability vector, the end identifier is detected, and the generation of the expression probability vector of the current splicing question is stopped.
[0127] Then, the expression probability matrix for the current splicing question is:
[0128]
[0129] S305 , multiplying the similarity probability of each of the similar questions by the corresponding expression probability matrix to obtain a result matrix corresponding to each of the similar questions.
[0130] In one embodiment, the similarity probabilities of K similar questions are multiplied by K expression probability matrices generated by the corresponding K concatenated questions to obtain corresponding K result matrices.
[0131] The multiplication of K similarity probabilities corresponds to the multiplication of K expression probability matrices. For example, the similarity probability corresponding to the first similar question is multiplied by the expression probability matrix generated by concatenating the first similar question and the target question.
[0132] For example, after two screenings, there are two similar questions. The similarity probabilities calculated are 0.7 for the first similar question and 0.3 for the second similar question. The expression probability matrices generated by concatenating the two similar questions with the target question are:
[0133] The expression probability matrix generated by the splicing question corresponding to the first similar question is:
[0134]
[0135] The expression probability matrix generated by the splicing question corresponding to the second similar question is:
[0136]
[0137] The similarity probability corresponding to the first similar question is multiplied by the expression probability matrix and is represented as:
[0138]
[0139] The similarity probability corresponding to the second similar question is multiplied by the expression probability matrix to express it as:
[0140]
[0141] S306 , adding the expression probability vectors corresponding to the corresponding rows in the result matrices to obtain the joint probability vectors of the corresponding rows; and combining the joint probability vectors to obtain a joint probability matrix.
[0142] In one embodiment, as in the example given in step 304 above, the result matrices obtained are:
[0143]
[0144] The joint probability vector is calculated by adding the probability vectors of the corresponding rows in each result matrix.
[0145] For example, the joint probability vector corresponding to the above result matrix is calculated as:
[0146] The first row of joint probability vector is: [0.175, 0.084, 0.161, 0.091, 0.189] + [0.045, 0.066, 0.099, 0.009, 0.081] = [0.22, 0.15, 0.26, 0.1, 0.27].
[0147] The second row of joint probability vector is: [0.105, 0.224, 0.105, 0.182, 0.084] + [0.,015, 0.036, 0.075, 0.108, 0.066] = [0.12, 0.26, 0.18, 0.29, 0.15].
[0148] The joint probability vector of the third row is: [0.154, 0.091, 0.238, 0.112, 0.105 + [0.096, 0.069, 0.042, 0.045, 0.048] = [0.25, 0.16, 0.28, 0.157, 153].
[0149] Combine the joint probability vectors row by row, and the joint probability matrix is expressed as:
[0150] S307, determining the maximum joint probability in each row of the joint probability vector of the joint probability matrix and the target characters corresponding to each maximum joint probability; combining each of the target characters to obtain an expression of the target question.
[0151] In one embodiment, the maximum joint probability value is determined in each row of the joint probability matrix, the preset character corresponding to the maximum joint probability value is determined as the target character, and the target characters are combined to obtain an expression of the target question.
[0152] As calculated in step S305 above, in the joint probability matrix, the maximum joint probability value of the first row of joint probability vectors is 0.27, the maximum joint probability value of the second row of joint probability vectors is 0.29, and the maximum joint probability value of the third row of joint probability vectors is 0.28. If the preset characters are "1, *, 4, -, 9", then the corresponding first target character determined by the joint probability matrix is "9", the second target character is "-", and the third target character is "4". The expression of the final target question is expressed as "9-4".
[0153] It should be noted that the expression label corresponding to each row of the joint probability vector in the joint probability matrix is determined, and the loss value of each character in the final expression can be calculated based on the expression label and the joint probability corresponding to each preset character in the joint probability vector of each row. The calculation formula is:
[0154]
[0155] Where C i is the value corresponding to any position of the expression label in each row of the joint probability vector, P i is the joint probability of each preset character in each row of the joint probability vector. The position of the expression label with the maximum joint probability in each row of the joint probability vector corresponds to 1, and the positions of other joint probabilities correspond to 0. By calculating the loss value, the maximum joint probability value in each row of the joint probability vector can be maximized, making the model more clear when determining the target character.
[0156] During the model training phase, the sample questions are input into the original model. Similar questions of the sample questions are screened, and then the expression probability matrix is calculated using the similar questions and the sample questions. When calculating the joint probability matrix, the joint probabilities generated at this time are random, while the expression labels are fixed. Backpropagation is performed through this formula for parameter learning, and ultimately the arrangement of the values of the joint probability vector in each row of the joint probability matrix can be adjusted to achieve a higher probability for the joint probability vector corresponding to the expression label at the position where the expression label is 1, while the probability of other positions is smaller.
[0157] It is worth noting that the expression labels corresponding to each row of the joint probability vector in the joint probability matrix are different.
[0158] For example, if the expression label of a row of joint probability vectors in the joint probability matrix is 10000, the value of the initial joint probability vector at position C0 may not be the largest. However, by using this formula for back propagation learning, the joint probability P0 at position C0 of the joint probability vector in this row is ultimately the largest joint probability value in the joint probability vector in this row. If the joint probability vector of this row is expressed as [0.39, 0.13, 0.09, 0.15, 0.24], the corresponding loss value is calculated as:
[0159]
[0160] It can be seen from the calculation process of this formula that during the calculation process, the joint probability value corresponding to the expression label at position 0 is ultimately represented by 0, and only the joint probability value corresponding to the expression label at position 1 is finally calculated to be a non-zero value. In order to minimize the loss value, the model adjusts the joint probability value corresponding to the position where the expression label is 1 to the maximum joint probability vector value in the joint probability vector of this row through parameter learning. After iterative training of the model, the problem-solving model can easily determine the preset character at this position when solving the target question.
[0161] Among them, the iterative training process of the model is to train the generation of the entire expression probability matrix based on the expression label corresponding to each row of the expression probability vector. The joint probability matrix generated by the original model is random, and the expression label of each row of the joint probability vector cannot fully correspond to the joint probability vector generated by the model. At this time, it is necessary to update and adjust the joint probability vector of the corresponding row according to the expression label, calculate the loss value, and improve the correspondence between the joint probability matrix generated by the model and each expression label. The expression label is used to continuously update and adjust the data of the corresponding joint probability vector in the joint probability matrix, and iterate until the number of training rounds is reached or the loss function of the model converges. The convergence of the loss function means that the loss values calculated multiple times in a row are within the threshold range. Within this threshold range, the corresponding target character can be accurately determined in each row of the joint probability vector generated by the model through the expression label.
[0162] In an embodiment of the present application, a target question is obtained, at least one similar question corresponding to the target question and the similarity probability between each similar question and the target question are obtained, each similar question is spliced with the target question to obtain a spliced question, each spliced question is traversed in turn, the expression probability vector corresponding to the currently traversed target spliced question is obtained, each expression probability vector is arranged in rows, and an expression probability matrix corresponding to the target spliced question is generated until all spliced questions are traversed, the similarity probability of each similar question is multiplied by the corresponding expression probability matrix to obtain a result matrix corresponding to each similar question, the expression probability vectors corresponding to the corresponding rows in each result matrix are added to obtain a joint probability vector of the corresponding row, the joint probability vectors are combined to obtain a joint probability matrix, the maximum joint probability in the joint probability vectors of each row of the joint probability matrix and the target characters corresponding to each maximum joint probability are determined, and the target characters are combined to obtain the expression of the target question. By screening similar questions for the target question in the corpus and calculating the similarity probabilities corresponding to the similar questions, the similar questions and the target question are spliced to generate the corresponding expression probability matrix, and then the joint probability matrix is calculated based on the similarity probability and the expression probability matrix. In the joint probability matrix, the preset characters corresponding to the maximum joint probability values of each row are determined as the target characters, and the target characters are combined in the order of each row of the joint probability matrix to obtain the expression of the target question. Similar questions are screened out by calculating the similarity probabilities in two different ways, which is more helpful for solving the target question. The final expression of the target question is calculated based on the similar questions, which improves the accuracy of solving the target question.
[0163] The following will be combined Figure 5 , the problem-solving device provided in the embodiment of the present application is introduced in detail. It should be noted that. Figure 5 The problem-solving device in the present application is used to execute the Figures 2 to 4For the sake of convenience, only the relevant parts of the embodiment of the present application are shown. For the specific technical details, please refer to the present application. Figures 2 to 4 The method embodiment shown.
[0164] See Figure 5 , which provides a structural diagram of a problem-solving device for this application. Figure 5 As shown, the problem-solving device 1 of the embodiment of the present application includes: an information acquisition module 11, a first calculation module 12, a second calculation module 13, and an expression determination module 14.
[0165] An information acquisition module 11 is configured to acquire a target topic, acquire at least one similar topic corresponding to the target topic, and a probability of similarity between each similar topic and the target topic;
[0166] A first calculation module 12 is configured to concatenate each of the similar questions with the target question to obtain a concatenated question, and calculate an expression probability matrix corresponding to each of the concatenated questions, wherein each row of the expression probability matrix is an expression probability vector corresponding to each preset character;
[0167] A second calculation module 13 is configured to calculate a joint probability matrix based on the similarity probabilities and the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters;
[0168] The expression determination module 14 is configured to determine the expression of the target question based on the joint probability matrix.
[0169] Optional, such as Figure 6 As shown, the information acquisition module 11 includes:
[0170] The vectorization unit 111 is used to vectorize at least one candidate question in the question bank to obtain a candidate question vector corresponding to each candidate question, and vectorize the target question to obtain a target question vector corresponding to the target question;
[0171] The data calculation unit 112 is used to calculate the cosine similarity between each of the candidate question vectors and the target question vector, and obtain the first similarity probability corresponding to each of the candidate question and the target question;
[0172] The information determining unit 113 is configured to determine N similar questions from the candidate questions and first similarity probabilities between the N similar questions and the target question based on the first similarity probabilities, where N is a positive integer and greater than or equal to 1.
[0173] Optional, such as Figure 7 As shown, the information determination unit 113 includes:
[0174] An information screening subunit 1131 is configured to determine N similar topics and the N similar topics from the topics to be selected based on each of the first similarity probabilities;
[0175] The vector acquisition subunit 1132 is configured to acquire first feature vectors corresponding to the N similar topics respectively through a text feature extractor, and acquire a second feature vector of the target topic;
[0176] The probability calculation subunit 1133 is configured to perform inner product of each of the first eigenvectors with the second eigenvector, and normalize the results of the inner product to obtain a second similarity probability between each of the N similar questions and the target question.
[0177] The information determination subunit 1134 is used to determine K similar questions among the N similar questions and the second similarity probabilities between the K similar questions and the target question based on each of the second similarity probabilities, where K is a positive integer and K is greater than or equal to 1, N is a positive integer and N is greater than or equal to 1, and K is less than or equal to N.
[0178] Optional, such as Figure 8 As shown, the first calculation module 12 includes:
[0179] A question splicing unit 121 is used to splice each of the similar questions with the target question to obtain a spliced question;
[0180] The question traversal unit 122 is used to traverse the splicing questions in sequence and obtain the expression probability vector of each character in the preset characters corresponding to the currently traversed target splicing question;
[0181] The data generating unit 123 is used to arrange the expression probability vectors in rows to generate an expression probability matrix corresponding to the target splicing question; until the traversal is completed.
[0182] Optional, such as Figure 9 As shown, the second calculation module 13 includes:
[0183] A data multiplication unit 131 is configured to multiply the similarity probability of each similar question by the corresponding expression probability matrix to obtain a result matrix corresponding to each similar question;
[0184] A data summing unit 132 is configured to add the expression probability vectors corresponding to the corresponding rows in each of the result matrices to obtain a joint probability vector for the corresponding row;
[0185] The joint data determination unit 133 is configured to combine the joint probability vectors to obtain a joint probability matrix.
[0186] Optionally, the expression determination module 14 is specifically configured to:
[0187] Determine the maximum joint probability in each row of the joint probability vector of the joint probability matrix and the target character corresponding to each maximum joint probability;
[0188] The target characters are combined to obtain an expression of the target question.
[0189] In an embodiment of the present application, at least one candidate topic in a corpus is vectorized to obtain a candidate topic vector corresponding to each candidate topic, and the target topic is vectorized to obtain a target topic vector corresponding to the target topic, and the cosine similarity of each candidate topic vector and the target topic vector is calculated respectively to obtain a first similarity probability corresponding to each candidate topic and the target topic, and N similar topics are determined in the candidate topics based on each first similarity probability, and the first feature vectors corresponding to the N similar topics are obtained by a text feature extractor, and the second feature vector corresponding to the target topic is obtained, and the vector inner product of each first feature vector and the second feature vector are performed respectively, and the result after the vector inner product is normalized to obtain the second similarity probability of the N similar topics and the target topic, and K similar topics are determined in the N similar topics based on each second similarity probability and the probability of the K similar topics and the target topic. The second similarity probability of the title purpose, respectively splice each similar question with the target question to obtain the spliced question, traverse each spliced question in turn, obtain the expression probability vector of each character in the preset characters corresponding to the currently traversed target spliced question, arrange each expression probability vector by row, and generate the expression probability matrix corresponding to the target spliced question, until all spliced questions are traversed, multiply the second similarity probability of each similar question with the corresponding expression probability matrix, and obtain the result matrix corresponding to each similar question, add the expression probability vectors corresponding to the corresponding rows in each result matrix to obtain the joint probability vector of the corresponding row, combine each joint probability vector to obtain a joint probability vector matrix, determine the maximum joint probability in the joint probability vector of each row of the joint probability matrix and the target characters corresponding to each maximum joint probability, combine each target character to obtain the expression of the target question. By calculating the cosine similarity between the target question and the candidate questions in the corpus for initial screening, N similar questions are obtained. Then, the similarity probability between the N similar questions and the target question is calculated through vector inner product, and K similar questions that are more similar to the target question are further obtained. The K similar questions are spliced with the target question to calculate the expression probability matrix, and then the K similar probabilities are respectively combined with the K expression probability matrix to calculate the joint probability matrix. The maximum joint probability and the target characters corresponding to each maximum joint probability are determined in each row of the joint probability vector of the joint probability matrix. The target characters are combined to obtain the expression corresponding to the target question. Similar questions are screened out through two calculations, and the final expression of the target problem is calculated based on the screened similar questions, which improves the accuracy of solving the target problem.
[0190] The present application also provides a computer storage medium that can store multiple instructions, which are suitable for being loaded and executed by a processor as described above. Figures 2 to 4 The problem-solving method of the embodiment shown in the figure can be found in the specific execution process. Figures 2 to 4The detailed description of the illustrated embodiment will not be repeated here.
[0191] See Figure 10 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 10 As shown, the terminal device 1000 may include: at least one processor 1001, at least one network interface 1002, at least one input / output interface 1003, at least one display unit 1004, at least one memory 1005, and at least one communication bus 1006. The processor 1001 may include one or more processing cores. The processor 1001 uses various interfaces and lines to connect the various parts of the entire electronic device 1000, and executes various functions and processes data of the terminal 1000 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1005, and calling data stored in the memory 1005. The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. The network interface 1002 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface or a Bluetooth interface). The communication bus 1006 is used to realize the connection and communication between these components. The display unit 1004 may be a touch panel. As Figure 10 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, an input and output interface module, and a problem-solving program.
[0192] exist Figure 10 In the electronic device 1000 shown, the input and output interface 1003 is mainly used to provide an interface for users and access devices and obtain data input by users and access devices.
[0193] In one embodiment, the processor 1001 may be configured to call a problem-solving program stored in the memory 1005 and specifically perform the following operations:
[0194] Obtain a target topic, obtain at least one similar topic corresponding to the target topic, and a similarity probability between each similar topic and the target topic;
[0195] Each of the similar questions is spliced with the target question to obtain a spliced question, and an expression probability matrix corresponding to each of the spliced questions is calculated, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character;
[0196] Calculating a joint probability matrix based on each of the similarity probabilities and each of the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters;
[0197] An expression of the target question is determined based on the joint probability matrix.
[0198] In one embodiment, when the processor 1001 executes the steps of obtaining a target topic, obtaining at least one similar topic corresponding to the target topic, and the similarity probability between each similar topic and the target topic, the processor 1001 specifically performs the following operations:
[0199] Vectorizing at least one candidate question in the question bank to obtain a candidate question vector corresponding to each candidate question, and vectorizing the target question to obtain a target question vector corresponding to the target question;
[0200] Calculating the cosine similarity between each candidate question vector and the target question vector respectively, and obtaining the first similarity probability corresponding to each candidate question and the target question respectively;
[0201] Based on each of the first similarity probabilities, N similar topics are determined from the topics to be selected, and first similarity probabilities between the N similar topics and the target topic, where N is a positive integer and greater than or equal to 1.
[0202] In one embodiment, when the processor 1001 determines N similar topics from the candidate topics based on the first similarity probabilities and the first similarity probabilities between the N similar topics and the target topic, where N is a positive integer and greater than or equal to 1, the processor 1001 specifically performs the following operations:
[0203] determining N similar topics and the N similar topics from the topics to be selected based on each of the first similarity probabilities;
[0204] Obtaining first feature vectors corresponding to the N similar topics respectively through a text feature extractor, and obtaining a second feature vector of the target topic;
[0205] Performing inner product of each of the first eigenvectors with the second eigenvector, and normalizing the results of the inner product, to obtain second similarity probabilities between the N similar questions and the target question;
[0206] Based on each of the second similarity probabilities, K similar questions and the second similarity probabilities between the K similar questions and the target question are determined among the N similar questions, where K is a positive integer and K is greater than or equal to 1, N is a positive integer and N is greater than or equal to 1, and K is less than or equal to N.
[0207] In one embodiment, when the processor 1001 executes the steps of splicing each of the similar questions with the target question to obtain spliced questions and calculating the expression probability matrix corresponding to each of the spliced questions, the processor 1001 specifically performs the following operations:
[0208] respectively concatenating the similar questions with the target question to obtain a concatenated question;
[0209] Traversing each of the splicing questions in sequence, and obtaining an expression probability vector of each character in the preset characters corresponding to the currently traversed target splicing question;
[0210] Arrange the expression probability vectors in rows to generate an expression probability matrix corresponding to the target splicing question;
[0211] Until the traversal ends.
[0212] In one embodiment, when the processor 1001 calculates the joint probability matrix based on the similarity probabilities and the expression probability matrices, the processor 1001 specifically performs the following operations:
[0213] Multiplying the similarity probability of each similar question by the corresponding expression probability matrix to obtain a result matrix corresponding to each similar question;
[0214] Adding the expression probability vectors corresponding to the corresponding rows in each of the result matrices to obtain a joint probability vector for the corresponding rows;
[0215] The joint probability vectors are combined to obtain a joint probability matrix.
[0216] In one embodiment, when executing the expression for determining the target topic based on the joint probability matrix, the processor 1001 specifically performs the following operations:
[0217] Determine the maximum joint probability in each row of the joint probability vector of the joint probability matrix and the target character corresponding to each maximum joint probability;
[0218] The target characters are combined to obtain an expression of the target question.
[0219] In an embodiment of the present application, at least one candidate topic in a corpus is vectorized to obtain a candidate topic vector corresponding to each candidate topic, and the target topic is vectorized to obtain a target topic vector corresponding to the target topic, and the cosine similarity of each candidate topic vector and the target topic vector is calculated respectively to obtain a first similarity probability corresponding to each candidate topic and the target topic, and N similar topics are determined in the candidate topics based on each first similarity probability, and the first feature vectors corresponding to the N similar topics are obtained by a text feature extractor, and the second feature vector corresponding to the target topic is obtained, and the vector inner product of each first feature vector and the second feature vector are performed respectively, and the result after the vector inner product is normalized to obtain the second similarity probability of the N similar topics and the target topic, and K similar topics are determined in the N similar topics based on each second similarity probability and the probability of the K similar topics and the target topic. The second similarity probability of the title purpose, respectively splice each similar question with the target question to obtain the spliced question, traverse each spliced question in turn, obtain the expression probability vector of each character in the preset characters corresponding to the currently traversed target spliced question, arrange each expression probability vector by row, and generate the expression probability matrix corresponding to the target spliced question, until all spliced questions are traversed, multiply the second similarity probability of each similar question with the corresponding expression probability matrix, and obtain the result matrix corresponding to each similar question, add the expression probability vectors corresponding to the corresponding rows in each result matrix to obtain the joint probability vector of the corresponding row, combine each joint probability vector to obtain a joint probability vector matrix, determine the maximum joint probability in the joint probability vector of each row of the joint probability matrix and the target characters corresponding to each maximum joint probability, combine each target character to obtain the expression of the target question. By calculating the cosine similarity between the target question and the candidate questions in the corpus for initial screening, N similar questions are obtained. Then, the similarity probability between the N similar questions and the target question is calculated through vector inner product, and K similar questions that are more similar to the target question are further obtained. The K similar questions are spliced with the target question to calculate the expression probability matrix, and then the K similar probabilities are respectively combined with the K expression probability matrix to calculate the joint probability matrix. The maximum joint probability and the target characters corresponding to each maximum joint probability are determined in each row of the joint probability vector of the joint probability matrix. The target characters are combined to obtain the expression corresponding to the target question. Similar questions are screened out through two calculations, and the final expression of the target problem is calculated based on the screened similar questions, which improves the accuracy of solving the target problem.
[0220] Those skilled in the art will clearly understand that the technical solution of this application can be implemented with the help of software and / or hardware. "Unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array (FPGA) or an integrated circuit (IC).
[0221] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0222] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0223] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interface, and the indirect coupling or communication connection of the device or unit can be electrical or other forms.
[0224] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0225] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0226] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory and includes a number of instructions for enabling an electronic device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk, and other media that can store program code.
[0227] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructing related hardware through a program. The program may be stored in a computer-readable memory, which may include a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0228] The above is only an exemplary embodiment of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure herein, those skilled in the art will easily think of other embodiments of the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not recorded in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A problem-solving method, characterized in that: The method comprises: Obtain a target topic, obtain at least one similar topic corresponding to the target topic, and a similarity probability between each similar topic and the target topic; Each of the similar questions is spliced with the target question to obtain a spliced question, and an expression probability matrix corresponding to each of the spliced questions is calculated, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character; A joint probability matrix is calculated based on each of the similarity probabilities and each of the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters; the calculation of the joint probability matrix based on each of the similarity probabilities and each of the expression probability matrices includes: multiplying the similarity probabilities of each of the similar questions by the corresponding expression probability matrix to obtain a result matrix corresponding to each of the similar questions; adding the expression probability vectors corresponding to corresponding rows in each of the result matrices to obtain a joint probability vector for the corresponding row; and combining the joint probability vectors to obtain a joint probability matrix; An expression of the target question is determined based on the joint probability matrix.
2. The method according to claim 1, characterized in that The obtaining of at least one similar topic corresponding to the target topic and a similarity probability between each similar topic and the target topic includes: Vectorizing at least one candidate topic in the corpus to obtain a candidate topic vector corresponding to each candidate topic, and vectorizing the target topic to obtain a target topic vector corresponding to the target topic; Calculating the cosine similarity between each candidate question vector and the target question vector respectively, and obtaining the first similarity probability corresponding to each candidate question and the target question respectively; Based on each of the first similarity probabilities, N similar topics are determined from the topics to be selected, where N is a positive integer and greater than or equal to 1.
3. The method according to claim 2, characterized in that The determining N similar topics from the to-be-selected topics based on the first similarity probabilities, where N is a positive integer and greater than or equal to 1, includes: Obtaining first feature vectors corresponding to the N similar topics respectively through a text feature extractor, and obtaining a second feature vector of the target topic; Performing inner product of each of the first eigenvectors with the second eigenvector, and normalizing the results of the inner product, to obtain second similarity probabilities between the N similar questions and the target question; Based on each of the second similarity probabilities, K similar questions and the second similarity probabilities between the K similar questions and the target question are determined among the N similar questions, where K is a positive integer and K is greater than or equal to 1, N is a positive integer and N is greater than or equal to 1, and K is less than or equal to N.
4. The method according to claim 1, wherein The step of respectively splicing each of the similar questions with the target question to obtain a spliced question, and calculating an expression probability matrix corresponding to each of the spliced questions, includes: respectively concatenating the similar questions with the target question to obtain a concatenated question; Traversing each of the splicing questions in sequence, and obtaining an expression probability vector of each character in the preset characters corresponding to the currently traversed target splicing question; Arrange the expression probability vectors in rows to generate an expression probability matrix corresponding to the target splicing question; Until the traversal ends.
5. The method according to claim 1, characterized in that The expression for determining the target question based on the joint probability matrix includes: Determine the maximum joint probability in each row of the joint probability vector of the joint probability matrix and the target character corresponding to each maximum joint probability; The target characters are combined to obtain an expression of the target question.
6. A problem-solving device, characterized in that: The device comprises: An information acquisition module is used to acquire a target topic, acquire at least one similar topic corresponding to the target topic, and a similarity probability between each similar topic and the target topic; A first calculation module is used to respectively splice each of the similar questions with the target question to obtain a spliced question, and calculate an expression probability matrix corresponding to each of the spliced questions, wherein each row in the expression probability matrix is an expression probability vector corresponding to each preset character; A second calculation module is configured to calculate a joint probability matrix based on each of the similarity probabilities and each of the expression probability matrices, wherein each row in the joint probability matrix is a joint probability vector corresponding to each of the preset characters; the second calculation module comprises: a data multiplication unit configured to multiply the similarity probabilities of each of the similar questions by the corresponding expression probability matrix to obtain a result matrix corresponding to each of the similar questions; a data summation unit configured to add the expression probability vectors corresponding to corresponding rows in each of the result matrices to obtain a joint probability vector for the corresponding row; and a joint data determination unit configured to combine the joint probability vectors to obtain a joint probability matrix; An expression determination module is used to determine the expression of the target question based on the joint probability matrix.
7. The device according to claim 6, characterized in that The information acquisition module includes: A vectorization unit, configured to vectorize at least one candidate topic in the corpus to obtain a candidate topic vector corresponding to each candidate topic, and vectorize the target topic to obtain a target topic vector corresponding to the target topic; A data calculation unit is used to calculate the cosine similarity between each of the candidate question vectors and the target question vector, and obtain a first similarity probability corresponding to each of the candidate question and the target question; An information determination unit is used to determine N similar questions in the candidate questions and the first similarity probabilities between the N similar questions and the target question based on the first similarity probabilities, where N is a positive integer and greater than or equal to 1.
8. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, which are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 5.
9. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps according to any one of claims 1 to 5.
Citation Information
Patent Citations
Mathematical problem answering method and device
CN110414683A
Automatic parallel test paper generating method and system based on machine learning
CN113656536A