Query reply method, electronic device, storage medium and program product
By introducing a combination of policy library and historical dialogue library in the large language model, determining the target context of the query text and generating reply text, the limitations of existing memory modules when solving different types of problems are solved, and more efficient and coherent are achieved. queries and answering skills.
Patent Information
- Application Number
- CN202411612202.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-02-18
AI Technical Summary
The existing memory modules have limitations in optimizing the problem-solving ability of large language models, and it is difficult to solve different types of problems with better generalization.
By selecting the target context in the policy library, obtaining the policy, combining the historical dialogue text in the short-term library and the long-term library, the target context of this round of inquiry text is determined, and text generation is performed based on the context to generate the reply text.
It realizes the selection of appropriate context strategies based on different dialogue intentions, generates reply texts with high coherence, and uses the experience of long-term libraries to solve similar problems, which improves the problem-solving ability of large language models.
Smart Images

Figure CN119474315A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more particularly to an inquiry answering method, an electronic device, a storage medium, and a program product. Background Art
[0002] At present, Large Language Model (LLM) is widely used in various business fields. The large language model can generate corresponding reply text based on the query text provided by the user.
[0003] In order to optimize the problem-solving ability of large language models, the common method in the industry is to upgrade the large language model to an agent to have a conversation with the user, and introduce a memory module to store the context record of the conversation, so that the agent can generate a response based on the context of the conversation to ensure the coherence of the response. However, most of the current memory modules are only used to solve a specific type of problem, which has limitations. Summary of the invention
[0004] The present disclosure provides an inquiry answering method, an electronic device, a storage medium and a program product.
[0005] According to one aspect of the present disclosure, a method for answering an inquiry is provided, comprising: obtaining a conversation intention classification of a current round of inquiry text; selecting a target context acquisition strategy in a strategy library, wherein the target context acquisition strategy corresponds to the conversation intention classification of the current round of inquiry text, and the target context acquisition strategy corresponds to at least one historical conversation library; determining a target context of the current round of inquiry text in the historical conversation library based on the target context acquisition strategy; and performing text generation based on the target context and the current round of inquiry text to obtain a reply text for the current round of inquiry text.
[0006] According to the inquiry answering method of at least one embodiment of the present disclosure, the historical conversation library includes a short-term library and a long-term library; the short-term library contains a first historical conversation text, the first historical conversation text is the previous K rounds of historical conversation text before the current round of inquiry text, K is an integer, and K≥1, and K is less than a preset value; the long-term library contains a second historical conversation text, and the similarity between the conversation intention classification of the second historical conversation text and the conversation intention classification of the current round of inquiry text is higher than a similarity threshold.
[0007] According to the inquiry answering method of at least one embodiment of the present disclosure, the conversation intention classification of the current round of inquiry text is obtained, including: obtaining the current round of inquiry text and the previous N rounds of historical conversation texts of the current round of inquiry text, N is an integer, and N≥1; extracting target keywords in the current round of inquiry text, the target keywords are commonly present in the current round of conversation text and at least one round of historical conversation text in the previous N rounds of historical conversation texts; and identifying the intention indication of the target keyword in the current round of conversation to obtain the conversation intention classification of the current round of inquiry text.
[0008] According to the inquiry answering method of at least one embodiment of the present disclosure, the intention indication of the target keyword in the current round of dialogue is identified to obtain the dialogue intention classification of the current round of inquiry text, including: in response to the target keyword involving multiple topics, a first classification is obtained; in response to the target keyword involving a question about at least one round of historical dialogue text in the previous N rounds of historical dialogue text, a second classification is obtained; in response to the target keyword involving a negation of at least one round of historical dialogue text in the previous N rounds of historical dialogue text, a third classification is obtained; in response to the target keyword involving a summary of at least one round of historical dialogue text in the previous N rounds of historical dialogue text, a fourth classification is obtained; and in response to the target keyword not corresponding to any of the first to fourth classifications, a fifth classification is obtained.
[0009] According to the inquiry answering method of at least one embodiment of the present disclosure, the target context is determined in the historical conversation library corresponding to the target context acquisition strategy, including: in response to the target context acquisition strategy being the first strategy, extracting the theme of the current round of inquiry text, and screening out historical conversation texts with the same theme in the long-term library as the target context.
[0010] According to the inquiry answering method of at least one embodiment of the present disclosure, the target context is determined in the historical conversation library corresponding to the target context acquisition strategy, including: in response to the target context acquisition strategy being the second strategy, the previous M rounds of historical conversation texts of the current round of inquiry text in the short-term library are determined as the target context, M is an integer, and M≤K.
[0011] According to the inquiry answering method of at least one embodiment of the present disclosure, the target context is determined in the historical conversation library corresponding to the target context acquisition strategy, including: in response to the target context acquisition strategy being the third strategy, extracting the subject and negative content in the current round of inquiry text, screening out the historical conversation texts with the same subject as the negative content in the short-term library and the long-term library, and determining the first M rounds of historical conversation texts of the current round of inquiry text in the screened short-term library and the historical conversation texts with the same subject in the screened long-term library as the target context, M is an integer, and M≤K.
[0012] According to the inquiry answering method of at least one embodiment of the present disclosure, the target context is determined in the historical conversation library corresponding to the target context acquisition strategy, including: in response to the target context acquisition strategy being the fourth strategy, summarizing the contents of the previous M rounds of historical conversation texts of the current round of inquiry text in the short-term library as summary texts, and determining the summary text as the target context, M is an integer, and M≤K.
[0013] According to the inquiry answering method of at least one embodiment of the present disclosure, the target context is determined in the historical conversation library corresponding to the target context acquisition strategy, including: in response to the target context acquisition strategy being the fifth strategy, historical conversation texts whose similarity with the current round of inquiry text is higher than a similarity screening threshold are screened out in the long-term library, and the screened historical conversation texts are determined as similar texts, and the previous M rounds of historical conversation texts of the current round of inquiry text in the short-term library and the similar texts are determined as the target context, M is an integer, and M≤K.
[0014] According to at least one embodiment of the inquiry answering method of the present disclosure, the method further includes: in response to the conversation intention being classified as a first out-of-library classification, text generation is performed based on the current round of inquiry text to obtain the reply text; wherein the first out-of-library classification does not correspond to any strategy in the strategy library, and the first out-of-library classification indicates that the current round of inquiry text is irrelevant to the context.
[0015] According to at least one embodiment of the inquiry answering method of the present disclosure, it also includes: in response to the conversation intention being classified as a second out-of-library classification, identifying a target tool corresponding to the current round of inquiry text; calling the target tool to generate the reply text; wherein the second out-of-library classification does not correspond to any strategy in the strategy library, and the second out-of-library classification indicates that the current round of inquiry text needs to call the target tool.
[0016] According to at least one embodiment of the inquiry answering method of the present disclosure, the method further includes: converting the inquiry text of the current round and the answer text into the historical conversation text and storing the text in the long-term library.
[0017] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the inquiry answering method of any embodiment of the present disclosure.
[0018] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the execution instructions are used to implement the inquiry answering method of any embodiment of the present disclosure.
[0019] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the inquiry answering method of any embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.
[0021] Figure 1 It is a schematic diagram of an application scenario of the inquiry answering method according to an embodiment of the present disclosure.
[0022] Figure 2 It is a flowchart of an inquiry answering method according to an embodiment of the present disclosure.
[0023] Figure 3 It is a flowchart of an inquiry answering method according to an embodiment of the present disclosure.
[0024] Figure 4 It is a flowchart of an inquiry answering method according to an embodiment of the present disclosure.
[0025] Figure 5 It is a flowchart of an inquiry answering method according to an embodiment of the present disclosure.
[0026] Figure 6 It is a flowchart of an inquiry answering method according to an embodiment of the present disclosure.
[0027] Figure 7 It is a flowchart of an inquiry answering method according to an embodiment of the present disclosure.
[0028] Figure 8 It is a flowchart of an inquiry answering method according to an embodiment of the present disclosure.
[0029] Fig. 9 It is a schematic block diagram of the structure of an inquiry answering device according to an embodiment of the present disclosure.
[0030] Fig.10 It is a schematic block diagram of the structure of an electronic device equipped with a query answering device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.
[0032] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0033] Currently, most of the optimizations for memory modules are aimed at solving a specific type of problem. For example, the HippoRAG solution focuses on solving the multi-hop question-answering problem, and the GraphRAG solution focuses on solving the global summary problem. Therefore, memory modules in the industry often have limitations, and there is no general solution to the problem.
[0034] Figure 1 The application scenario of the inquiry answering method of an embodiment of the present disclosure is shown. In this application scenario, the large language model and the memory module are constructed as a decision module of an agent. When the decision module obtains the query text uploaded by the user, it selects the appropriate context from the historical dialogue library, and passes the query text and context to the agent, which generates a reply based on the context and the query text.
[0035] Among them, the historical dialogue library includes a short-term library and a long-term library. The short-term library stores the historical dialogue texts of the most recent rounds of dialogue, providing the short-term memory of the intelligent agent. When the text in the short-term library is selected as the context, the generated reply content can be made coherent with the previous rounds of dialogue to ensure the continuity of the dialogue. The long-term library stores relatively old historical dialogue texts, providing the long-term memory of the intelligent agent. The amount of data of the historical dialogue texts stored in the long-term library is much larger than the amount of data in the short-term library, making it easier to retrieve dialogues similar to the current query text in the long-term library, so as to help the intelligent agent generate replies with the help of the reply experience of similar dialogues.
[0036] One embodiment of the present disclosure is to configure a memory module with a variety of different strategies, and different strategies correspond to different context selection methods. When the decision module obtains the inquiry text uploaded by the user, the inquiry text is passed to the large language model, and the dialogue intent classification of the inquiry text is determined by the large language model. The strategy that should be used for this round of inquiry is judged based on the dialogue intent classification of the inquiry text, so that the memory module selects context in the short-term library and / or long-term library according to the strategy to adapt to inquiry texts with different dialogue intent classifications. In this way, the context obtained based on different strategies can solve problems of different types of inquiry texts. If the context is selected in the short-term library according to the strategy, a response with strong coherence can be generated. If the context is selected in the long-term library according to the strategy, the experience of solving similar problems with historical dialogue texts in the long-term library can be used to generate a response.
[0037] Figure 2 FIG. 1 is a schematic diagram showing the overall process of a query answering method M100 according to an embodiment of the present disclosure. Figure 2 The method shown includes steps S110 to S170. The method can be executed by electronic devices such as mobile phones and tablet computers.
[0038] Specifically, Figure 2 The methods shown include: S110: Obtain the conversation intention classification of the current round of inquiry text.
[0039] The current round of inquiry text refers to the inquiry text provided by the user in the current round of ongoing dialogue. This article records a query text provided by the user and a corresponding reply text generated for the query text as a round of dialogue. If in a round of dialogue, there is only the query text provided by the user, and the reply text has not been generated, then the round of dialogue is recorded as an ongoing dialogue. If the reply text has been generated, it means that the round of dialogue has ended.
[0040] In one example, multiple categories are pre-set according to the types of unresolved questions that may correspond to the semantics of the inquiry text. The conversation intention classification of the inquiry text can be determined based on the unresolved questions corresponding to the semantics of the inquiry text in this round. For example, a question to be solved is: to ask about the content of the previous conversation. And the type of this unresolved question is set to "follow-up question classification". If the semantics of the inquiry text is identified and the semantics of the inquiry text indicates that it is necessary to ask about the content of the previous conversation, then the conversation intention classification of this inquiry text can be determined as "follow-up question classification".
[0041] In another example, the conversation intention classification of the inquiry text can be set according to conditions such as whether the conversation intention needs to be associated with the context, whether it needs to be associated with the historical conversation text in the short-term library, and whether it needs to be associated with the historical conversation text in the long-term library.
[0042] For example, first determine whether the query text needs to be associated with context. If the query text does not need to be associated with context, it is recorded as the first classification. If the query text needs to be associated with context, determine whether the query text needs to be associated with the historical dialogue text in the short-term library. If it is necessary to associate the historical dialogue text in the short-term library, further determine whether to associate the historical dialogue text in the long-term library at the same time. If it is determined that only the historical dialogue text in the short-term library needs to be associated, further determine whether to filter the historical dialogue text in the short-term library or exclude the historical dialogue text in the short-term library; if the historical dialogue text in the short-term library is filtered, it is recorded as the second classification; if the historical dialogue text in the short-term library is excluded, it is recorded as the third classification; if neither is filtered nor excluded, it is recorded as the fourth classification. If it is determined that the historical dialogue text in the long-term library is simultaneously associated, further determine whether to filter the historical dialogue text or exclude the historical dialogue text; if the historical dialogue text is filtered, it is recorded as the fifth classification; if the historical dialogue text is excluded, it is recorded as the sixth classification; if neither is filtered nor excluded, it is recorded as the seventh classification. If there is no need to associate the historical dialogue texts in the short-term library, it is further determined whether to filter the historical dialogue texts in the long-term library or to exclude the historical dialogue texts in the long-term library; if the historical dialogue texts in the long-term library are filtered, it is recorded as the eighth classification; if the historical dialogue texts in the long-term library are excluded, it is recorded as the ninth classification; if neither is filtered nor excluded, it is recorded as the tenth classification. In this way, the dialogue intention classification of the inquiry text has a strong correspondence with the historical dialogue library, making the correspondence between the strategy formulated according to the dialogue intention classification of the inquiry text and the historical dialogue library more intuitive.
[0043] S130: Select a target context acquisition strategy in a strategy library.
[0044] Among them, the target context acquisition strategy corresponds to the conversation intent classification of the current round of inquiry text, and corresponds to at least one historical conversation library. Specifically, a conversation intent classification uniquely corresponds to one strategy (referring to the context acquisition strategy, the same below). If the strategy that uniquely corresponds to the conversation intent classification is in the strategy library, then the strategy may correspond to one historical conversation library or two historical conversation libraries. For example, if a strategy in the strategy library selects context only from the short-term library, then the strategy corresponds to one historical conversation library. If a strategy in the strategy library selects context from both the short-term library and the long-term library, then the strategy corresponds to two historical conversation libraries.
[0045] In one example, the types of dialogue intention classification are more than the types of policies in the policy library. That is to say, the policies corresponding to some dialogue intention classifications are not in the policy library. Specifically, each policy in the policy library corresponds to at least one historical dialogue library. If the policy corresponding to the dialogue intention classification is a policy in the policy library, it means that the context of generating the answer to the inquiry text needs to be obtained in at least one historical dialogue library. If the policy corresponding to the dialogue intention classification is not in the policy library, it means that the context of generating the answer to the inquiry text does not need to be obtained from the historical dialogue library. For example, there are dialogue intention classifications that do not need to be associated with context, dialogue intention classifications that need to be associated with contexts that are not in the historical dialogue library, and so on. The implementation method of the present disclosure mainly uses the historical dialogue library that is a mixture of short-term and long-term historical dialogue texts to provide context, so as to make full use of the coherence provided by the short-term library and / or the similar experience provided by the long-term library to solve the problem. Therefore, for the case where the policy corresponding to the dialogue intention classification is not in the policy library, as an expandable implementation method of the present disclosure, it is not limited here.
[0046] In one example, the process of the above-mentioned step S110 and step S130 is implemented through a large language model (which can be various existing large language models). Specifically, the current round of inquiry text and the policy library are input into the trained large language model, and the trained large language model can extract the dialogue intent classification of the current round of inquiry text, and select the target context acquisition strategy corresponding to the dialogue intent classification in the policy library according to the dialogue intent classification, and finally output the target context acquisition strategy. That is, the current round of inquiry text and the policy library are used as the input of the large language model, the output of the large language model is the target context acquisition strategy, and the process of selecting the target context acquisition strategy in the policy library according to the dialogue intent classification is an imperceptible process.
[0047] S150: Determine the target context of the current round of inquiry text in the historical dialogue library based on the target context acquisition strategy.
[0048] Among them, the historical dialogue library is the space for storing memories in the memory module.
[0049] In some embodiments of the present disclosure, the historical conversation library includes a short-term library and a long-term library, which correspond to short-term memory and long-term memory, respectively.
[0050] The short-term library contains the first historical dialogue text. The first historical dialogue text is a historical dialogue text that is close to the dialogue round of the current round of inquiry text. In one example, the short-term library contains K rounds of historical dialogue text before the current round of inquiry text, K is an integer greater than 1, and K is less than a preset value, and the preset value is used to limit the degree of proximity to the round of the current round of inquiry text. For example, when K=10, it means that at most 10 rounds of historical dialogue text before the current round of inquiry text are stored in the short-term library, and the historical dialogue texts of the 10th round and less than the 10th round before the current round of inquiry text are considered to be historical dialogue texts that are close to the dialogue round of the current round of inquiry text. Assuming that the current round of inquiry text is the 20th round of dialogue, the historical dialogue texts of the 10th to 19th rounds of dialogue are the first historical dialogue texts. If the 20th round of dialogue ends and the inquiry text of the 21st round of dialogue becomes the new current round of inquiry text, the range of the first historical dialogue text is changed to the historical dialogue texts of the 11th to 20th rounds of dialogue. For the specific numerical values of the preset values, appropriate adjustments or changes are made under the guidance of the technical solution of the present disclosure, which all fall within the protection scope of the present disclosure.
[0051] The long-term database contains historical dialogue texts of various dialogue intention topics. Among the historical dialogue texts in the long-term database, the historical dialogue texts with a dialogue intention classification similar to that of the current round of inquiry text are recorded as the second historical dialogue text. In one example, the similarity between the dialogue intention classification of the second historical dialogue text and the dialogue intention classification of the current round of inquiry text is higher than the similarity threshold. For example, the dialogue intention of the current round of inquiry text is "questioning about word A", word A is a vocabulary in the field of computer software development, and the dialogue intention is classified as the questioning class in the field of computer software development; the dialogue intention of a historical dialogue text in the long-term database is "questioning about word B", word B is a vocabulary in the field of Android mobile phone software development, and the dialogue intention is classified as the questioning class in the field of Android mobile phone software development; if the similarity of the two dialogue intention classifications of "questioning class in the field of computer software development" and "questioning class in the field of Android mobile phone software development" is calculated to be higher than the similarity threshold according to the configured similarity calculation rule, the historical dialogue text corresponding to "questioning about word B" is determined as the second historical dialogue text corresponding to the current round of inquiry text.
[0052] When determining the target context of the current round of inquiry text in the historical dialogue library based on the target context acquisition strategy, if the target context is determined in the short-term library, it can help improve the coherence of the conversation; if the target context is determined in the long-term library, the experience of similar classification problems can be used to solve the problem of the original inquiry text.
[0053] The target context may be a historical conversation text in the historical conversation library, or multiple historical conversation texts, or an integrated text obtained by integrating multiple historical conversation texts, or a prompt word constructed based on the historical conversation texts in the historical conversation library, and there is no limitation here.
[0054] To determine the target context in the historical conversation library, you can configure the corresponding context determination conditions in the target context acquisition strategy based on business needs, the type of problem being solved, and other factors. For example, assuming that the target context acquisition strategy does not have a context determination condition configured, and the historical conversation library corresponding to the target context acquisition strategy is a short-term library, all historical conversation texts in the short-term library are determined as the target context. Assuming that the target context acquisition strategy is configured with a context determination condition of: the first M rounds of historical conversation texts in the short-term library, the first M rounds of historical conversation texts in the short-term library are determined as the target context.
[0055] S170: Generate text based on the target context and the current round of inquiry text to obtain a reply text.
[0056] In one example, after obtaining the target context, the target context and the current round of inquiry text are passed into an intelligent agent (which may be an intelligent agent based on a large language model), and the intelligent agent can perform text generation processing to generate a corresponding reply text. Among them, the target context is used to construct the prompt words of the intelligent agent. The target context can be directly used as the prompt words corresponding to the current round of inquiry text, and the target context can be converted into the prompt words corresponding to the current round of inquiry text based on a prompt word generation template, which is not limited here. In other embodiments, a model trained by a machine learning algorithm can be used to perform natural language processing and text generation and other processing processes to generate a corresponding reply text, for example, the target context and the current round of inquiry text are input into an intelligent agent based on a large language model to generate a reply text, which is not limited here.
[0057] In this way, the target context obtained based on the above steps S110 to S170 can help the intelligent agent generate a response text with higher coherence and / or a response text that uses the experience of the long-term library to solve similar problems.
[0058] Regarding step S110, in some embodiments of the present disclosure, it may include the following steps: Figure 3 Steps S1110 to S1130 are shown.
[0059] S1110. Obtain the text of the current round of inquiry and the text of the previous N rounds of historical conversations.
[0060] Among them, the inquiry text of this round is the inquiry text of the currently ongoing conversation, and N is an integer greater than 1. Assume that the currently ongoing conversation is the i-th round of conversation, then the previous N rounds of historical conversation text refer to the conversation text of the iN-th round, the i-1-th round, and each round of conversation between the iN-th round and the i-1-th round. The value of N can be set according to factors such as actual application requirements, inquiry response efficiency requirements, and the computing power of a large language model. There is no limitation here. For the specific value of N, appropriate adjustments or changes are made under the inspiration of the technical solution of the present disclosure, which all fall within the protection scope of the present disclosure.
[0061] S1120, extracting target keywords from the query text of this round.
[0062] Among them, keywords are words that reflect the core content or theme of the text. The target keywords are keywords that exist in at least one round of dialogue text in the current round of dialogue text and the previous N rounds of historical dialogue text. Extracting keywords from text can be achieved through a large language model, which will not be elaborated here.
[0063] For example, assuming that: N=5, the currently ongoing conversation is the i-th round of conversation, this round of conversation includes the content "second-hand house transaction", "second-hand house transaction" is extracted as a keyword, and the keyword "second-hand house transaction" is also included in the i-3 round of conversation, then "second-hand house transaction" is determined as the target keyword in this round of inquiry text.
[0064] The target keyword may be a semantically identical word. For example, "second-hand housing transaction" and "second-hand housing sale" have the same semantics. If the content "second-hand housing transaction" is included in the current round of dialogue, "second-hand housing transaction" is extracted as a keyword, and the keyword "second-hand housing sale" is also included in the i-3 round of dialogue, then "second-hand housing transaction" can be determined as the target keyword in the current round of inquiry text.
[0065] S1130, identifying the intention indication of the target keyword in the current round of dialogue, and obtaining the dialogue intention classification of the current round of inquiry text.
[0066] Steps S1131 to S1135 provided below illustrate an optional configuration method for obtaining a dialog intent classification of the current round of inquiry text based on the intent indication.
[0067] Regarding step S1130, in some embodiments of the present disclosure, it may include: Figure 4 Steps S1131 to S1135 are shown.
[0068] S1131. In response to the target keyword involving multiple topics, a first classification is obtained.
[0069] The first category indicates that the same conversation involves discussing multiple topics. Based on this, the strategy corresponding to the first category can be configured to filter historical conversation texts of the same topic in the long-term library as the target context.
[0070] S1132. In response to the target keyword being related to a question about at least one round of historical dialogue text among the previous N rounds of historical dialogue text, a second classification is obtained.
[0071] The second category represents the user's supplementary questions for the most recent N rounds of inquiries. Usually, in this type of scenario, it is only necessary to associate the short-term memory of the previous N rounds of historical dialogue texts in the short-term library. Based on this, the strategy corresponding to the second category can be configured to select the previous N rounds of historical dialogue texts in the short-term library.
[0072] S1133. In response to the target keyword involving the negation of at least one round of historical dialogue text among the previous N rounds of historical dialogue text, a third classification is obtained.
[0073] The third category indicates that the replies in the N rounds of historical conversation texts before the user feedback or implicit feedback are incorrect. Incorrect conversations do not need to be stored in the historical conversation library, and incorrect conversations should not be associated when associating contexts. Based on this, the strategy corresponding to the third category can be configured to filter out historical conversation texts similar to the target keyword in the historical conversation library, and select historical conversation texts from the historical conversation library after filtering.
[0074] S1134. In response to the target keyword being related to a summary of at least one round of historical dialogue text among the previous N rounds of historical dialogue text, a fourth classification is obtained.
[0075] The fourth category indicates that it is necessary to use the summary information of the previous N rounds of historical conversation text context to reply. Based on this, the strategy corresponding to the fourth category can be configured to perform summary processing on the previous N rounds of historical conversation text in the short-term library to obtain the summary text, and determine the summary text as the target context.
[0076] S1135. In response to the target keyword not corresponding to any of the first to fourth categories, a fifth category is obtained.
[0077] The fifth category indicates that the target keyword does not belong to any of the first to fourth categories. For this case, the fifth category is configured as a general category type. Based on this, the strategy corresponding to the fifth category can be configured to screen the historical conversation texts similar to the target keyword in the long-term library, and obtain the previous N rounds of historical conversation texts in the short-term library, and use them together as context texts, so that the context texts have good coherence and can provide similar problem-solving experience, so as to be suitable for solving general problems.
[0078] In some implementations of the present disclosure, the above steps S1131 to S1135 are combined, and the strategies corresponding to the first category, the second category, the third category, the fourth category, and the fifth category are recorded as the first strategy, the second strategy, the third strategy, the fourth strategy, and the fifth strategy, respectively, to obtain five different strategies in the strategy library. The strategy library of the inquiry and reply method of the implementation of the present disclosure is not limited to the above five different strategies, and can be expanded according to business needs, which is not limited here.
[0079] Regarding step S150, in some embodiments of the present disclosure, it may also include the following Figure 5 Steps S1501 to S1505 are shown.
[0080] S1501: In response to the target context acquisition strategy being the first strategy, extract the topic of the current round of inquiry text, and filter out historical conversation texts with the same topic in the long-term library as the target context.
[0081] The first strategy is a multi-topic strategy, which means that only partially filtered historical conversation texts in long-term conversations are used as target contexts, and the filtering condition is based on the same topic.
[0082] In one example, the topic of the current round of inquiry text and the topic of the historical conversation text can be semantically recognized and extracted through a large language model.
[0083] In one example, the text similarity of the current round of inquiry text and the historical conversation text can be calculated, and the vector of the current round of inquiry text and the vector of the historical conversation text can be compared using a measure such as cosine similarity. If the cosine similarity is greater than 0.9, it is considered that the topic of the current round of inquiry text and the historical conversation text is the same. The cosine similarity greater than 0.9 is an example of the technical solution of the present disclosure. Appropriate adjustments or changes based on the technical solution of the present disclosure fall within the protection scope of the present disclosure.
[0084] In one example, a topic parameter can be used to identify a type of topic, and the same topic parameter represents the same topic. For example, assuming that the topic parameter of the current round of inquiry text is character "01", the historical conversation text with the same topic parameter of character "01" is the selected target context.
[0085] S1502: In response to the target context acquisition strategy being the second strategy, the previous M rounds of historical conversation texts of the current round of inquiry text in the short-term library are determined as the target context.
[0086] The second strategy is the questioning strategy, which means that only some of the historical dialogue texts selected in the short-term library are used as the target context. The screening condition is to select the most recent M rounds of dialogue, where M is an integer and M≤K. Assuming that the current round is the i-th round, the most recent M rounds of dialogue refer to the dialogue texts of the iM-th round, the i-1-th round, and each round of dialogue between the iM-th round and the i-1-th round.
[0087] In one example, if the most recent M rounds of historical conversation text are used as the target context and there is a problem of excessively long tokens, the most recent M rounds of conversation are intercepted according to s% of the maximum token supported by the large language model. Among them, s=70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, etc., which are not listed here one by one. If the output is too long, the value of s is adaptively reduced, and if the output is too short, the value of s is adaptively increased.
[0088] S1503. In response to the target context acquisition strategy being the third strategy, extract the topic and negative content in the current round of inquiry text, screen out historical conversation texts whose similarity with the negative content is higher than a similarity screening threshold in the short-term library and the long-term library, and determine the first M rounds of historical conversation texts of the current round of inquiry text in the screened short-term library and the historical conversation texts with the same topic in the screened long-term library as the target context.
[0089] Negative content refers to the semantics of a text that negates a subject. Negative content in a text can be determined by searching for characters, words, sentences, and other features that have negative semantics. For example, "The answer to xx is wrong", "xx content is incorrect", etc.
[0090] The third strategy is the feedback strategy, which means that the target context is obtained by using the historical dialogue texts in the short-term library and the long-term library and filtering out some content. The filtered content is the content with the same theme as the negative content in the current round of inquiry text. For example, the negative content in the current round of inquiry text is "the interpretation of vocabulary A is incorrect", and its theme is "the interpretation of vocabulary A", then all historical dialogue texts with the theme of "the interpretation of vocabulary A" in the historical dialogue library are filtered out. Furthermore, the filtered historical dialogue texts in the historical dialogue library can be deleted to avoid the wrong content from being selected as the context. Among them, the context selected in the short-term library is the most recent M rounds of historical dialogue texts after the short-term library is filtered out; the context selected in the long-term library is the historical dialogue text with the same theme as the current round of inquiry text in the historical dialogue text after the long-term library is filtered out.
[0091] S1504: In response to the target context acquisition strategy being the fourth strategy, the contents of the previous M rounds of historical dialogue texts of the current round of inquiry text in the short-term library are summarized into summary texts, and the summary texts are determined as the target context.
[0092] The fourth strategy is the summary strategy, which means that only part of the filtered historical conversation text in the short-term library is used as the target context. The filtering condition is to select the most recent M rounds of conversations and summarize the contents of the most recent M rounds of conversations to obtain a summary text.
[0093] S1505: In response to the target context acquisition strategy being the fifth strategy, historical conversation texts whose similarity to the current round of inquiry text is higher than a similarity screening threshold are screened out in the long-term library, and the screened historical conversation texts are determined as similar texts, and the previous M rounds of historical conversation texts and similar texts of the current round of inquiry text in the short-term library are determined as target contexts.
[0094] The fifth strategy is a general strategy. It can be used in situations where the historical dialogue text in the historical dialogue library needs to be used as context and is not applicable to the first to fourth strategies. The fifth strategy means using some of the historical dialogue texts selected from the short-term library and the long-term library. The selection condition of the short-term library is to select the most recent M rounds of dialogue, and the selection condition of the long-term library is to select similar texts.
[0095] In one example, the text similarity of the current round of inquiry text and the historical conversation text can be calculated, and the vector of the current round of inquiry text and the vector of the historical conversation text can be compared using a measure such as cosine similarity. If the cosine similarity is greater than 0.8, it is considered that the similarity between the current round of inquiry text and the historical conversation text is higher than the similarity screening threshold, and the historical conversation text is determined as a similar text. The value of the similarity screening threshold is appropriately adjusted or changed under the inspiration of the technical solution of the present disclosure, and all fall within the protection scope of the present disclosure.
[0096] In some embodiments of the present disclosure, the inquiry answering method M100 may also include: Figure 6 Step S120 is shown.
[0097] S120 . In response to the dialog intention being classified as an out-of-library classification, a reply text is generated based on the current round of inquiry text.
[0098] Among them, the out-of-library classification does not correspond to the strategy in the strategy library. That is to say, when the dialogue classification is identified as an out-of-library classification, there is no need to use the strategy in the strategy library to associate the historical dialogue text in the historical dialogue library as context.
[0099] Regarding step S120, in some embodiments of the present disclosure, it may include the following steps: Figure 8 Steps S1201 to S1203 are shown.
[0100] S1201. In response to the dialog intention being classified as a first out-of-library classification, text generation is performed based on the current round of inquiry text to obtain a reply text.
[0101] Among them, the first out-of-library classification does not correspond to any strategy in the strategy library, and the first out-of-library classification indicates that the current round of inquiry text is irrelevant to the context.
[0102] For example, when the current round of inquiry text raises a question on a new topic, there is no need to associate the morning and afternoon for the answer, and the conversation intention classification of the current round of inquiry text will be determined as the first out-of-library classification. In this case, the answer text can be generated by performing natural language processing and text generation processes based only on the current round of inquiry text, for example, directly inputting the current round of inquiry text into the intelligent agent to obtain the answer text.
[0103] S1202: In response to the dialog intention being classified as a second out-of-library classification, identifying a target tool corresponding to the current round of inquiry text.
[0104] Among them, the second out-of-library classification does not correspond to any strategy in the strategy library, and the second out-of-library classification indicates that the current round of inquiry text needs to call the target tool.
[0105] In one example, if it is identified that the current round of inquiry text contains keywords such as the name of the tool, the parameters of the tool, etc., the conversation intention classification of the current round of inquiry text is identified as the second out-of-library classification.
[0106] S1203. Call the target tool to generate a reply text.
[0107] When the conversation intention is classified as a classification outside the second library, the specific tool to be executed is selected according to the extracted specific tool name, and the tool parameters are passed in to obtain the execution result, and the execution result is used as the reply text.
[0108] In some embodiments of the present disclosure, the inquiry answering method M100 may also include: Figure 8 Step S190 is shown.
[0109] S190, convert the inquiry text and reply text of this round into historical dialogue text and store it in a long-term database.
[0110] After obtaining the reply text, the current round of inquiry text and reply text are passed into the large language model, and the information of the current round of dialogue text is extracted according to the topic of the current round of inquiry text, and then the extracted information is processed by text conversion to obtain the historical dialogue text in vector form, and the historical dialogue text in vector form is stored in the long-term library. Among them, the extracted topic information can be used to compare the similarity with the new inquiry text to determine whether it is a similar text or the same topic text. This makes it easier to identify the dialogue intention classification of the new inquiry text to determine the corresponding strategy.
[0111] Based on any of the above embodiments, the present disclosure also provides an inquiry answering device. Fig. 9 It is a schematic block diagram of the structure of an inquiry answering device according to an embodiment of the present disclosure.
[0112] like Fig. 9 As shown, the inquiry answering device includes: The acquisition module 110 is used to obtain the dialog intention classification of the current round of inquiry text.
[0113] The selection module 120 is used to select a target context acquisition strategy from the strategy library, where the target context acquisition strategy corresponds to the dialog intention classification of the current round of inquiry text, and the target context acquisition strategy corresponds to at least one historical dialog library.
[0114] The determination module 130 is used to determine the target context of the current round of inquiry text in the historical dialogue library based on the target context acquisition strategy.
[0115] The reply module 140 is used to generate text based on the target context and the current round of inquiry text to obtain a reply text for the current round of inquiry text.
[0116] In some embodiments of the present disclosure, the inquiry answering device further includes a slicing module (not shown), which is used to split the knowledge package to obtain multiple slicing packages. Specifically, the slicing module can be used to obtain the knowledge package and identify the topological structure of the knowledge package; and in response to the topological structure of the knowledge package being a decision flow forest structure, split the knowledge package into multiple slicing packages, each slicing package corresponding to a decision flow in the knowledge package.
[0117] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0118] The execution subject of the inquiry answering method in the specific implementation manner of the present disclosure may be an electronic device such as a mobile phone, a tablet computer, or a server.
[0119] Therefore, based on any of the above embodiments, the present disclosure also provides an electronic device, which can execute the inquiry answering method of any of the embodiments described above in the present disclosure, and the inquiry answering device of any of the embodiments described above can be configured on the electronic device.
[0120] Fig.10 It is a schematic block diagram of the structure of an electronic device 1000 equipped with an inquiry answering device according to an embodiment of the present disclosure.
[0121] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.
[0122] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.
[0123] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.
[0124] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.
[0125] A computer program or instruction may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, a computer program or instruction may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0126] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may 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.) containing computer-usable program code.
[0127] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable query answering device to produce a machine, so that the instructions executed by the processor of the computer or other programmable query answering device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0128] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable query answering device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, the instruction device implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0129] These computer program instructions may also be loaded onto a computer or other programmable query answering device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0130] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.
[0131] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0132] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. A method for answering an inquiry, characterized in that: include: Get the conversation intent classification of this round of inquiry text; Selecting a target context acquisition strategy from the strategy library, wherein the target context acquisition strategy corresponds to the dialog intention classification of the current round of inquiry text, and the target context acquisition strategy corresponds to at least one historical dialog library; Determining the target context of the current round of inquiry text in the historical dialogue library based on the target context acquisition strategy; as well as Text generation is performed based on the target context and the current round of inquiry text to obtain a reply text for the current round of inquiry text.
2. The inquiry answering method according to claim 1, characterized in that: The historical dialogue library includes a short-term library and a long-term library; The short-term database contains a first historical dialogue text, where the first historical dialogue text is the K rounds of historical dialogue text before the current round of inquiry text, where K is an integer, and K≥1, and K is less than a preset value; The long-term library contains a second historical dialogue text, and the similarity between the dialogue intention classification of the second historical dialogue text and the dialogue intention classification of the current round of inquiry text is higher than a similarity threshold.
3. The inquiry answering method according to claim 2, characterized in that: Determining the target context in the historical dialogue library corresponding to the target context acquisition strategy includes: In response to the target context acquisition strategy being the first strategy, the subject of the current round of inquiry text is extracted, and historical conversation texts with the same subject are screened out from the long-term library as the target context.
4. The inquiry answering method according to claim 2, characterized in that: Determining the target context in the historical dialogue library corresponding to the target context acquisition strategy includes: In response to the target context acquisition strategy being the second strategy, the previous M rounds of historical conversation texts of the current round of inquiry texts in the short-term library are determined as the target contexts, where M is an integer and M≤K.
5. The inquiry answering method according to claim 2, characterized in that: Determining the target context in the historical dialogue library corresponding to the target context acquisition strategy includes: In response to the target context acquisition strategy being the third strategy, the topic and negative content in the current round of inquiry text are extracted, historical conversation texts with the same topic as the negative content are screened out in the short-term library and the long-term library, and the first M rounds of historical conversation texts of the current round of inquiry text in the screened short-term library and the historical conversation texts with the same topic in the screened long-term library are determined as the target context, M is an integer, and M≤K.
6. The inquiry answering method according to claim 2, characterized in that: Determining the target context in the historical dialogue library corresponding to the target context acquisition strategy includes: In response to the target context acquisition strategy being the fourth strategy, the contents of the previous M rounds of historical dialogue texts of the current round of inquiry text in the short-term library are summarized as summary texts, and the summary texts are determined as the target contexts, where M is an integer and M≤K.
7. The inquiry answering method according to claim 2, characterized in that: Determining the target context in the historical dialogue library corresponding to the target context acquisition strategy includes: In response to the target context acquisition strategy being the fifth strategy, historical conversation texts whose similarity with the current round of inquiry text is higher than a similarity screening threshold are screened out in the long-term library, and the screened historical conversation texts are determined as similar texts, and the previous M rounds of historical conversation texts of the current round of inquiry text in the short-term library and the similar texts are determined as the target context, where M is an integer and M≤K; Optionally, the inquiry reply method further includes: Converting the current round of inquiry text and the answer text into the historical dialogue text and storing them in the long-term library; Optionally, obtain the conversation intent classification of the current round of inquiry text, including: Obtain the current round of inquiry text and the previous N rounds of historical dialogue texts of the current round of inquiry text, where N is an integer and N≥1; Extracting target keywords from the current round of inquiry text, wherein the target keywords are present in the current round of conversation text and at least one round of historical conversation text among the previous N rounds of historical conversation texts; and Identify the intention indication of the target keyword in the current round of dialogue, and obtain the dialogue intention classification of the current round of inquiry text; Optionally, identifying the intention indication of the target keyword in the current round of dialogue to obtain the dialogue intention classification of the current round of inquiry text includes: In response to the target keyword involving multiple topics, obtaining a first classification; In response to the target keyword being related to a question about at least one round of historical dialogue text among the first N rounds of historical dialogue text, obtaining a second classification; In response to the target keyword involving a negation of at least one round of historical dialogue text among the first N rounds of historical dialogue text, obtaining a third classification; In response to the target keyword being related to a summary of at least one round of historical dialogue text among the first N rounds of historical dialogue text, a fourth classification is obtained; and In response to the target keyword not corresponding to any of the first to fourth categories, obtaining a fifth category; Optionally, the inquiry reply method further includes: In response to the dialog intention being classified as a first out-of-library classification, generating text based on the current round of inquiry text to obtain the reply text; The first out-of-library classification does not correspond to any policy in the policy library, and the first out-of-library classification indicates that the current round of inquiry text is irrelevant to the context; Optionally, the inquiry reply method further includes: In response to the dialog intention being classified as a second out-of-library classification, identifying a target tool corresponding to the current round of inquiry text; Calling the target tool to generate the reply text; The second out-of-library classification does not correspond to any policy in the policy library, and the second out-of-library classification indicates that the current round of inquiry text needs to call a target tool.
8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instructions stored in the memory, so that the processor executes the inquiry answering method according to any one of claims 1 to 7.
9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the inquiry answering method according to any one of claims 1 to 7 when executed by the processor.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the inquiry answering method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Inference method and device based on large language model, electronic equipment and medium
CN121009995A