Data query method and device, electronic equipment and computer readable storage medium
By finding similar answers to similar questions in the Q&A knowledge base and using pre-trained Q&A model and RAG services, the problem of the Q&A model generating inaccurate answers is solved, and more accurate answers are achieved, reducing the risk of user misleading.
Patent Information
- Application Number
- CN202510329408.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-08-01
AI Technical Summary
The existing question-and-answer model has low accuracy in the number of training samples and question types, especially in professional scenarios.
By finding similar answers to similar questions with similarity meet the requirements in the Q&A knowledge base, and using a pre-trained Q&A model to generate answers, combining similarity detection and retrieval enhancement generation RAG services, ensuring the accuracy of the answers.
It improves the accuracy of the answer content generated by the Q&A model and reduces the risk of users being misled by inaccurate answers, especially in professional scenarios to provide more accurate answers.
Smart Images

Figure CN120407724A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a data query method, apparatus, electronic device, and computer-readable storage medium. Background Art
[0002] With the development of artificial intelligence technology, intelligent answering systems have become an important part of human-computer interaction and are being more and more widely used in various industries. An intelligent answering system can understand questions raised by users and provide corresponding answers. Related technologies can use pre-trained question-and-answer models to answer questions raised by users. However, due to limitations in the number of training samples and the types of questions involved in the training process of the question-and-answer model, the accuracy of the answer content generated by the question-and-answer model is sometimes relatively low. In this way, it may provide users with some inaccurate answers and mislead users. Especially for question-and-answer in some professional scenarios, for example, for the scenario of company rules and regulations Q&A, the internal Q&A scenario of logistics enterprise employees, etc., inaccurate answers may cause great inconvenience to users. Summary of the Invention
[0003] This application provides a data query method, apparatus, electronic device, and computer-readable storage medium, which can better avoid providing inaccurate answers to users, provide more accurate answers to users, and thus reduce the situation of misleading users due to providing inaccurate answers. The specific solutions are as follows:
[0004] In a first aspect, this application provides a data query method, and the method includes:
[0005] Obtain query information in a target scenario;
[0006] Search in the pre-set question-and-answer knowledge base corresponding to the target scenario for similar answer content corresponding to similar questions whose similarity to the query information meets a preset similarity requirement;
[0007] Generate a first answer content corresponding to the query information based on a pre-trained question-and-answer model, and the question-and-answer model is trained with the question-and-answer knowledge in the question-and-answer knowledge base as samples;
[0008] Detect whether the similarity between the first answer content and the similar answer content is greater than a first preset similarity threshold;
[0009] If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information.
[0010] Optionally, before searching in the Q&A knowledge base corresponding to the preset target scenario for similar answer content corresponding to a similar question whose similarity to the query information meets a preset similarity requirement, the method further includes:
[0011] Search in the Q&A knowledge base corresponding to the preset target scenario for answer knowledge corresponding to a question that is consistent with the query information, and determine the answer knowledge as the answer result corresponding to the query information;
[0012] If no question consistent with the query information is found in the Q&A knowledge base, perform the step of searching in the Q&A knowledge base corresponding to the preset target scenario for similar answer content corresponding to a similar question whose similarity to the query information meets a preset similarity requirement.
[0013] Optionally, the method further includes:
[0014] If the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold, determine the information indicating inability to answer as the answer result corresponding to the query information.
[0015] Optionally, the method further includes:
[0016] If the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold, input the query information into a large model of the Retrieval-Augmented Generation (RAG) service, so that the large model generates a second answer content corresponding to the query information based on the knowledge base corresponding to the target scenario;
[0017] Generate an answer result corresponding to the query information according to the second answer content.
[0018] Optionally, before inputting the query information into a large model of the Retrieval-Augmented Generation (RAG) service, the method further includes:
[0019] Detect whether the Retrieval-Augmented Generation (RAG) service is enabled, where the Retrieval-Augmented Generation (RAG) service is used to generate answer content through a large model and the knowledge base corresponding to the target scenario;
[0020] If the Retrieval-Augmented Generation (RAG) service is enabled, perform the step of inputting the query information into a large model of the Retrieval-Augmented Generation (RAG) service.
[0021] Optionally, the generating an answer result corresponding to the query information according to the second answer content includes:
[0022] Detect whether the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold;
[0023] If the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold, determine the second answer content as the answer result corresponding to the query information;
[0024] If the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, determine the information indicating that the answer cannot be provided as the answer result corresponding to the query information.
[0025] Optionally, there are multiple pieces of the similar answer content. Detecting whether the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold includes:
[0026] Detect whether the similarity between the first answer content and at least one of the multiple pieces of similar answer content is greater than the first preset similarity threshold.
[0027] Optionally, finding the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement from the pre-set Q&A knowledge base corresponding to the target scenario includes:
[0028] Find the similar answer content corresponding to each similar question whose similarity to the query information is greater than the second preset similarity threshold from the pre-set Q&A knowledge base corresponding to the target scenario.
[0029] Optionally, finding the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement from the pre-set Q&A knowledge base corresponding to the target scenario includes:
[0030] Find the N similar answer content corresponding to the N similar questions whose similarity to the query information is among the top N from the pre-set Q&A knowledge base corresponding to the target scenario, where N is an integer greater than 1.
[0031] Optionally, the Q&A knowledge in the Q&A knowledge base is in the form of vector Q&A knowledge.
[0032] Optionally, the method is applied to a server, and the method further includes:
[0033] If it is detected that the artificial service condition is met, the query information is sent to the artificial side, so that the artificial side displays the query information, obtains the artificial answer content corresponding to the query information input by the artificial side, and sends the artificial answer content to the server; wherein, the artificial service condition includes at least one of the following: the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold and it is detected that the RAG service is not enabled;
[0034] Obtain the artificial answer content from the artificial side, and determine the artificial answer content as the answer result corresponding to the query information.
[0035] Optionally, the method further includes:
[0036] Update the artificial answer result and the query information as a question-and-answer pair in the question-and-answer knowledge base.
[0037] In a second aspect, the present application further provides a data query method, which is applied to a server, and the method includes:
[0038] Obtain the query information input by the user in the target scenario from the client;
[0039] Search in the question-and-answer knowledge base corresponding to the target scenario set in advance for the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement;
[0040] Generate the first answer content corresponding to the query information based on a pre-trained question-and-answer model, and the question-and-answer model is trained with the question-and-answer knowledge in the question-and-answer knowledge base as samples;
[0041] Detect whether the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold;
[0042] If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information;
[0043] Send the answer result to the client, so that the client displays the answer result.
[0044] In a third aspect, the present application further provides a data query device, and the device includes:
[0045] An acquisition unit, configured to acquire query information in a target scenario;
[0046] A search unit, configured to search, from a pre-set Q&A knowledge base corresponding to the target scenario, for similar answer content corresponding to a similar question whose similarity to the query information meets a pre-set similarity requirement;
[0047] A generation unit, configured to generate first answer content corresponding to the query information based on a pre-trained Q&A model, where the Q&A model is trained with Q&A knowledge in the Q&A knowledge base as samples;
[0048] A detection unit, configured to detect whether the similarity between the first answer content and the similar answer content is greater than a first pre-set similarity threshold;
[0049] A determination unit, configured to, if the similarity between the first answer content and the similar answer content is greater than the first pre-set similarity threshold, determine the first answer content as the answer result corresponding to the query information.
[0050] In a fourth aspect, the present application further provides an electronic device, including: a processor, a memory, and computer program instructions stored on the memory and executable on the processor; when the processor executes the computer program instructions, the method described in any one of the first aspect to the second aspect is implemented.
[0051] In a fifth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, the method described in any one of the first aspect to the second aspect is implemented.
[0052] In a sixth aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method described in any one of the first aspect to the second aspect is implemented.
[0053] Compared with the prior art, the present application has the following advantages:
[0054] The data query method provided by the embodiments of the present application obtains query information in a target scenario, and searches for similar answer content corresponding to similar questions whose similarity to the query information meets a preset similarity requirement from the pre-set question-and-answer knowledge base corresponding to the target scenario. Since the similar questions are similar to the query information, there is a relatively high probability that the similar answer content corresponding to the similar questions is the correct answer corresponding to the query information. However, since there are usually still certain differences between the similar questions and the query information, and there may be multiple similar questions, it is impossible to ensure that the similar answer content is the actual answer corresponding to the query information, and there may sometimes be multiple similar questions, and it is impossible to determine which similar question is the actual answer corresponding to the query information. Therefore, the present application will also generate a first answer content corresponding to the query information based on a pre-trained question-and-answer model. Since the question-and-answer model is trained with the question-and-answer knowledge in the question-and-answer knowledge base as samples, the question-and-answer model can accurately answer the trained questions, and the question-and-answer model can learn the structure and semantics of the language by training a large amount of text data, so that the model can understand the semantics of the input query information, and thus generate an answer content that matches the semantics of the query information. In this way, the question-and-answer model can not only accurately understand the semantics of the query information, but also accurately answer the questions with the same semantics that have been trained. However, for questions that the question-and-answer model has not been trained on, the answer content of the question-and-answer model may be relatively low. Therefore, the present application will detect whether the similarity between the first answer content and the similar answer content is greater than a first preset similarity threshold. If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, it means that the query information is a question that the question-and-answer model has been trained on, indicating that the first answer content generated by the question-and-answer model is accurate. In this case, the first answer content can be determined as the answer result corresponding to the query information and fed back to the user.
[0055] It can be seen that the solution provided by the present application determines the first answer content as the answer result corresponding to the query information only when the first answer content generated by the question-and-answer model is relatively similar to the similar answer content in the knowledge base, that is, uses the similar answer content in the knowledge base to verify the accuracy of the first answer content generated by the model, so as to avoid feeding back inaccurate answers generated by the model for questions that have not been trained to the user, and can better avoid providing inaccurate answers to the user, so as to provide more accurate answers to the user, thereby reducing the situation of misleading the user due to providing inaccurate answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 is a schematic diagram of an application scenario of the data query solution provided by the present application;
[0057] Figure 2 is a schematic flowchart of an example of the data query method provided by the embodiments of the present application;
[0058] Figure 3 It is a schematic flowchart of another example of the data query method provided by the embodiments of the present application;
[0059] Figure 4 It is a schematic flowchart of yet another example of the data query method provided by the embodiments of the present application;
[0060] Figure 5 It is a block diagram of the structure of the electronic device provided by the present application. Detailed implementation manners
[0061] In order to enable those skilled in the art to better understand the technical solutions of the present application, the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. However, the present application can be implemented in many other ways different from the following description. Therefore, all other embodiments obtained by those of ordinary skill in the art based on the embodiments provided in the present application without creative efforts shall fall within the protection scope of the present application.
[0062] It should be noted that the terms "first", "source domain", "third", etc. in the claims, specifications and drawings of the present application are used to distinguish similar objects and are not used to describe a specific order or sequence. Such data can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than that shown or described herein. In addition, the terms "comprising", "having" and their variants are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily limit to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0063] To facilitate the understanding of the embodiments of the present application, the application background of the embodiments will be described.
[0064] With the development of artificial intelligence technology, intelligent answering systems have become an important part of human-computer interaction and are being more and more widely used in various industries. Intelligent answering systems can understand the questions raised by users and provide corresponding answers.
[0065] Related technologies can use pre-trained question-and-answer models to answer questions raised by users. However, due to limitations such as the number of training samples and the types of questions involved in the training process of the question-and-answer model, the accuracy of the answer content generated by the question-and-answer model is sometimes relatively low. In this way, it may provide users with some inaccurate answers and mislead users. Especially for question-and-answer in some professional scenarios, for example, for the scenario of company rules and regulations question-and-answer, the internal question-and-answer scenario of employees in logistics enterprises, etc., inaccurate answers may cause great inconvenience to users.
[0066] Related technologies can also determine the answer corresponding to the query information through the vector matching method. For example, a question-and-answer knowledge base in vector form can be set up, and the answer corresponding to the question that is the same (identical or highly similar) as the query information is searched in the question-and-answer knowledge base. However, due to the different expression forms of questions input by different users, it is often impossible to find exactly the same question through the vector matching method, resulting in a relatively high matching failure rate, and thus a relatively high probability of not being able to obtain the answer content. And if the answer corresponding to a similar question is determined as the answer to the query information, some mismatched answers may be fed back to the user, resulting in misleading the user.
[0067] To solve the above problems, the embodiments of the present application provide a data query method, device, electronic device and computer-readable storage medium. The aim is to better avoid providing inaccurate answers to users, so as to provide more accurate answers to users, thereby reducing the situation of misleading users due to providing inaccurate answers.
[0068] The data query method provided by the present application can be applied to data query in various professional fields. Specifically, it can be applied to information query within an enterprise. For example, it can be applied to the internal employee information query of a logistics enterprise, or to the internal employee information query of an e-commerce enterprise. Or, it can be applied to information query of professional knowledge, such as information query of medical knowledge, information query of scientific and technological knowledge, etc. The present application does not specifically limit the specific application fields of data query. Of course, the data query method provided by the present application can also be applied to the general information query field. For example, it can be applied to daily life information query, translation information query, etc., but not limited thereto.
[0069] To facilitate the understanding of the method embodiments of the present application, its application scenario is introduced. Please refer to Figure 1 , Figure 1 is a schematic diagram of the application scenario of the solution provided by the embodiments of the present application. This application scenario is a schematic example and does not serve as a specific description of its application scenario. As Figure 1As shown, in this application scenario, a server 102 and a client 101 are provided. In this embodiment, a connection is established between the client 101 and the server 102 through network communication for data transmission.
[0070] The client 101 can be an electronic device with display and data processing functions such as a mobile phone, a tablet computer (pad), a smart watch, a desktop computer, a smart TV, a VR device, a vehicle-mounted device, a wearable device, a laptop computer, etc. The client 101 is used to obtain the query information input by the user and send the query information to the server 102, so that the server 102 determines the answer result corresponding to the query information, and obtains and displays the answer result from the server 102 to display the answer result for the user. The client 101 can also be used to send access requests, interaction information, etc. to the server 102, so that the server 102 sends the corresponding request data to the client 101 for display.
[0071] The server 102 has high computing power. The server 102 can be a server. The server 102 has high-speed processor (central processing unit, CPU) computing power, long-term reliable operation, strong input / output (I / O) external data throughput capacity, and better scalability. The server 102 can be a single server or a server cluster. The server 102 is used to obtain the query information input by the user from the client 101, generate the query result corresponding to the query information, and send the query result to the client 101. The server 102 can also provide other specific services for the client 101, such as user information access, website access, application program access, etc., which are not specifically limited in this application.
[0072] Communication can be carried out between the client 101 and the server 102, and between the streaming end 103 and the server 102 using various communication systems. For example, it can be a wired communication system or a wireless communication system. The wireless communication system can be, for example, a global system for mobile communications (GSM) system, a code division multiple access (CDMA) system, a wideband code division multiple access (WCDMA) system, a general packet radio service (GPRS), a long term evolution (LTE) system, an LTE frequency division duplex (FDD) system, an LTE time division duplex (TDD), a universal mobile telecommunication system (UMTS), a worldwide interoperability for microwave access (WiMAX) communication system, a future fifth generation (5G) system or a new radio (NR), a satellite communication system, etc.
[0073] Embodiment 1
[0074] The first embodiment of the present application provides a data query method. This method can be applied to an electronic device, which can be a server, that is, a program corresponding to the data query method of the present application is deployed on the server; the electronic device can specifically be an electronic device with data processing functions such as a server, a desktop computer, a laptop computer, a mobile phone, a tablet computer (pad), a smart watch, a smart TV, a VR device, a vehicle-mounted device, a wearable device, etc. Optionally, the above electronic device can also be a client, that is, a program corresponding to the data query method of the present application is deployed on the client. Since the server has strong computing resources and query capabilities, the following embodiments will introduce the solution of the present application with the electronic device being the server as an example, and the execution situation of the client can refer to that of the server.
[0075] As Figure 2 、 Figure 3 shown, the data query method provided by the first embodiment of the present application includes the following steps S110 to S150.
[0076] Step S110: Obtain query information in the target scenario.
[0077] The above target scenarios may include, but are not limited to, internal Q&A scenarios in logistics enterprises, medical knowledge Q&A scenarios, online shopping Q&A scenarios, travel consultation Q&A scenarios, daily life knowledge Q&A scenarios, etc. The above target scenarios are any scenarios that require the use of a Q&A system for data query.
[0078] In the embodiments of the present application, when the execution entity is the server, the user can input query information on the client, and the client can send the query information input by the user to the client. The server obtains the query information in the target scenario input by the user from the client. Among them, a query client corresponding to the target scenario is installed in the electronic device corresponding to the client, and a query server corresponding to the target scenario is installed in the electronic device corresponding to the server.
[0079] Alternatively, when the execution entity is the client, the client can directly obtain the query information in the target scenario input by the user.
[0080] Step S120: Search in the Q&A knowledge base corresponding to the preset target scenario for the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement.
[0081] The above Q&A knowledge base stores various Q&A knowledge in the target scenario. Specifically, the Q&A knowledge in the Q&A knowledge base can be created through materials such as existing internal enterprise materials, externally searched materials, and user feedback information. Existing internal enterprise materials may include existing documents, manuals, frequently asked questions (FAQ) pages, etc.; externally searched materials may include external materials such as industry reports, technical documents, and public databases; user materials may include user feedback from channels such as customer service records, social media comments, and online forum discussions.
[0082] In the embodiments of the present application, Q&A knowledge can be extracted manually from the above various materials, or can be extracted from various materials through a Q&A extraction model. The Q&A extraction model can be a large model or a pre-trained model for extracting Q&A knowledge, and the present application does not specifically limit it.
[0083] It can be understood that the Q&A knowledge base covers a large amount of Q&A knowledge in the target scenario. The Q&A knowledge in the Q&A knowledge base is usually standard Q&A, which can provide basic support for data query. The information in the Q&A knowledge base is paired information of questions and answers. In the embodiments of the present application, the Q&A knowledge in the Q&A knowledge base can be Q&A knowledge in text form, that is, Q&A knowledge represented by natural language text, or Q&A knowledge in vector form, that is, converting the Q&A knowledge in text form into vector form for expression. Among them, when the Q&A knowledge in the Q&A knowledge base is Q&A knowledge in vector form, it is more convenient to calculate the similarity between the query information and the questions in the Q&A knowledge base.
[0084] In a specific embodiment, step S120 can be implemented according to the following steps: calculate the similarity between the query information and each question in the Q&A knowledge base, and according to the similarity between the query information and each question in the Q&A knowledge base, find in the Q&A knowledge base a similar question whose similarity to the query information meets a preset similarity requirement, and determine the answer corresponding to the similar question as the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement.
[0085] Optionally, when calculating the similarity between the query information and each question in the Q&A knowledge base, the vector distance or cosine similarity between the vector corresponding to the query information and the vector corresponding to the question in the Q&A knowledge base can be calculated, and according to this vector distance or cosine similarity, the similarity between the query information and the question in the Q&A knowledge base is determined. This vector matching calculation method can capture the semantic similarity between the query information and the questions in the Q&A knowledge base, making the similarity calculation more accurate. Or, the text repetition rate between the query information and the questions in the Q&A knowledge base can also be calculated, and the similarity between the query information and the questions in the Q&A knowledge base is determined according to the text repetition rate. Among them, the higher the text repetition rate, the higher the similarity between the query information and the questions in the knowledge base.
[0086] In one implementation manner, step S120 can be implemented according to the following steps: find in the Q&A knowledge base corresponding to the preset target scenario each similar answer content corresponding to each similar question whose similarity to the query information is greater than a second preset similarity threshold. That is to say, the similarity between each similar question and the query information is greater than the second similarity threshold, and the second similarity threshold can be specifically set according to the actual situation, which is not specifically limited in the present application. This implementation manner determines the questions with higher similarity to the query information as similar questions. Since the similarity between each of the similar questions determined in this implementation manner and the query information is relatively high, the corresponding similar answer content is also closer to the answer corresponding to the query information, so as to better provide a reference for Q&A queries.
[0087] In another embodiment, step S120 may be implemented as follows: Search for the N similar answer contents corresponding to the N similar questions whose similarity to the query information ranks among the top N from the Q&A knowledge base corresponding to the preset target scenario, where N is an integer greater than 1. Specifically, N may be any integer from 3 to 10, or may be a larger or smaller integer greater than 1, which is not specifically limited in this application. In this embodiment, the questions ranked among the top N in similarity are determined as similar questions. In this way, the situation where the similar answer content corresponding to the similar question cannot be determined can be avoided, so that the determination of the similar answer content can be better ensured, and a reference basis can be provided for the shortcomings of the subsequent answer results.
[0088] Step S130: Generate a first answer content corresponding to the query information based on a pre-trained Q&A model, where the Q&A model is trained with the Q&A knowledge in the Q&A knowledge base as samples.
[0089] Since the Q&A model is trained with the Q&A knowledge in the Q&A knowledge base as samples, and the Q&A knowledge in the Q&A knowledge base corresponds to the target scenario, the trained Q&A model is used to generate the answer content corresponding to the query information in the target scenario.
[0090] The above Q&A model may be a neural network model, a decision tree model, a probabilistic graph model, etc., or may be other machine learning models. In the embodiments of this application, a large model in the related art may be used as the basic model, and the basic model is fine-tuned with the Q&A knowledge in the Q&A knowledge base to obtain a fine-tuned Q&A model that can quickly answer query information. That is to say, in the embodiments of this application, the Q&A knowledge of the target scenario marked in the Q&A knowledge base can be used to train a basic model, so as to obtain a Q&A model that can handle the Q&A tasks of the target scenario. This process can be understood as a process of fine-tuning the basic model through the process of supervised fine-tuning (SFT) to obtain the Q&A model.
[0091] Specifically, the Q&A model can be trained through the following steps: Input the questions in the Q&A knowledge base into the basic model to be trained to obtain an output answer. According to the difference between the output answer and the true answer corresponding to the input question, adjust the model parameters of the basic model to be trained until the basic model after adjusting the parameters meets the convergence condition, and determine the basic model after adjusting the parameters as the Q&A model. The convergence condition may be that the difference between the output answer of the model and the corresponding true answer is less than a preset difference, the accuracy of the test result obtained by testing the test model with test samples is higher than a preset accuracy threshold, etc. The specific content of the convergence condition is not limited in this application, and those skilled in the art can flexibly set it according to the actual situation.
[0092] Step S140: Detect whether the similarity between the first answer content and the similar answer content is greater than a first preset similarity threshold.
[0093] Since the query questions input by users are diverse, and the Q&A knowledge in the Q&A knowledge base may not fully cover all kinds of questions, or there may be situations where the content in the Q&A knowledge base is updated but the training Q&A model is not updated in time, etc. Therefore, the Q&A model may encounter many questions that have not been trained. In this case, the Q&A model may answer off-topic or randomly, resulting in incorrect answers. In this case, if the first answer content generated by the Q&A model is directly fed back to the user, it will mislead the user. Therefore, this application will detect whether the similarity between the first answer content and the similar answer content is greater than a first preset similarity threshold.
[0094] Specifically, the electronic device can convert the first answer content and the similar answer content into vectors, and determine the similarity between the first answer content and the similar answer content by comparing the vector distance or cosine similarity between the vector corresponding to the first answer content and the vector corresponding to the similar answer content. Alternatively, the text repetition rate between the first answer content and the similar answer content can also be compared, and the similarity between the first answer content and the similar answer content can be determined according to this repetition rate. The setting of the first similarity threshold can be set according to the actual situation, and this application does not specifically limit it.
[0095] Step S150: If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information.
[0096] When the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, it indicates that the similarity between the first answer content and the similar answer content is relatively high, which means that the first answer content output by the Q&A model is not a random answer, but an answer based on the trained data, that is, the query information input into the Q&A model is the data that the Q&A model has been trained on. Therefore, its answer is accurate, and the first answer content can be determined as the answer result corresponding to the query information. Subsequently, the answer result can also be sent to the client so that the client can display the answer result to the user.
[0097] When the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold, it indicates that the similarity between the first answer content and the similar answer content is relatively low. This shows that the first answer content output by the Q&A model may be a random answer based on free play, and it also indicates that the query information input into the Q&A model may be data that the Q&A model has not been trained on. Therefore, its answer is inaccurate. In this case, the information used to indicate that there is no answer can be determined as the answer result corresponding to the query information. The information used to indicate that there is no answer can be prompt text such as "unable to answer" or "unable to reply" for prompting that there is no answer, or it can be an empty (null) information, or other information that can indicate that there is no answer, so that the user can know that there is no answer result corresponding to the query information.
[0098] In one implementation, as Figure 3 shown, the above data query method may further include the following steps S160 to step S170.
[0099] Step S160: If the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold, then input the query information into the large model of the Retrieval-Augmented Generation (RAG) service, so that the large model of the RAG service generates the second answer content corresponding to the query information based on the knowledge base corresponding to the target scenario.
[0100] Among them, Retrieval-Augmented Generation (RAG for short) refers to an artificial intelligence technology that combines information retrieval technology and generative models, aiming to improve the quality and accuracy of text generation tasks. By retrieving relevant information from an external knowledge base and integrating it into the generation process, RAG can provide more accurate and context-related answers.
[0101] The large model in RAG can be a large model that has been trained in related technologies. The above knowledge base can be the same as the content in the above Q&A knowledge base. In order to make the reference information of the large model of RAG more abundant, in addition to including the Q&A knowledge in the above Q&A knowledge base, the above knowledge base can also include other knowledge corresponding to the target scenario. For example, it can include various reference documents, laws and regulations, historical archives, enterprise training materials, meeting minutes, project reports, policy documents, news reports, academic papers, technical manuals, etc. corresponding to the target scenario, but not limited to this.
[0102] Step S170: Generate the answer result corresponding to the query information according to the second answer content.
[0103] Specifically, the above-mentioned second answer content can be determined as the answer result corresponding to the query information. Alternatively, it can also be determined whether to determine the second answer content as the answer result or to determine the information indicating that no answer can be provided as the answer result corresponding to the query information based on whether the second answer content meets the accuracy requirement.
[0104] In this embodiment, the RAG service is introduced, so that when the question-and-answer model cannot obtain accurate answer content, the RAG service with stronger data query capabilities can be used for answering. Due to the powerful question-answering ability of the large model in the RAG service and the rich knowledge of the target scenario in the knowledge base, more accurate answers can be obtained.
[0105] In a specific embodiment, as Figure 3 shown, step S170 can be implemented according to the following steps S171 to S173.
[0106] Step S171: Detect whether the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold.
[0107] The specific execution process of step S171 is similar to that of step S140, and will not be elaborated here.
[0108] Step S172: If the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold, determine the second answer content as the answer result corresponding to the query information.
[0109] Step S173: If the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, determine the information indicating that no answer can be provided as the answer result corresponding to the query information.
[0110] The execution processes and related descriptions of steps S172 and S173 can refer to step S150. In this embodiment, the second answer content is compared with the similar answers, and the second answer content can be verified through the similar answers. When the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold, it indicates that the similarity between the second answer content and the similar answer content is relatively high, which means that the second answer content output by the large model is relatively accurate, and the second answer content can be determined as the answer result corresponding to the query information. When the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, it indicates that the similarity between the second answer content and the similar answer content is relatively low, which means that the second answer content output by the large model is inaccurate. In this case, the information indicating that the answer cannot be provided can be determined as the answer result corresponding to the query information, so that the user can know that the answer result corresponding to the query information cannot be queried.
[0111] In a specific embodiment, before step S160, the above method may further include the following step S180.
[0112] Step S180: Detect whether to enable the Retrieval-Augmented Generation (RAG) service, which is used to generate answer content through the large model and the knowledge base corresponding to the target scenario.
[0113] Since the access cost of the RAG service is relatively high, this application provides an option to enable it selectively, and developers can choose whether to enable the RAG service according to actual needs. When it is detected that the RAG service is enabled, step S160 is then executed, which can avoid query errors. When it is detected that the RAG service is not enabled, the information indicating that the answer cannot be provided can be determined as the answer result corresponding to the query information.
[0114] In one implementation, when there are multiple similar answer contents, step S140 may specifically detect whether the similarity between the first answer content and at least one of the multiple similar answer contents is greater than the first preset similarity threshold.
[0115] For example, step S140 may detect whether the similarity between the first answer content and each of the multiple similar answer contents is greater than the first preset similarity threshold. In this case, the similarity between the first answer content and the similar answer content in step S150 is greater than the first preset similarity threshold, that is, the similarity between the first answer content and each of the similar answer contents is greater than the first preset similarity threshold. This situation can make the determined answer result more accurate.
[0116] Alternatively, it is also possible to detect whether the similarity between the first answer content and any one of the multiple similar answer contents is greater than a first preset similarity threshold. In this case, the similarity between the first answer content and the similar answer content in step S150 is greater than the first preset similarity threshold, that is, the similarity between the first answer content and any one of the similar answer contents is greater than the first preset similarity threshold. This situation can not only better ensure the accuracy of the answer result, but also better avoid misjudging the first answer content as an inaccurate answer, so as to obtain an accurate answer result more quickly.
[0117] In one implementation, before step S120, the following step S120a may further be included.
[0118] Step S120a: Search for the answer knowledge corresponding to the question that is consistent with the query information from the pre-set Q&A knowledge base corresponding to the target scenario, and determine this answer knowledge as the answer result corresponding to the query information.
[0119] The question that is consistent with the query information may be the same question as the query information, that is, the query information is the same as this consistent question. Or, the question that is consistent with the query information may also be a question whose similarity to the query information is greater than a third preset similarity, where the third preset similarity is greater than the first preset similarity and the second preset similarity, and the third preset similarity may be set to a relatively large value. For example, the gap between the third preset similarity and the similarity when they are the same is less than a preset gap. If the similarity when they are the same is 100%, then the gap between the third preset similarity and 100% may be less than 10%, that is, the third preset similarity is a value in the range of 90% to 100%. In this case, it indicates that there is a question in the Q&A knowledge base that is the same as or basically the same as the query information, and directly determining the answer corresponding to this question as the answer result corresponding to the query information can not only accurately obtain the answer result, but also improve the query efficiency.
[0120] If step S120a fails to find a question that is consistent with the query information from the Q&A knowledge base, then step S120 is executed. That is to say, in the case of not finding a question that is consistent with the query information, the subsequent step of finding the answer result through the Q&A model is executed. In this way, when the question to be searched exists in the Q&A knowledge base, the answer can be directly obtained, saving the subsequent query process and ensuring the query accuracy rate.
[0121] In one implementation, when the above data query method is applied to the server, the above data query method may further include the following steps S190 to step S1100.
[0122] Step S190: If it is detected that the artificial service condition is satisfied, send the query information to the artificial end, so that the artificial end displays the query information, obtains the artificial answer content corresponding to the query information input by the artificial end, and sends the artificial answer content to the server.
[0123] Among them, the artificial service condition includes at least one of the following: the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold and it is detected that the RAG service is not enabled.
[0124] The above artificial end is the device end corresponding to the artificial customer service. The artificial customer service can provide answers to various questions at the artificial end and send them to the server.
[0125] Step S1100: Obtain the artificial answer content from the artificial end, and determine the artificial answer content as the answer result corresponding to the query information.
[0126] In this embodiment, by setting the artificial end, the artificial customer service can answer the questions that are not accurately answered by both the question-and-answer model and the RAG service through the artificial end, so that the user can obtain an accurate answer result.
[0127] In one embodiment, the above data query method may further include the following steps: Update the artificial answer result and the query information as a question-and-answer pair in the question-and-answer knowledge base, so that it can provide a reference basis for subsequent question-and-answer queries.
[0128] The data query method provided by the embodiments of the present application obtains query information in a target scenario, and searches for the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement in the question-and-answer knowledge base corresponding to the preset target scenario. Since the similar question is similar to the query information, there is a relatively high probability that the similar answer content corresponding to the similar question is the correct answer corresponding to the query information. However, since there are usually still certain differences between the similar question and the query information, and there may be multiple similar questions, it is impossible to ensure that the similar answer content is the actual answer corresponding to the query information, and there may sometimes be multiple similar questions, and it is impossible to control which similar question is the actual answer corresponding to the query information. Therefore, the present application will also generate the first answer content corresponding to the query information based on a pre-trained question-and-answer model. Since the question-and-answer model is trained with the question-and-answer knowledge in the question-and-answer knowledge base as samples, the question-and-answer model can accurately answer the trained questions, and the question-and-answer model can learn the structure and semantics of the language by training a large amount of text data, so that the model can understand the semantics of the input query information, thereby generating an answer content that matches the semantics of the query information. In this way, the question-and-answer model can not only accurately understand the semantics of the query information, but also accurately answer the questions with the same semantics that have been trained. However, for the questions that the question-and-answer model has not been trained on, the answer content of the question-and-answer model may be relatively low. Therefore, the present application will detect whether the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold. If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, it indicates that the query information is a question that the question-and-answer model has been trained on, indicating that the first answer content generated by the question-and-answer model is accurate. In this case, the first answer content can be determined as the answer result corresponding to the query information and fed back to the user.
[0129] It can be seen that the solution provided by the present application determines the first answer content as the answer result corresponding to the query information only when the first answer content generated by the question-and-answer model is relatively similar to the similar answer content in the knowledge base, that is, uses the similar answer content in the knowledge base to verify the accuracy of the first answer content generated by the model, so as to avoid feeding back the inaccurate answers generated by the model for questions that have not been trained to the user, and can better avoid providing inaccurate answers to the user, so as to provide more accurate answers to the user, thereby reducing the situation of misleading the user caused by providing inaccurate answers.
[0130] The following introduces the process of the data query method provided by the present application through specific examples. As Figure 4 shown, the data query method provided in this example includes the following steps 1 to 11, and the execution subject of this example is the server.
[0131] Step 1: Obtain the query information input by the user on the client side of the Q&A interaction system.
[0132] Step 2: Determine whether it is possible to find the answer knowledge corresponding to the question that matches the query information in the Q&A knowledge base.
[0133] The process of Step 2 is to determine whether a question that matches the query information can be found in the Q&A knowledge base.
[0134] Step 3: If the answer knowledge corresponding to the question that matches the query information can be found in Step 2, then send the answer knowledge as the answer result to the client.
[0135] Step 4: If the answer knowledge corresponding to the question that matches the query information cannot be found in Step 2, then send the query information to the AI engineering service.
[0136] The AI engineering service is used to query information through the Q&A model and the RAG service.
[0137] Step 5: Search for the N similar answer contents corresponding to the N similar questions with the highest similarity to the query information in the vector database.
[0138] The vector database is the Q&A knowledge base in vector form.
[0139] Step 6: Input the query information into the Q&A model to obtain the first answer content.
[0140] The Q&A model can be a model obtained by fine-tuning a large model in the STF fine-tuning manner.
[0141] Step 7: Perform result comparison to determine whether the similarity between the first answer content and the similar answer contents is greater than the first preset similarity threshold.
[0142] Determining whether the similarity between the first answer content and the similar answer contents is greater than the first preset similarity threshold is to compare whether the first answer content is accurate.
[0143] Step 8: If the judgment result in Step 7 is greater, then send the first answer content to the result assembly module for result assembly. The result assembly module determines the second answer content as the answer result and sends it to the client.
[0144] The judgment result in Step 7 being greater indicates that the first answer content is accurate.
[0145] Step 9: If the judgment result in Step 7 is less than or equal, then determine whether to enable the RAG service.
[0146] If the judgment result in Step 7 is less than or equal, it indicates that the first answer content is inaccurate, which means that the query information is untrained content.
[0147] Step 10: If the judgment result in Step 9 is yes, determine the second answer content corresponding to the query information through the RAG service, and perform a fallback verification to determine whether the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold (i.e., perform a fallback verification). If it is greater, send the second answer content to the result assembly module for result assembly, and the result assembly module sends the second answer content to the client as the answer result.
[0148] Step 11: If the judgment result in Step 9 is no, send the judgment result to the result assembly module, and the result assembly module determines the information indicating that the answer cannot be provided as the answer result corresponding to the query information and sends it to the client.
[0149] The execution process of each step in this example has been specifically introduced above, and this example will not be repeated.
[0150] Embodiment 2
[0151] The second embodiment of the present application also provides a data query method, which is applied to the server side. The method includes the following steps S210 to step S250.
[0152] Step S210: Obtain the query information in the target scenario input by the user from the client.
[0153] Step S220: Search in the Q&A knowledge base corresponding to the target scenario set in advance for the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement.
[0154] Step S230: Generate the first answer content corresponding to the query information based on a pre-trained Q&A model, and the Q&A model is trained with the Q&A knowledge in the Q&A knowledge base as samples.
[0155] Step S240: Detect whether the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold.
[0156] Step S250: If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information.
[0157] Step S260: Send the answer result to the client so that the client can display the answer result.
[0158] This embodiment describes the data query method from the perspective of specific application scenarios. The execution processes of this embodiment are similar to those of the first embodiment. For the details of the relevant technical features and the achieved effects, please refer to the corresponding description of the data query method embodiment provided in the above first embodiment.
[0159] Embodiment III
[0160] The third embodiment of this application also provides a data query device corresponding to the data query method embodiment provided in the first embodiment. Since the device embodiment is basically similar to the method embodiment, the description is relatively simple. For the details of the relevant technical features and the achieved effects, please refer to the corresponding description of the data query method embodiment provided above. The data query device provided in this embodiment includes:
[0161] An acquisition unit, configured to acquire query information in a target scenario;
[0162] A search unit, configured to search, in the question-and-answer knowledge base corresponding to the preset target scenario, for similar answer content corresponding to a similar question whose similarity to the query information meets a preset similarity requirement;
[0163] A generation unit, configured to generate first answer content corresponding to the query information based on a pre-trained question-and-answer model, where the question-and-answer model is trained using the question-and-answer knowledge in the question-and-answer knowledge base;
[0164] A detection unit, configured to detect whether the similarity between the first answer content and the similar answer content is greater than a first preset similarity threshold;
[0165] A determination unit, configured to, if the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information.
[0166] Optionally, the search unit is specifically configured to search, in the question-and-answer knowledge base corresponding to the preset target scenario, for answer knowledge corresponding to a question that is consistent with the query information, and determine the answer knowledge as the answer result corresponding to the query information; if no question that is consistent with the query information is found in the question-and-answer knowledge base, search for similar answer content corresponding to a similar question whose similarity to the query information meets a preset similarity requirement in the question-and-answer knowledge base corresponding to the preset target scenario.
[0167] Optionally, the determination unit is further configured to: if the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold, determine information indicating that an answer cannot be provided as the answer result corresponding to the query information.
[0168] Optionally, the generating unit is further configured to: if the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold, input the query information into the large model of the retrieval-augmented generation (RAG) service, so that the large model generates the second answer content corresponding to the query information based on the knowledge base corresponding to the target scenario;
[0169] The determining unit is further configured to: generate the answer result corresponding to the query information according to the second answer content.
[0170] Optionally, the detecting unit is further configured to: detect whether the retrieval-augmented generation (RAG) service is enabled, and the retrieval-augmented generation (RAG) service is used to generate answer content through a large model and the knowledge base corresponding to the target scenario;
[0171] The generating unit is specifically configured to: if the retrieval-augmented generation (RAG) service is enabled, perform the step of inputting the query information into the large model of the retrieval-augmented generation (RAG) service.
[0172] Optionally, the determining unit is specifically configured to: detect whether the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold; if the similarity between the second answer content and the similar answer content is greater than the first preset similarity threshold, determine the second answer content as the answer result corresponding to the query information; if the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, determine the information indicating that the question cannot be answered as the answer result corresponding to the query information.
[0173] Optionally, there are multiple pieces of the similar answer content, and the detecting unit is specifically configured to:
[0174] detect whether the similarity between the first answer content and at least one of the multiple pieces of similar answer content is greater than the first preset similarity threshold.
[0175] Optionally, the searching unit is specifically configured to:
[0176] search for each piece of similar answer content corresponding to each similar question whose similarity to the query information is greater than the second preset similarity threshold from the pre-set Q&A knowledge base corresponding to the target scenario.
[0177] Optionally, the searching unit is specifically configured to:
[0178] search for N pieces of similar answer content corresponding to N similar questions whose similarity to the query information is among the top N from the pre-set Q&A knowledge base corresponding to the target scenario, where N is an integer greater than 1.
[0179] Optionally, the Q&A knowledge in the Q&A knowledge base is Q&A knowledge in vector form.
[0180] Optionally, the device is applied to a server, and the device further includes:
[0181] An artificial generation unit, configured to, if it is detected that the artificial service condition is satisfied, send the query information to the artificial end, so that the artificial end displays the query information, and obtain the artificial answer content corresponding to the query information input by the artificial end, and send the artificial answer content to the server; wherein, the artificial service condition includes at least one of the following: the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold and it is detected that the RAG service is not enabled; obtain the artificial answer content from the artificial end, and determine the artificial answer content as the answer result corresponding to the query information.
[0182] Optionally, the device further includes:
[0183] An update unit, configured to update the artificial answer result and the query information as a Q&A pair in the Q&A knowledge base.
[0184] Embodiment 4
[0185] The fourth embodiment of the present application also provides an electronic device embodiment corresponding to the data query method provided in the first embodiment. The following description of the electronic device embodiment is only illustrative. The electronic device embodiment is as follows:
[0186] Please refer to Figure 5 to understand the above electronic device, Figure 5 is a schematic diagram of the electronic device. The electronic device provided in this embodiment includes: a processor 1001, a memory 1002, a communication bus 1003, and a communication interface 1004;
[0187] The memory 1002 is used to store computer instructions for data processing. When the computer instructions are read and executed by the processor 1001, the following steps are performed:
[0188] Obtain query information in a target scenario;
[0189] Search in the Q&A knowledge base corresponding to the target scenario set in advance for similar answer content corresponding to similar questions whose similarity to the query information meets the preset similarity requirement;
[0190] Generate a first answer content corresponding to the query information based on a pre-trained Q&A model, and the Q&A model is trained with the Q&A knowledge in the Q&A knowledge base as samples;
[0191] Detect whether the similarity between the first answer content and the similar answer content is greater than a first preset similarity threshold;
[0192] If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information.
[0193] The fifth embodiment of the present application also provides a computer-readable storage medium for implementing the method described in the first embodiment. The description of the computer-readable storage medium embodiment provided in the present application is relatively simple. For the relevant parts, please refer to the corresponding description of the above method embodiment. The following described embodiments are only illustrative.
[0194] The computer-readable storage medium provided in this embodiment stores computer instructions, and when the instructions are executed by a processor, the following steps are implemented:
[0195] Obtain query information in a target scenario;
[0196] Search in the question-and-answer knowledge base corresponding to the target scenario set in advance for similar answer content corresponding to similar questions whose similarity to the query information meets the preset similarity requirement;
[0197] Generate the first answer content corresponding to the query information based on a pre-trained question-and-answer model, and the question-and-answer model is trained with the question-and-answer knowledge in the question-and-answer knowledge base as samples;
[0198] Detect whether the similarity between the first answer content and the similar answer content is greater than a first preset similarity threshold;
[0199] If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information.
[0200] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0201] Memory may include non-permanent memory in computer-readable media, random access memory (RAM) and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0202] 1. A computer-readable medium includes both permanent and non-permanent, removable and non-removable media that can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information accessible by a computing device. As defined herein, a computer-readable medium does not include transitory media such as modulated data signals and carrier waves.
[0203] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0204] Although the present application is disclosed above in preferred embodiments, it is not intended to limit the present application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be determined by the scope defined by the claims of the present application.
Claims
1. A data query method, characterized in that, The method includes: Obtaining query information in a target scenario; Searching in a pre-set Q&A knowledge base corresponding to the target scenario for similar answer content corresponding to a similar question whose similarity to the query information meets a pre-set similarity requirement; Generating first answer content corresponding to the query information based on a pre-trained Q&A model, where the Q&A model is trained with Q&A knowledge in the Q&A knowledge base as samples; Detecting whether the similarity between the first answer content and the similar answer content is greater than a first pre-set similarity threshold; If the similarity between the first answer content and the similar answer content is greater than the first pre-set similarity threshold, determining the first answer content as the answer result corresponding to the query information.
2. The data query method according to claim 1, wherein Before searching in a pre-set Q&A knowledge base corresponding to the target scenario for similar answer content corresponding to a similar question whose similarity to the query information meets a pre-set similarity requirement, the method further includes: Searching in a pre-set Q&A knowledge base corresponding to the target scenario for answer knowledge corresponding to a question that is consistent with the query information, and determining the answer knowledge as the answer result corresponding to the query information; If no question that is consistent with the query information is found in the Q&A knowledge base, performing the step of searching in a pre-set Q&A knowledge base corresponding to the target scenario for similar answer content corresponding to a similar question whose similarity to the query information meets a pre-set similarity requirement.
3. The data query method according to claim 1, wherein The method further includes: If the similarity between the first answer content and the similar answer content is less than or equal to the first pre-set similarity threshold, determining information indicating that an answer cannot be provided as the answer result corresponding to the query information.
4. The data query method according to claim 1, wherein The method further includes: If the similarity between the first answer content and the similar answer content is less than or equal to the first pre-set similarity threshold, inputting the query information into a large model of a retrieval-augmented generation (RAG) service, so that the large model generates second answer content corresponding to the query information based on a knowledge base corresponding to the target scenario; Generating an answer result corresponding to the query information according to the second answer content.
5. The data query method according to claim 4, wherein Before inputting the query information into a large model of a retrieval-augmented generation (RAG) service, the method further includes: Detecting whether the retrieval-augmented generation (RAG) service is enabled, where the retrieval-augmented generation (RAG) service is used to generate answer content through a large model and a knowledge base corresponding to the target scenario; If the retrieval-augmented generation (RAG) service is enabled, performing the step of inputting the query information into a large model of the retrieval-augmented generation (RAG) service.
6. The data query method according to claim 4, wherein The generating an answer result corresponding to the query information according to the second answer content includes: Detecting whether the similarity between the second answer content and the similar answer content is greater than the first pre-set similarity threshold; If the similarity between the second answer content and the similar answer content is greater than the first pre-set similarity threshold, determining the second answer content as the answer result corresponding to the query information; If the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, the information indicating that the answer cannot be provided is determined as the answer result corresponding to the query information.
7. The data query method according to claim 1, wherein There are multiple pieces of the similar answer content. Detecting whether the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold includes: Detecting whether the similarity between the first answer content and at least one of the multiple pieces of similar answer content is greater than the first preset similarity threshold.
8. The data query method according to claim 7, characterized in that, Searching for the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement from the pre-set Q&A knowledge base corresponding to the target scenario includes: Searching for each piece of similar answer content corresponding to each similar question whose similarity to the query information is greater than the second preset similarity threshold from the pre-set Q&A knowledge base corresponding to the target scenario.
9. The data query method according to claim 7, wherein Searching for the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement from the pre-set Q&A knowledge base corresponding to the target scenario includes: Searching for N pieces of similar answer content corresponding to N similar questions whose similarity to the query information ranks among the top N from the pre-set Q&A knowledge base corresponding to the target scenario, where N is an integer greater than 1.
10. The data query method according to claim 1, wherein The Q&A knowledge in the Q&A knowledge base is in vector form.
11. The data query method according to claim 4, wherein The method is applied to the server side, and the method further includes: If it is detected that the artificial service condition is met, the query information is sent to the artificial side, so that the artificial side displays the query information, and obtains the artificial answer content corresponding to the query information input by the artificial side, and sends the artificial answer content to the server side; where the artificial service condition includes at least one of the following: the similarity between the second answer content and the similar answer content is less than or equal to the first preset similarity threshold, the similarity between the first answer content and the similar answer content is less than or equal to the first preset similarity threshold and it is detected that the RAG service is not enabled. Obtaining the artificial answer content from the artificial side and determining the artificial answer content as the answer result corresponding to the query information.
12. The data query method according to claim 11, wherein The method further includes: Updating the artificial answer result and the query information as a Q&A pair in the Q&A knowledge base.
13. A data query method, characterized in that, Applied to the server side, the method includes: Obtaining the query information input by the user in the target scenario from the client; Searching for the similar answer content corresponding to the similar question whose similarity to the query information meets the preset similarity requirement from the pre-set Q&A knowledge base corresponding to the target scenario; Generating the first answer content corresponding to the query information based on the pre-trained Q&A model, and the Q&A model is trained with the Q&A knowledge in the Q&A knowledge base as samples; Detecting whether the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold; If the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determine the first answer content as the answer result corresponding to the query information; Send the answer result to the client so that the client can display the answer result.
14. A data query device, characterized in that, The device includes: An acquisition unit for acquiring query information in a target scenario; A search unit for searching, in the Q&A knowledge base corresponding to the target scenario set in advance, for similar answer content corresponding to a similar question whose similarity to the query information meets a preset similarity requirement; A generation unit for generating, based on a pre-trained Q&A model, the first answer content corresponding to the query information, where the Q&A model is trained using the Q&A knowledge in the Q&A knowledge base as samples; A detection unit for detecting whether the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold; A determination unit for, if the similarity between the first answer content and the similar answer content is greater than the first preset similarity threshold, determining the first answer content as the answer result corresponding to the query information.
15. An electronic device, characterized in that, It includes: A processor, a memory, and computer program instructions stored on the memory and executable on the processor; When the processor executes the computer program instructions, the method described in any one of claims 1-13 above is implemented.
16. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by the processor, the method described in any one of claims 1-13 above is implemented.