Question-answer interaction method and related device, electronic device and storage medium

By retrieving and processing historical attention features in question and answer interactions, repeated calculations are avoided, computing resource utilization and articulation efficiency are improved, and the problems of computing resource waste and delay in multi-round conversations are solved.

CN118484525BActive Publication Date: 2024-10-29IFLYTEK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410947840.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-10-29
Estimated Expiration
2044-07-16

AI Technical Summary

Technical Problem

In the Q&A interaction scenario with multiple rounds of conversations, historical calculation leads to repeated calculations, a waste of computing resources, long first ring delay and low articulation efficiency.

Method used

By obtaining the current statement input by the user, calling the GPU computing resources to process the statement, calling the historical attention features to the GPU memory space, and processing the current and historical features based on the attention mechanism, generating a reply statement, in order from new to old in generation time Write features back to external storage to avoid repeated calculations.

Benefits of technology

It improves the utilization of computing resources and enunciation efficiency, reduces the first response delay, and relieves the pressure on the GPU memory space for historical features, especially in long text interaction scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118484525B_ABST
    Figure CN118484525B_ABST
Patent Text Reader

Abstract

The present application discloses a question-answering interaction method and related devices, electronic devices and storage media, wherein the question-answering interaction method includes: obtaining the first sentence input by the user in the current round; calling the GPU computing resources to process the first sentence, obtaining the current attention feature in the current round, and retrieving the historical attention features of the historical rounds in the external storage space to the GPU memory space; calling the GPU computing resources to process the current attention features and the historical attention features to obtain the second sentence; retrieving the key features and value features in the GPU memory space in order of generation time from new to old, and writing them back to the external storage space for use in the next round of the current round. The above scheme can improve the utilization rate and pronunciation efficiency of computing resources, and reduce the first response delay as much as possible. In addition, through heterogeneous caching, the pressure on the demand for GPU memory space to save historical attention features can be greatly alleviated, especially in the interactive scenario of long texts.
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 interaction method and related devices, electronic devices, and storage media. Background Art

[0002] With the rapid development of artificial intelligence technology, machine dialogue using artificial intelligence models such as large language models has been increasingly widely used in areas such as intelligent customer service and knowledge question and answer.

[0003] At present, in the scenario of multi-round conversational question-answering interaction, there are cases where historically calculated questions are repeatedly calculated, which not only wastes computing resources, but also causes a particularly large first-response delay and relatively low pronunciation efficiency. In view of this, how to improve the utilization rate of computing resources and pronunciation efficiency, and reduce the first-response delay as much as possible, has become an urgent problem to be solved. Summary of the invention

[0004] The main technical problem solved by the present application is to provide a question-answering interaction method and related devices, electronic devices and storage media, which can improve the utilization rate of computing resources and the efficiency of pronunciation, and reduce the first-response delay as much as possible.

[0005] In order to solve the above technical problems, the first aspect of the present application provides a question-answer interaction method, including: obtaining a first sentence input by a user in a current round; calling a GPU computing resource to process the first sentence, obtaining a current attention feature of an attention mechanism in the current round, and retrieving the historical attention features of the attention mechanism in historical rounds before the current round in an external storage space to a GPU video memory space; wherein the historical attention features include historical key features and historical value features; calling a GPU computing resource to process the current attention features and the historical attention features based on the attention mechanism to obtain a second sentence in reply to the first sentence; retrieving the key features and value features in the GPU video memory space in order of generation time from new to old, and writing them back to the external storage space for use in the next round of the current round.

[0006] In order to solve the above technical problems, the second aspect of the present application provides a question-answer interaction device, including: a sentence acquisition module, a first call module, a second call module and a feature write-back module, the sentence acquisition module is used to obtain the first sentence input by the user in the current round; the first call module is used to call the GPU computing resources to process the first sentence, obtain the current attention feature of the attention mechanism in the current round, and call the historical attention features of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU video memory space; wherein the historical attention features include historical key features and historical value features; the second call module is used to call the GPU computing resources to process the current attention features and the historical attention features based on the attention mechanism to obtain a second sentence in reply to the first sentence; the feature write-back module is used to call the key features and value features in the GPU video memory space in order of generation time from new to old, and write them back to the external storage space for use in the next round of the current round.

[0007] In order to solve the above technical problems, the third aspect of the present application provides an electronic device, which at least includes a memory and a processor coupled to each other, the memory at least stores program instructions, the processor at least includes a graphics processor, and the processor is used to execute program instructions to implement the question-and-answer interaction method in the above first aspect.

[0008] In order to solve the above technical problems, the fourth aspect of the present application provides a computer-readable storage medium, which stores program instructions that can be executed by a processor, and the program instructions are used to implement the question-and-answer interaction method of the first aspect.

[0009] The above scheme obtains the first sentence input by the user in the current round, calls the GPU computing resources to process the first sentence, obtains the current attention feature of the attention mechanism in the current round, and calls the attention feature of the attention mechanism in the historical round before the current round in the external storage space to the GPU memory space, and the historical attention feature includes the historical key feature and the historical value feature, and then calls the GPU computing resources to process the current attention feature and the historical attention feature based on the attention mechanism to obtain the second sentence to reply to the first sentence, and calls the key feature and the value feature in the GPU memory space in the order of generation time from new to old, and writes them back to the external storage space for the next round of the current round. On the one hand, the historical attention feature is directly called, and a new historical attention feature is generated after the current round, and is written back to the external storage space for the next round of retrieval, which can avoid repeated calculations as much as possible, help to improve the utilization rate of computing resources and the efficiency of pronunciation, and reduce the first response delay as much as possible. In addition, by calling the historical attention feature from the external storage space, that is, heterogeneous cache, the pressure on the demand for GPU memory space for saving historical attention features can be greatly alleviated, especially in the interactive scenario of long text. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1 It is a flowchart of an embodiment of the question-answering interactive method of the present application;

[0011] Figure 2 is a schematic diagram of an embodiment of a target video memory space;

[0012] Figure 3 It is a schematic diagram of the framework of an embodiment of the question-answering interactive device of the present application;

[0013] Figure 4 It is a schematic diagram of the framework of an embodiment of the electronic device of the present application;

[0014] Figure 5 It is a schematic diagram of a framework of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0015] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.

[0016] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0017] The terms "system" and "network" are often used interchangeably in this article. The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the fragment " / " in this article generally indicates that the associated objects before and after are in an "or" relationship. In addition, "many" in this article means two or more than two.

[0018] See also Figure 1 , Figure 1 This is a flow chart of an embodiment of the question-answer interaction method of the present application. Specifically, it may include the following steps:

[0019] Step S11: Obtain the first sentence input by the user in the current round.

[0020] In an implementation scenario, during the question-answering interaction, there may be at least one round of dialogue, and each round may include a first sentence input by the user and a second sentence in which the machine replies to the first sentence. For example, as a possible example, in the first round, the first sentence input by the user may be "I have a technical article here: ... Please help me refine the technical highlights in this technical article", and the second sentence in which the machine replies to the first sentence may be "This technical article has the following technical highlights: (1) ..., (2) ..., (3) ..."; in the second round, the first sentence input by the user may be "For technical highlight (1), please analyze the similarities and differences with the existing XX technology", and the second sentence in which the machine replies to the first sentence may be "The similarities include: (1) ..., (2) ..., and the differences include: (1) ..., (2) ..."; in the third round, the first sentence input by the user may be "For the above difference (1), please state how it is specifically implemented according to the description in the technical article", and the second sentence in which the machine replies to the first sentence may be "According to the record in this technical article, the specific implementation of difference (1) is as follows: first step, ..., second step, ..., third step, ...". Of course, the above example is only a possible example in the actual application process, and does not limit the specific content of the first statement and the second statement. In addition, for the convenience of description, in the embodiment of the present disclosure, the first statement in the first round can be recorded as Q1, and the second statement can be recorded as A1, the first statement in the second round can be recorded as Q2, and the second statement can be recorded as A2, the first statement in the third round can be recorded as Q3, and the second statement can be recorded as A3, and other rounds can be deduced in the same way, and no examples are given here one by one.

[0021] In an implementation scenario, the first sentence can be obtained by the user through text input, voice input, etc. It should be noted that when the user inputs the first sentence through text, the first sentence in text form can be directly obtained, and subsequent processing operations can be directly performed. When the user inputs the first sentence through voice, the first sentence in voice form can be recognized first to obtain the first sentence in text form, and then subsequent processing operations can be performed.

[0022] Step S12: Call the GPU computing resources to process the first statement, obtain the current attention features of the attention mechanism in the current round, and retrieve the historical attention features of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU video memory space.

[0023] In the disclosed embodiment, the historical attention features include historical key features and historical value features. It should be noted that question-answer interaction can be implemented based on the attention mechanism, that is, the second sentence in which the machine replies to the first sentence can be generated based on the attention mechanism. Exemplarily, taking the use of a large language model to generate the second sentence as an example, the large language model may include a Transformer structure, and the Transformer structure includes a network layer of an attention mechanism, such as a multi-head attention mechanism, a self-attention mechanism, etc., which are not limited here. In the case of using other artificial intelligence models to generate the second sentence, the same can be applied, and examples will not be given one by one here. In addition, regarding the method of obtaining the attention features of the attention mechanism (i.e., query features Q, key features K, and value features V) and the principles of their interaction with each other, please refer to the technical details of the attention mechanism, which will not be repeated here.

[0024] In an implementation scenario, after obtaining the first sentence in text form, the GPU computing resources can be called to process the first sentence to obtain the current attention feature of the attention mechanism in the current round. It should be noted that the current attention feature may include the current query feature, the current key feature, and the current value feature obtained by processing the first sentence. For the specific acquisition method, please refer to the technical details of the attention mechanism, which will not be repeated here.

[0025] In one implementation scenario, the external storage space is a storage space different from the GPU memory space. Exemplarily, the external storage space may include but is not limited to: CPU memory space, hard disk storage space, etc., which are not limited here.

[0026] In one implementation scenario, the historical rounds of the current round may include at least one round from the first round when the user starts the session to the previous round of the current round. Taking the current round as the third round as an example, the historical rounds may include the second round, or the historical rounds may include the second round and the first round. Other situations can be deduced by analogy, and examples are not given one by one here. In addition, in the long text scenario, the historical attention features may further include the historical attention features of the summary text of the long text. Exemplarily, still taking the aforementioned question-and-answer interaction as an example, the historical attention features may also include the attention features corresponding to the summary text of the technical article. For ease of description, the summary text may be denoted as S.

[0027] In an implementation scenario, taking the current round as the third round as an example, the current attention features may include the attention features of the first sentence Q3, and the historical attention features may include the attention features of Q1, A1, Q2, and A2. Of course, in the long text scenario, the attention features of the summary text S may also be included, that is, the historical attention features may include the attention features of S, Q1, A1, Q2, and A2. In addition, in the case where the artificial intelligence model generates sentences through retrieval enhancement, the attention features of the retrieval content RAG3 of the first sentence Q3 in the current round may also be included, that is, the historical attention features may include the attention features of S, Q1, A1, Q2, A2, and RAG3. It should be noted that the above examples are only several possible examples of the content contained in the historical attention features when the current round is the third round, and the specific content of the historical attention features is not limited thereto.

[0028] In an implementation scenario, in the process of retrieving historical attention features, it can be determined whether the total length of the current attention feature and the historical attention feature exceeds the preset window length, and based on whether the total length exceeds the preset window length, different retrieval methods are used to retrieve feature information that does not exceed the preset window length in order of generation time from new to old, and write it back to the target memory space in the GPU memory space, and the GPU computing resources retrieve the feature information from the target memory space and perform attention mechanism processing. It should be noted that the preset window length is used to reflect the number of historical review frames when generating the second sentence. In other words, the more historical review frames there are when generating the second sentence, the larger the preset window length can be set, and conversely, the fewer historical review frames there are when generating the second sentence, the smaller the preset window length can be set. The specific value of the preset window length is not limited here. In the above method, before retrieving the historical attention features, it is first determined whether the total length of the current attention features and the historical attention features exceeds the preset window length, and then different retrieval methods are used to retrieve the relevant feature information into the target memory space in the GPU memory space according to the judgment result. This method can adaptively retrieve features for different lengths, which helps to improve the efficiency of feature retrieval.

[0029] In a specific implementation scenario, in response to the total length not exceeding the preset window length, the historical attention features can be directly retrieved into the target memory space in the GPU memory space. For ease of description, the target memory space can be recorded as history_kv_gpu. In addition, the current attention features are copied to the target memory space history_kv_gpu. Exemplarily, the current attention features can be copied to the target memory space history_kv_gpu after the historical attention features. Exemplarily, please refer to Figure 2 , Figure 2 FIG. 1 is a schematic diagram of an embodiment of a target video memory space. Figure 2As shown, taking the current round as the third round as an example, the historical attention features may include: the attention features of S, Q1, A1, Q2, and A2 (i.e., K and V of the above five), and the current attention features may include the attention features of Q3. Of course, Figure 2 The above method is only a possible example in the actual application process, and does not limit the specific content in the target video memory space. For example, when the historical attention feature further includes the attention feature of the retrieval content (such as RAG3), it can be deduced by analogy, and no examples are given here one by one. In the above method, in response to the total length not exceeding the preset window length, the historical attention feature is retrieved to the target video memory space in the GPU video memory space, and the current attention feature is copied to the target video memory space, so that the GPU computing resources can retrieve the feature information from the target video memory space and perform attention mechanism processing. Therefore, it can be directly retrieved to the target video memory space when the total length does not exceed the preset window length, which helps to improve the efficiency of retrieving historical feature information.

[0030] In a specific implementation scenario, as another implementation method, different from the above situation, in response to the total length exceeding the preset window length, a temporary video memory space can be opened in the GPU video memory space, and the temporary video memory space is used to temporarily store the current attention features and historical attention features. In other words, the temporary video memory space can be reclaimed after the use is over. On this basis, feature information whose length does not exceed the preset window length can be retrieved in order from new to old, and written back to the target video memory space. Please continue to refer to Figure 2 , still taking the current round as the third round as an example, the difference is Figure 2 In the above situation, when the total length exceeds the preset window length, Figure 2The feature information shown, that is, the historical attention features represented by the attention features of S, Q1, A1, Q2, and A2 (that is, K and V of the above five) and the current attention features represented by the attention features of Q3, are first stored in the temporary video memory space. For example, the attention features of S, Q1, A1, Q2, A2, and Q3 can be stored in the temporary video memory space in sequence according to the generation order, and then the feature information with the maximum preset window length is taken from back to front, and written back to the target video memory space history_kv_gpu. Of course, the GPU pointer can also be used as the KV historical cache space for subsequent decoding (ie, decode) calculations. Of course, the above example is only a possible example in the actual application process, and does not limit the specific content in the target video memory space. For example, when the historical attention features further include the attention features of the retrieval content (such as RAG3), it can be deduced by analogy, and no examples are given here one by one. In the above method, in response to the total length exceeding the preset window length, temporary video memory space is opened in the GPUI video memory space for temporarily storing the current attention features and historical attention features, and then the feature information whose length does not exceed the preset window length is retrieved in order from new to old in terms of generation time, and written back to the target video memory space. Therefore, when the total length exceeds the preset window length, the temporary video memory space can be used as a temporary transfer of the historical cache KV, which helps to improve the efficiency of retrieving historical feature information.

[0031] In one implementation scenario, in order to further improve the efficiency of question-answering interaction, before retrieving the historical attention features of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU memory space, the first predicted duration of retrieving the historical attention feature values ​​from the external storage space to the GPU memory space can be obtained, and the second predicted duration of recalculating the historical attention features using GPU resources can be obtained. In response to the first predicted duration being less than the second predicted duration, the step of retrieving the historical attention features of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU memory space can be executed. The above method compares the first predicted duration of retrieving the historical attention features and the second predicted duration of recalculating the historical attention features, and directly retrieves the historical attention features when the former is less than the latter, which can ensure that retrieving the attention features is more efficient than recalculating as much as possible, which helps to improve the efficiency of question-answering interaction.

[0032] In a specific implementation scenario, different from the aforementioned situation, after obtaining the first predicted duration and the second predicted duration, in response to the first predicted duration being longer than the second predicted duration, the historical attention features can be recalculated using GPU computing resources. It should be noted that for the specific process of calculating the attention features, please refer to the technical details of the attention mechanism, which will not be repeated here. The above method, in response to the first predicted duration being longer than the second predicted duration, uses GPU computing resources to recalculate the historical attention features. This can use GPU computing resources to recalculate when it takes more time to retrieve the historical attention features, which helps to improve the efficiency of question-answering interaction.

[0033] In a specific implementation scenario, when the first prediction duration is equal to the second prediction duration, in order to improve the utilization of GPU computing resources, the historical attention features can be directly retrieved from the external storage space, or, if there are idle GPU computing resources, the spatial GPU computing resources can be used to recalculate the historical attention features.

[0034] Step S13: Calling GPU computing resources to process current attention features and historical attention features based on the attention mechanism to obtain a second sentence in response to the first sentence.

[0035] Specifically, after obtaining the feature information required by the attention mechanism (such as query feature Q, key feature K, and value feature V), the GPU computing resources can be called to process the current attention features and historical attention features based on the attention mechanism. In particular, the GPU resources can be called to process the current attention features and historical attention features in the target video memory space history_kv_gpu based on the attention mechanism, such as encoding, decoding and other processes. For details, please refer to the model architecture such as Transformer to obtain the second sentence in response to the first sentence. The specific process of attention mechanism and encoding and decoding will not be described here. For details, please refer to the technical details of model architectures such as Transformer. Still taking the current round as the third round as an example, for the convenience of description, the second sentence in response to the first sentence Q3 can be recorded as A3. Other cases can be deduced by analogy, and no examples are given here.

[0036] Step S14: retrieve the key features and value features in the GPU memory space in order of generation time from new to old, and write them back to the external storage space for use in the next round of the current round.

[0037] In one implementation scenario, the external storage space includes at least the CPU memory space. In this case, the key features and value features (i.e., KV features) in the GPU memory space can be retrieved in order from the newest to the oldest generation time and written back to the CPU memory space. It should be noted that at this time, since the key features and value features of the second sentence have been generated, in order to facilitate the next round of retrieval and use, the key features and value features (i.e., KV features) of the second sentence will also be retrieved and written back to the CPU memory space. The above method, which retrieves the key features and value features in the GPU memory space in order from the newest to the oldest generation time and writes them back to the CPU memory space, can maximize the speed of subsequent retrieval of historical attention features.

[0038] In a specific implementation scenario, when the total length of the historical attention features and the current attention features does not exceed the preset window length, as described above, the historical attention features can be retrieved into the target memory space in the GPU memory space, and the current attention features are copied to the target memory space. In other words, the target memory space history_kv_gpu stores historical attention features and current attention features in sequence. For example, when the current round is the third round, the target memory space history_kv_gpu stores attention features of S, Q1, A1, Q2, A2, and Q3. Therefore, the following historical KV features can be scheduled and written back in order from new to old in terms of generation time: A3, Q3, A2, Q2, A1, Q1, S, to the CPU memory space history_kv_cpu. Of course, the above example is only a possible example in actual application, and other possible situations are not limited thereto.

[0039] In a specific implementation scenario, different from the aforementioned situation, when the total length of the historical attention features and the current attention features exceeds the preset window length, as mentioned above, the current attention features and the historical attention features can be temporarily stored in the temporary memory space opened up in the GPU memory space. In other words, the temporary memory space stores historical attention features and current attention features in sequence. For example, when the current round is the third round, the temporary memory space stores the attention features of S, Q1, A1, Q2, A2, and Q3. Therefore, the following historical KV features can be scheduled and written back in order from new to old in terms of generation time: A3, Q3, A2, Q2, A1, Q1, S, to the CPU memory space history_kv_cpu. In addition, during the retrieval process, it is possible to simultaneously detect whether the total length of the retrieved features exceeds the preset threshold. If it exceeds, the retrieval is stopped. Of course, the above example is only a possible example in the actual application process, and other possible situations are not limited thereto.

[0040] In another implementation scenario, as mentioned above, the external storage space may further include a hard disk storage space. Then, when it is detected that the CPU memory space is full, in response to the presence of feature information that has not been written back in the GPU memory space, the feature information that has not been written back in the GPU memory space may be retrieved in order of generation time from new to old, and written back to the hard disk storage space. Of course, in actual application, if the CPU memory space is not full, but the feature information that has not been written back belongs to the cold data of interactive question and answer, this part of the cold data may be retrieved from the GPU memory space in order of generation time from new to old, and written back to the hard disk storage space. The above method realizes heterogeneous storage caching of KV features through GPU memory space, CPU memory space, and hard disk storage space, which can help improve the utilization rate of GPU computing resources and the efficiency of interactive question and answer while being limited by the GPU memory space.

[0041] In one implementation scenario, as described above, each user can have a conversation with the machine, and the activity level of each user in the conversation with the machine is obtained, and the user ID (i.e., user_id) of each user can be maintained by the user ID pool. In response to detecting a session request from a new user requesting to have a conversation with the machine, it can be detected whether there is an idle user ID in the user ID pool, and then based on whether there is a user ID in the user ID pool, an idle user ID in the user ID pool is assigned to the new user, so that the user can have a conversation with the machine based on the assigned user ID, or, based on the activity level, at least one of the aforementioned users can be proposed to free up an idle user ID for the new user. The above method can improve the utilization efficiency of GPU resources by updating the activity level of the user in the conversation with the machine and combining the maintained user ID pool to perform user management.

[0042] In a specific implementation scenario, the user's activity level can be updated every time the user has a new conversation with the machine. For example, the more new conversations there are between the user and the machine, the higher the user's activity level is. Conversely, the fewer new conversations there are between the user and the machine, the lower the user's activity level is. Of course, the above example is only a simple example of the positive correlation between new conversations between the user and the machine and the activity level, and does not limit the specific mathematical mapping relationship between new conversations between the user and the machine and the activity level. For example, it can be a linear relationship or a nonlinear relationship, which is not limited here.

[0043] In a specific implementation scenario, the user ID pool may be related to the abundance of GPU resources, for example, the more abundant the GPU resources, the more user IDs there may be in the user ID pool, and vice versa, the scarcer the GPU resources, the fewer user IDs there may be in the user ID pool. Similar to the relationship between the aforementioned new session and the activity level, the specific mathematical mapping relationship between the abundance of GPU resources and the user ID pool is not limited here, for example, it may be a linear relationship or a nonlinear relationship.

[0044] In a specific implementation scenario, if there are idle user identifiers in the user identifier pool, the idle user identifier can be directly assigned to the new user, so that the new user can communicate with the machine based on the assigned user identifier.

[0045] In a specific implementation scenario, if there is no idle user ID in the user ID pool, at least one of the users may be kicked out based on the activity level to free up an idle user ID for the new user. For example, the users may be sorted in order from low to high activity level, and the users before a preset rank (e.g., the first 2, the first 3, etc.) may be kicked out to free up an idle user ID for the new user.

[0046] It should be noted that, considering the application scenarios of multiple users in actual applications, it is also possible to maintain a mapping from a user to historical information (such as historical text, historical KV), so as to avoid, as much as possible, erroneously calling other users' historical KVs when generating a second sentence for replying to a user's first sentence. In addition, as mentioned above, the second reply can be obtained through encoding, decoding and other operation processes based on the attention mechanism, so at the beginning of the session, the text can be parsed as json, and matched segment by segment according to the json fields. When all fields of the historical text completely match the current text and are not exactly the same, the history can be reset without resetting, and the remaining fields can be used as input for additional calculation.

[0047] The above scheme obtains the first sentence input by the user in the current round, calls the GPU computing resources to process the first sentence, obtains the current attention feature of the attention mechanism in the current round, and calls the attention feature of the attention mechanism in the historical round before the current round in the external storage space to the GPU memory space, and the historical attention feature includes the historical key feature and the historical value feature, and then calls the GPU computing resources to process the current attention feature and the historical attention feature based on the attention mechanism to obtain the second sentence to reply to the first sentence, and calls the key feature and the value feature in the GPU memory space in the order of generation time from new to old, and writes them back to the external storage space for the next round of the current round. On the one hand, the historical attention feature is directly called, and a new historical attention feature is generated after the current round, and is written back to the external storage space for the next round of retrieval, which can avoid repeated calculations as much as possible, help to improve the utilization rate of computing resources and the efficiency of pronunciation, and reduce the first response delay as much as possible. In addition, by calling the historical attention feature from the external storage space, that is, heterogeneous cache, the pressure on the demand for GPU memory space for saving historical attention features can be greatly alleviated, especially in the interactive scenario of long text.

[0048] See also Figure 3 , Figure 3 It is a schematic diagram of the framework of an embodiment of the question-answering interactive device 30 of the present application. The question-answering interactive device 30 includes: a sentence acquisition module 31, a first call module 32, a second call module 33 and a feature write-back module 34. The sentence acquisition module 31 is used to acquire the first sentence input by the user in the current round; the first call module 32 is used to call the GPU computing resources to process the first sentence, obtain the current attention feature of the attention mechanism in the current round, and call the historical attention features of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU memory space; wherein the historical attention features include historical key features and historical value features; the second call module 33 is used to call the GPU computing resources to process the current attention features and historical attention features based on the attention mechanism to obtain the second sentence that replies to the first sentence; the feature write-back module 34 is used to call the key features and value features in the GPU memory space in the order of generation time from new to old, and write them back to the external storage space for the next round of the current round.

[0049] In the above scheme, the question-answering interaction device 30 obtains the first sentence input by the user in the current round, calls the GPU computing resources to process the first sentence, obtains the current attention feature of the attention mechanism in the current round, and calls the attention feature of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU memory space, and the historical attention feature includes the historical key feature and the historical value feature, and then calls the GPU computing resources to process the current attention feature and the historical attention feature based on the attention mechanism to obtain the second sentence in reply to the first sentence, and calls the key feature and the value feature in the GPU memory space in order from the new to the old generation time, and writes them back to the external storage space for use in the next round of the current round. On the one hand, the historical attention feature is directly called, and a new historical attention feature is generated after the current round, and is written back to the external storage space for retrieval in the next round, which can avoid repeated calculations as much as possible, help to improve the utilization rate of computing resources and the efficiency of pronunciation, and reduce the first response delay as much as possible. In addition, by retrieving historical attention features from external storage space, namely heterogeneous cache, the pressure on GPU memory space required to store historical attention features can be greatly alleviated, especially in interactive scenarios with long texts.

[0050] In some disclosed embodiments, the first retrieval module 32 includes a length judgment submodule, which is used to determine whether the total length of the current attention feature and the historical attention feature exceeds the preset window length; the first retrieval module 32 includes a feature retrieval submodule, which is used to retrieve feature information that does not exceed the preset window length in order of generation time from new to old, based on whether the total length exceeds the preset window length, using different retrieval methods, and write it back to the target video memory space in the GPU video memory space; wherein, the GPU computing resources retrieve the feature information from the target video memory space and perform attention mechanism processing.

[0051] In some disclosed embodiments, the feature extraction submodule is specifically used to retrieve the historical attention features into the target memory space in the GPU memory space in response to the total length not exceeding the preset window length; wherein the current attention features are copied to the target memory space.

[0052] In some disclosed embodiments, the feature extraction submodule is specifically used to allocate temporary video memory space in the GPU video memory space in response to a total length exceeding a preset window length; wherein the temporary video memory space is used to temporarily store current attention features and historical attention features; feature information whose length does not exceed the preset window length is retrieved in order of generation time from new to old, and written back to the target video memory space.

[0053] In some disclosed embodiments, the question-and-answer interaction device 30 also includes a duration prediction module, which is used to obtain a first predicted duration for retrieving historical attention features from an external storage space to a GPU video memory space, and to obtain a second predicted duration for recalculating the historical attention features using GPU computing resources; the first retrieval module 32 is specifically used to execute the step of retrieving the historical attention features of the attention mechanism in historical rounds before the current round in the external storage space to the GPU video memory space in response to the first predicted duration being less than the second predicted duration.

[0054] In some disclosed embodiments, the question-answer interaction device 30 further includes a feature calculation module for recalculating historical attention features using GPU computing resources in response to the first predicted duration being longer than the second predicted duration.

[0055] In some disclosed embodiments, the external storage space includes at least CPU memory space, and the second calling module 33 is specifically used to call key features and value features in the GPU video memory space in order of generation time from new to old, and write them back to the CPU memory space.

[0056] In some disclosed embodiments, the external storage space also includes hard disk storage space. The second retrieval module 33 is specifically used to, when the CPU memory space is full, in response to the presence of feature information that has not been written back in the GPU video memory space, retrieve the feature information that has not been written back in the GPU video memory space in order of generation time from new to old, and write it back to the hard disk storage space.

[0057] In some disclosed embodiments, the question-and-answer interaction device 30 further includes an activity evaluation module for obtaining the activity level of each user in communicating with the machine; wherein the user ID of each user is maintained by a user ID pool; the question-and-answer interaction device 30 further includes an ID detection module for detecting whether there is an idle user ID in the user ID pool in response to detecting a session request from a new user requesting to communicate with the machine; the question-and-answer interaction device 30 further includes an ID assignment module for assigning an idle user ID in the user ID pool to the new user based on whether there is an idle user ID in the user ID pool, or, based on the activity level, kicking out at least one of the users to free up an idle user ID for the new user.

[0058] See also Figure 4 , Figure 4It is a schematic diagram of the framework of an embodiment of an electronic device 40 of the present application. The electronic device 40 includes a memory 41 and a processor 42 coupled to each other, the memory 41 at least stores program instructions, and the processor 42 includes at least a graphics processor (not shown). It should be noted that, as a possible example, the processor 42 may also include a central processing unit (not shown). In addition, as a possible example, the memory 41 may include but is not limited to volatile storage media such as memory, and non-volatile storage media such as hard disks. The processor 42 is used to execute program instructions to implement the steps in any of the above-mentioned question-and-answer interaction method embodiments. For details, please refer to the aforementioned disclosed embodiments, which will not be repeated here. The electronic device 40 may specifically include but is not limited to mobile phones, tablet computers, learning machines, office books, etc., and the specific type of the electronic device 40 is not limited here.

[0059] Specifically, the processor 42 is used to control itself and the memory 41 to implement the steps in any of the above-mentioned question-answer interaction method embodiments. The processor 42 can also be called a CPU (Central Processing Unit). The processor 42 may be an integrated circuit chip with signal processing capabilities. The processor 42 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 42 can be implemented by an integrated circuit chip.

[0060] In the above scheme, the electronic device 40 obtains the first sentence input by the user in the current round, calls the GPU computing resources to process the first sentence, obtains the current attention feature of the attention mechanism in the current round, and calls the attention feature of the attention mechanism in the historical round before the current round in the external storage space to the GPU memory space, and the historical attention feature includes the historical key feature and the historical value feature, and then calls the GPU computing resources to process the current attention feature and the historical attention feature based on the attention mechanism to obtain the second sentence to reply to the first sentence, and calls the key feature and the value feature in the GPU memory space in order from the new to the old generation time, and writes them back to the external storage space for use in the next round of the current round. On the one hand, the historical attention feature is directly called, and a new historical attention feature is generated after the current round, and is written back to the external storage space for retrieval in the next round, which can avoid repeated calculations as much as possible, help to improve the utilization rate of computing resources and the efficiency of pronunciation, and reduce the first response delay as much as possible. In addition, by retrieving historical attention features from external storage space, namely heterogeneous cache, the pressure on GPU memory space required to store historical attention features can be greatly alleviated, especially in interactive scenarios with long texts.

[0061] See also Figure 5 , Figure 5 1 is a schematic diagram of a framework of an embodiment of a computer-readable storage medium 50 of the present application. The computer-readable storage medium 50 stores program instructions 51 that can be executed by a processor, and the program instructions 51 are used to implement the steps in any of the above-mentioned question-answer interaction method embodiments.

[0062] In the above scheme, the computer-readable storage medium 50 obtains the first sentence input by the user in the current round, calls the GPU computing resources to process the first sentence, obtains the current attention feature of the attention mechanism in the current round, and calls the attention feature of the attention mechanism in the historical round before the current round in the external storage space to the GPU memory space, and the historical attention feature includes the historical key feature and the historical value feature, and then calls the GPU computing resources to process the current attention feature and the historical attention feature based on the attention mechanism to obtain the second sentence to reply to the first sentence, and calls the key feature and the value feature in the GPU memory space in order from the new to the old generation time, and writes them back to the external storage space for use in the next round of the current round. On the one hand, the historical attention feature is directly called, and a new historical attention feature is generated after the current round, and is written back to the external storage space for retrieval in the next round, which can avoid repeated calculations as much as possible, help to improve the utilization rate of computing resources and the efficiency of pronunciation, and reduce the first response delay as much as possible. In addition, by retrieving historical attention features from external storage space, namely heterogeneous cache, the pressure on GPU memory space required to store historical attention features can be greatly alleviated, especially in interactive scenarios with long texts.

[0063] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0064] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0065] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0066] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0067] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0068] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0069] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

Claims

1. A question-answering interactive method, characterized in that: include: Get the first sentence entered by the user in the current round; Calling GPU computing resources to process the first statement, obtaining the current attention features of the attention mechanism in the current round, obtaining a first predicted duration for retrieving the historical attention features of the attention mechanism in the historical rounds before the current round from the external storage space to the GPU memory space, and obtaining a second predicted duration for recalculating the historical attention features using the GPU computing resources, and in response to the first predicted duration being less than the second predicted duration, retrieving the historical attention features of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU memory space, and in response to the first predicted duration being more than the second predicted duration, recalculating the historical attention features using the GPU computing resources; wherein the historical attention features include historical key features and historical value features; Calling the GPU computing resource to process the current attention feature and the historical attention feature based on the attention mechanism to obtain a second statement in response to the first statement; The key features and value features in the GPU memory space are retrieved in order of generation time from new to old, and written back to the external storage space for use in the next round of the current round.

2. The method according to claim 1, characterized in that The step of retrieving the historical attention features of the attention mechanism in the historical rounds before the current round in the external storage space to the GPU memory space includes: Determining whether the total length of the current attention feature and the historical attention feature exceeds a preset window length; Based on whether the total length exceeds the preset window length, different calling methods are used to call feature information that does not exceed the preset window length in the order of generation time from new to old, and write it back to the target video memory space in the GPU video memory space; The GPU computing resource retrieves feature information from the target video memory space and performs attention mechanism processing.

3. The method according to claim 2, characterized in that The method further comprises: In response to the total length not exceeding the preset window length, retrieving the historical attention feature into the target video memory space in the GPU video memory space; Wherein, the current attention feature is copied to the target video memory space.

4. The method according to claim 2, characterized in that: The method further comprises: In response to the total length exceeding the preset window length, a temporary video memory space is opened in the GPU video memory space; wherein the temporary video memory space is used to temporarily store the current attention feature and the historical attention feature; Feature information whose length does not exceed the preset window length is retrieved in the order of generation time from new to old, and written back to the target video memory space.

5. The method according to claim 1, characterized in that The external storage space includes at least a CPU memory space, and the step of retrieving key features and value features in the GPU memory space in a descending order of generation time and writing them back to the external storage space includes: The key features and value features in the GPU memory space are retrieved in order of generation time from new to old, and written back to the CPU memory space.

6. The method according to claim 5, characterized in that The external storage space also includes a hard disk storage space. When the CPU memory space is full, the method further includes: In response to the presence of unwritten feature information in the GPU video memory space, the unwritten feature information in the GPU video memory space is retrieved in a descending order of generation time, and written back to the hard disk storage space.

7. The method according to claim 1, characterized in that The method further comprises: Obtaining the activity level of each user's conversation with the machine; wherein the user ID of each user is maintained by a user ID pool; In response to detecting a session request from a new user requesting to have a conversation with the machine, detecting whether there is an idle user identifier in the user identifier pool; Based on whether there is an idle user identifier in the user identifier pool, an idle user identifier in the user identifier pool is assigned to the new user, or, based on the activity level, at least one of the users is kicked out to free up an idle user identifier for the new user.

8. A question-answering interactive device, characterized in that: include: A sentence acquisition module, used to acquire the first sentence input by the user in the current round; A first calling module is used to call the GPU computing resources to process the first statement, obtain the current attention feature of the attention mechanism in the current round, obtain the first predicted duration of calling the historical attention feature of the attention mechanism in the historical round before the current round from the external storage space to the GPU memory space, and obtain the second predicted duration of recalculating the historical attention feature using the GPU computing resources, and in response to the first predicted duration being less than the second predicted duration, call the historical attention feature of the attention mechanism in the historical round before the current round in the external storage space to the GPU memory space, and in response to the first predicted duration being more than the second predicted duration, recalculate the historical attention feature using the GPU computing resources; wherein the historical attention feature includes a historical key feature and a historical value feature; A second calling module is used to call the GPU computing resource to process the current attention feature and the historical attention feature based on the attention mechanism to obtain a second statement in response to the first statement; The feature write-back module is used to retrieve the key features and value features in the GPU memory space in order of generation time from new to old, and write them back to the external storage space for use in the next round of the current round.

9. An electronic device, characterized in that: The system comprises at least a memory and a processor coupled to each other, wherein the memory stores at least program instructions, and the processor comprises at least a graphics processor, and the processor is used to execute the program instructions to implement the question-answering interaction method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Program instructions that can be executed by a processor are stored, and the program instructions are used to implement the question-answering interaction method described in any one of claims 1 to 7.