Data storage, query method, device and electronic equipment
By integrating the semantic model of business feature information, the question and answer data is converted into semantic vectors and stored, which solves the problem of low data query accuracy in the existing technology and achieves more efficient data matching and query.
Patent Information
- Application Number
- CN202110874995.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-07-30
AI Technical Summary
The storage method of question and answer data in the prior art results in low accuracy of data query, which affects the efficiency of the intelligent customer service system.
A semantic model that integrates business feature information is used to convert the question and answer data into semantic vectors, and store them in different storage locations according to the question semantic vector and the response semantic vector. The storage location is determined by calculating the cosine distance and attention value of the semantic vector to improve the efficiency of data query. Accuracy.
The accuracy of data query is improved, allowing the intelligent customer service system to more accurately match and query response data, improving the efficiency of the system.
Smart Images

Figure CN113568929B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of distributed storage technology, and specifically to a data storage and query method, device and electronic device. Background Art
[0002] At present, intelligent customer service systems have been increasingly widely used. In the application process of intelligent customer service systems, question and answer data need to be stored, and the storage quality of question and answer data directly affects the efficiency of data query of intelligent customer service systems.
[0003] In the related art, the storage location of the question and answer data is generally constructed through a search engine, and the corresponding question and answer data is matched through the keyword query interface provided by the search engine, or the key value corresponding to the question and answer data is constructed through a memory database to store the question and answer data, or a semantic index tree is constructed through a neural network model to store the question and answer data. In the process of implementing the embodiments of the present invention, the inventor found that based on the storage method of the question and answer data in the related art, the accuracy of data query is low. Summary of the invention
[0004] In view of the above problems, an embodiment of the present invention provides a data storage and query method, device and electronic device, which are used to solve the problem of low data query accuracy in the prior art.
[0005] According to one aspect of an embodiment of the present invention, a data storage method is provided, the method comprising:
[0006] Acquire question and answer data, wherein the question and answer data includes question data and answer data;
[0007] Convert the question-answer data into a semantic vector using a semantic model integrating business feature information, wherein the semantic vector includes a question semantic vector and an answer semantic vector;
[0008] According to the question semantic vector and the answer semantic vector, the question data and the answer data are respectively stored in different storage locations.
[0009] In an optional manner, the method further includes:
[0010] Acquire training data, wherein the training data includes question-answer sentence pairs and business sentences;
[0011] Generate an initial question semantic vector and an initial answer semantic vector corresponding to the question-answer sentence pair, and generate an initial business semantic vector corresponding to the business sentence;
[0012] Calculating a correlation value between the question-answer sentence pair and the business sentence according to the initial question semantic vector, the initial answer semantic vector and the initial business semantic vector;
[0013] If the correlation value is greater than a preset correlation threshold, the combination of the question-answer sentence pair and the business sentence is determined as a positive training example; if the correlation value is not greater than the preset correlation threshold, the combination of the question-answer sentence pair and the business sentence is determined as a negative training example;
[0014] The initial semantic model is trained according to the positive training examples and the negative training examples to generate the semantic model of the fused service feature information.
[0015] In an optional manner, the method further includes:
[0016] Randomly generate a reference vector, and normalize the reference vector according to the number of nodes in the storage cluster to generate a preset reference vector;
[0017] Calculating the cosine distance and attention value between the question semantic vector and the preset reference vector;
[0018] The storage location of the question data is determined according to the cosine distance and the attention value.
[0019] In an optional manner, the method includes:
[0020] Determine target answer data corresponding to target question data, wherein the target question data is any question data, and the target answer data is answer data associated with the target question data;
[0021] Determine the node number, the total number of node slots and the storage slot number corresponding to the storage location of the target problem data;
[0022] The storage location of the target response data is determined according to the node number, the total number of node slots and the storage slot number.
[0023] In an optional manner, the determining target answer data corresponding to the target question data includes:
[0024] Calculate the cosine distance between the semantic vector of the target question data and the semantic vector of each answer data;
[0025] Determine a preset number of semantic vectors of the response data according to the cosine distance from small to large;
[0026] The response data corresponding to the semantic vectors of the preset number of response data are determined as target response data.
[0027] In an optional manner, storing the question data and the answer data in different storage locations according to the question semantic vector and the answer semantic vector respectively includes:
[0028] Determine the semantic vector of the target question data as the storage key of the target question data, and determine the storage locations of the target question data and the target answer data as the storage value of the target question data;
[0029] The semantic vector of the target response data is determined as a storage key of the target response data, and the target response data is determined as a storage value of the target response data.
[0030] According to another aspect of an embodiment of the present invention, a data query method is provided, the method comprising:
[0031] Get the problem data;
[0032] Convert the problem data into a problem semantic vector using a semantic model that integrates business feature information;
[0033] Determine a target storage location corresponding to the question semantic vector and a plurality of similar question data stored in the target storage location;
[0034] Querying similar answer data corresponding to the similar question data;
[0035] The semantic similarity between the question data and the similar answer data is calculated, and the similar answer data is sorted and displayed from large to small according to the semantic similarity.
[0036] According to another aspect of an embodiment of the present invention, there is provided a data storage device, the device comprising:
[0037] An acquisition module, used to acquire question and answer data, wherein the question and answer data includes question data and answer data;
[0038] A conversion module, used to convert the question and answer data into a semantic vector using a semantic model integrating business feature information, wherein the semantic vector includes a question semantic vector and an answer semantic vector;
[0039] A storage module is used to store the question data and the answer data in different storage locations according to the question semantic vector and the answer semantic vector.
[0040] According to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0041] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the operation of the above-mentioned data storage method.
[0042] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and when the executable instruction is executed on an electronic device, the electronic device executes the operation of the above-mentioned data storage method.
[0043] In an embodiment of the present invention, when data is stored, question and answer data can be converted into semantic vectors by using a semantic model that integrates business feature information. The semantic vector includes a question semantic vector and an answer semantic vector. According to the question semantic vector and the answer semantic vector, the question data and the answer data can be stored in different storage locations, respectively. In the above manner, the semantic model that integrates business feature information can convert question and answer data into semantic vectors that include business feature information, so that when performing data query, more matching answer data can be queried based on the question data, thereby improving the accuracy of data query.
[0044] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:
[0046] Figure 1 A schematic diagram showing a flow chart of a data storage method provided by an embodiment of the present invention is shown;
[0047] Figure 2 A schematic diagram showing the structure of a semantic model provided by an embodiment of the present invention is shown;
[0048] Figure 3 A schematic diagram of a storage structure provided by an embodiment of the present invention is shown;
[0049] Figure 4 A schematic diagram showing a flow chart of a data query method provided by an embodiment of the present invention;
[0050] Figure 5 A schematic diagram showing the structure of a data storage device provided by an embodiment of the present invention is shown;
[0051] Figure 6 A schematic structural diagram of an electronic device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0052] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0053] Figure 1 The flowchart of the data storage method according to the embodiment of the present invention is shown, and the method is executed by an electronic device. The memory of the electronic device is used to store at least one executable instruction, and the executable instruction enables the processor of the electronic device to execute the operation of the data storage method.
[0054] like Figure 1 As shown, the method comprises the following steps:
[0055] Step 110: Acquire question and answer data, where the question and answer data includes question data and answer data.
[0056] The question and answer data may be data that the intelligent customer service system needs to save, including question data and answer data corresponding to the question data. For example, the question and answer data is "Q: How to cancel the gold membership? Answer: Click the Migu video cancel button to cancel", the question data is "Q: How to cancel the gold membership?", and the answer data is "Answer: Click the Migu video cancel button to cancel".
[0057] Step 120: Use a semantic model that integrates business feature information to convert the question and answer data into a semantic vector, where the semantic vector includes a question semantic vector and an answer semantic vector.
[0058] Among them, question and answer data generally contains information related to business features. For example, in "Q: How to cancel the gold membership? A: Click the Migu video unsubscribe button to unsubscribe", the information related to the business features is "gold membership". The semantic model that integrates business feature information can convert the question data into a question semantic vector, and convert the answer data into an answer semantic vector, so that the question semantic vector and the answer semantic vector can represent the business information. Unlike the existing artificial intelligence model that generates semantic vectors based on the language itself, the semantic model that integrates business feature information can generate semantic vectors based on the language itself and the business feature information. For example, for users asking "I want to unsubscribe from the gold membership" and "I don't want the gold membership", the existing artificial intelligence model is likely to determine that the semantics are not similar, while for users asking "I want to unsubscribe from the gold membership" and "I want to unsubscribe from the audiobook membership", the existing artificial intelligence model is likely to determine that the semantics are similar. The defects of the existing artificial intelligence model can be avoided by integrating the semantic model of business feature information.
[0059] In an optional manner, the initial semantic model may be trained to generate a semantic model that integrates business feature information. Further, training data may be acquired in advance, the training data including question-answer pairs and business statements, the question-answer data pair may be, for example, "Q: How to cancel a gold membership? A: Click the cancel button in Migu Video to cancel directly", and the business statement may include, for example, "Migu Video Gold Member", "Migu Audiobook Member", etc. Then, an initial question semantic vector and an initial answer semantic vector corresponding to the question-answer pair are generated, and an initial business semantic vector corresponding to the business statement is generated. Further, the correlation value of the question-answer pair and the business statement is calculated based on the initial question semantic vector, the initial answer semantic vector, and the initial business semantic vector. If the correlation value is greater than a preset correlation threshold, the combination of the question-answer pair and the business statement is determined as a positive training example. If the correlation value is not greater than the preset correlation threshold, the combination of the question-answer pair and the business statement is determined as a negative training example. Based on the positive training examples and the negative training examples, the initial semantic model is trained to generate a semantic model that integrates business feature information.
[0060] Figure 2 FIG. 2 shows a schematic diagram of the structure of the semantic model provided by an embodiment of the present invention. Figure 2 As shown, the semantic model includes a data preprocessing module and a GAN generation module. The data preprocessing module is used to process the corpus data to determine the training data, convert the question data in the training data into the initial question semantic vector, convert the answer data in the training data into the initial answer semantic vector, and convert the business statement into the initial business semantic vector; the GAN generation module is used to train the initial semantic model according to the initial question semantic vector, the initial answer semantic vector and the initial business semantic vector to generate a semantic model that integrates business feature information. The training method of the semantic model that integrates business feature information is described below.
[0061] After obtaining the training data, the training data is first preprocessed, that is, the question and answer sentence pairs and the business sentences are segmented. Further, the Jieba word segmentation tool can be used for word segmentation. For example, the word set "gold member, how, cancel" can be obtained by performing word segmentation on the question data "how to cancel a gold member". Then, the word set corresponding to the question and answer sentence pair and the word set corresponding to the business sentence are input into the Bert model, and multiple semantic vectors corresponding to each sentence are generated by the Bert model, and a semantic vector group is constructed according to the multiple semantic vectors. For example, inputting the word set "gold member, how, cancel" into the Bert model can generate three semantic vectors V1, V2 and V3, and further, a semantic vector group V = {V1, V2, V3} can be constructed. Then, the constructed semantic vector group is input into the LSTM model to generate an initial semantic vector, that is, the semantic vector group corresponding to the question sentence is input into the LSTM model to generate an initial question semantic vector, the semantic vector group corresponding to the answer sentence is input into the LSTM model to generate an initial answer semantic vector, and the semantic vector group corresponding to the business sentence is input into the LSTM model to generate an initial business semantic vector. For example, inputting the semantic vector group V = {V1, V2, V3} into the LSTM model can obtain V'. It should be noted that since each sentence contains a different number of word segments, the number of semantic vectors contained in the semantic vector group corresponding to each sentence is also different. The LSTM model can process the semantic vector groups with different numbers of semantic vectors into the initial semantic vectors corresponding to each sentence, and at the same time effectively preserve the information contained in each semantic vector group. The initial semantic vectors corresponding to each sentence have the same dimension.
[0062] Among them, after obtaining the initial semantic vector corresponding to each sentence through the LSTM model, positive training examples and negative training examples can be constructed to train the business discrimination model of the GAN generation module. The positive training examples and negative training examples are both combinations of question-answering sentence pairs and business sentences. In the combination of question-answering sentence pairs and business sentences corresponding to the positive training examples, the question-answering sentence pairs are not related to the business sentences, and in the combination of question-answering sentence pairs and business sentences corresponding to the negative training examples, the question-answering sentence pairs are related to the business sentences. For example, since the question-answer pair "Q: How do I cancel a gold membership? A: You can cancel by clicking the cancel button in the Migu video" is related to the business sentence "gold membership", the combination of the question-answer pair "Q: How do I cancel a gold membership? A: You can cancel by clicking the cancel button in the Migu video" and the business sentence "gold membership" is a positive training example; since the question-answer pair "Q: How do I cancel a gold membership? A: You can cancel by clicking the cancel button in the Migu video" is not related to the business sentence "audiobook membership", the combination of the question-answer pair "Q: How do I cancel a gold membership? A: You can cancel by clicking the cancel button in the Migu video" and the business sentence "audiobook membership" is a negative training example.
[0063] Furthermore, the relevance of the question and answer statement to the business statement is calculated by the following formula.
[0064]
[0065] Among them, b is the semantic vector of the business statement, q is the semantic vector of the question statement, a is the semantic vector of the answer statement, s is the vector dot product operation function, n is the sequence number of the business statement, N is the total number of business statements, and Sim is the correlation value between the corresponding question and answer statement pair and the business statement. Through the above formula, the correlation value of the question and answer statement pair and any business statement can be calculated. If Sim is greater than the preset correlation threshold, the combination of the question and answer statement pair and the business statement is determined as a positive training example. If Sim is not greater than the preset correlation threshold, the combination of the question and answer statement pair and the business statement is determined as a negative training example.
[0066] Furthermore, the constructed positive training examples and negative training examples can be input into the business discrimination model so that the business discrimination model can discriminate whether the question-answer sentence pair is related to the business sentence. After the business discrimination model is trained, the initial semantic vector corresponding to the question-answer sentence pair obtained by the LSTM model can be input into the question-answer generation model, and the initial semantic vector corresponding to the business sentence can be input into the business generation model. Both the question-answer generation model and the business generation model include a combined LSTM layer and a one-dimensional convolution layer; the combined LSTM layer can extract the features of the initial semantic vector, and the one-dimensional convolution layer can perform a convolution transformation to obtain a transformed semantic vector. The business attention model can fuse the transformed semantic vector corresponding to the question-answer sentence pair and the transformed semantic vector corresponding to the business sentence pair. When the business attention model performs vector fusion, the question-answer pair can be randomly combined with the business statement to generate a combined semantic vector corresponding to the random combination of the question-answer pair and the business statement. The encoder part of the Transformer is used to read the combined semantic vector and encode it. The encoding result is output to the trained business discrimination model, so that the business discrimination model can determine whether the combined semantic vector contains correct business information, and further adjust the model parameters of the question-answer generation model, the business generation model, and the business attention model according to the discrimination result of the business discrimination model. The trained question-answer generation model, the business generation model, and the business attention model are semantic models that integrate business feature information. In the above scheme, the question-answer pair is fused with the business statement through the GAN generation network to generate a semantic vector containing business information, so that the business information in the question-answer pair can be accurately identified.
[0067] Step 130: According to the question semantic vector and the answer semantic vector, the question data and the answer data are stored in different storage locations respectively.
[0068] The storage location of the question data can be determined based on the question semantic vector and the preset reference vector, and the preset reference vector is a random vector in the vector space. Furthermore, a reference vector can be randomly generated, and the reference vector can be normalized according to the number of nodes in the storage cluster to generate the preset reference vector, and the cosine distance and attention value between the question semantic vector and the preset reference vector are calculated, and the storage location of the question data is determined based on the cosine distance and the attention value. The storage location of the question data is not the same as the storage location of the answer data.
[0069] Figure 3 FIG. 2 shows a schematic diagram of a storage structure provided by an embodiment of the present invention. Figure 3 As shown, the storage structure provided by the embodiment of the present invention is a Redis cluster storage structure. The Redis cluster storage structure includes multiple nodes, each node includes multiple storage slots, and the storage slots in each node may include a question slot and a response slot. For the Redis distributed storage method, this embodiment no longer uses the original storage structure of Redis, but divides the storage slots of Redis into two categories, namely, question slots and response slots. The question slots are used to store question data, and the response slots are used to store response data. Each storage slot stores data in the form of Key-Value. Furthermore, the question slots and the response slots have different data storage forms.
[0070] Among them, the data storage form of the question slot can be {question data semantic vector: question data content, answer data storage location}, that is, the question data semantic vector is the storage key of the question slot, which can be easily queried according to the question data semantic vector to obtain the answer data storage location. The question data content and the answer data storage location are the storage values of the question slot, and the answer data storage location includes the storage slot number and storage node of the answer data. The answer data storage location can include multiple answer data storage locations, and the answer data storage location corresponds to the storage locations of multiple similar answer data. Setting the answer data storage location to multiple can make up for the shortcomings of semantic matching. For example, when the question data is "I want to cancel the gold membership", in addition to querying the answer data corresponding to the question data, similar answer data can also be queried, such as "gold members can have the following benefits", which can prevent the single answer data queried from being inaccurate when errors occur in the semantic model matching of the integrated business feature information, and improve the accuracy of semantic matching. Further, the number of answer data storage locations can be determined based on the training data, for example, it can be set to 20.
[0071] The data storage format of the response slot can be {response data semantic vector: response data content}, that is, the response data semantic vector is the storage key of the response slot, and the response data content is the storage value of the response slot. Furthermore, the storage location of the question data can be determined by generating a random vector in the vector space according to a preset reference vector. The storage location of the question data can be determined, for example, by calculating the following formula.
[0072] C id =[cos(V t ,V i )+attn(V t ,V i )]%M
[0073] Among them, Vt is the preset reference vector, Vi is the semantic vector of the question data, M is the total number of question slots, cos() is the cosine distance calculation function, attn is the attention value calculation function, and Cid is the calculated question slot number. M can be determined according to the total number of storage slots. For example, Redis includes a total of 16384 storage slots, and the total number of question slots and the total number of answer slots each account for half, both of which are 8192.
[0074] In an optional manner, the storage location of the response data can be determined based on the storage location of the question data. Furthermore, the target response data corresponding to the target question data can be determined, the target question data is any question data, and the target response data is the response data associated with the target question data; the node number, the total number of node slots, and the storage slot number corresponding to the storage location of the target question data are determined; the storage location of the target response data is determined based on the node number, the total number of node slots, and the storage slot number. When determining the target response data corresponding to the target question data, the cosine distance between the semantic vector of the target question data and the semantic vector of each response data can be calculated, and the semantic vectors of a preset number of response data are determined from small to large according to the cosine distance, and the response data corresponding to the semantic vectors of the preset number of response data are determined as the target response data.
[0075] Furthermore, when calculating the storage location of the target answer data according to the storage location of the target question data, the following formula may be used for calculation.
[0076] D id =[C id +i*C num ]%M
[0077] Among them, Cid is the storage slot number of the problem data, i is the node number of the problem data, Cnum is the number of storage slots of each node, and M is the total number of problem slots. Through the above formula, the query request of the answer data is dispersed to different nodes, which solves the problem of data query hotspots and maintains the high efficiency and high response speed of the Redis cluster.
[0078] When the question data and answer data are stored in corresponding storage locations respectively, the semantic vector of the target question data can be determined as the storage key of the target question data, the storage locations of the target question data and the target answer data can be determined as the storage value of the target question data, the semantic vector of the target answer data can be determined as the storage key of the target answer data, and the target answer data can be determined as the storage value of the target answer data.
[0079] Furthermore, before storing the question data and the answer data in the corresponding storage locations, the Redis storage system can be initialized in advance, including reading the number of nodes, the number of slots, and the distribution of slots in the Redis cluster. Using the storage locations of the question data and similar answer data, a Key-Value storage structure for the question data is constructed for storage; a Key-Value storage structure for the answer data is constructed and stored according to the calculated storage location, thereby realizing the separate storage of the question data and the answer data.
[0080] In an embodiment of the present invention, when data is stored, question and answer data can be converted into semantic vectors by using a semantic model that integrates business feature information. The semantic vector includes a question semantic vector and an answer semantic vector. According to the question semantic vector and the answer semantic vector, the question data and the answer data can be stored in different storage locations, respectively. In the above manner, the semantic model that integrates business feature information can convert question and answer data into semantic vectors that include business feature information, so that when performing data query, more matching answer data can be queried based on the question data, thereby improving the accuracy of data query.
[0081] Figure 4 The flowchart of the data query method of the embodiment of the present invention is shown, and the method is executed by an electronic device. The memory of the electronic device is used to store at least one executable instruction, and the executable instruction enables the processor of the electronic device to execute the operation of the data query method.
[0082] like Figure 4 As shown, the method comprises the following steps:
[0083] Step 210: Obtain question data.
[0084] Among them, question data are generally questions asked by users, such as "How to cancel a Migu audiobook membership?", "How to cancel a gold membership?", etc.
[0085] Step 220: Use the semantic model that integrates the service feature information to convert the question data into a question semantic vector.
[0086] Among them, the semantic model of the fusion service feature information in the above embodiment can be used to convert the question data into a question semantic vector. Furthermore, the Bert model can be used for word segmentation, and the word set after word segmentation can be converted into an initial semantic vector through the LSTM model, and then the initial semantic vector is input into the question-answering generation model and the service generation model respectively, and fused through the service attention model to obtain the question semantic vector.
[0087] Step 230: Determine a target storage location corresponding to the question semantic vector and a plurality of similar question data stored in the target storage location.
[0088] The target storage location corresponding to the question semantic vector can be calculated according to the formula in the above embodiment, that is, the storage slot number of the similar question data is determined. The storage slot of the similar question data stores multiple similar question data similar to the question data and the storage location of the corresponding similar answer data.
[0089] Step 240: Query similar answer data corresponding to the similar question data.
[0090] Among them, the storage location of similar answer data can be queried according to the storage slot number of similar question data, and multiple similar answer data corresponding to similar question data can be queried at the storage location of similar answer data. For multiple question data initiated at the same time, the answer slots of similar answer data corresponding to each question data can be distributed on different nodes, solving the query hotspot problem and balancing the system load.
[0091] Step 250: Calculate the semantic similarity between the question data and the similar answer data, sort and display the similar answer data from large to small according to the semantic similarity.
[0092] Among them, the cosine function can be used to calculate the semantic similarity between the question data and each similar answer data, and the similar answer data can be sorted and displayed from large to small according to the semantic similarity for user reference.
[0093] In the embodiment of the present invention, by using a semantic model that integrates business feature information, the question data can be converted into a question semantic vector, and further the target storage location corresponding to the question semantic vector and multiple similar question data stored in the target storage location can be determined; similar answer data corresponding to similar question data are queried, and the semantic similarity between the question data and the similar answer data is calculated, and the similar answer data is sorted and displayed from large to small according to the semantic similarity. It can be seen that in the embodiment of the present invention, multiple similar answer data can be obtained and sorted and displayed according to the question semantic vector, which improves the accuracy of generating answer data.
[0094] Figure 5 FIG. 2 shows a schematic diagram of the structure of a data storage device according to an embodiment of the present invention. Figure 5 As shown, the device 300 includes: an acquisition module 310 , a conversion module 320 and a storage module 330 .
[0095] Among them, the acquisition module 310 is used to acquire question and answer data, which includes question data and answer data; the conversion module 320 is used to use a semantic model that integrates business feature information to convert the question and answer data into semantic vectors, which include question semantic vectors and answer semantic vectors; the storage module 330 is used to store the question data and the answer data in different storage locations according to the question semantic vector and the answer semantic vector, respectively.
[0096] In an optional manner, the apparatus 300 further includes a generating module, configured to:
[0097] Acquire training data, wherein the training data includes question-answer sentence pairs and business sentences;
[0098] Generate an initial question semantic vector and an initial answer semantic vector corresponding to the question-answer sentence pair, and generate an initial business semantic vector corresponding to the business sentence;
[0099] Calculating a correlation value between the question-answer sentence pair and the business sentence according to the initial question semantic vector, the initial answer semantic vector and the initial business semantic vector;
[0100] If the correlation value is greater than a preset correlation threshold, the combination of the question-answer sentence pair and the business sentence is determined as a positive training example; if the correlation value is not greater than the preset correlation threshold, the combination of the question-answer sentence pair and the business sentence is determined as a negative training example;
[0101] The initial semantic model is trained according to the positive training examples and the negative training examples to generate the semantic model of the fused service feature information.
[0102] In an optional manner, the storage module 330 is used to:
[0103] Randomly generate a reference vector, and normalize the reference vector according to the number of nodes in the storage cluster to generate a preset reference vector;
[0104] Calculating the cosine distance and attention value between the question semantic vector and the preset reference vector;
[0105] The storage location of the question data is determined according to the cosine distance and the attention value.
[0106] In an optional manner, the storage module 330 is used to:
[0107] Determine target answer data corresponding to target question data, wherein the target question data is any question data, and the target answer data is answer data associated with the target question data;
[0108] Determine the node number, the total number of node slots and the storage slot number corresponding to the storage location of the target problem data;
[0109] The storage location of the target response data is determined according to the node number, the total number of node slots and the storage slot number.
[0110] In an optional manner, the storage module 330 is used to:
[0111] Calculate the cosine distance between the semantic vector of the target question data and the semantic vector of each answer data;
[0112] Determine a preset number of semantic vectors of the response data according to the cosine distance from small to large;
[0113] The response data corresponding to the semantic vectors of the preset number of response data are determined as target response data.
[0114] In an optional manner, the storage module 330 is used to:
[0115] Determine the semantic vector of the target question data as the storage key of the target question data, and determine the storage locations of the target question data and the target answer data as the storage value of the target question data;
[0116] The semantic vector of the target response data is determined as a storage key of the target response data, and the target response data is determined as a storage value of the target response data.
[0117] In an embodiment of the present invention, when data is stored, question and answer data can be converted into semantic vectors by using a semantic model that integrates business feature information. The semantic vector includes a question semantic vector and an answer semantic vector. According to the question semantic vector and the answer semantic vector, the question data and the answer data can be stored in different storage locations, respectively. In the above manner, the semantic model that integrates business feature information can convert question and answer data into semantic vectors that include business feature information, so that when performing data query, more matching answer data can be queried based on the question data, thereby improving the accuracy of data query.
[0118] Figure 6 A schematic diagram of the structure of an electronic device according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.
[0119] like Figure 6 As shown, the electronic device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0120] The processor 402, the communication interface 404, and the memory 406 communicate with each other via the communication bus 408. The communication interface 404 is used to communicate with other devices such as a client or other server network elements. The processor 402 is used to execute the program 410, which can specifically execute the relevant steps in the above-mentioned data storage method embodiment.
[0121] Specifically, the program 410 may include program code including computer executable instructions.
[0122] The processor 402 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0123] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0124] Program 410 can be specifically called by processor 402 to enable the electronic device to perform the following operations:
[0125] Acquire question and answer data, wherein the question and answer data includes question data and answer data;
[0126] Convert the question-answer data into a semantic vector using a semantic model integrating business feature information, wherein the semantic vector includes a question semantic vector and an answer semantic vector;
[0127] According to the question semantic vector and the answer semantic vector, the question data and the answer data are respectively stored in different storage locations.
[0128] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:
[0129] Acquire training data, wherein the training data includes question-answer sentence pairs and business sentences;
[0130] Generate an initial question semantic vector and an initial answer semantic vector corresponding to the question-answer sentence pair, and generate an initial business semantic vector corresponding to the business sentence;
[0131] Calculating a correlation value between the question-answer sentence pair and the business sentence according to the initial question semantic vector, the initial answer semantic vector and the initial business semantic vector;
[0132] If the correlation value is greater than a preset correlation threshold, the combination of the question-answer sentence pair and the business sentence is determined as a positive training example; if the correlation value is not greater than the preset correlation threshold, the combination of the question-answer sentence pair and the business sentence is determined as a negative training example;
[0133] The initial semantic model is trained according to the positive training examples and the negative training examples to generate the semantic model of the fused service feature information.
[0134] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:
[0135] Randomly generate a reference vector, and normalize the reference vector according to the number of nodes in the storage cluster to generate a preset reference vector;
[0136] Calculating the cosine distance and attention value between the question semantic vector and the preset reference vector;
[0137] The storage location of the question data is determined according to the cosine distance and the attention value.
[0138] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:
[0139] Determine target answer data corresponding to target question data, wherein the target question data is any question data, and the target answer data is answer data associated with the target question data;
[0140] Determine the node number, the total number of node slots and the storage slot number corresponding to the storage location of the target problem data;
[0141] The storage location of the target response data is determined according to the node number, the total number of node slots and the storage slot number.
[0142] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:
[0143] Calculate the cosine distance between the semantic vector of the target question data and the semantic vector of each answer data;
[0144] Determine a preset number of semantic vectors of the response data according to the cosine distance from small to large;
[0145] The response data corresponding to the semantic vectors of the preset number of response data are determined as target response data.
[0146] In an optional manner, the program 410 is called by the processor 402 to enable the electronic device to perform the following operations:
[0147] Determine the semantic vector of the target question data as the storage key of the target question data, and determine the storage locations of the target question data and the target answer data as the storage value of the target question data;
[0148] The semantic vector of the target response data is determined as a storage key of the target response data, and the target response data is determined as a storage value of the target response data.
[0149] In an embodiment of the present invention, when data is stored, question and answer data can be converted into semantic vectors by using a semantic model that integrates business feature information. The semantic vector includes a question semantic vector and an answer semantic vector. According to the question semantic vector and the answer semantic vector, the question data and the answer data can be stored in different storage locations, respectively. In the above manner, the semantic model that integrates business feature information can convert question and answer data into semantic vectors that include business feature information, so that when performing data query, more matching answer data can be queried based on the question data, thereby improving the accuracy of data query.
[0150] An embodiment of the present invention provides a computer-readable storage medium, wherein the storage medium stores at least one executable instruction. When the executable instruction is executed on an electronic device, the electronic device executes the data storage method in any of the above method embodiments.
[0151] An embodiment of the present invention provides a data storage device for executing the above data storage method.
[0152] An embodiment of the present invention provides a computer program, which can be called by a processor to enable an electronic device to execute the data storage method in any of the above method embodiments.
[0153] An embodiment of the present invention provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed on a computer, the computer executes the data storage method in any of the above method embodiments.
[0154] The algorithm or display provided herein is not inherently related to any particular computer, virtual system or other equipment. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the embodiment of the present invention is not directed to any specific programming language yet. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description made to specific languages above is for disclosing the best mode of the present invention.
[0155] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0156] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than those expressly recited in each claim.
[0157] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0158] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.
Claims
1. A data storage method, characterized in that: The method comprises: Acquire question and answer data, wherein the question and answer data includes question data and answer data; The question-answer data is converted into a semantic vector using a semantic model that integrates business feature information, wherein the semantic vector includes a question semantic vector and an answer semantic vector; wherein the semantic model is obtained in the following manner: obtaining training data, wherein the training data includes a question-answer sentence pair and a business sentence; generating an initial question semantic vector and an initial answer semantic vector corresponding to the question-answer sentence pair, and generating an initial business semantic vector corresponding to the business sentence; calculating a correlation value between the question-answer sentence pair and the business sentence according to the initial question semantic vector, the initial answer semantic vector and the initial business semantic vector; if the correlation value is greater than a preset correlation threshold, determining the combination of the question-answer sentence pair and the business sentence as a positive training example, and if the correlation value is not greater than the preset correlation threshold, determining the combination of the question-answer sentence pair and the business sentence as a negative training example; training the initial semantic model according to the positive training examples and the negative training examples to generate a semantic model that integrates business feature information; According to the question semantic vector and the answer semantic vector, the question data and the answer data are stored in different storage locations respectively, wherein the storage location includes a question slot and an answer slot, the question data semantic vector is the storage Key of the question slot; the question data content and the answer data storage location are the storage Value of the question slot; the answer data storage location includes the storage slot number and storage node of the answer data.
2. The method according to claim 1, characterized in that The method further comprises: Randomly generate a reference vector, and normalize the reference vector according to the number of nodes in the storage cluster to generate a preset reference vector; Calculating the cosine distance and attention value between the question semantic vector and the preset reference vector; The storage location of the question data is determined according to the cosine distance and the attention value.
3. The method according to claim 2, characterized in that The method comprises: Determine target answer data corresponding to target question data, wherein the target question data is any question data, and the target answer data is answer data associated with the target question data; Determine the node number, the total number of node slots and the storage slot number corresponding to the storage location of the target problem data; The storage location of the target response data is determined according to the node number, the total number of node slots and the storage slot number.
4. The method according to claim 3, characterized in that The target answer data corresponding to the target question data is determined to include: Calculate the cosine distance between the semantic vector of the target question data and the semantic vector of each answer data; Determine a preset number of semantic vectors of the response data according to the cosine distance from small to large; The response data corresponding to the semantic vectors of the preset number of response data are determined as target response data.
5. The method according to claim 3 or 4, characterized in that: The storing the question data and the answer data in different storage locations according to the question semantic vector and the answer semantic vector respectively comprises: Determine the semantic vector of the target question data as the storage key of the target question data, and determine the storage locations of the target question data and the target answer data as the storage value of the target question data; The semantic vector of the target response data is determined as a storage key of the target response data, and the target response data is determined as a storage value of the target response data.
6. A data query method, characterized in that: The method comprises: Get the problem data; The question data is converted into a question semantic vector using a semantic model that integrates business feature information; wherein the semantic model is obtained in the following manner: obtaining training data, the training data including question-answer sentence pairs and business sentences; generating an initial question semantic vector and an initial answer semantic vector corresponding to the question-answer sentence pair, and generating an initial business semantic vector corresponding to the business sentence; calculating a correlation value between the question-answer sentence pair and the business sentence based on the initial question semantic vector, the initial answer semantic vector and the initial business semantic vector; if the correlation value is greater than a preset correlation threshold, determining the combination of the question-answer sentence pair and the business sentence is a positive training example. If the correlation value is not greater than the preset correlation threshold, the combination of the question-answer statement pair and the business statement is determined as a negative training example. According to the positive training examples and the negative training examples, the initial semantic model is trained to generate a semantic model of the fused business feature information. The question data and the answer data are stored in different storage locations, the storage location includes a question slot and an answer slot, and the question data semantic vector is the storage Key of the question slot. The question data content and the answer data storage location are the storage Value of the question slot. The answer data storage location includes the storage slot number and storage node of the answer data. Determine a target storage location corresponding to the question semantic vector and a plurality of similar question data stored in the target storage location; Querying similar answer data corresponding to the similar question data; The semantic similarity between the question data and the similar answer data is calculated, and the similar answer data is sorted and displayed from large to small according to the semantic similarity.
7. A data storage device, characterized in that: The device comprises: An acquisition module, used to acquire question and answer data, wherein the question and answer data includes question data and answer data; A conversion module, used to convert the question and answer data into a semantic vector using a semantic model that integrates business feature information, wherein the semantic vector includes a question semantic vector and an answer semantic vector; wherein the semantic model is obtained in the following manner: obtaining training data, wherein the training data includes a question and answer sentence pair and a business sentence; generating an initial question semantic vector and an initial answer semantic vector corresponding to the question and answer sentence pair, and generating an initial business semantic vector corresponding to the business sentence; calculating a correlation value between the question and answer sentence pair and the business sentence based on the initial question semantic vector, the initial answer semantic vector and the initial business semantic vector; if the correlation value is greater than a preset correlation threshold, determining the combination of the question and answer sentence pair and the business sentence as a positive training example, and if the correlation value is not greater than the preset correlation threshold, determining the combination of the question and answer sentence pair and the business sentence as a negative training example; training the initial semantic model based on the positive training examples and the negative training examples to generate a semantic model that integrates business feature information; A storage module is used to store the question data and the answer data in different storage locations according to the question semantic vector and the answer semantic vector, respectively, wherein the storage location includes a question slot and an answer slot, the question data semantic vector is the storage Key of the question slot; the question data content and the answer data storage location are the storage Value of the question slot; the answer data storage location includes the storage slot number and storage node of the answer data.
8. An electronic device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation of the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that: The storage medium stores at least one executable instruction, and when the executable instruction is executed on the electronic device, the electronic device executes the operation of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and apparatus for establishing specialized knowledge question / answer system
CN105468648A
Redis-based mass data storage method and device, medium and equipment
CN109597834A
