An answer extraction method in an intelligent question-answering system
By using heterogeneous information networks and factorization machine technology, the problem of insufficient question-and-answer corpora in the chemical industry has been solved, enabling the automatic extraction and fusion of high-quality answers and improving the reliability and accuracy of the answers.
Patent Information
- Application Number
- CN202011271342.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-08-24
- Filing Date
- 2020-11-13
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2040-11-13
AI Technical Summary
The chemical industry suffers from a lack of question-and-answer corpora, and the cost and time required for manual construction are high. The answers in question-and-answer communities are unreliable and highly redundant, making it difficult to extract high-quality answers from them.
A heterogeneous information network is used to construct user representations. Combining factorization machine and text feature extraction techniques, a community network is constructed through two meta-paths to select high-quality answers, filter redundant clauses, and sort and merge the answers.
The accuracy of answer quality prediction and extraction has been improved. The constructed prediction model performs far better than other methods on the Chemical Industry Forum dataset and can better reflect user relationships and text characteristics.
Smart Images

Figure CN112328768B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text extraction technology, and more specifically, to a method for extracting answers in an intelligent question-answering system. Background Technology
[0002] Intelligent question-answering systems allow users to freely input questions in natural language. The system automatically analyzes the user's question and returns a precise and concise answer. Compared to traditional answer acquisition methods, intelligent question-answering systems offer users a more convenient knowledge acquisition service and will be a major mode of human-computer interaction in the future development of intelligent systems. Whether a retrieval-based or generative intelligent question-answering system, a question-answering corpus is an indispensable part of the system, providing the data foundation for the entire system. Practice has proven that the quality of the question-answering corpus directly affects the performance of the question-answering system.
[0003] A petrochemical safety engineering research institute urgently needs to build an intelligent question-and-answer system for the chemical industry due to business expansion. However, a question-and-answer corpus for the chemical industry is scarce, and manual construction would require a significant investment of manpower and resources, with a long development cycle. Therefore, utilizing question-and-answer information from chemical industry question-and-answer communities, researching answer extraction techniques, and automatically constructing high-quality question-and-answer corpora has become the main research direction.
[0004] Answer extraction technology is a crucial component of question-and-answer systems. In Q&A communities, questions and answers are user-generated. Due to a lack of control measures, coupled with the limitations of users' knowledge and their own subjectivity, answers in Q&A communities suffer from low reliability and high redundancy. In Q&A communities, the best answer is usually determined by user submissions or likes. However, a single answer in a Q&A community typically only covers a portion of the complete answer and cannot fully satisfy the user's needs, resulting in many incomplete and one-sided answers. Therefore, how to extract relevant clauses from answers and synthesize high-quality, user-satisfying answers is a key problem to be solved. Summary of the Invention
[0005] This invention provides a way to extract high-quality, professional answers from question-and-answer communities. It offers a more reasonable and accurate data acquisition method, a more scientific and comprehensive answer integration method, and considers all possibilities in an intelligent question-and-answer system.
[0006] The technical solution of the present invention is as follows:
[0007] A method for extracting answers in an intelligent question-answering system, the specific processing steps of which are as follows:
[0008] 101) Steps for establishing user representation data: Define a heterogeneous information network G = (V, E), which contains a set of objects V and a set of connections E, and a meta-path p generated based on this heterogeneous network: The walking path P of the distributed generation metapath is generated according to the following formula:
[0009]
[0010] Where, n t It is the t-th node in the walking path, and v is of type A. t , It has A t+1 The first-order neighborhood set of a node v of type v;
[0011] The metapath sequence includes user nodes and problem nodes. Problem nodes are removed from the metapath sequence. A length threshold is set for the traversal path. The traversal path will repeatedly follow the metapath pattern until the predefined length threshold is reached, thus completing the establishment of user representation data.
[0012] 102) Data processing steps: Extract text features from the question-and-answer data and predict the quality of the answers; the quality prediction of the answers uses a factorization machine, which combines features in pairs to link the relationships between features and constructs cross-term features to judge the matching value of the question-and-answer data and improve the effect of the data processing model.
[0013] Define the training model data D = (X, y) for predicting the quality of the answers, where X ∈ R. n×r This indicates that the current dataset D has n instances, each instance consisting of a sparse vector of dimension r, y∈R. n Then it represents the real labels corresponding to n instances, (X i ,y i ) represents the i-th instance X i The corresponding label is y i ;
[0014] Factorization machines can decompose and model the interactions between different features of an input dataset D = (X, y). Their d-th order interaction model is expressed as follows:
[0015]
[0016] Where the model parameter w0 represents the global bias, w j This indicates the weight corresponding to feature j. Let represent the latent factor vector corresponding to feature j when it interacts with other features of order i, and k represent the dimension of the latent factor vector obtained by decomposition.
[0017] The loss function of the factorization machine is defined as follows:
[0018]
[0019] Where σ represents the step function sigmoid:
[0020]
[0021] Therefore, the gradient of the loss function with respect to the values of the corresponding weights is:
[0022]
[0023] 103) Answer extraction steps: Sort the question-and-answer data matching value obtained in step 102) to obtain a candidate answer set, and sort the candidate answer set according to the matching value. Merge the three with the highest matching value to obtain the answer with higher question-and-answer data matching value, and push it to the questioner as the final answer. Among them, the answer fusion first divides the answer into sentences to form multiple clauses, obtains the text vector of the clause from the clause, and selects the positive clauses in the text vector for fusion.
[0024] Furthermore, the meta-path pattern in step 101) includes the following:
[0025] Metapath 1:
[0026] Metapath 2:
[0027] For each user node u in a heterogeneous information network, the walking path constructs a co-occurrence neighborhood N of all user sequences based on walking paths that reach a length threshold. u The user representation is optimized using the following formula:
[0028] max∑ u∈V logPr(N u |f(u)) Formula (2)
[0029] Where, f:V→R d It is a function that maps each node onto a d-dimensional feature space, N u ∈V represents the neighbors of a user node in a given user sequence.
[0030] Furthermore, text feature extraction includes static text feature extraction and user static feature extraction; static text feature extraction includes the number of Chinese characters, average sentence length, word proportion, and domain word proportion, the relevant definitions of which are as follows:
[0031] The number of Chinese characters refers to the number of Chinese characters in an answer. This feature reflects the user's most intuitive feeling about the answer.
[0032] The average sentence length is the average length of the Chinese text in the clauses used to calculate the answer.
[0033] The word count ratio is the ratio of the number of words to the length of the Chinese text. The number of words is determined by Jieba word segmentation based on an expert-built dictionary for the chemical industry. The number of words after removing stop words from the stop word list is recorded as the number of words.
[0034] The domain term ratio is the ratio of the number of domain terms to the length of the Chinese text, where the number of domain terms is the number of chemical engineering domain terms appearing in the answer text;
[0035] User static feature extraction includes personal information and usage data of users recorded in the forum, specifically including user ID, email status, space access volume, number of friends, number of replies, posting reward status, video verification, gender, number of albums, etc.
[0036] Furthermore, text feature extraction also includes text vector generation, which generates text vectors based on weighted word vectors. This process includes three steps: word segmentation, word vector representation, and text vector representation, as detailed below:
[0037] 201) Word segmentation steps: By using the Jieba Chinese word segmentation tool and combining it with experts from the Safety Engineering Research Institute to build a dictionary for the chemical industry, the accuracy of the Jieba Chinese word segmentation tool can be improved;
[0038] 202) Word vector representation steps: For the set of sentences Q in the question or answer, after segmenting each sentence into words, the word2vector algorithm is used to learn how to map each word c in the description into an N1-dimensional feature vector ω. c :
[0039]
[0040] Where, ω c Indicates that the sentence Q i The N1-dimensional vector generated by any word c in the text;
[0041] 203) Text vector representation steps: The importance of words appearing in the question-answer pair is measured using the following method, calculated using the following formula:
[0042] K(c,Q i ) = TF(c, Q i )·IDF(c) Formula (8)
[0043] Wherein, TF(c,Q) i ) is the word c in Q i The number of times it appears in s represents the total number of documents, and s(c) represents the total number of documents containing the word c;
[0044] Calculate the value of each word c in the Q&A text to obtain the weight K(c,Q of the word c in the question and answer text i ), and finally use the following formula to obtain the text vector of each question and the text vector of each answer:
[0045]
[0046] Among them, sen_vec represents the text vector, m represents the number of words in the text, ω c represents the word vector of each word, and K(c,Q i ) represents the weight of each word.
[0047] Furthermore, in the process of fusing answers in step 103), it includes filtering redundant clauses and sentence sorting;
[0048] Cosine similarity is used to measure the semantic similarity between two clauses when filtering redundant clauses. The specific cosine similarity measurement formula is as follows:
[0049]
[0050] Among them, x i and y i are the values of the two clause vectors in the i-th dimension respectively, and a and b represent the two clause vectors; the closer the cosine value is to 1, the closer the included angle is to 0 degrees, that is, the more similar the two vectors are, and when the included angle is equal to 0, the two vectors are equal;
[0051] Thus, the cosine similarity between any two answer clauses is obtained to construct a clause similarity matrix, and the matrix form is as follows:
[0052]
[0053] Among them, n is the number of clauses, and a ij represents the cosine similarity between clause i and clause j. Since the cosine similarity between two identical clauses is 1, and the similarity between clause i and clause j is the same as the similarity between clause j and clause i, this matrix is a symmetric matrix with a diagonal value of 1;
[0054] The specific code judgment process for finding redundant clauses is as follows:
[0055] (1.1) Set the similarity threshold to k, initialize the similarity matrix, and mark each row in the matrix as true;
[0056] (1.2) For i = 1; i < n; i++; perform a traversal loop;
[0057] (1.3) If the i-th row of the similarity matrix is true, proceed to the next step; if it is false, jump to step 1.2;
[0058] (1.4) Put the clauses corresponding to the columns where all values in the i-th row of the similarity matrix are > k into the list List i ;
[0059] (1.5) Search for the matching value of the candidate answer corresponding to each clause in List i ;
[0060] (1.6) Append the clause from the answer with the highest matching value to the result list. If the matching values are the same, choose any one of them;
[0061] (1.7) Set the rows of the similarity matrix corresponding to the remaining clauses in List i to false and jump to step 1.2; otherwise, output the result of result;
[0062] Sentence sorting includes encoding, fitness, and fusion derivation;
[0063] Encoding will filter all candidate answer clauses of a question by redundant clauses, sort them in descending order of their matching values in the answers and the order of each clause in the original answers, and then perform decimal encoding; each clause has a relative positional relationship in its corresponding answer, thus defining the order relationship between candidate clauses as a sentence sorting template; construct an order relationship probability matrix through the probability values of the front-back relationships between any two answer clauses, and the matrix form is as follows:
[0064]
[0065] Among them, n is the number of clauses, a i,j represents the range of the front-back relationship probability value between clause i and clause j, which is [0, 1]; since the same sentence will not appear twice in the answer, for the diagonal a i,i , the text sets it to a value -1 that does not belong to the normal probability value range; for two sentences m and k that were originally in the same answer, when m < k, a m,k = 1, when m > k, a m,k = 0; thus correctly marking the word order of m and k in the original sentence;
[0066] Fitness: In the sequence composed of n clauses, the sum of the front-back relationship probability values of adjacent two clauses is calculated to obtain the fitness. The specific fitness formula is as follows: <00002i,j It is the value of the i-th row and j-th column in the sentence sequence probability matrix;
[0069] Fusion derivation, randomly generate the sorting sequence of n sentences; then sort the clause sequences in the population from largest to smallest fitness, set the selection probability of the clause sequence to be proportional to its fitness, and randomly select x to retain from all clause sequences according to the sorting sequence;
[0070] Then randomly select two clause sequences, and then randomly select a segment of clause sequence for exchange; if the crossover causes a conflict in the clause sequence, keep the exchanged clause segment unchanged, obtain the position of the conflicting clause in the exchange segment, and replace the conflicting clause outside the exchange segment with the clause at the corresponding position of another clause sequence;
[0071] Set the mutation rate, according to this setting for the selected mutated clause sequence, randomly take three integers, satisfying 1 < u < v < w < n, where n is the clause length; insert the clause segment between u and v (including u and v) behind w;
[0072] The specific logic code process is as follows:
[0073] (2.1) Generate a sentence sorting template, generate a sentence sequence probability matrix;
[0074] (2.2) Set the population size q = n * (n - 1), and initialize the population;
[0075] (2.3) Delete the clause sequences that conflict with the sentence sorting template;
[0076] (2.4) If the current population size p = q, jump to step 2.6;
[0077] (2.5) Randomly generate q - p clause sequences, add them to the population, and jump to step 2.3;
[0078] (2.6) Calculate the fitness of each clause sequence in the population and sort them in order;
[0079] (2.7) Perform a fusion derivation operation on the population;
[0080] (2.8) Delete the clause sequences that conflict with the sentence sorting template; [[ID=,38]]
[0081] (2.9) If the population size p = 0, then jump to step 2.2;
[0082] (2.10) If the absolute difference between the fitness values of the optimal clause sequences in the previous and current rounds < 0.001 or the number of loops > 1000, then output the best clause sequence in this round and end the sorting; or enter the next step;
[0083] (2.11) Keep the optimal min(p,q) clause sequence and jump to step 2.4 to continue.
[0084] The advantages of this invention compared to the prior art are:
[0085] The overlapping module degree of communities discovered by this invention through the construction of a community network using two meta-paths is significantly higher than that discovered through the construction of a homogeneous network using a single meta-path. Therefore, the heterogeneous information network constructed using the two meta-paths as filtering conditions can better reflect the real relationships between users. The prediction model constructed in this paper significantly outperforms other prediction methods in predicting answer quality and answer clauses on the Haichuan Chemical Forum dataset, and takes into account the characteristics of the text more effectively. Attached Figure Description
[0086] Figure 1 A user representation diagram for a heterogeneous information network;
[0087] Figure 2 A user representation diagram for a homogeneous information network;
[0088] Figure 3 This is a flowchart illustrating the answer quality prediction and matching value of the present invention.
[0089] Figure 4 This is a flowchart of the answer extraction process of this invention. Detailed Implementation
[0090] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. Parts not described or not explained in detail in the text can be implemented by conventional technical means.
[0091] like Figures 1 to 4 As shown, a method for extracting answers in an intelligent question-answering system includes the following specific processing steps:
[0092] 101) Steps for establishing user-represented data: Define a heterogeneous information network G = (V, E), containing an object set V and a connection set E. Also define a type mapping function f: V → A and a connection mapping function g: E → R. A and R represent predefined object and connection sets, respectively, and |V| + |R| > 2. Also define a meta-path p generated based on this heterogeneous network: It represents a range from A1 to A. t+1 The complex relationship between them is R = R1oR2o...oR l A t+1 This represents the type of the (t+1)th node, R. l Indicates node type A t With node type A t+1The relationship between them, where 'o' is the composition operator in the relation. Specifically, the meta-path P is generated based on the distribution according to the following formula:
[0093]
[0094] Where P represents the walking path, which is the corresponding probability, indicating the probability that the t-th node is v and the (t+1)-th node is x. p represents the meta-path, and n t This is the t-th node in the traversal path, where t represents the order, v represents the current node, and x represents the next node. It has A t+1 A set of first-order neighborhoods of a node v of type A. t+1 Indicates the type of the (t+1)th node. This indicates that the neighbors of node v belong to type A. t+1 What are the nodes? Here is the number of nodes. φ(x)A t+1 The type is A t+1 The node set is non-empty.
[0095] The metapath sequence includes user nodes and problem nodes. Problem nodes are removed from the metapath sequence. A length threshold is set for the traversal path. The traversal path will repeatedly follow the metapath pattern until the predefined length threshold is reached, thus completing the establishment of user representation data.
[0096] Specifically, using the Haichuan Chemical Forum as the data foundation, given its large user base and rich data types of user characteristics, a heterogeneous information network is employed to establish user representation data. Vector representations of users in the question-and-answer community not only avoid extensive feature engineering but also effectively fuse different types of user features. Assume the following question-and-answer relationships exist between users in the question-and-answer community, as shown in Table 1:
[0097] Table 1. Question and Answer Relationships Among Community Users
[0098] Tab.2-1Relationship table of Q&A among community users
[0099] Questioner ID Problem ID List of answering user IDs User 1 Question a {User 2, User 4, User 5, User 7} User 1 Question b {User 2, User 3, User 4, User 6, User 7} User 2 Question c {User 3, User 6, User 8, User 9} User 3 Question d {User 8, User 9, User 10, User 11}
[0100] Representation learning is performed on users; therefore, in traditional homogeneous networks, the node type is user, and the edges represent question-and-answer relationships between users, thus constructing homogeneous information networks such as... Figure 2As shown, the edges between users represent question-and-answer relationships, but they cannot indicate which users have answered the same question. Therefore, homogeneous information networks cannot fully represent the information in Table 1. Heterogeneous information networks can capture multiple types of objects and add the concept of meta-paths, thus better simulating the real world. In the diagram, the two types of nodes are named user i and question / answer j, respectively. Question-and-answer relationships are represented by solid edges, and answer-and-answer relationships are represented by dashed edges. A user can ask or answer multiple questions. The relationship between the questioning user and the question is one-to-one, while the relationship between the answering user and the question is many-to-many.
[0101] The patterns of metapaths include the following:
[0102] Metapath 1:
[0103] Metapath 2:
[0104] Meta-path 1 illustrates the interaction between users and questions in a manner where the user to the left of the question is the questioner, and the user to the right is the answerer. That is, a user asks a question, and that question is answered by other users. The user to the right of the question then becomes the questioner again, thus continuing the sequence.
[0105] Metapath 2 illustrates the interaction between users and questions in a manner where the user to the left of a question is a respondent, and the user to the right is also a respondent; that is, users on both sides of a question have answered it simultaneously. The user to the right of the question then becomes a respondent for another question, thus continuing the sequence.
[0106] by Figure 1 Taking a heterogeneous information network as an example, based on the designed meta-path 1, the following n sequences can be obtained:
[0107] Sequence 1: User 1 - Question b - User 2 - Question c - User 3 - Question d - User 8;
[0108] Sequence 2: User 2 - Question c - User 1 - Question b - User 3 - Question d - User 10;
[0109] …………
[0110] Sequence n: User 1 - Question a - User 2 - Question c - User 3 - Question d - User 11;
[0111] by Figure 1 Taking a heterogeneous information network as an example, based on the designed meta-path 2, the following m sequences can be obtained:
[0112] Sequence n+1: User 4 - Question b - User 6 - Question c - User 8 - Question d - User 10;
[0113] Sequence n+2: User 5 - Problem a - User 7 - Problem b - User 6 - Problem c - User 9;
[0114] …………
[0115] Sequence n+m: User 3 - Question c - User 9 - Question d - User 8 - Question c - User 6;
[0116] The meta-path sequence obtained above includes nodes for both users and questions. However, this scheme only focuses on the vector representation of users, therefore, question type nodes need to be removed from the meta-path sequence. Figure 1 Taking a heterogeneous information network as an example, after type constraints and filtering, the n+m sequences collected by meta-path 1 and meta-path 2 designed in this scheme can be used to obtain the following n+m homogeneous node sequences:
[0117] Sequence 1: User 1 - User 2 - User 3 - User 8;
[0118] Sequence 2: User 2 - User 1 - User 3 - User 10;
[0119] …………
[0120] Sequence n: User 1 - User 2 - User 3 - User 11;
[0121] Sequence n+1: User 4 - User 6 - User 8 - User 10;
[0122] Sequence n+2: User 5 - User 7 - User 6 - User 9;
[0123] …………
[0124] Sequence n+m: User 3 - User 9 - User 8 - User 6;
[0125] Analyzing the above n+m node sequences, it's easy to see that the sequence collected by meta-path 2 rarely appears... Figure 2 In the constructed homogeneous network, this demonstrates that the heterogeneous information network constructed by this scheme has a stronger data heterogeneity modeling capability than the homogeneous network or even the original heterogeneous information network.
[0126] For each user node u in a heterogeneous information network, the walking path constructs a co-occurrence neighborhood N of all user sequences based on walking paths that reach a length threshold. u The target is optimized for the user representation using the following formula:
[0127] max∑ u∈V logPr(N u |f(u)) Formula (2)
[0128] Where, f:V→Rd It is a function that maps each node onto a d-dimensional feature space, N u ∈V represents the neighbors of a user node in a given user sequence.
[0129] By using overlap module degree as the evaluation metric, the same community question-and-answer data was compared across three networks built with different user representation data, and the results are shown in Table 2:
[0130] Table 2-4 Comparative Experiment Results on Real Datasets
[0131]
[0132] The higher the degree of overlap, the better the social segmentation effect. By comparing the experimental results in Table 2, it is easy to find that the degree of overlap of communities found on the community network constructed using two meta-paths is significantly higher than that found on the community network constructed using a single meta-path, i.e., a homogeneous network. The heterogeneous information network constructed by using two meta-paths as the screening condition in this scheme can better reflect the real relationships between users.
[0133] 102) Data processing steps: Extract text features from the question-and-answer data and predict the quality of the answers. Answer quality prediction uses a factorization machine, which combines features pairwise to link the relationships between features, constructing cross-term features to determine the matching value of the question-and-answer data and improve the effectiveness of the data processing model. The specific process is as follows: Figure 3 As shown:
[0134] Text feature extraction includes static text feature extraction, user static feature extraction, and text vector generation. Static text feature extraction includes the number of Chinese characters, average sentence length, word proportion, and domain word proportion, the relevant definitions of which are as follows:
[0135] The number of Chinese characters refers to the number of Chinese characters in an answer. This feature reflects the user's most intuitive feeling about the answer.
[0136] The average sentence length is the average length of the Chinese text in the clauses used to calculate the answer.
[0137] The word count ratio is the ratio of the number of words to the length of the Chinese text. The number of words is determined by Jieba word segmentation based on an expert-built dictionary for the chemical industry. The number of words after removing stop words from the stop word list is recorded as the number of words.
[0138] The domain term ratio is the ratio of the number of domain terms to the length of the Chinese text, where the number of domain terms is the number of chemical engineering domain terms appearing in the answer text;
[0139] User static feature extraction includes personal information and usage data of users recorded in the forum, specifically including user ID, email status, space access volume, number of friends, number of replies, posting reward status, video verification, gender, number of albums, etc.
[0140] Text vector generation, which generates text vectors based on weighted word vectors, includes three steps: word segmentation, word vector representation, and text vector representation, as detailed below:
[0141] 201) Word segmentation steps: By using the Jieba Chinese word segmentation tool and combining it with experts from the Safety Engineering Research Institute to build a dictionary for the chemical industry, the accuracy of the Jieba Chinese word segmentation tool can be improved.
[0142] 202) Word vector representation steps: For the set of sentences Q in the question or answer, after segmenting each sentence into words, the word2vector algorithm is used to learn how to map each word c in the description into an N1-dimensional feature vector ω. c :
[0143]
[0144] Where, ω c Indicates that the sentence Q i The N1-dimensional vector generated by any word c in the vector, where v represents an element in the word vector.
[0145] 203) Text vector representation steps: The importance of words appearing in the question-answer pair is measured using the following method, calculated using the following formula:
[0146] K(c,Q i ) = TF(c, Q i )·IDF(c) Formula (8)
[0147] Wherein, TF(c,Q) i ) is the word c in Q i The number of times it appears in s represents the total number of documents, and s(c) represents the total number of documents containing the word c;
[0148] Calculate the value of each word c in the question and answer text to obtain the weight K(c,Q) of word c in the question and answer texts. i Finally, the text vector for each question and the text vector for each answer are obtained using the following formula:
[0149]
[0150] Where sen_vec represents the text vector, m represents the number of words in the text, and ω c K(c,Q) represents the word vector for each word. i) represents the weight of each word.
[0151] Extracting answers from a small set of high-quality candidate answers is more accurate than extracting answers from the entire set of answers for a single question. In typical Q&A communities, over one-third of the answers lack wealth information as a matching value. To better extract answers to these questions, it's necessary to build a training model that predicts answer quality. This model would predict wealth as a matching value for answers to questions without wealth information, thus predicting answer quality and selecting high-quality answers to provide a candidate set for subsequent answer extraction.
[0152] Define the training model data D = (X, y) for predicting the quality of the answers, where X ∈ R. n×r This indicates that the current dataset D has n instances, each instance consisting of a sparse vector of dimension r, y∈R. n Then it represents the real labels corresponding to n instances, (X i ,y i ) represents the i-th instance X i The corresponding label is y i A vector R has n rows and r columns, where n rows represent n instances and r columns represent r dimensions.
[0153] Factorization machines can decompose and model the interactions between different features of an input dataset D = (X, y). Their d-th order interaction model is expressed as follows:
[0154]
[0155] Where the model parameter w0 represents the global bias, w j This indicates the weight corresponding to feature j. Let represent the latent factor vector corresponding to feature j when it interacts with other features of order i, and k represent the dimension of the latent factor vector obtained by decomposition.
[0156] The loss function of the factorization machine represents the loss between the predicted value and the true value, and is defined as follows:
[0157]
[0158] Where m represents the number of instances, the formula means that each instance corresponds to a predicted value and a true value, the loss of the two is calculated separately and then summed;
[0159] σ represents the step function sigmoid, as follows:
[0160]
[0161] Therefore, the gradient of the loss function with respect to the corresponding weights after substituting the step function sigmoid is:
[0162]
[0163] To verify the effectiveness of the answer quality prediction model constructed in this paper, Wide&Deep, BERT+LSTM, and BERT+CNN models were trained. The prediction performance of different models on the test set is shown in Table 3.
[0164] Table 3 Comparison of accuracy, MSE, and EVS among different algorithms
[0165]
[0166] Topn accuracy: The prediction results are sorted in descending order. The ratio of the number of correctly predicted samples (m) to the number of correctly predicted samples (n) among the top n samples is denoted as Topn accuracy. Selecting the top 3 answers is for obtaining a candidate set for answer extraction, while selecting the top 1 answer prepares for answer extraction in subsequent steps. This scheme assumes that answers with high scores and those with good scores contain higher quality sentences. Therefore, this scheme selects sentences from the top 1 answer as the benchmark for calculating similarity in answer extraction.
[0167] MSE: The index is calculated as the mean of the sum of squares of the errors between the fitted data and the corresponding sample points of the original data. The smaller the value, the better the fit.
[0168] EVS: The variance score used to explain the regression model. Its value ranges from [0,1]. The closer it is to 1, the better the independent variable can explain the variance variation of the dependent variable. The smaller the value, the worse the effect.
[0169] As shown in Table 3, the prediction model constructed in this paper performs significantly better than the other three prediction algorithms in predicting answer quality on the Haichuan Chemical Forum dataset.
[0170] 103) Answer Extraction Steps: The question-and-answer data obtained in step 102) is sorted by matching value to obtain a candidate answer set. This candidate answer set is then further sorted according to matching value. The three answers with the highest matching value are merged to obtain the answer with the highest question-and-answer data matching value, which is then pushed to the questioner as the final answer. The answer fusion process first involves segmenting the answer into clauses, obtaining the text vector of each clause, and selecting the positive clauses from the text vectors for fusion. This scheme does not only select the top 1 answer because of the incompleteness of knowledge in a single answer. The top 3 answers are chosen instead of more for two reasons: First, experts in the chemical industry randomly selected 500 questions from the Haichuan Chemical Forum and constructed the best answers through manual answer extraction. By comparing the best answers with the top 10 answers with the highest wealth value, it was found that the answers to most questions could be found in the top 3. Second, the more candidate answers are introduced, the more clauses the answer extraction algorithm processes, increasing the algorithm's running time and leading to a larger cumulative error.
[0171] The specific processing procedure is as follows: Figure 4 As shown, the process of merging answers includes filtering redundant clauses and sorting sentences. The candidate answer set has been explained in the previous steps.
[0172] To filter redundant clauses, cosine similarity is used to measure the semantic similarity between two clauses. The specific formula for cosine similarity is as follows:
[0173]
[0174] Where, x i and y i These are the values of the two clause vectors in the i-th dimension, where a and b represent the two clause vectors; the closer the cosine value is to 1, the closer the angle is to 0 degrees, meaning the two vectors are more similar, and when the angle is equal to 0, the two vectors are equal.
[0175] This allows us to construct a clause similarity matrix using the cosine similarity between any two answer clauses. The matrix has the following form:
[0176]
[0177] Where n is the number of clauses, a ij This represents the cosine similarity between clause i and clause j. Since the cosine similarity between two identical clauses is 1, the similarity between clause i and clause j is the same as the similarity between clause j and clause i. Therefore, this matrix is a symmetric matrix with diagonal values of 1.
[0178] The specific code judgment process for finding redundant clauses is as follows:
[0179] (1.1) Set the similarity threshold to k, initialize the similarity matrix, and mark each row in the matrix as true;
[0180] (1.2) For i = 1; i < n; i++; perform a traversal loop;
[0181] (1.3) If the i-th row of the similarity matrix is true, continue to the next step; if it is false, jump to step 1.2;
[0182] (1.4) Put the clauses corresponding to the columns with all values > k in the i-th row of the similarity matrix into the list List i ;
[0183] (1.5) Search for the matching value of the candidate answer corresponding to each clause in List i ;
[0184] (1.6) Append the clause from the answer with the highest matching value to the result list. If the matching values are the same, choose any one of them;
[0185] (1.7) Set the rows of the similarity matrix corresponding to the remaining clauses in List i to false, and jump to step 1.2; otherwise, output the result of result.
[0186] There is a parameter k in the code for finding redundant clauses, and the value of k will directly affect the calculation result of non-redundant clauses. Regarding the setting of the k value, the following processing flow is adopted:
[0187] (1) Experts from a certain safety engineering research institute annotate the semantically repeated clauses in 500 questions;
[0188] (2) Construct pairs of semantically repeated clauses;
[0189] (3) Calculate the cosine similarity of pairs of semantically repeated clauses
[0190] (4) Obtain that the mean of the cosine similarity is 0.8922 and the standard deviation is 0.092.
[0191] (5) Take k as the mean - standard deviation, that is, 0.8.
[0192] Sentence sorting includes encoding, fitness, and fusion derivation.
[0193] Encoding will filter all candidate answer clauses of a problem with redundant clauses, sort them in descending order of their answer matching values and the order of each clause in the original answer, and then perform decimal encoding; each clause has a relative positional relationship in the answer where it is located, and thus the sequential relationship between candidate clauses is defined as a sentence sorting template; a sequential relationship probability matrix is constructed through the probability values of the front-back relationship between any two answer clauses, and the matrix form is as follows:
[0194]
[0195] Among them, n is the number of clauses, a i,j represents the range of the probability value of the front-back relationship between clause i and clause j is [0, 1]; since the same sentence will not appear twice in the answer, for the diagonal a i,i , the text sets it to a value -1 that does not belong to the normal probability value range; for two sentences m and k that were originally in the same answer, when m < k, a m,k = 1, when m > k, a m,k = 0; thus correctly marking the word order of m and k in the original sentence;
[0196] Fitness, in the sequence composed of n clauses, the sum of the probability values of the front-back relationship between adjacent two clauses is obtained as the fitness, and the specific fitness formula is as follows:
[0197]
[0198] Among them, a i,j is the value of the i-th row and j-th column in the sentence front-back relationship probability matrix;
[0199] Fusion and derivation, randomly generate a sorting sequence of n sentences; then sort the clause sequences in the population from largest to smallest in terms of fitness, set the selection probability of the clause sequence to be proportional to its fitness, and randomly select x to retain from all clause sequences according to the sorting sequence;
[0200] Then randomly select two clause sequences, and randomly select a segment of the clause sequence for exchange; if the exchange causes a conflict in the clause sequence, keep the exchanged clause segment unchanged, obtain the position of the conflicting clause in the exchange segment, and replace the conflicting clause outside the exchange segment with the clause at the corresponding position in the other clause sequence;
[0201] Set the mutation rate, and according to this setting, for the selected mutated clause sequence, randomly take three integers that satisfy 1 < u < v < w < n, where n is the clause length; insert the clause segment between u and v (including u and v) behind w;
[0202] The specific logic code process is as follows:
[0203] (2.1) Generate a sentence sorting template and generate a probability matrix of sentence order;
[0204] (2.2) Set the population size q = n*(n-1) and initialize the population;
[0205] (2.3) Delete clause sequences that conflict with the sentence sorting template;
[0206] (2.4) If the current population size p = q, jump to step 2.6;
[0207] (2.5) Randomly generate qp clause sequences, add them to the population, and jump to step 2.3;
[0208] (2.6) Calculate the fitness of each clause sequence in the population and arrange them in order of priority;
[0209] (2.7) Perform fusion and derivation operations on the population;
[0210] (2.8) Delete clause sequences that conflict with the sentence sorting template;
[0211] (2.9) If the population size p = 0, then proceed to step 2.2;
[0212] (2.10) If the absolute difference in fitness values between the two rounds of optimal clause sequences is <0.001 or the number of iterations is >1000, then output the optimal clause sequence for this round and end the sorting; or proceed to the next step.
[0213] (2.11) Keep the optimal min(p,q) clause sequence and jump to step 2.4 to continue.
[0214] To verify the effectiveness of the answer extraction model constructed in this scheme, the Wide&Deep model was trained. The prediction performance of different models on the test set is shown in Table 4:
[0215] Table 4-4 Comparison of accuracy, MSE, and EVS among different algorithms
[0216]
[0217] As shown in Table 4, the prediction model constructed in this paper performs far better than the Wide&Deep prediction algorithm on the Haichuan Chemical Forum dataset in predicting answer clauses.
[0218] In summary, the overlap module degree of communities discovered by this scheme using two meta-paths to construct the community network is significantly higher than that discovered using a single meta-path, i.e., a homogeneous network. Therefore, the heterogeneous information network constructed using two meta-paths as filtering conditions can better reflect the real relationships between users. The constructed prediction model, on the Haichuan Chemical Forum dataset, significantly outperforms other prediction methods in terms of answer quality prediction and answer clause prediction, and takes into account the characteristics of the text more effectively.
[0219] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several improvements and modifications without departing from the concept of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for extracting answers in an intelligent question-answering system, characterized in that, The specific processing steps are as follows: 101) Steps for establishing user representation data: Establish a heterogeneous information network It comprises a set of objects V and a set of connections E, based on a heterogeneous information network. Generated metapath p : The traversal path P of the meta-path is generated according to the following formula: ; Where P represents the walking path, which is the corresponding probability, indicating the probability that the t-th node is v and the (t+1)-th node is x, and p represents the meta-path. It is the t-th node in the traversal path, where t represents the order. v Let x represent the current node and x represent the next node. It has The first-order neighborhood set of a node v of type v; Indicate the type of the (t+1)th node; The type is The node set is non-empty; The metapath sequence includes user nodes and problem nodes. Problem nodes are removed from the metapath sequence. A length threshold is set for the traversal path. The traversal path will repeatedly follow the metapath pattern until the predefined length threshold is reached, thus completing the establishment of user representation data. 102) Data processing steps: Extract text features from the question-and-answer data and predict the quality of the answers; the quality prediction of the answers uses a factorization machine, which combines features in pairs to link the relationships between features and constructs cross-term features to judge the matching value of the question-and-answer data and improve the effect of the data processing model. Training model data for setting the quality of predicted answers ,in, This indicates that the current dataset D has n instances, and each instance consists of a sparse vector of dimension r. This represents the actual labels corresponding to n instances. Represents the i-th instance The corresponding tag is ; Factorization machines can process input datasets. The interactions between different features are decomposed and modeled, and the d-order interaction model is expressed by the following formula: ; Among them, model parameters Indicates global bias. This indicates the weight corresponding to feature j. Let represent the latent factor vector corresponding to feature j when it interacts with other features of order i, and k represent the dimension of the latent factor vector obtained by decomposition. The loss function of the factorization machine is defined as follows: ; Where m represents the number of instances, and the formula indicates that each instance corresponds to a predicted value. and a true value Calculate the losses of the two separately and then sum them up. σ represents the step function sigmoid: ; Therefore, the gradient of the loss function with respect to the corresponding weights after substituting the step function sigmoid is: ; 103) Answer extraction steps: Sort the question-and-answer data matching value obtained in step 102) to obtain a candidate answer set, and sort the candidate answer set according to the matching value. Merge the three with the highest matching value to obtain the answer with higher question-and-answer data matching value, and push it to the questioner as the final answer. Among them, the answer fusion first divides the answer into sentences to form multiple clauses, obtains the text vector of the clause from the clause, and selects the positive clauses in the text vector for fusion.
2. The answer extraction method in an intelligent question-answering system according to claim 1, characterized in that: The metapath patterns in step 101) include the following: Metapath 1: ; Metapath 2: ; The traversal path is for each user node in the heterogeneous information network. u Construct co-occurrence neighborhoods in all user sequences based on walk paths that reach a length threshold. .
3. The answer extraction method in an intelligent question-answering system according to claim 1, characterized in that: Text feature extraction includes static text feature extraction and user static feature extraction. Static text feature extraction includes the number of Chinese characters, average sentence length, word proportion, and domain word proportion, the relevant definitions of which are as follows: The number of Chinese characters refers to the number of Chinese characters in an answer. This feature reflects the user's most intuitive feeling about the answer. The average sentence length is the average length of the Chinese text in the clauses used to calculate the answer. ; The word count ratio is the ratio of the number of words to the length of the Chinese text. The number of words is calculated by performing Jieba word segmentation based on an expert-built dictionary for the chemical industry, and then removing stop words from the stop word list. The domain term ratio is the ratio of the number of domain terms to the length of the Chinese text, where the number of domain terms is the number of chemical engineering domain terms appearing in the answer text; User static feature extraction includes personal information and usage data of users recorded in the forum, specifically including user ID, email status, space access volume, number of friends, number of replies, posting reward status, video verification, gender, number of albums, etc.
4. The answer extraction method in an intelligent question-answering system according to claim 3, characterized in that: Text feature extraction also includes text vector generation, which generates text vectors based on weighted word vectors. This process includes three steps: word segmentation, word vector representation, and text vector representation, as detailed below: 201) Word segmentation steps: By using the Jieba Chinese word segmentation tool and combining it with experts from the Safety Engineering Research Institute to build a dictionary for the chemical industry, the accuracy of the Jieba Chinese word segmentation tool can be improved; 202) Word vector representation steps: For the set of sentences Q in the question or answer, after segmenting each sentence into words, the word2vector algorithm is used to learn how to map each word c in the description to a word vector. 3D eigenvector representation : ; in, Indicates the sentence Q i Any word c in the generated A dimensional vector; 203) Text vector representation steps: The importance of words appearing in the question-answer pair is measured using the following method, calculated using the following formula: ; in, The word 'c' is in The number of times it appears in s represents the total number of documents, and s(c) represents the total number of documents containing the word c; Calculate the value of each word c in the question and answer text to obtain the weight of word c in the question and answer texts. Finally, the text vector for each question and the text vector for each answer are obtained using the following formulas: ; Where sen_vec represents the text vector, and m represents the number of words in the text. This represents the word vector for each word. This represents the weight of each word.
Citation Information
Patent Citations
Answer determination method and device for intelligent questions and answers
CN110309283A
Answer Ranking In Community Question-Answering Sites
US20100191686A1