Intelligent question answering method, device, equipment and storage medium
By extracting the feature vectors of the sentences to be asked and the candidate question statements, calculating the matching degree and determining the target question statements, the shortcomings in real-time and accuracy of the existing intelligent question-and-answer methods are solved, and more efficient intelligent question-and-answer processing is achieved.
Patent Information
- Application Number
- CN202110389804.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-12
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-04-12
AI Technical Summary
The existing intelligent question-and-answer methods have insufficient processing efficiency and accuracy, especially in question-and-answer processing at the accident site, with low real-time and accuracy.
An intelligent question-and-answer method is proposed. By extracting the sentences to be asked from the question-and-answer request, and obtaining candidate question statements based on the corpus, using the preset vector table for statement matrix construction and feature extraction, calculating the matching degree of the feature vector and normalizing it, determining the target question statement and obtaining the corresponding answers.
It improves the real-time and accuracy of the intelligent question-and-answer method, reduces the need for multi-layer model structure processing, and improves the efficiency of determining reply statements.
Smart Images

Figure CN113064972B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an intelligent question-answering method, device, equipment and storage medium. Background Art
[0002] At present, after an accident, many car owners may have questions such as how to protect the accident scene and how to define the accident responsibility, and then consult the traffic accident handling center. With the rapid development of artificial intelligence, intelligent question-answering methods based on Transformer-DSSM have also emerged. However, in the existing intelligent question-answering methods, the structure of the Transformer-DSSM algorithm is relatively complex, resulting in low processing efficiency of the current intelligent question-answering methods. At the same time, the accuracy of the current intelligent question-answering methods is low.
[0003] Therefore, how to improve the real-time and accuracy of intelligent question-answering methods has become an urgent problem to be solved. Summary of the invention
[0004] In view of the above, it is necessary to provide an intelligent question-answering method, device, equipment and storage medium that can improve the real-time and accuracy of the intelligent question-answering method.
[0005] In one aspect, the present invention provides an intelligent question-answering method, the intelligent question-answering method comprising:
[0006] When a question-and-answer request is received, a sentence to be asked is extracted from the question-and-answer request, and candidate question sentences are obtained from a preset corpus according to the question-and-answer request;
[0007] Acquire a first sentence matrix of the sentence to be asked based on a preset vector table, and acquire a second sentence matrix of the candidate question sentence based on the preset vector table;
[0008] Performing feature extraction on the first sentence matrix to obtain a first feature vector, and performing feature extraction on the second sentence matrix to obtain a second feature vector;
[0009] Calculating a matching degree between the first feature vector and the second feature vector;
[0010] Normalizing the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence;
[0011] Determine the candidate question sentence with the greatest similarity probability as the target question sentence;
[0012] An answer corresponding to the target question sentence is obtained as a reply sentence to the sentence to be asked.
[0013] According to an optional embodiment of the present invention, obtaining a candidate question sentence from a preset corpus according to the question and answer request includes:
[0014] Acquire a field corresponding to the sentence to be asked from the question and answer request;
[0015] Acquire a target list from the preset corpus according to the domain;
[0016] All sentences in the target list are determined as the candidate question sentences.
[0017] According to an optional embodiment of the present invention, obtaining the first sentence matrix of the sentence to be asked based on a preset vector table includes:
[0018] Performing word segmentation processing on the sentence to be asked to obtain sentence segmentation;
[0019] Determine the word segmentation position of the sentence participle in the sentence to be asked according to the sentence to be asked;
[0020] Obtaining a word segmentation vector of the sentence segmentation from the preset vector table;
[0021] The word segmentation vectors are merged according to the word segmentation positions to obtain the first sentence matrix.
[0022] According to an optional embodiment of the present invention, extracting features from the first sentence matrix to obtain a first feature vector includes:
[0023] Using a first feature encoder to encode the first sentence matrix to obtain a first encoding matrix, and using a second feature encoder to encode the first sentence matrix to obtain a second encoding matrix;
[0024] Concatenating the first encoding matrix and the second encoding matrix to obtain a concatenated matrix;
[0025] Using a preset fully connected layer to perform feature integration on the concatenated matrix to obtain an integrated matrix;
[0026] The average value in each dimension of the integrated matrix is calculated to obtain the first eigenvector.
[0027] According to an optional embodiment of the present invention, the encoding process of the first sentence matrix using the first feature encoder to obtain the first encoding matrix includes:
[0028] Acquire information corresponding to the first sentence matrix from the character vector table as a character matrix, and acquire information corresponding to the first sentence matrix from the position vector table as a position matrix;
[0029] Calculating the sum of the character matrix and the position matrix to obtain a mapping matrix;
[0030] Processing the mapping matrix using a multi-head attention mechanism to obtain an attention matrix;
[0031] Calculating the sum of the mapping matrix and the attention matrix to obtain a feature matrix;
[0032] Normalizing the characteristic matrix to obtain a normalized matrix;
[0033] Using the preset fully connected layer to perform feature integration on the normalized matrix to obtain a target matrix;
[0034] Calculating the sum of the normalized matrix and the target matrix, and performing normalization processing on the calculated matrix to obtain a calculation matrix;
[0035] The calculation matrix is mapped according to a preset feature vector table to obtain the first encoding matrix.
[0036] According to an optional embodiment of the present invention, calculating the matching degree between the first feature vector and the second feature vector includes:
[0037] Calculating the values of the first eigenvector and the second eigenvector using a cosine distance formula to obtain a first similarity;
[0038] Calculating the variance of the first eigenvector according to the value of each dimension in the first eigenvector to obtain a first variance, and calculating the variance of the second eigenvector according to the value of each dimension in the second eigenvector to obtain a second variance;
[0039] Calculating the sum of the first variance and the second variance to obtain a total variance;
[0040] Calculating the difference between the first eigenvector and the second eigenvector to obtain a difference vector, and calculating the variance of the difference vector according to the value of each dimension in the difference vector to obtain a third variance;
[0041] Dividing the third variance by the total variance to obtain a second similarity;
[0042] A weighted sum operation is performed on the first similarity and the second similarity according to a preset weight coefficient to obtain the matching degree.
[0043] According to an optional embodiment of the present invention, after obtaining an answer corresponding to the target question sentence as a reply sentence to the sentence to be asked, the method further includes:
[0044] Obtaining a request number for the question and answer request;
[0045] Generate prompt information according to the request number and the reply statement;
[0046] Encrypt the prompt information using a symmetric encryption algorithm to obtain a ciphertext;
[0047] Acquire a triggering user of the question and answer request from the question and answer request;
[0048] The ciphertext is sent to the terminal device of the triggering user.
[0049] On the other hand, the present invention further provides an intelligent question-answering device, the intelligent question-answering device comprising:
[0050] an acquisition unit, configured to extract a sentence to be asked from a question-and-answer request when a question-and-answer request is received, and to acquire a candidate question sentence from a preset corpus according to the question-and-answer request;
[0051] The acquisition unit is further used to acquire a first sentence matrix of the sentence to be asked based on a preset vector table, and to acquire a second sentence matrix of the candidate question sentence based on the preset vector table;
[0052] An extraction unit, configured to perform feature extraction on the first sentence matrix to obtain a first feature vector, and perform feature extraction on the second sentence matrix to obtain a second feature vector;
[0053] A calculation unit, used to calculate the matching degree between the first feature vector and the second feature vector;
[0054] A processing unit, configured to normalize the matching degree to obtain a similarity probability between the sentence to be asked and the candidate question sentence;
[0055] A determination unit, configured to determine the candidate question sentence with the highest similarity probability as a target question sentence;
[0056] The acquisition unit is further used to acquire an answer corresponding to the target question sentence as a reply sentence to the sentence to be asked.
[0057] On the other hand, the present invention further provides an electronic device, comprising:
[0058] a memory storing computer readable instructions; and
[0059] A processor executes computer-readable instructions stored in the memory to implement the intelligent question-answering method.
[0060] On the other hand, the present invention also proposes a computer-readable storage medium, in which computer-readable instructions are stored. The computer-readable instructions are executed by a processor in an electronic device to implement the intelligent question-answering method.
[0061] It can be seen from the above technical solutions that the present invention improves the semantic representation ability of the first feature vector and the second feature vector by extracting features from the first sentence matrix and the second sentence matrix, and effectively improves the accuracy of the matching degree by calculating the similarity between the first feature vector and the second feature vector in a variety of ways, thereby doubly improving the accuracy of the reply sentence. In addition, the present invention does not need to process the question sentence and the candidate question sentence through a multi-layer model structure, thereby improving the efficiency of determining the reply sentence and thus improving the real-time performance of intelligent question and answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 It is a flow chart of a preferred embodiment of the intelligent question-answering method of the present invention.
[0063] Figure 2 It is a functional module diagram of a preferred embodiment of the intelligent question-answering device of the present invention.
[0064] Figure 3 It is a schematic diagram of the structure of an electronic device of a preferred embodiment of the present invention for implementing the intelligent question-answering method. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0066] like Figure 1 FIG. 1 is a flow chart of a preferred embodiment of the intelligent question-answering method of the present invention. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.
[0067] The intelligent question-answering method is applied to smart traffic scenarios, thereby promoting the construction of smart cities. The intelligent question-answering method is applied to one or more electronic devices, which are devices that can automatically perform numerical calculations and / or information processing according to pre-set or stored computer-readable instructions, and whose hardware includes but is not limited to microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0068] The electronic device may be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0069] The electronic device may include a network device and / or a user device. The network device includes, but is not limited to, a single network electronic device, an electronic device group consisting of multiple network electronic devices, or a cloud consisting of a large number of hosts or network electronic devices based on cloud computing.
[0070] The network where the electronic device is located includes, but is not limited to: the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.
[0071] S10, when a question-and-answer request is received, extracting a sentence to be asked from the question-and-answer request, and acquiring candidate question sentences from a preset corpus according to the question-and-answer request.
[0072] In at least one embodiment of the present invention, the question and answer request may be triggered by a staff member of a traffic accident handling center, or by a staff member of a medical center. The present invention does not limit the person who triggers the question and answer request.
[0073] The information carried in the question and answer request includes, but is not limited to: field, statement number, etc.
[0074] The sentence to be asked a question refers to a sentence that needs to be queried for a question.
[0075] The preset corpus stores pre-set question sentences corresponding to multiple fields.
[0076] The candidate question sentences refer to all pre-set question sentences stored in the preset corpus.
[0077] In at least one embodiment of the present invention, the electronic device extracting the sentence to be asked from the question and answer request includes:
[0078] Parsing the message of the question and answer request to obtain data information carried in the message;
[0079] Acquire information indicating the problem from the data information as a statement number;
[0080] A statement corresponding to the statement number is obtained from the to-be-processed library as the to-be-questioned statement.
[0081] The data information includes, but is not limited to: the statement number, etc.
[0082] The sentence number is used to indicate the question sentence.
[0083] The to-be-processed library stores a plurality of unprocessed question statements and the numbers of the question statements.
[0084] By parsing the message, the efficiency of obtaining the data information can be improved, and the sentence to be asked can be accurately obtained from the library to be processed through the mapping relationship between the sentence number and the sentence.
[0085] In at least one embodiment of the present invention, the electronic device acquiring a candidate question sentence from a preset corpus according to the question-answer request includes:
[0086] Acquire a field corresponding to the sentence to be asked from the question and answer request;
[0087] Acquire a target list from the preset corpus according to the domain;
[0088] All sentences in the target list are determined as the candidate question sentences.
[0089] The field may be a traffic accident question-and-answer field, or a medical question-and-answer field. The present invention does not limit the specific form of the field.
[0090] The target list stores a plurality of question sentences corresponding to the field.
[0091] The field can be accurately determined through the question and answer request, and then the target list can be accurately obtained from the preset corpus according to the field, thereby accurately obtaining the candidate question sentences.
[0092] S11, obtaining a first sentence matrix of the sentence to be asked based on a preset vector table, and obtaining a second sentence matrix of the candidate question sentence based on the preset vector table.
[0093] In at least one embodiment of the present invention, the preset vector table stores representation vectors of multiple characters.
[0094] The first sentence matrix is composed of a representation vector of each character in the sentence to be asked, and the number of row vectors in the first sentence matrix is the same as the number of characters in the sentence to be asked.
[0095] The second sentence matrix is composed of a representation vector of each character in the candidate question sentence, and the number of row vectors in the second sentence matrix is the same as the number of characters in the candidate question sentence.
[0096] In at least one embodiment of the present invention, the electronic device acquiring the first sentence matrix of the sentence to be asked based on the preset vector table includes:
[0097] Performing word segmentation processing on the sentence to be asked to obtain sentence segmentation;
[0098] Determine the word segmentation position of the sentence participle in the sentence to be asked according to the sentence to be asked;
[0099] Obtaining a word segmentation vector of the sentence segmentation from the preset vector table;
[0100] The word segmentation vectors are merged according to the word segmentation positions to obtain the first sentence matrix.
[0101] The sentence segmentation refers to the vocabulary in the sentence to be asked.
[0102] The word segmentation position refers to the arrangement position of the sentence participle in the sentence to be asked.
[0103] The word segmentation positions can be used to ensure that the first sentence matrix generated has the position information of the sentence segmentation, thereby improving the generation accuracy of the first sentence matrix.
[0104] Specifically, the electronic device performs word segmentation processing on the sentence to be asked, and the sentence segmentation obtained includes:
[0105] Segment the sentence to be asked according to a preset dictionary to obtain multiple segmentation paths of the sentence to be asked and segmentation words of each segmentation path;
[0106] Calculating the segmentation probability of each segmentation path according to the segmentation weights in the preset dictionary;
[0107] The segmentation word corresponding to the segmentation path with the largest segmentation probability is determined as the sentence segmentation word.
[0108] The preset dictionary includes a plurality of words and a word segmentation weight of each word.
[0109] Through the above implementation, the sentence segmentation can be quickly generated according to needs.
[0110] Specifically, the electronic device calculates the segmentation probability of each segmentation path according to the word segmentation weight in the preset dictionary, including:
[0111] Obtaining the segmentation weight of the segmentation word in each segmentation path in the preset dictionary;
[0112] The sum of the word segmentation weights obtained in each segmentation path is calculated to obtain the segmentation probability.
[0113] In at least one embodiment of the present invention, the manner in which the electronic device obtains the second sentence matrix of the candidate question sentence based on the preset vector table is the same as the manner in which the electronic device obtains the first sentence matrix of the sentence to be asked based on the preset vector table, and the present invention will not go into details therein.
[0114] S12, performing feature extraction on the first sentence matrix to obtain a first feature vector, and performing feature extraction on the second sentence matrix to obtain a second feature vector.
[0115] In at least one embodiment of the present invention, the first feature vector is used to indicate the semantics of the sentence to be asked, and the second feature vector is used to indicate the semantics of the candidate question sentence.
[0116] In at least one embodiment of the present invention, the electronic device extracts features from the first sentence matrix to obtain a first feature vector, comprising:
[0117] Using a first feature encoder to encode the first sentence matrix to obtain a first encoding matrix, and using a second feature encoder to encode the first sentence matrix to obtain a second encoding matrix;
[0118] Concatenating the first encoding matrix and the second encoding matrix to obtain a concatenated matrix;
[0119] Using a preset fully connected layer to perform feature integration on the concatenated matrix to obtain an integrated matrix;
[0120] The average value in each dimension of the integrated matrix is calculated to obtain the first eigenvector.
[0121] The first encoding matrix and the second encoding matrix are obtained by encoding the first sentence matrix in different encoding methods.
[0122] The first feature encoder and the second feature encoder can improve the semantic representation capability of the splicing matrix, and the preset fully connected layer can integrate highly abstract features, thereby improving the generation accuracy of the first feature vector.
[0123] Specifically, the electronic device uses a first feature encoder to encode the first sentence matrix, and the first encoding matrix obtained includes:
[0124] Acquire information corresponding to the first sentence matrix from the character vector table as a character matrix, and acquire information corresponding to the first sentence matrix from the position vector table as a position matrix;
[0125] Calculating the sum of the character matrix and the position matrix to obtain a mapping matrix;
[0126] Processing the mapping matrix using a multi-head attention mechanism to obtain an attention matrix;
[0127] Calculating the sum of the mapping matrix and the attention matrix to obtain a feature matrix;
[0128] Normalizing the characteristic matrix to obtain a normalized matrix;
[0129] Using the preset fully connected layer to perform feature integration on the normalized matrix to obtain a target matrix;
[0130] Calculating the sum of the normalized matrix and the target matrix, and performing normalization processing on the calculated matrix to obtain a calculation matrix;
[0131] The calculation matrix is mapped according to a preset feature vector table to obtain the first encoding matrix.
[0132] The character vector table stores vectors representing multiple characters.
[0133] The position vector table stores vectors representing multiple positions.
[0134] The mapping matrix can be accurately generated through the character vector table and the position vector table. The mapping matrix is processed by a multi-head attention mechanism to improve the semantic representation ability of the attention matrix. Through a series of operations on the attention matrix, the generation accuracy of the initial matrix can be improved.
[0135] Specifically, the electronic device calculates the sum of the character matrix and the position matrix to obtain a mapping matrix including:
[0136] For any element in the character matrix, determining the element in the position matrix corresponding to the any element as the corresponding element;
[0137] Calculate the sum of any one element and the corresponding element to obtain the sum of elements corresponding to any one element;
[0138] The mapping matrix is obtained by concatenating the sum of the elements according to the position of any one of the elements in the character matrix.
[0139] Through the above implementation, the mapping matrix can be accurately determined.
[0140] Furthermore, the manner in which the electronic device processes the mapping matrix using a multi-head attention mechanism belongs to the prior art and will not be elaborated in the present invention.
[0141] Furthermore, the electronic device calculates the sum of the mapping matrix and the attention matrix in the same manner as the electronic device calculates the sum of the character matrix and the position matrix, which is not elaborated in the present invention.
[0142] Furthermore, the electronic device normalizes the feature matrix to obtain a normalized matrix including:
[0143] Adjusting any characteristic element in the characteristic matrix to a preset range, obtaining a target element corresponding to the any characteristic element, and determining a ratio of adjusting the any characteristic element to the target element as an adjustment ratio;
[0144] Adjusting other characteristic elements in the characteristic matrix except the any one characteristic element according to the adjustment ratio to obtain adjustment elements corresponding to the other characteristic elements;
[0145] The target element and the adjustment element are concatenated to obtain the normalized matrix.
[0146] The preset range is usually set to [0, 1].
[0147] Through the adjustment ratio, all elements in the feature matrix can be adjusted according to the same ratio, so as to accurately generate the normalized matrix.
[0148] Specifically, the electronic device uses a second feature encoder to encode the first sentence matrix, and the second encoding matrix obtained includes:
[0149] Performing convolution processing on the character matrix using a preset convolution layer to obtain a convolution matrix;
[0150] The convolution matrix is mapped according to the preset feature vector table to obtain the second encoding matrix.
[0151] The preset convolutional layers include: a first convolutional layer with three convolutional kernels of 5*5, a second convolutional layer with two convolutional kernels of 3*3, and a third convolutional layer with one convolutional kernel of 1*1.
[0152] In at least one embodiment of the present invention, the electronic device performs feature extraction on the second sentence matrix in the same manner as the electronic device performs feature extraction on the first sentence matrix, and the present invention will not elaborate on this.
[0153] S13: Calculate the matching degree between the first feature vector and the second feature vector.
[0154] In at least one embodiment of the present invention, the matching degree refers to the matching status of the first feature vector and the second feature vector.
[0155] In at least one embodiment of the present invention, the electronic device calculating the matching degree between the first feature vector and the second feature vector includes:
[0156] Calculating the values of the first eigenvector and the second eigenvector using a cosine distance formula to obtain a first similarity;
[0157] Calculating the variance of the first eigenvector according to the value of each dimension in the first eigenvector to obtain a first variance, and calculating the variance of the second eigenvector according to the value of each dimension in the second eigenvector to obtain a second variance;
[0158] Calculating the sum of the first variance and the second variance to obtain a total variance;
[0159] Calculating the difference between the first eigenvector and the second eigenvector to obtain a difference vector, and calculating the variance of the difference vector according to the value of each dimension in the difference vector to obtain a third variance;
[0160] Dividing the third variance by the total variance to obtain a second similarity;
[0161] A weighted sum operation is performed on the first similarity and the second similarity according to a preset weight coefficient to obtain the matching degree.
[0162] The preset weight coefficient is set according to the importance of the first similarity and the second similarity in the matching degree, and the present invention does not limit the method for determining the preset weight coefficient.
[0163] The accuracy of the matching degree can be effectively improved through the first similarity and the second similarity.
[0164] Specifically, the electronic device calculates the variance of the first feature vector according to the value of each dimension in the first feature vector to obtain a first variance. The specific formula is as follows:
[0165]
[0166] Among them, s1 is the first variance, x1, x2, ... xN are the values of each dimension in the first feature vector, N is the total number of dimensions in the first feature vector, and M is the average value of all dimensions in the first feature vector.
[0167] Furthermore, the manner in which the electronic device calculates the variance of the second eigenvector based on the values of each dimension in the second eigenvector is the same as the manner in which the electronic device calculates the variance of the first eigenvector based on the values of each dimension in the first eigenvector, and the present invention will not repeat it.
[0168] Further, the electronic device calculates a difference between the first eigenvector and the second eigenvector, and obtaining the difference vector includes:
[0169] Obtain any vector element in the first feature vector, and determine the element dimension of the any vector element in the first feature vector;
[0170] Determine the value corresponding to the dimension of the element in the second feature vector as the element of the corresponding dimension;
[0171] The difference between any of the vector elements and the corresponding dimension elements is calculated, and the difference is concatenated to obtain the difference vector.
[0172] Furthermore, the electronic device performs a weighted sum operation on the first similarity and the second similarity according to a preset weight coefficient to obtain the matching degree, including:
[0173] Acquire a coefficient corresponding to the first similarity from the preset weight coefficients as a first coefficient, and acquire a coefficient corresponding to the second similarity from the preset weight coefficients as a second coefficient;
[0174] Calculating the product of the first similarity and the first coefficient to obtain a first value, and calculating the product of the second similarity and the second coefficient to obtain a second value;
[0175] The sum of the first value and the second value is calculated to obtain the matching degree.
[0176] S14, normalizing the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence.
[0177] In at least one embodiment of the present invention, the similarity probability refers to the similarity between the sentence to be asked and the candidate question sentences. The sum of the similarity probabilities between the sentence to be asked and all the candidate question sentences is 1.
[0178] In at least one embodiment of the present invention, the electronic device normalizes the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence, including:
[0179] The matching degree is processed into a normal distribution to obtain the similarity probability.
[0180] The sum of the probabilities of the similarity probabilities is 1.
[0181] By normalizing the matching degree, the target question sentence can be quickly determined according to the matching degree.
[0182] S15, determining the candidate question sentence with the highest similarity probability as the target question sentence.
[0183] In at least one embodiment of the present invention, the target question sentence refers to the candidate question sentence with the highest probability of being similar to the sentence to be asked among all the candidate question sentences.
[0184] S16, obtaining an answer corresponding to the target question sentence as a reply sentence to the sentence to be asked.
[0185] It should be emphasized that in order to further ensure the privacy and security of the above reply statement, the above reply statement can also be stored in a node of a blockchain.
[0186] In at least one embodiment of the present invention, the electronic device obtaining an answer corresponding to the target question sentence as a reply sentence to the sentence to be asked includes:
[0187] Obtaining a target number for the target question sentence;
[0188] Writing the target number and the field into a preset query template to obtain a query statement;
[0189] The query statement is run to obtain the reply statement.
[0190] The preset query template may be a structured query statement.
[0191] The query statement can be quickly generated through the preset query template. Since the query statement includes the target number and the field, the reply statement can be accurately obtained.
[0192] In at least one embodiment of the present invention, after obtaining the answer corresponding to the target question sentence as a reply sentence to the sentence to be asked, the method further includes:
[0193] Obtaining a request number for the question and answer request;
[0194] Generate prompt information according to the request number and the reply statement;
[0195] Encrypt the prompt information using a symmetric encryption algorithm to obtain a ciphertext;
[0196] Acquire a triggering user of the question and answer request from the question and answer request;
[0197] The ciphertext is sent to the terminal device of the triggering user.
[0198] Prompt information is generated through the request number and the reply statement, and the generated prompt information has the request number and the reply statement, so that the triggered user can quickly learn the request corresponding to the reply statement, and the prompt information is encrypted by a symmetric encryption algorithm, which can not only quickly generate the ciphertext but also improve the security of the prompt information.
[0199] It can be seen from the above technical solutions that the present invention improves the semantic representation ability of the first feature vector and the second feature vector by extracting features from the first sentence matrix and the second sentence matrix, and effectively improves the accuracy of the matching degree by calculating the similarity between the first feature vector and the second feature vector in a variety of ways, thereby doubly improving the accuracy of the reply sentence. In addition, the present invention does not need to process the question sentence and the candidate question sentence through a multi-layer model structure, thereby improving the efficiency of determining the reply sentence and thus improving the real-time performance of intelligent question and answer.
[0200] like Figure 2 As shown, it is a functional module diagram of a preferred embodiment of the intelligent question-answering device of the present invention. The intelligent question-answering device 11 includes an acquisition unit 110, an extraction unit 111, a calculation unit 112, a processing unit 113, a determination unit 114, a generation unit 115, an encryption unit 116 and a sending unit 117. The module / unit referred to in the present invention refers to a series of computer-readable instruction segments that can be acquired by the processor 13 and can perform fixed functions, which are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0201] When a question-and-answer request is received, the acquisition unit 110 extracts the sentence to be asked from the question-and-answer request, and acquires candidate question sentences from a preset corpus according to the question-and-answer request.
[0202] In at least one embodiment of the present invention, the question and answer request may be triggered by a staff member of a traffic accident handling center, or by a staff member of a medical center. The present invention does not limit the person who triggers the question and answer request.
[0203] The information carried in the question and answer request includes, but is not limited to: field, statement number, etc.
[0204] The sentence to be asked a question refers to a sentence that needs to be queried for a question.
[0205] The preset corpus stores pre-set question sentences corresponding to multiple fields.
[0206] The candidate question sentences refer to all pre-set question sentences stored in the preset corpus.
[0207] In at least one embodiment of the present invention, the acquiring unit 110 extracts the sentence to be asked from the question and answer request, including:
[0208] Parsing the message of the question and answer request to obtain data information carried in the message;
[0209] Acquire information indicating the problem from the data information as a statement number;
[0210] A statement corresponding to the statement number is obtained from the to-be-processed library as the to-be-questioned statement.
[0211] The data information includes, but is not limited to: the statement number, etc.
[0212] The sentence number is used to indicate the question sentence.
[0213] The to-be-processed library stores a plurality of unprocessed question statements and the numbers of the question statements.
[0214] By parsing the message, the efficiency of obtaining the data information can be improved, and the sentence to be asked can be accurately obtained from the library to be processed through the mapping relationship between the sentence number and the sentence.
[0215] In at least one embodiment of the present invention, the acquiring unit 110 acquires candidate question sentences from a preset corpus according to the question-answer request, including:
[0216] Acquire a field corresponding to the sentence to be asked from the question and answer request;
[0217] Acquire a target list from the preset corpus according to the domain;
[0218] All sentences in the target list are determined as the candidate question sentences.
[0219] The field may be a traffic accident question-and-answer field, or a medical question-and-answer field. The present invention does not limit the specific form of the field.
[0220] The target list stores a plurality of question sentences corresponding to the field.
[0221] The field can be accurately determined through the question and answer request, and then the target list can be accurately obtained from the preset corpus according to the field, thereby accurately obtaining the candidate question sentences.
[0222] The acquisition unit 110 acquires a first sentence matrix of the sentence to be asked based on a preset vector table, and acquires a second sentence matrix of the candidate question sentence based on the preset vector table.
[0223] In at least one embodiment of the present invention, the preset vector table stores representation vectors of multiple characters.
[0224] The first sentence matrix is composed of a representation vector of each character in the sentence to be asked, and the number of row vectors in the first sentence matrix is the same as the number of characters in the sentence to be asked.
[0225] The second sentence matrix is composed of a representation vector of each character in the candidate question sentence, and the number of row vectors in the second sentence matrix is the same as the number of characters in the candidate question sentence.
[0226] In at least one embodiment of the present invention, the acquiring unit 110 acquires the first sentence matrix of the sentence to be asked based on the preset vector table, including:
[0227] Performing word segmentation processing on the sentence to be asked to obtain sentence segmentation;
[0228] Determine the word segmentation position of the sentence participle in the sentence to be asked according to the sentence to be asked;
[0229] Obtaining a word segmentation vector of the sentence segmentation from the preset vector table;
[0230] The word segmentation vectors are merged according to the word segmentation positions to obtain the first sentence matrix.
[0231] The sentence segmentation refers to the vocabulary in the sentence to be asked.
[0232] The word segmentation position refers to the arrangement position of the sentence participle in the sentence to be asked.
[0233] The word segmentation positions can be used to ensure that the first sentence matrix generated has the position information of the sentence segmentation, thereby improving the generation accuracy of the first sentence matrix.
[0234] Specifically, the acquisition unit 110 performs word segmentation processing on the sentence to be asked, and obtains the sentence segmentation including:
[0235] Segment the sentence to be asked according to a preset dictionary to obtain multiple segmentation paths of the sentence to be asked and segmentation words of each segmentation path;
[0236] Calculating the segmentation probability of each segmentation path according to the segmentation weights in the preset dictionary;
[0237] The segmentation word corresponding to the segmentation path with the largest segmentation probability is determined as the sentence segmentation word.
[0238] The preset dictionary includes a plurality of words and a word segmentation weight of each word.
[0239] Through the above implementation, the sentence segmentation can be quickly generated according to needs.
[0240] Specifically, the acquisition unit 110 calculates the segmentation probability of each segmentation path according to the word segmentation weight in the preset dictionary, including:
[0241] Obtaining the segmentation weight of the segmentation word in each segmentation path in the preset dictionary;
[0242] The sum of the word segmentation weights obtained in each segmentation path is calculated to obtain the segmentation probability.
[0243] In at least one embodiment of the present invention, the manner in which the acquisition unit 110 acquires the second sentence matrix of the candidate question sentence based on the preset vector table is the same as the manner in which the acquisition unit 110 acquires the first sentence matrix of the sentence to be asked based on the preset vector table, and the present invention will not elaborate on this.
[0244] The extraction unit 111 performs feature extraction on the first sentence matrix to obtain a first feature vector, and performs feature extraction on the second sentence matrix to obtain a second feature vector.
[0245] In at least one embodiment of the present invention, the first feature vector is used to indicate the semantics of the sentence to be asked, and the second feature vector is used to indicate the semantics of the candidate question sentence.
[0246] In at least one embodiment of the present invention, the extracting unit 111 performs feature extraction on the first sentence matrix to obtain a first feature vector including:
[0247] Using a first feature encoder to encode the first sentence matrix to obtain a first encoding matrix, and using a second feature encoder to encode the first sentence matrix to obtain a second encoding matrix;
[0248] Concatenating the first encoding matrix and the second encoding matrix to obtain a concatenated matrix;
[0249] Using a preset fully connected layer to perform feature integration on the concatenated matrix to obtain an integrated matrix;
[0250] The average value in each dimension of the integrated matrix is calculated to obtain the first eigenvector.
[0251] The first encoding matrix and the second encoding matrix are obtained by encoding the first sentence matrix in different encoding methods.
[0252] The first feature encoder and the second feature encoder can improve the semantic representation capability of the splicing matrix, and the preset fully connected layer can integrate highly abstract features, thereby improving the generation accuracy of the first feature vector.
[0253] Specifically, the extraction unit 111 uses a first feature encoder to encode the first sentence matrix, and the first encoding matrix obtained includes:
[0254] Acquire information corresponding to the first sentence matrix from the character vector table as a character matrix, and acquire information corresponding to the first sentence matrix from the position vector table as a position matrix;
[0255] Calculating the sum of the character matrix and the position matrix to obtain a mapping matrix;
[0256] Processing the mapping matrix using a multi-head attention mechanism to obtain an attention matrix;
[0257] Calculating the sum of the mapping matrix and the attention matrix to obtain a feature matrix;
[0258] Normalizing the characteristic matrix to obtain a normalized matrix;
[0259] Using the preset fully connected layer to perform feature integration on the normalized matrix to obtain a target matrix;
[0260] Calculating the sum of the normalized matrix and the target matrix, and performing normalization processing on the calculated matrix to obtain a calculation matrix;
[0261] The calculation matrix is mapped according to a preset feature vector table to obtain the first encoding matrix.
[0262] The character vector table stores vectors representing multiple characters.
[0263] The position vector table stores vectors representing multiple positions.
[0264] The mapping matrix can be accurately generated through the character vector table and the position vector table. The mapping matrix is processed by a multi-head attention mechanism to improve the semantic representation ability of the attention matrix. Through a series of operations on the attention matrix, the generation accuracy of the initial matrix can be improved.
[0265] Specifically, the extraction unit 111 calculates the sum of the character matrix and the position matrix to obtain a mapping matrix including:
[0266] For any element in the character matrix, determining the element in the position matrix corresponding to the any element as the corresponding element;
[0267] Calculate the sum of any one element and the corresponding element to obtain the sum of elements corresponding to any one element;
[0268] The mapping matrix is obtained by concatenating the sum of the elements according to the position of any one of the elements in the character matrix.
[0269] Through the above implementation, the mapping matrix can be accurately determined.
[0270] Furthermore, the way in which the extraction unit 111 processes the mapping matrix using a multi-head attention mechanism belongs to the prior art and will not be described in detail in the present invention.
[0271] Furthermore, the extraction unit 111 calculates the sum of the mapping matrix and the attention matrix in the same manner as the extraction unit 111 calculates the sum of the character matrix and the position matrix, which is not elaborated in the present invention.
[0272] Furthermore, the extraction unit 111 is prepared to perform normalization processing on the feature matrix, and the obtained normalized matrix includes:
[0273] Adjusting any characteristic element in the characteristic matrix to a preset range, obtaining a target element corresponding to the any characteristic element, and determining a ratio of adjusting the any characteristic element to the target element as an adjustment ratio;
[0274] Adjusting other characteristic elements in the characteristic matrix except the any one characteristic element according to the adjustment ratio to obtain adjustment elements corresponding to the other characteristic elements;
[0275] The target element and the adjustment element are concatenated to obtain the normalized matrix.
[0276] The preset range is usually set to [0, 1].
[0277] Through the adjustment ratio, all elements in the feature matrix can be adjusted according to the same ratio, so as to accurately generate the normalized matrix.
[0278] Specifically, the extraction unit 111 uses a second feature encoder to encode the first sentence matrix, and the second encoding matrix obtained includes:
[0279] Performing convolution processing on the character matrix using a preset convolution layer to obtain a convolution matrix;
[0280] The convolution matrix is mapped according to the preset feature vector table to obtain the second encoding matrix.
[0281] The preset convolutional layers include: a first convolutional layer with three convolutional kernels of 5*5, a second convolutional layer with two convolutional kernels of 3*3, and a third convolutional layer with one convolutional kernel of 1*1.
[0282] In at least one embodiment of the present invention, the extraction unit 111 performs feature extraction on the second sentence matrix in the same manner as the extraction unit 111 performs feature extraction on the first sentence matrix, which is not described in detail in the present invention.
[0283] The calculation unit 112 calculates a matching degree between the first feature vector and the second feature vector.
[0284] In at least one embodiment of the present invention, the matching degree refers to the matching status of the first feature vector and the second feature vector.
[0285] In at least one embodiment of the present invention, the calculating unit 112 calculates the matching degree between the first feature vector and the second feature vector including:
[0286] Calculating the values of the first eigenvector and the second eigenvector using a cosine distance formula to obtain a first similarity;
[0287] Calculating the variance of the first eigenvector according to the value of each dimension in the first eigenvector to obtain a first variance, and calculating the variance of the second eigenvector according to the value of each dimension in the second eigenvector to obtain a second variance;
[0288] Calculating the sum of the first variance and the second variance to obtain a total variance;
[0289] Calculating the difference between the first eigenvector and the second eigenvector to obtain a difference vector, and calculating the variance of the difference vector according to the value of each dimension in the difference vector to obtain a third variance;
[0290] Dividing the third variance by the total variance to obtain a second similarity;
[0291] A weighted sum operation is performed on the first similarity and the second similarity according to a preset weight coefficient to obtain the matching degree.
[0292] The preset weight coefficient is set according to the importance of the first similarity and the second similarity in the matching degree, and the present invention does not limit the method for determining the preset weight coefficient.
[0293] The accuracy of the matching degree can be effectively improved through the first similarity and the second similarity.
[0294] Specifically, the calculation unit 11 calculates the variance of the first feature vector according to the value of each dimension in the first feature vector to obtain a first variance. The specific formula is as follows:
[0295]
[0296] Among them, s1 is the first variance, x1, x2, ... xN are the values of each dimension in the first feature vector, N is the total number of dimensions in the first feature vector, and M is the average value of all dimensions in the first feature vector.
[0297] Furthermore, the way in which the calculation unit 11 calculates the variance of the second eigenvector according to the values of each dimension in the second eigenvector is the same as the way in which the calculation unit 11 calculates the variance of the first eigenvector according to the values of each dimension in the first eigenvector, and the present invention will not repeat it.
[0298] Further, the calculation unit 11 calculates the difference between the first eigenvector and the second eigenvector, and the difference vector obtained includes:
[0299] Obtain any vector element in the first feature vector, and determine the element dimension of the any vector element in the first feature vector;
[0300] Determine the value corresponding to the dimension of the element in the second feature vector as the element of the corresponding dimension;
[0301] The difference between any of the vector elements and the corresponding dimension elements is calculated, and the difference is concatenated to obtain the difference vector.
[0302] Furthermore, the calculation unit 11 performs a weighted sum operation on the first similarity and the second similarity according to a preset weight coefficient to obtain the matching degree, which includes:
[0303] Acquire a coefficient corresponding to the first similarity from the preset weight coefficients as a first coefficient, and acquire a coefficient corresponding to the second similarity from the preset weight coefficients as a second coefficient;
[0304] Calculating the product of the first similarity and the first coefficient to obtain a first value, and calculating the product of the second similarity and the second coefficient to obtain a second value;
[0305] The sum of the first value and the second value is calculated to obtain the matching degree.
[0306] The processing unit 113 normalizes the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence.
[0307] In at least one embodiment of the present invention, the similarity probability refers to the similarity between the sentence to be asked and the candidate question sentences. The sum of the similarity probabilities between the sentence to be asked and all the candidate question sentences is 1.
[0308] In at least one embodiment of the present invention, the processing unit 113 normalizes the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence, including:
[0309] The matching degree is processed into a normal distribution to obtain the similarity probability.
[0310] The sum of the probabilities of the similarity probabilities is 1.
[0311] By normalizing the matching degree, the target question sentence can be quickly determined according to the matching degree.
[0312] The determining unit 114 determines the candidate question sentence with the highest similarity probability as the target question sentence.
[0313] In at least one embodiment of the present invention, the target question sentence refers to the candidate question sentence with the highest probability of being similar to the sentence to be asked among all the candidate question sentences.
[0314] The acquisition unit 110 acquires an answer corresponding to the target question sentence as a reply sentence to the sentence to be asked.
[0315] It should be emphasized that in order to further ensure the privacy and security of the above reply statement, the above reply statement can also be stored in a node of a blockchain.
[0316] In at least one embodiment of the present invention, the acquiring unit 110 acquires the answer corresponding to the target question sentence as a reply sentence to the sentence to be asked, including:
[0317] Obtaining a target number for the target question sentence;
[0318] Writing the target number and the field into a preset query template to obtain a query statement;
[0319] The query statement is run to obtain the reply statement.
[0320] The preset query template may be a structured query statement.
[0321] The query statement can be quickly generated through the preset query template. Since the query statement includes the target number and the field, the reply statement can be accurately obtained.
[0322] In at least one embodiment of the present invention, after obtaining the answer corresponding to the target question sentence as the reply sentence of the sentence to be asked, the obtaining unit 110 obtains the request number of the question and answer request;
[0323] The generating unit 115 generates prompt information according to the request number and the reply statement;
[0324] The encryption unit 116 encrypts the prompt information using a symmetric encryption algorithm to obtain a ciphertext;
[0325] The acquisition unit 110 acquires a triggering user of the question and answer request from the question and answer request;
[0326] The sending unit 117 sends the ciphertext to the terminal device of the triggering user.
[0327] Prompt information is generated through the request number and the reply statement, and the generated prompt information has the request number and the reply statement, so that the triggered user can quickly learn the request corresponding to the reply statement, and the prompt information is encrypted by a symmetric encryption algorithm, which can not only quickly generate the ciphertext but also improve the security of the prompt information.
[0328] It can be seen from the above technical solutions that the present invention improves the semantic representation ability of the first feature vector and the second feature vector by extracting features from the first sentence matrix and the second sentence matrix, and effectively improves the accuracy of the matching degree by calculating the similarity between the first feature vector and the second feature vector in a variety of ways, thereby doubly improving the accuracy of the reply sentence. In addition, the present invention does not need to process the question sentence and the candidate question sentence through a multi-layer model structure, thereby improving the efficiency of determining the reply sentence and thus improving the real-time performance of intelligent question and answer.
[0329] like Figure 3 , which is a schematic diagram of the structure of an electronic device of a preferred embodiment of the intelligent question-answering method of the present invention.
[0330] In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer-readable instructions stored in the memory 12 and executable on the processor 13, such as an intelligent question-answering program.
[0331] Those skilled in the art will understand that the schematic diagram is merely an example of the electronic device 1 and does not constitute a limitation on the electronic device 1. The electronic device 1 may include more or fewer components than shown in the diagram, or a combination of certain components, or different components. For example, the electronic device 1 may also include input and output devices, network access devices, buses, etc.
[0332] The processor 13 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 13 is the computing core and control center of the electronic device 1, and uses various interfaces and lines to connect various parts of the entire electronic device 1, and executes the operating system of the electronic device 1 and various installed applications, program codes, etc.
[0333] Exemplarily, the computer-readable instructions may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer-readable instructions in the electronic device 1. For example, the computer-readable instructions may be divided into an acquisition unit 110, an extraction unit 111, a calculation unit 112, a processing unit 113, a determination unit 114, a generation unit 115, an encryption unit 116, and a sending unit 117.
[0334] The memory 12 can be used to store the computer-readable instructions and / or modules, and the processor 13 implements various functions of the electronic device 1 by running or executing the computer-readable instructions and / or modules stored in the memory 12, and calling the data stored in the memory 12. The memory 12 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device, etc. The memory 12 can include non-volatile and volatile memories, such as: a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other storage devices.
[0335] The memory 12 may be an external memory and / or an internal memory of the electronic device 1. Furthermore, the memory 12 may be a memory in a physical form, such as a memory stick, a TF card (Trans-flash Card), and the like.
[0336] If the module / unit integrated in the electronic device 1 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 storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also instruct the relevant hardware to complete it through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed by the processor, the steps of the above-mentioned various method embodiments can be implemented.
[0337] The computer-readable instructions include computer-readable instruction codes, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer-readable instruction code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM).
[0338] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0339] Combination Figure 1 The memory 12 in the electronic device 1 stores computer-readable instructions to implement an intelligent question-answering method, and the processor 13 can execute the computer-readable instructions to implement:
[0340] When a question-and-answer request is received, a sentence to be asked is extracted from the question-and-answer request, and candidate question sentences are obtained from a preset corpus according to the question-and-answer request;
[0341] Acquire a first sentence matrix of the sentence to be asked based on a preset vector table, and acquire a second sentence matrix of the candidate question sentence based on the preset vector table;
[0342] Performing feature extraction on the first sentence matrix to obtain a first feature vector, and performing feature extraction on the second sentence matrix to obtain a second feature vector;
[0343] Calculating a matching degree between the first feature vector and the second feature vector;
[0344] Normalizing the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence;
[0345] Determine the candidate question sentence with the greatest similarity probability as the target question sentence;
[0346] An answer corresponding to the target question sentence is obtained as a reply sentence to the sentence to be asked.
[0347] Specifically, the specific implementation method of the processor 13 for the above-mentioned computer readable instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0348] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0349] The computer-readable storage medium stores computer-readable instructions, wherein the computer-readable instructions are used to implement the following steps when executed by the processor 13:
[0350] When a question-and-answer request is received, a sentence to be asked is extracted from the question-and-answer request, and candidate question sentences are obtained from a preset corpus according to the question-and-answer request;
[0351] Acquire a first sentence matrix of the sentence to be asked based on a preset vector table, and acquire a second sentence matrix of the candidate question sentence based on the preset vector table;
[0352] Performing feature extraction on the first sentence matrix to obtain a first feature vector, and performing feature extraction on the second sentence matrix to obtain a second feature vector;
[0353] Calculating a matching degree between the first feature vector and the second feature vector;
[0354] Normalizing the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence;
[0355] Determine the candidate question sentence with the greatest similarity probability as the target question sentence;
[0356] An answer corresponding to the target question sentence is obtained as a reply sentence to the sentence to be asked.
[0357] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0358] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0359] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0360] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices mentioned can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0361] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. An intelligent question-answering method, characterized in that: The intelligent question-answering method comprises: When a question-and-answer request is received, a sentence to be asked is extracted from the question-and-answer request, and candidate question sentences are obtained from a preset corpus according to the question-and-answer request; Acquire a first sentence matrix of the sentence to be asked based on a preset vector table, and acquire a second sentence matrix of the candidate question sentence based on the preset vector table; Performing feature extraction on the first sentence matrix to obtain a first feature vector, and performing feature extraction on the second sentence matrix to obtain a second feature vector, wherein the first feature vector is used to indicate the semantics of the sentence to be asked, and the second feature vector is used to indicate the semantics of the candidate question sentence, and the feature extraction on the first sentence matrix to obtain the first feature vector includes: encoding the first sentence matrix using a first feature encoder to obtain a first encoding matrix, and encoding the first sentence matrix using a second feature encoder to obtain a second encoding matrix; splicing the first encoding matrix and the second encoding matrix to obtain a spliced matrix; performing feature integration on the spliced matrix using a preset fully connected layer to obtain an integrated matrix; calculating the average value in each dimension of the integrated matrix to obtain the first feature vector, wherein the first encoding matrix and the second encoding matrix are obtained by encoding the first sentence matrix in different encoding methods; Calculating the matching degree between the first feature vector and the second feature vector, including: using the cosine distance formula to calculate the values of the first feature vector and the second feature vector to obtain a first similarity; calculating the variance of the first feature vector according to the value of each dimension in the first feature vector to obtain a first variance, and calculating the variance of the second feature vector according to the value of each dimension in the second feature vector to obtain a second variance; calculating the sum of the first variance and the second variance to obtain a total variance; calculating the difference between the first feature vector and the second feature vector to obtain a difference vector, and calculating the variance of the difference vector according to the value of each dimension in the difference vector to obtain a third variance; dividing the third variance by the total variance to obtain a second similarity; performing a weighted sum operation on the first similarity and the second similarity according to a preset weight coefficient to obtain the matching degree; Normalizing the matching degree to obtain the similarity probability between the sentence to be asked and the candidate question sentence; Determine the candidate question sentence with the greatest similarity probability as the target question sentence; An answer corresponding to the target question sentence is obtained as a reply sentence to the sentence to be asked.
2. The intelligent question-answering method according to claim 1, characterized in that: The acquiring of candidate question sentences from a preset corpus according to the question-answer request includes: Acquire a field corresponding to the sentence to be asked from the question and answer request; Acquire a target list from the preset corpus according to the domain; All sentences in the target list are determined as the candidate question sentences.
3. The intelligent question-answering method according to claim 1, characterized in that: The step of obtaining the first sentence matrix of the sentence to be asked based on the preset vector table includes: Performing word segmentation processing on the sentence to be asked to obtain sentence segmentation; Determine the word segmentation position of the sentence participle in the sentence to be asked according to the sentence to be asked; Obtaining a word segmentation vector of the sentence segmentation from the preset vector table; The word segmentation vectors are merged according to the word segmentation positions to obtain the first sentence matrix.
4. The intelligent question-answering method according to claim 1, wherein: The encoding process of the first sentence matrix by using the first feature encoder to obtain the first encoding matrix includes: Acquire information corresponding to the first sentence matrix from the character vector table as a character matrix, and acquire information corresponding to the first sentence matrix from the position vector table as a position matrix; Calculating the sum of the character matrix and the position matrix to obtain a mapping matrix; Processing the mapping matrix using a multi-head attention mechanism to obtain an attention matrix; Calculating the sum of the mapping matrix and the attention matrix to obtain a feature matrix; Normalizing the characteristic matrix to obtain a normalized matrix; Using the preset fully connected layer to perform feature integration on the normalized matrix to obtain a target matrix; Calculating the sum of the normalized matrix and the target matrix, and performing normalization processing on the calculated matrix to obtain a calculation matrix; The calculation matrix is mapped according to a preset feature vector table to obtain the first encoding matrix.
5. The intelligent question-answering method according to claim 1, wherein: After obtaining the answer corresponding to the target question sentence as a reply sentence to the sentence to be asked, the method further includes: Obtaining a request number for the question and answer request; Generate prompt information according to the request number and the reply statement; Encrypt the prompt information using a symmetric encryption algorithm to obtain a ciphertext; Acquire a triggering user of the question and answer request from the question and answer request; The ciphertext is sent to the terminal device of the triggering user.
6. An intelligent question-answering device, characterized in that: The intelligent question-answering device comprises: an acquisition unit, configured to extract a sentence to be asked from a question-and-answer request when a question-and-answer request is received, and to acquire a candidate question sentence from a preset corpus according to the question-and-answer request; The acquisition unit is further used to acquire a first sentence matrix of the sentence to be asked based on a preset vector table, and to acquire a second sentence matrix of the candidate question sentence based on the preset vector table; An extraction unit is used to perform feature extraction on the first sentence matrix to obtain a first feature vector, and to perform feature extraction on the second sentence matrix to obtain a second feature vector, wherein the first feature vector is used to indicate the semantics of the sentence to be asked, and the second feature vector is used to indicate the semantics of the candidate question sentence, and the feature extraction on the first sentence matrix to obtain the first feature vector includes: encoding the first sentence matrix using a first feature encoder to obtain a first encoding matrix, and encoding the first sentence matrix using a second feature encoder to obtain a second encoding matrix; splicing the first encoding matrix and the second encoding matrix to obtain a spliced matrix; performing feature integration on the spliced matrix using a preset fully connected layer to obtain an integrated matrix; calculating the average value in each dimension of the integrated matrix to obtain the first feature vector, wherein the first encoding matrix and the second encoding matrix are obtained by encoding the first sentence matrix in different encoding methods; A calculation unit, used to calculate the matching degree between the first feature vector and the second feature vector, including: using the cosine distance formula to calculate the values of the first feature vector and the second feature vector to obtain a first similarity; calculating the variance of the first feature vector according to the value of each dimension in the first feature vector to obtain a first variance, and calculating the variance of the second feature vector according to the value of each dimension in the second feature vector to obtain a second variance; calculating the sum of the first variance and the second variance to obtain a total variance; calculating the difference between the first feature vector and the second feature vector to obtain a difference vector, and calculating the variance of the difference vector according to the value of each dimension in the difference vector to obtain a third variance; dividing the third variance by the total variance to obtain a second similarity; performing a weighted sum operation on the first similarity and the second similarity according to a preset weight coefficient to obtain the matching degree; A processing unit, configured to normalize the matching degree to obtain a similarity probability between the sentence to be asked and the candidate question sentence; A determination unit, configured to determine the candidate question sentence with the highest similarity probability as a target question sentence; The acquisition unit is further used to acquire an answer corresponding to the target question sentence as a reply sentence to the sentence to be asked.
7. An electronic device, characterized in that: The electronic device comprises: a memory storing computer-readable instructions; and A processor executes computer-readable instructions stored in the memory to implement the intelligent question-answering method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions are executed by a processor in an electronic device to implement the intelligent question-answering method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Evidence obtaining method and system based on image recognition, computer equipment and storage medium
CN110969143A
Transformer model-based question and answer method, question and answer device and storage device
CN111881279A
Information retrieval method and device based on voice semantics and computer equipment
CN112287069A