Question and answer method and device, equipment and storage medium

By identifying the intent and slots of the target problem in the question-and-answer system, determining the data query type based on the intent, and selecting appropriate query strategies, the problem of poor flexibility in the existing question-and-answer system is solved, and more efficient data processing and query is achieved.

CN118897879APending Publication Date: 2024-11-05CHINA MERCHANTS BANK

Patent Information

Application Number
CN202410853252.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-11-05

AI Technical Summary

Technical Problem

The existing question-and-answer system lacks flexibility when dealing with user problems and cannot effectively analyze and answer the characteristics of query data, resulting in poor processing speed and flexibility.

Method used

By obtaining target problems, intent identification and slot identification, determine the data query type corresponding to the target intent, and call the corresponding query strategy to query the target slots, flexibly adjust the data query method based on the characteristics of the query data.

Benefits of technology

It improves the speed, flexibility and scalability of data processing and query, and can respond to user problems more accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118897879A_ABST
    Figure CN118897879A_ABST
Patent Text Reader

Abstract

The invention discloses a question and answer method, device and equipment and a storage medium, and relates to the technical field of artificial intelligence. The question and answer method comprises the steps of obtaining a target question; performing intention recognition and slot recognition on the target problem to obtain a target intention and a target slot; and determining a data query type corresponding to the target intention, calling a query strategy corresponding to the data query type to query a request body corresponding to the target slot position, and returning an answer. According to the method, the data query mode can be flexibly adjusted in combination with the characteristics of the query data, and the speed, flexibility and expansibility of data processing and query are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering method, apparatus, device, and storage medium. Background Art

[0002] With the continuous development of natural language processing technology, intelligent question answering systems have gradually become a research hotspot. These systems can extract knowledge from a large number of documents and give accurate answers to users' questions.

[0003] Conventional question-answering processing methods usually directly match the contents of all files in the pre-built file database with the user's questions by keywords, and then find the most relevant content to the user's question as the knowledge background for answering the user's question. However, this solution cannot analyze and answer the query data based on its characteristics, and the flexibility of the question-answering solution is poor. Summary of the invention

[0004] The main purpose of this application is to provide a question-answering method, device, equipment and storage medium, aiming to solve the technical problem of poor flexibility of existing question-answering solutions.

[0005] To achieve the above purpose, the present application provides a question-answering method, which includes:

[0006] Get the target question;

[0007] Performing intent recognition and slot recognition on the target problem to obtain a target intent and a target slot;

[0008] Determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

[0009] In one embodiment, the step of performing intent recognition and slot recognition on the target question to obtain the target intent and the target slot includes:

[0010] Similar questions that meet preset similarity conditions with the target question are screened out from multiple historical questions in a preset question database, and intentions and slots corresponding to the similar questions are screened out in the preset question database to obtain a target intention and a target slot.

[0011] In one embodiment, the step of selecting similar questions that meet preset similarity conditions with the target question from a plurality of historical questions in a preset question database, and selecting intents and slots corresponding to the similar questions in the preset question database to obtain the target intent and target slot comprises:

[0012] Performing feature processing on the target problem to obtain target problem features;

[0013] Calculating the similarity between the target question feature and each historical question feature in the preset question database;

[0014] Based on the similarity between the target question feature and each of the historical question features, similar features are screened out from the multiple historical question features in the preset question database to obtain the similar question from the historical questions corresponding to the similar features, and the intentions and slots corresponding to the similar questions are screened out in the preset database to obtain the target intention and the target slot.

[0015] In one embodiment, the preset question database includes a first question database and a second question database; based on the similarity between the target question feature and each of the historical question features, similar features are screened out from the multiple historical question features in the preset question database to obtain the similar question from the historical questions corresponding to the similar features, and the intent and slot corresponding to the similar question are screened out in the preset database, and the step of obtaining the target intent and the target slot includes:

[0016] Screening out at least one candidate feature from a plurality of historical question features in the first question database, the candidate feature having a similarity with the target question feature greater than a preset threshold;

[0017] If there is a candidate feature consistent with the target question feature among the at least one candidate feature, then searching the first question database for a candidate feature consistent with the target question feature as the similar feature, and searching the first question database for a question identifier corresponding to the similar feature to obtain a similar question identifier, so as to determine the similar question by the similar question identifier;

[0018] The intent and slot corresponding to the similar question identifier are searched in the second question database to obtain the target intent and the target slot.

[0019] In one embodiment, after the step of selecting at least one candidate feature having a similarity with the target question feature greater than a preset threshold from the plurality of question features in the first question database, the step further includes:

[0020] If there is no candidate feature consistent with the target question feature among the at least one candidate feature, one of the candidate features is selected as the similar feature from the at least one candidate feature, and a question identifier corresponding to the similar feature is searched in the first question database to obtain a similar question identifier.

[0021] In one embodiment, after the step of selecting at least one candidate feature having a similarity with the target question feature greater than a preset threshold from the plurality of question features in the first question database, the step further includes:

[0022] If there is no candidate feature consistent with the target question feature in the at least one similar feature, semantic recognition is performed on the target question through a pre-trained large language model to obtain the real intent and real slot corresponding to the target question;

[0023] Construct and store the association between the target question, the real intention and the real slot in the preset question database.

[0024] In one embodiment, the step of determining the data query type corresponding to the target intent, and calling the query strategy corresponding to the data query type to query the request body corresponding to the target slot and then returning the answer includes:

[0025] Determine the data query type corresponding to the target intent based on preset business rules;

[0026] If the data query type is real-time query, calling the first query strategy;

[0027] When the query strategy called is the first query strategy, selecting a preset query interface corresponding to the target intent to perform data query, and generating a target call request for the preset query interface based on the target intent;

[0028] Calling the preset query interface through the target call request to query the request body corresponding to the target slot to obtain the answer;

[0029] If the data query type is a non-real-time query, calling a second query strategy;

[0030] When the query strategy called is the second query strategy, a preset domain knowledge base corresponding to the target intent is selected for data query, and a target query statement is generated based on the target slot;

[0031] The target query statement is used to query the request body corresponding to the target slot in the preset domain knowledge base to obtain the answer.

[0032] In one embodiment, the step of generating a target call request for the preset query interface based on the target intent includes:

[0033] Based on the target intent, determining whether parameters need to be passed when calling the preset query interface for data query;

[0034] If so, obtaining a preset first request template corresponding to the target intent, and filling the request body in the preset first request template based on the target slot to obtain the target call request;

[0035] If not, a preset second request template corresponding to the target intent is called as the target call request.

[0036] In one embodiment, the step of invoking the preset query interface through the target call request to query the request body corresponding to the target slot to obtain the answer includes:

[0037] Executing the target call request to call the preset query interface, and receiving response data for the request body returned by the preset query interface;

[0038] Desensitizing the response data to obtain desensitized response data;

[0039] Obtain a preset reply template corresponding to the target intent, and fill the desensitized response data into the preset reply template to obtain the answer.

[0040] In addition, to achieve the above purpose, the present application also provides a question-answering device, which includes:

[0041] A question acquisition module is used to obtain the target question;

[0042] An intention slot acquisition module, used to perform intention recognition and slot recognition on the target problem to obtain a target intention and a target slot;

[0043] The query module is used to determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

[0044] In addition, to achieve the above-mentioned purpose, the present application also provides a question-and-answer device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the question-and-answer method as described above.

[0045] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, which is a computer-readable storage medium, and a program for implementing the question-and-answer method is stored on the computer-readable storage medium. The program for implementing the question-and-answer method is executed by a processor to implement the steps of the question-and-answer method as described above.

[0046] The present application provides a question-and-answer method, apparatus, device, and storage medium, which obtains a target question; performs intent recognition and slot recognition on the target question to obtain a target intent and a target slot; determines the data query type corresponding to the target intent, and calls a query strategy corresponding to the data query type to query the request body corresponding to the target slot and returns an answer. The present application identifies the target intent and target slot corresponding to the target question, determines the data query type based on the target intent, and selects the corresponding query strategy based on the data query type to query the request body corresponding to the target slot. In this way, the data query method can be flexibly adjusted in combination with the characteristics of the query data, thereby improving the speed, flexibility, and scalability of data processing and querying. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0049] Figure 1 A flowchart diagram of an embodiment of the question-and-answer method of this application;

[0050] Figure 2 A flowchart diagram of another embodiment of the question-and-answer method of the present application;

[0051] Figure 3 This is a schematic diagram of the module structure of the question-answering device according to an embodiment of the present application;

[0052] Figure 4 A schematic diagram of the device structure of the hardware operating environment involved in the question-and-answer method in the embodiment of the present application.

[0053] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0054] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0055] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0056] The main solution of this application is: obtain the target question; perform intent recognition and slot recognition on the target question to obtain the target intent and target slot; determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

[0057] In current question-answering processing methods, the contents of all files in a pre-built file database are usually directly matched with the user's questions by keywords, and the most relevant content is found as the knowledge background for answering the user's questions. However, this solution cannot analyze and answer the query data based on its characteristics, and the flexibility of the question-answering solution is poor.

[0058] The present application identifies the target intent and target slot corresponding to the target question, determines the data query type based on the target intent, and selects the corresponding query strategy based on the data query type to query the request body corresponding to the target slot. In this way, the data query method can be flexibly adjusted according to the characteristics of the query data, thereby improving the speed, flexibility and scalability of data processing and query.

[0059] Explanation of the technical terms involved in this application:

[0060] Intent: In natural language processing tasks, intent refers to the purpose of the user's question. For example, if the user says "Book a ticket for the Wolf Warriors movie this afternoon", the system needs to recognize that the user's intent is to book a movie ticket.

[0061] Slot: It can be understood as a clearly defined attribute of an entity. For example, after the system recognizes the intent of "ordering movie tickets", it will recognize that the slots that need to be filled for this intent include information such as the movie name, theater name, time, quantity, and seat location, and there are corresponding slots for movie name, theater name, time, quantity, and seat location.

[0062] It should be noted that the execution subject of this embodiment may be a question-and-answer device, or a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a question-and-answer device capable of realizing the above functions, etc., and this embodiment does not specifically limit this. The following takes the question-and-answer device as an example to illustrate this embodiment and the following embodiments.

[0063] Based on this, the present application embodiment proposes a question-and-answer method, please refer to Figure 1 The question-answering method of this embodiment includes steps S10 to S30:

[0064] Step S10, obtaining the target question.

[0065] In the solution of this embodiment, the target question may be a question input by the user in the question input box of the interactive interface, or may be a question asked by the user in voice on the interactive client.

[0066] Step S20, perform intent recognition and slot recognition on the target question to obtain the target intent and target slot.

[0067] In a feasible implementation, the above step S20 may include: performing intent recognition and slot recognition on the target question through a pre-trained large language model to obtain a target intent and a target slot.

[0068] Through this implementation, intent recognition can be performed based on the original text information of the target question, and the accuracy of intent recognition and slot recognition is higher.

[0069] In another feasible implementation, the above step S20 may include: screening out similar questions that meet preset similarity conditions with the target question from multiple historical questions in the preset question database, and screening out the intents and slots corresponding to the similar questions in the preset question database to obtain the target intent and target slot. Specifically, the preset question database stores relevant processing record information for each historical question. The relevant processing record information may include: the intent and slot corresponding to each historical question. The intent and slot corresponding to each historical question may be obtained by performing semantic recognition on each historical question through a pre-trained large language model. It should be noted that a question may include one or more intents, and each intent may correspond to one or more slots.

[0070] Compared with the above implementation, the present implementation stores a large number of problem handling records in a database, retrieves the problem handling records based on the huge number of processing records, and responds to user questions based on the acquired problem handling records. The response speed is faster and will not be affected by the resources and tokens of the large language model, and can also be met in high-performance scenarios.

[0071] Step S30, determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

[0072] In this embodiment, the question-answering device can obtain a preset business rule, which is configured with multiple intents within the preset intent range, for example, defining an intent Figure 1 ,meaning Figure 2Within the preset intention range. Then, by judging whether the target intention is within the preset intention range, the data query type corresponding to the target intention can be determined. Specifically, the data query type can include real-time query and non-real-time query. Real-time query means that the request query data corresponding to the target question is real-time type data, that is, it does not belong to data that changes in a short period of time, for example, when the target question is "What is the temperature today?". Non-real-time query means that the request query data corresponding to the target question is non-real-time type data, that is, it belongs to data that will not change for a long time. For example, when the target question is "Who invented Newton's law?", the data query type corresponding to the target question is non-real-time query. When the target intention is not within the preset intention range, the data query type corresponding to the target intention is determined to be real-time query; when the target intention is within the preset intention range, the data query type corresponding to the target intention is determined to be non-real-time query.

[0073] After determining the data query type corresponding to the target intent, the question-and-answer device can read the pre-constructed correspondence between the data query type and the query strategy from the storage module, determine the corresponding query strategy, and call the corresponding query strategy to query the request body corresponding to the target slot and return the answer.

[0074] Specifically, the request body corresponding to the target slot refers to the entity value or attribute value corresponding to the target slot. For example, if the target slot is the temperature, the request body corresponding to the target slot is the temperature value.

[0075] This embodiment uses the above scheme to obtain the target question; perform intent recognition and slot recognition on the target question to obtain the target intent and target slot; determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer. This application first identifies the target intent and target slot corresponding to the target question, and determines the data query type based on the target intent, and selects the corresponding query strategy based on the data query type to query the request body corresponding to the target slot. In this way, the data query method can be flexibly adjusted in combination with the characteristics of the query data, thereby improving the speed, flexibility and scalability of data processing and query.

[0076] Based on the above embodiment, in a feasible implementation manner, the above step S20 may include step S201:

[0077] Step S201: Filter out similar questions that meet preset similarity conditions with the target question from multiple historical questions in the preset question database, and filter out intents and slots corresponding to the similar questions in the preset question database to obtain the target intent and target slot.

[0078] In this embodiment, the target question can be feature processed to obtain the target question feature, and based on the target question feature, the intention and slot corresponding to the historical question that meets the preset similarity condition with the target question can be screened out in the preset question database to obtain the target intention and target slot. Exemplarily, the preset database contains multiple historical questions. When the similarity between the problem feature obtained after feature processing of a certain historical question and the target question feature is greater than a preset threshold, it is determined that the historical question and the target question meet the preset similarity condition. When calculating the similarity, algorithms such as cosine similarity, Euclidean distance, Manhattan distance or Pearson correlation coefficient can be used for calculation.

[0079] As a feasible implementation, the above step S201 may include: performing feature processing on the target question to obtain a target feature question; searching for a historical question corresponding to at least one historical question feature that satisfies a preset similarity condition with the target question feature in a preset question database to obtain at least one historical question that satisfies a preset similarity condition with the target question, selecting a historical question with the highest similarity from the at least one historical question, and selecting the intent and slot corresponding to the historical question with the highest similarity as the target intent and target slot based on the preset question database. Specifically, in this implementation, the preset question database stores the correspondence between question identifiers, questions, question features, intents, and slots.

[0080] As another feasible implementation, the above step S201 may include S2011 to S2013:

[0081] Step S2011, perform feature processing on the target problem to obtain the target problem features.

[0082] In the present embodiment, feature processing of the target problem to obtain the target problem feature may include: extracting the target problem feature using a preset feature extraction model to obtain the target problem feature, and the target problem feature may be a semantic vector of the target problem. The feature extraction model may specifically be a semantic vectorization model, for example, the semantic vectorization model may be any deep learning model such as BERT (Bidirectional Encoder Representations from Transformers) or LSTM (Long Short-Term Memory) that can convert text phrases and sentences into vectors.

[0083] Step S2012, calculating the similarity between the target question feature and each historical question feature in the preset question database.

[0084] When calculating similarity, algorithms such as cosine similarity, Euclidean distance, Manhattan distance, or Pearson correlation coefficient may be used for calculation.

[0085] Step S2013, based on the similarity between the target question feature and each historical question feature, similar features are screened out from the multiple historical question features in the preset question database to obtain similar questions from the historical questions corresponding to the similar features, and the intents and slots corresponding to the similar questions are screened out in the preset database to obtain the target intent and target slot.

[0086] Specifically, the preset question database may include a first question database and a second question database. The first question database only stores question identifiers and question features, and the second question database is used for question identifiers, original text information of questions, and intents and slots extracted from questions.

[0087] Furthermore, the above step S2013 may include steps A1 to A4:

[0088] Step A1, screening out at least one candidate feature whose similarity with the target question feature is greater than a preset threshold from multiple question features in the first question database.

[0089] The question-answering device may use algorithms such as cosine similarity, Euclidean distance, Manhattan distance, or Pearson correlation coefficient to calculate the similarity between the target question feature and each question feature in the first question database, and select question features with a similarity greater than a preset threshold as candidate features. The candidate features may include one or more.

[0090] Furthermore, since a single question may involve multiple intents, multiple candidate features need to be obtained when screening candidate selection. At the same time, due to the different ways of asking questions by users, the forms of questions asked by users for the same intent may be different. In order to ensure the efficiency of data processing by the system, an upper limit on the number of candidate features screened can be set. This upper limit can be set according to the upper limit on the number of intents involved in a single question.

[0091] Step A2: If there is a candidate feature consistent with the target question feature among at least one candidate feature, the candidate feature consistent with the target question feature is searched in the first question database as a similar feature, and the question identifier corresponding to the similar feature is searched in the first question database to obtain the similar question identifier, so as to determine the similar question by the similar question identifier.

[0092] Specifically, the first question database stores the correspondence between question features and question identifiers. If there is a candidate feature consistent with the target question feature in the first question database, the candidate feature consistent with the target question is used as a similar feature, and the question identifier corresponding to the similar feature is queried in the first question database as the target question identifier. At the same time, it can be determined that the question corresponding to the similar feature is consistent with the target question and meets the preset similarity condition.

[0093] Step A3: If there is no candidate feature consistent with the target question feature in at least one candidate feature, a candidate feature is selected from at least one candidate feature as a similar feature, and a question identifier corresponding to the similar feature is searched in the first question database to obtain a similar question identifier.

[0094] Specifically, if there is no candidate feature consistent with the target question feature in the first question database, a candidate feature is randomly selected from multiple candidate features in the first question database as a similar feature, and the problem identifier corresponding to the similar feature is determined through the first question database to obtain a similar problem identifier, and similar problems can be determined through the similar problem identifier. Alternatively, if there is no candidate feature consistent with the target question feature in the first question database, the candidate feature with the highest similarity is selected from multiple candidate features in the first question database as a similar feature.

[0095] Step A4, searching the second question database for the intent and slot corresponding to the similar question identifier to obtain the target intent and target slot.

[0096] Specifically, the second question database stores the question identifier, the original text information of the question, and the intent and slot extracted from the question. Therefore, after determining the similar question identifier, a similar question whose similarity to the target question meets the preset conditions can be determined, and the intent and slot of the historical question corresponding to the similar question identifier can be searched in the second question database to obtain the target intent and target slot.

[0097] Through the above scheme, by constructing the first question database and the second question database, the first question database stores question identifiers and question features, thereby using the similarity of feature space to quickly retrieve historical questions with high similarity to the target question without complex matching or analysis of the original text, thereby effectively reducing the data scale and improving query efficiency. The second question database is used to store the original text information of the question, as well as the intent and slot extracted from the question, which can be easily queried, updated and managed. The first question database and the second question database each play different roles, which can improve the efficiency of data query on the basis of increasing the data scale of database query.

[0098] In a feasible implementation manner, the question-answering method of this embodiment may further include step S260:

[0099] Step S260: Regularly clear the relevant processing record information of the questions in the first question database whose access times meet the preset access conditions; the relevant processing record information includes the question identifier corresponding to the question, the question characteristics and the record information of the corresponding relationship between the two.

[0100] Specifically, when the number of accesses is the least, it is determined that the number of accesses meets the preset access condition, or when the number of accesses is less than a preset number threshold, it is determined that the number of accesses meets the preset access condition.

[0101] Through the above solution, by regularly performing data cleaning operations on the first problem database, it is possible to ensure that the magnitude of the vector database is within a certain range without affecting the response rate.

[0102] In a feasible implementation manner, the above step A1 may further include steps A5 to A6:

[0103] Step A5: If there is no candidate feature consistent with the target question feature among at least one candidate feature, semantic recognition of the target question is performed through a pre-trained large language model to obtain the true intent and true slot corresponding to the target question.

[0104] Specifically, when there are no candidate features consistent with the target question features, that is, there are no historical questions consistent with the target question in the preset question database, the target intent is semantically recognized through a pre-trained large language model, where semantic recognition can include intent recognition and slot recognition, so as to obtain the real intent and real slot corresponding to the target question.

[0105] Furthermore, in order to improve the accuracy of intent recognition, when there is no candidate feature consistent with the target question feature among at least one candidate feature, the historical question corresponding to the similar feature with the highest similarity is determined, and the target business field involved in the historical question is determined, and the intent recognition and slot recognition are performed through the preset large language model corresponding to the target business field to obtain the true analysis result corresponding to the target question. Among them, each business field corresponds to each preset large language model. For example, when the business field is the medical field, it corresponds to the large language model A, which is specifically used to process text information in the medical field.

[0106] Step A6, construct and store the association between the target question, the real intention and the real slot in the preset question database.

[0107] After determining the real intent and real slot corresponding to the target question, the association relationship among the target question, the real intent and the real slot is constructed and stored in the preset question database. Specifically, the question identifier, the target question feature and the corresponding relationship between the question identifier and the target question feature are added to the first question database, and the target question identifier, the original text information of the target question, the real intent and the real slot and the processing record of the association relationship are added to the second question database.

[0108] Through the above scheme, when there is no historical question consistent with the target question in the preset question database, the processing record of the target question is saved in the preset question database, which can facilitate the subsequent question-answering system to identify the target question.

[0109] Based on the above implementation, in a feasible implementation, the above step S30 may include:

[0110] Step S301, determining the data query type corresponding to the target intent based on preset business rules.

[0111] Specifically, for the method of determining the data query type, please refer to the relevant content above, which will not be repeated here.

[0112] Step S302, if the data query type is a real-time query, the first query strategy is called; when the called query strategy is the first query strategy, a preset query interface corresponding to the target intent is selected for data query, and a target call request for the preset query interface is generated based on the target intent.

[0113] In the present embodiment, query strategies corresponding to different data query types are pre-configured. When the data query type is a real-time query, preset configuration information corresponding to the target intent is obtained, and the preset configuration information may include information such as a preset query interface, a preset first request template, a preset second request template, and a preset reply template corresponding to the target intent. Thus, the preset query interface can be determined through the preset configuration information corresponding to the target intent, and a target call request for the preset query interface can be generated based on the target intent.

[0114] Specifically, in the above step S302, generating a target call request for the preset query interface based on the target intent may include: based on the target intent, determining whether it is necessary to pass parameters when calling the preset query interface for data query; if so, obtaining a preset first request template corresponding to the target intent, and filling the request body in the preset call request template based on the target slot to obtain the target call request; if not, obtaining a preset second request corresponding to the target intent as the target call request. Among them, the preset first request template and the preset second request template are both call request templates corresponding to when calling the preset query interface, and the difference is that: the preset first request template does not contain the passing parameters, and the preset second request template contains the passing parameters.

[0115] For example, assuming the target intent is to query the weather in Guangzhou, the target slot is: Guangzhou, and the preset second request template corresponding to the target intent is GET / weather? city=[request body / passed parameters filled in], Host: weather-api.com; then fill the target slot to the preset call request template end, and the target call request obtained is: GET / weather? city=[Guangzhou], Host: weather-api.com. Assuming the target intent is to query the current time, the target slot is the current time, and the preset second request template corresponding to the target intent is GET / time HTTP / 1.1, Host:api.example.com, and the preset second request template is directly used to call the interface to obtain the answer.

[0116] Step S303, calling the preset query interface through the target call request to query the request body corresponding to the target slot to obtain the answer.

[0117] Specifically, the above step S303 may include steps S3031 to S3033:

[0118] Step S3031, executing the target call request to call the preset query interface, and receiving the response data for the request body returned by the preset query interface.

[0119] Step S3032, desensitize the response data to obtain desensitized response data.

[0120] Specifically, when desensitizing data, it can include: classifying each piece of information contained in the response data, distinguishing sensitive information from non-sensitive information and marking them; then, for the data marked as sensitive information, replacing, encrypting or masking them. For example, sensitive information can be encrypted using an encryption algorithm, or replaced with a randomly generated character sequence.

[0121] In this implementation scheme, considering that for real-time query type questions, the answers to the questions are retrieved through a third-party service interface and are not filtered. In order to improve the security of the data and retain the useful information and features of the data as much as possible, sensitive data will not be handed over to the large model for processing, and it will only be responsible for the parsing work.

[0122] Step S3033, obtain a preset reply template corresponding to the target intent, and fill the desensitized response data into the preset reply template to obtain an answer.

[0123] Specifically, for intentions within the preset intent range, there is corresponding configuration information. Therefore, the preset response template corresponding to the target intent can be extracted from the preset configuration information corresponding to the target intent, and the demolded feedback data can be filled into the preset response template to obtain the answer.

[0124] Step S304, if the data query type is a non-real-time query, the second query strategy is called; when the called query strategy is the second query strategy, a preset domain knowledge base corresponding to the target intent is selected for data query, and a target query statement is generated based on the target slot.

[0125] Specifically, when the data query type is a non-real-time query, it means that real-time data does not need to be obtained when retrieving the target question, and thus the answer can be obtained by performing a data query through a preset domain knowledge base corresponding to the target intent, wherein the preset domain knowledge base corresponding to the target intent is pre-configured.

[0126] Wherein, when generating a target query statement based on the target slot, it may include: filling a preset question template according to the target slot, generating a structured statement corresponding to the target question, and constructing the target query statement through the structured statement corresponding to the target question. Wherein, the target slot may include one or more.

[0127] Step S305, querying the request body corresponding to the target slot in the preset domain knowledge base through the target query statement to obtain the answer.

[0128] In the above embodiment, based on the preset question template and target slot corresponding to the target intent, it can be converted into a structured statement through the template filling method, and then the structured statement is used to build a Neo4j query statement, so that the target query statement can be used to query in the preset domain knowledge base to obtain the slot value corresponding to the target slot, and the slot value corresponding to each target slot is filled into the preset response template corresponding to the target slot to obtain the answer.

[0129] Through the above implementation plan, the data query type is determined by the target intent, and when the data query type is a real-time query, the answer is obtained by calling the interface. When the data query type is a non-real-time query, the answer is obtained by searching the preset domain knowledge base. In this way, the appropriate data query method for the target question can be analyzed, and the answer to the question can be retrieved using the appropriate data query method, which can improve the coverage of the question and answer function and the flexibility of the question and answer processing solution.

[0130] For example, please refer to Figure 2 , Figure 2 A brief flowchart of a question-answering method is provided, as follows:

[0131] First, after receiving the target question raised by the user, the target feature is processed to obtain the target feature vector, and based on the target feature vector, N similar features that meet the preset similarity conditions with the target feature vector are found in the preset question database, and then it is determined whether there is a similar feature consistent with the target question feature among the N similar features. If so, the intention and slot corresponding to the historical question corresponding to the similar feature consistent with the target question feature are selected as the target intention and target slot, and then based on the preset business rules, it is determined whether the target intention is an intention within the preset intention range. If the target intention is an intention within the preset intention range, the data query type corresponding to the target intention is determined to be a real-time query, otherwise the data query type corresponding to the target intention is determined to be a non-real-time query. When the data query type corresponding to the target intention is a real-time query, the first query strategy is called, and the first query strategy includes: determining that the target search system is a preset query interface corresponding to the target preset intention through the configuration information corresponding to the target intention, and determining whether parameters need to be passed when calling the preset query interface. If so, a target call request is generated based on the target slot filling request, and the preset query interface is called using the target call request to obtain response data. If not, the preset query interface is directly called to return the response data. After obtaining the response data, the response data is anonymized, and the anonymized response data is filled into a preset answer template to obtain an answer.

[0132] When it is determined that the data query type corresponding to the target intent is a non-real-time query, the second query strategy is called, and the second query strategy includes: performing a data query through a preset domain knowledge base corresponding to the target intent to obtain an answer.

[0133] Among them, when there is no similar feature consistent with the target question feature among the N similar features, the target question is identified by intent and slot through the pre-trained large language model to obtain the real intent and real slot corresponding to the target question, and the question identification, real intent and real slot corresponding to the target question are saved in the preset question database.

[0134] It should be noted that the above examples are only used to assist in understanding the present application and do not constitute a limitation on the question-and-answer method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0135] The present application also provides a question-and-answer device. Figure 3 , the question-answering device comprises:

[0136] A question acquisition module 10 is used to acquire a target question;

[0137] The intention slot acquisition module 20 is used to perform intention recognition and slot recognition on the target question to obtain the target intention and target slot;

[0138] The query module 30 is used to determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

[0139] Optionally, the intention slot acquisition module 20 is further used for:

[0140] Similar questions that meet preset similarity conditions with the target question are screened out from multiple historical questions in the preset question database, and intents and slots corresponding to the similar questions are screened out in the preset question database to obtain the target intent and target slot.

[0141] Optionally, the intention slot acquisition module 20 is further used for:

[0142] Perform feature processing on the target problem to obtain the target problem features;

[0143] Calculate the similarity between the target question features and the features of each historical question in the preset question database;

[0144] Based on the similarity between the target question features and the features of each historical question, similar features are screened out from multiple historical question features in a preset question database to obtain similar questions from the historical questions corresponding to the similar features, and the intentions and slots corresponding to the similar questions are screened out in the preset database to obtain the target intention and target slot.

[0145] Optionally, the intention slot acquisition module 20 is further used for:

[0146] Perform feature processing on the target problem to obtain the target problem features;

[0147] Calculate the similarity between the target question features and the features of each historical question in the preset question database;

[0148] Based on the similarity between the target question features and the features of each historical question, similar features are screened out from multiple historical question features in a preset question database to obtain similar questions from the historical questions corresponding to the similar features, and the intentions and slots corresponding to the similar questions are screened out in the preset database to obtain the target intention and target slot.

[0149] Optionally, the intention slot acquisition module 20 is further used for:

[0150] If there is no candidate feature consistent with the target question feature in the at least one candidate feature, a candidate feature is selected from the at least one candidate feature as a similar feature, and a question identifier corresponding to the similar feature is searched in the first question database to obtain a similar question identifier.

[0151] Optionally, the intention slot acquisition module 20 is further used for:

[0152] If at least one of the candidate features does not have a similar feature that is consistent with the target question feature, the target question is semantically recognized through the pre-trained large language model to obtain the true intent and true slot corresponding to the target question;

[0153] Construct and store the relationship between the target question, the real intention and the real slot in the preset question database.

[0154] Optionally, the query module 30 is further used for:

[0155] Determine the data query type corresponding to the target intent based on preset business rules;

[0156] If the data query type is real-time query, the first query strategy is called;

[0157] When the query strategy called is the first query strategy, a preset query interface corresponding to the target intent is selected to perform data query, and a target call request for the preset query interface is generated based on the target intent;

[0158] The preset query interface is called through the target call request to query the request body corresponding to the target slot and obtain the answer;

[0159] If the data query type is non-real-time query, the second query strategy is called;

[0160] When the query strategy called is the second query strategy, a preset domain knowledge base corresponding to the target intent is selected for data query, and a target query statement is generated based on the target slot;

[0161] The target query statement is used to query the request body corresponding to the target slot in the preset domain knowledge base to obtain the answer.

[0162] Optionally, the query module 30 is further used for:

[0163] Based on the target intent, determine whether parameters need to be passed when calling the preset query interface for data query;

[0164] If so, obtain a preset first request template corresponding to the target intent, and fill the request body in the preset first request template based on the target slot to obtain a target call request;

[0165] If not, a preset second request template corresponding to the target intent is called as the target call request.

[0166] Optionally, the query module 30 is further used for:

[0167] Execute the target call request to call the preset query interface, and receive the response data for the request body returned by the preset query interface;

[0168] Desensitize the response data to obtain desensitized response data;

[0169] Get the preset reply template corresponding to the target intent, and fill the desensitized response data into the preset reply template to get the answer.

[0170] The question-and-answer device provided in the embodiment of the present application adopts the question-and-answer method in the above embodiment, which can solve the technical problem of poor flexibility of the existing question-and-answer solution. Compared with the prior art, the beneficial effects of the question-and-answer device provided in the embodiment of the present application are the same as the beneficial effects of the question-and-answer method provided in the above embodiment, and other technical features in the question-and-answer device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0171] The present application provides a question-and-answer device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the question-and-answer method in the above-mentioned embodiment 1.

[0172] Reference below Figure 4, which shows a schematic diagram of the structure of a question-answering device suitable for implementing the embodiment of the present application. The question-answering device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The question-and-answer device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0173] like Figure 4 As shown, the question-answering device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the question-answering device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the question-answering device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a question-answering device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0174] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0175] The question-and-answer device provided by the present application adopts the question-and-answer method in the above embodiment, which can solve the technical problem of poor flexibility of the existing question-and-answer solution. Compared with the prior art, the beneficial effects of the question-and-answer device provided by the present application are the same as the beneficial effects of the question-and-answer method provided by the above embodiment, and the other technical features in the question-and-answer device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0176] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0177] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0178] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the question-answering method in the above-mentioned embodiment.

[0179] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0180] The computer-readable storage medium may be included in the question-answering device; or may exist independently without being assembled into the question-answering device.

[0181] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the question-and-answer device, the question-and-answer device: obtains the target question; performs intent recognition and slot recognition on the target question to obtain the target intent and the target slot; determines the data query type corresponding to the target intent, and calls the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

[0182] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0183] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0184] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0185] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned question-and-answer method, and can solve the technical problems of question-and-answer. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the question-and-answer method provided in the above-mentioned embodiment, and will not be repeated here.

[0186] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.

Claims

1. A question-answering method, characterized in that: The method comprises: Get the target question; Performing intent recognition and slot recognition on the target problem to obtain a target intent and a target slot; Determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

2. The method according to claim 1, characterized in that The step of performing intent recognition and slot recognition on the target problem to obtain the target intent and the target slot comprises: Similar questions that meet preset similarity conditions with the target question are screened out from multiple historical questions in a preset question database, and intentions and slots corresponding to the similar questions are screened out in the preset question database to obtain a target intention and a target slot.

3. The method according to claim 2, characterized in that The step of selecting similar questions that meet preset similarity conditions with the target question from a plurality of historical questions in a preset question database, and selecting intents and slots corresponding to the similar questions in the preset question database to obtain the target intent and target slot comprises: Performing feature processing on the target problem to obtain target problem features; Calculating the similarity between the target question feature and each historical question feature in the preset question database; Based on the similarity between the target question feature and each of the historical question features, similar features are screened out from the multiple historical question features in the preset question database to obtain the similar question from the historical questions corresponding to the similar features, and the intentions and slots corresponding to the similar questions are screened out in the preset database to obtain the target intention and the target slot.

4. The method according to claim 3, characterized in that The preset question database includes a first question database and a second question database; based on the similarity between the target question feature and each of the historical question features, similar features are screened out from the multiple historical question features in the preset question database, so as to obtain the similar question from the historical questions corresponding to the similar features, and the intent and slot corresponding to the similar question are screened out in the preset database, and the step of obtaining the target intent and the target slot includes: Screening out at least one candidate feature from a plurality of historical question features in the first question database, the candidate feature having a similarity with the target question feature greater than a preset threshold; If there is a candidate feature consistent with the target question feature among the at least one candidate feature, then searching the first question database for a candidate feature consistent with the target question feature as the similar feature, and searching the first question database for a question identifier corresponding to the similar feature to obtain a similar question identifier, so as to determine the similar question by the similar question identifier; The intent and slot corresponding to the similar question identifier are searched in the second question database to obtain the target intent and the target slot.

5. The method according to claim 4, characterized in that After the step of selecting at least one candidate feature whose similarity with the target question feature is greater than a preset threshold from the plurality of question features in the first question database, the method further includes: If there is no candidate feature consistent with the target question feature among the at least one candidate feature, one of the candidate features is selected as the similar feature from the at least one candidate feature, and a question identifier corresponding to the similar feature is searched in the first question database to obtain a similar question identifier.

6. The method according to claim 4, characterized in that After the step of selecting at least one candidate feature whose similarity with the target question feature is greater than a preset threshold from the plurality of question features in the first question database, the method further includes: If there is no similar feature consistent with the target question feature in the at least one candidate feature, semantic recognition is performed on the target question through a pre-trained large language model to obtain the real intent and real slot corresponding to the target question; Construct and store the association between the target question, the real intention and the real slot in the preset question database.

7. The method according to claim 1, characterized in that The step of determining the data query type corresponding to the target intent, and calling the query strategy corresponding to the data query type to query the request body corresponding to the target slot and then returning the answer comprises: Determine the data query type corresponding to the target intent based on preset business rules; If the data query type is real-time query, calling the first query strategy; When the query strategy called is the first query strategy, selecting a preset query interface corresponding to the target intent to perform data query, and generating a target call request for the preset query interface based on the target intent; Calling the preset query interface through the target call request to query the request body corresponding to the target slot to obtain the answer; If the data query type is a non-real-time query, calling a second query strategy; When the query strategy called is the second query strategy, a preset domain knowledge base corresponding to the target intent is selected for data query, and a target query statement is generated based on the target slot; The target query statement is used to query the request body corresponding to the target slot in the preset domain knowledge base to obtain the answer.

8. The method according to claim 7, characterized in that The step of generating a target call request for the preset query interface based on the target intent comprises: Based on the target intent, determining whether parameters need to be passed when calling the preset query interface for data query; If so, obtaining a preset first request template corresponding to the target intent, and filling the request body in the preset first request template based on the target slot to obtain the target call request; If not, a preset second request template corresponding to the target intent is called as the target call request.

9. The method according to claim 8, characterized in that The step of invoking the preset query interface through the target call request to query the request body corresponding to the target slot to obtain the answer comprises: Executing the target call request to call the preset query interface, and receiving response data for the request body returned by the preset query interface; Desensitizing the response data to obtain desensitized response data; Obtain a preset reply template corresponding to the target intent, and fill the desensitized response data into the preset reply template to obtain the answer.

10. A question-answering device, characterized in that: The question-answering device comprises: A question acquisition module is used to obtain the target question; An intention slot acquisition module is used to perform intention recognition and slot recognition on the target problem to obtain the target intention and target slot; The query module is used to determine the data query type corresponding to the target intent, and call the query strategy corresponding to the data query type to query the request body corresponding to the target slot and return the answer.

11. A question-answering device, characterized in that: The question-answering device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the question-answering method according to any one of claims 1 to 9.

12. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the question-and-answer method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Question and answer method and device, electronic equipment and storage medium

    CN113157867A

  • Question and answer method, system and device based on natural language processing and storage medium

    CN113704444A

  • User question labeling method and device

    CN114490975A

  • Large model-based vertical field data integration method, apparatus and device, and medium

    CN117114112A

  • Media data searching method and device, storage medium and electronic equipment

    CN117435750A

Cited By

  • Retrieval question and answer method and device for table, medium, equipment and program product

    CN120429310A

  • Methods, devices, media, equipment, and programs for searching and answering questions in tables.

    CN120429310B