A large language model intelligent interaction method based on memory recall
By introducing a memory backtracking mechanism into the large language model, storing and proofreading the interactive output results, the problem of inconsistent output in long-term interactions is solved, and the stability and reliability of the interaction of the large language model are achieved.
Patent Information
- Application Number
- CN202410687153.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-05-30
AI Technical Summary
During the long-term interaction of existing large language models, the output results are inconsistent with the historical output results.
Using a large language model intelligent interaction method based on memory backtracking, the input text is preprocessed, token response sequences are generated and mapped to multiple sets of token pools, the response sequences and coded values are stored as historical output results, and the consistency of the output results is verified when new inputs are new, and self-detection is performed to ensure the consistency of the output.
The stability of interaction between large language models is realized. By comparing the output results of existing models with the output results of other models, the output problems of inconsistencies in long-term interactions are corrected, and the reliability of interaction is improved.
Smart Images

Figure CN118981514B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of large model interaction, and in particular relates to a large language model intelligent interaction method based on memory recall. Background Art
[0002] With the development of society, the rise of artificial intelligence has led to the birth of a series of large language models. Large language models refer to language models that are trained on large-scale text corpora and include at least tens of billions of parameters. They are designed to understand and generate human language, and through this large amount of text training, they can perform a wide range of interactive and generative tasks.
[0003] In the prior art, generally, the user's prompt words are used and the prompt words are abstracted into tokens so that the large language model can understand and remember the user's interaction behavior during an interaction process and generate short-term logical and recognizable interactions. However, although the interaction method using prompt word tokens can achieve relatively ideal dialogue and generative tasks with concise input, there is a problem of inconsistency between output results and historical output results during long-term interactions.
[0004] In view of this, it is urgent to propose a large language model intelligent interaction method based on memory recall to solve the problem of consistent output results of long-term interactions based on the existing large model. Summary of the invention
[0005] The present invention provides a large language model intelligent interaction method based on memory backtracking to solve the problem of consistent output results of long-term interaction.
[0006] A first aspect of the present invention provides a large language model intelligent interaction method based on memory backtracking, comprising the following steps:
[0007] S1. Get input text;
[0008] S2, preprocessing the input text, dividing the first input text into preset sizes according to a preset segmentation rule, generating a token response sequence and mapping it to multiple groups of different token pools;
[0009] S3, obtaining a discrete combination set generated when the response sequence is mapped to each group of the token pool;
[0010] The discrete combination set is a probabilistic discrete unit generated according to each sequence unit included in the response sequence, and the generation steps are:
[0011] Each sequence unit is mapped to the token pool.
[0012] Get the combination with the highest probability from one token to another;
[0013] And stop when the Nth token is obtained and the probability of obtaining it is 1.
[0014] Store the encoding value when the probability discrete unit is generated;
[0015] S4. Store the response sequence and the corresponding encoding values of the first input text as a historical output result.
[0016] S5. When a new input text is obtained, the historical output results are proofread according to the output results and the consistency of the output results in the multiple groups of token pools is self-checked, and then the interaction is performed.
[0017] Furthermore, each group of the token pool is stored by a large language model, and a corresponding mapping rule is established, and the mapping rule includes:
[0018] The number of tokens divided by the first input text;
[0019] The number of characters in the token unit segmented by the first input text;
[0020] The number of character intervals of the token units segmented by the first input text;
[0021] Sort the tokens segmented by the first input text;
[0022] And the preset segmentation rule at least includes any segmentation method in the mapping rule.
[0023] Furthermore, the step of performing the self-detection includes:
[0024] Obtain the output results of each of the token pools, and if the output results are consistent under the preset conditions, output the results;
[0025] If the output results of any of the token pools are inconsistent under the preset conditions, the first self-detection is performed on the corresponding large language model and the result is output.
[0026] Furthermore, the specific steps of performing the first self-test are as follows:
[0027] From the historical output results, the sequence units corresponding to the same number of tokens included in the probability discrete unit and the same probability between tokens are constructed as a sequence unit set;
[0028] Generate a first input text including the sequence unit set, and assign a value to the first input text;
[0029] Generate a second input text by removing the sequence unit set, and assign a value to the second input text;
[0030] Performing output tests on the first input text and the second input text respectively to obtain a sample average value of the accuracy of the output results;
[0031] If the sample mean value is within the preset confidence interval, output the recognition result;
[0032] Otherwise, a second self-test is performed.
[0033] Further, the step of performing the second self-test includes:
[0034] Obtain an inconsistent large language model, reconstruct the second input text into a third input text and store it, and mark the first question data when storing it;
[0035] constructing a fourth input text including the second input text,
[0036] The token sorting index mode and the number of tokens of the third input text are the same as those of the second input text.
[0037] The fourth input text and the second input text have the same number of characters in the token and the same character spacing between tokens;
[0038] Execute the outputs of S1-S4 on the third input text and the fourth input text respectively, and remove the output result of the large language model containing the first question data;
[0039] If the output result of a certain text recognition model is inconsistent under the preset conditions, the second question data is marked to the large language model and returns to the first self-detection.
[0040] Furthermore, if all of the large language models are inconsistent within a preset range, an interactive reset is initiated and error correction is performed.
[0041] Further, each of the large language models is proofread in sequence according to the timestamp order in which the first query data and the second query data were generated;
[0042] When the output result of the large language shows a mapping occurrence error, and when the total number and total type of mappings are both within a preset range, the mappings identified as errors in the query model are adjusted to mapping types within the preset range;
[0043] When the output result in the large language is a historical error, the discrete probability unit with the highest frequency in other large language models in the previous interaction is written into the large language model, and a forced index and a forced starting unit are generated to execute step S3.
[0044] Furthermore, the preset range includes:
[0045] Token quantity threshold
[0046] The threshold of the number of characters in a token unit
[0047] The threshold of the number of character intervals in a token unit
[0048] Threshold for token sorting;
[0049] The mapping type, number of mappings, and threshold of the mapping rate of response units to tokens
[0050] The threshold value for the number of discrete probability units with the highest frequency in the previous input.
[0051] A second aspect of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it is suitable for implementing the method provided by the first aspect of the present invention.
[0052] According to a third aspect of the present invention, there is provided a storage medium having a computer program stored thereon, which, when executed by a processor, is suitable for implementing the method provided by the first aspect of the present invention.
[0053] The above technical solution of the present invention has the following advantages compared with the prior art:
[0054] The present invention realizes error correction for long-time interactions in a large language model by comparing the output results in an existing model with unexpected output results of the existing model, thereby achieving stability of the interaction of the large language model. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a flowchart of the method provided by the embodiment of the present invention.
[0056] Figure 2 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention DETAILED DESCRIPTION
[0057] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.
[0058] Embodiment 1
[0059] A first aspect of the present invention provides a large language model intelligent interaction method based on memory backtracking, comprising the following steps:
[0060] S1. Get input text;
[0061] S2, preprocessing the input text, dividing the first input text into preset sizes according to a preset segmentation rule, generating a token response sequence and mapping it to multiple groups of different token pools;
[0062] S3, obtaining a discrete combination set generated when the response sequence is mapped to each group of the token pool;
[0063] The discrete combination set is a probabilistic discrete unit generated according to each sequence unit included in the response sequence, and the generation steps are:
[0064] Each sequence unit is mapped to the token pool.
[0065] Get the combination with the highest probability from one token to another;
[0066] And stop when the Nth token is obtained and the probability of obtaining it is 1.
[0067] Store the encoding value when the probability discrete unit is generated;
[0068] S4. Store the response sequence and the corresponding encoding values regarding the first input text as historical output results; the encoding values in the disclosed embodiment are used to quickly check the relevance of tokens mapped to the same segmented unit during two different interactions, and are also used to provide rapid indexing and generation of associated texts for historical interactions during subsequent input.
[0069] S5. When a new input text is obtained, the historical output results are proofread according to the output results and the consistency of the output results in the multiple groups of token pools is self-checked, and then the interaction is performed.
[0070] Furthermore, each group of the token pool is stored by a large language model, and a corresponding mapping rule is established, and the mapping rule includes:
[0071] The number of tokens divided by the first input text;
[0072] The number of characters in the token unit segmented by the first input text;
[0073] The number of character intervals of the token units segmented by the first input text;
[0074] Sort the tokens segmented by the first input text;
[0075] And the preset segmentation rule at least includes any segmentation method in the mapping rule.
[0076] Furthermore, the step of performing the self-detection includes:
[0077] Obtain the output results of each of the token pools, and if the output results are consistent under the preset conditions, output the results;
[0078] If the output results of any of the token pools are inconsistent under the preset conditions, the first self-detection is performed on the corresponding large language model and the result is output.
[0079] Furthermore, the specific steps of performing the first self-test are as follows:
[0080] From the historical output results, the sequence units corresponding to the same number of tokens included in the probability discrete unit and the same probability between tokens are constructed as a sequence unit set;
[0081] Generate a first input text including the sequence unit set, and assign a value to the first input text;
[0082] Generate a second input text by removing the sequence unit set, and assign a value to the second input text;
[0083] Performing output tests on the first input text and the second input text respectively to obtain a sample average value of the accuracy of the output results;
[0084] If the sample mean value is within the preset confidence interval, output the recognition result;
[0085] Otherwise, a second self-test is performed.
[0086] In this embodiment, three text recognition models are taken as examples.
[0087] First, use model A and model B to output at the same time, compare the output results a and b, and if a=b, output the result.
[0088] If a≠b, model C is used for re-recognition, and the recognition result c is compared with a and b. When c=a or c=b, the result c is output.
[0089] When a, b, and c are not equal, the recognition result is incorrect and the output result is marked as p. i , p i Assign a value of 0. When at least two of a, b, and c are equal, the recognition result is correct, and the first self-detection is correct, and the output result is marked as q j .
[0090] Marked p i,q j Together they form a set R, namely:
[0091] R=(p t ,q j ),i=1,2,...,m,j=1,2,...,n
[0092] Then calculate the value of the output accuracy I of the number of samples in the set R:
[0093]
[0094] Among them, I is the recognition accuracy; m+n is the total number of samples, where m is p i The number of n is q j The number of i ,q j ——Output tag value.
[0095] The confidence interval of the sample is determined based on the actual threshold requirements within the preset range.
[0096] Further, the step of performing the second self-test includes:
[0097] Obtain an inconsistent large language model, reconstruct the second input text into a third input text and store it, and mark the first question data when storing it;
[0098] constructing a fourth input text including the second input text,
[0099] The token sorting index mode and the number of tokens of the third input text are the same as those of the second input text.
[0100] The fourth input text and the second input text have the same number of characters in the token and the same character spacing between tokens;
[0101] Execute the outputs of S1-S4 on the third input text and the fourth input text respectively, and remove the output result of the large language model containing the first question data;
[0102] If the output result of a certain text recognition model is inconsistent under the preset conditions, the second question data is marked to the large language model and returns to the first self-detection.
[0103] Furthermore, if all of the large language models are inconsistent within a preset range, an interactive reset is initiated and error correction is performed.
[0104] Further, each of the large language models is proofread in sequence according to the timestamp order in which the first query data and the second query data were generated;
[0105] When the output result of the large language shows a mapping occurrence error, and when the total number and total type of mappings are both within a preset range, the mappings identified as errors in the query model are adjusted to mapping types within the preset range;
[0106] When the output result in the large language is a historical error, the discrete probability unit with the highest frequency in other large language models in the previous interaction is written into the large language model, and a forced index and a forced starting unit are generated to execute step S3.
[0107] It should be noted that when performing the second self-detection, a judgment is made one by one based on the entirety of the preset range and corrected to a preset value, such as a threshold value of the number of tokens;
[0108] The threshold of the number of characters in a token unit;
[0109] The threshold of the number of character intervals in a token unit;
[0110] Threshold for token sorting;
[0111] The mapping type, number of mappings, and threshold of the mapping occurrence rate of the response unit to the token.
[0112] The coding value in S4 of the disclosed embodiment needs to be verified during each detection to verify the correlation with the previous input text. If the correlation is not within the preset range, the second question data is still written. It should be noted that the preset range of correlation is related to the total number of units corresponding to the same coding value in each of the models.
[0113] Furthermore, the preset range includes:
[0114] The threshold of the number of tokens;
[0115] The threshold of the number of characters in a token unit;
[0116] The threshold of the number of character intervals in a token unit;
[0117] Threshold for token sorting;
[0118] The mapping type, mapping quantity and mapping occurrence threshold of the response unit to the token, in the embodiment of the present disclosure, is the part-of-speech combination type of the characters in which the number of characters of the token unit is truncated when a unit is generated into a discrete combination set by a large language model.
[0119] The threshold value of the number of discrete probability units with the highest frequency in the previous input. The present invention realizes error correction for long-term interaction in a large language model by comparing the output results in the existing model with the unexpected output results of the existing model, thereby achieving the stability of the interaction of the large language model.
[0120] Embodiment 2
[0121] Combination Figure 2 As shown, an embodiment of the present disclosure provides an electronic device, including a processor (processor) 30 and a memory (memory) 31.
[0122] Optionally, the device may further include a communication interface (CommunicationInterface) 32 and a bus 33. The processor 30, the communication interface 32, and the memory 31 may communicate with each other through the bus 33. The communication interface 32 may be used for information transmission. The processor 30 may call the logic instructions in the memory 31 to execute the method of the above embodiment.
[0123] An embodiment of the present disclosure provides a storage medium storing computer executable instructions, wherein the computer executable instructions are configured to execute the above method.
[0124] The above-mentioned storage medium may be a transient computer-readable storage medium or a non-transient computer-readable storage medium. Non-transient storage media include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes, and may also be a transient storage medium.
[0125] The above description and accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. The parts and features of some embodiments may be included in or replace the parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
Claims
1. A large language model intelligent interaction method based on memory recall, characterized in that: The steps include: S1. Get input text; S2, preprocessing the input text, dividing the first input text into preset sizes according to a preset segmentation rule, generating a token response sequence and mapping it to multiple groups of different token pools; S3, obtaining a discrete combination set generated when the response sequence is mapped to each group of the token pool; The discrete combination set is a probabilistic discrete unit generated according to each sequence unit included in the response sequence, and the generation steps are: Each sequence unit is mapped to the token pool. Get the combination with the highest probability from one token to another; And stop when the Nth token is obtained and the probability of obtaining it is 1. Store the encoding value when the probability discrete unit is generated; S4, storing the response sequence and the corresponding code values regarding the first input text as a historical output result; S5. When a new input text is obtained, the historical output results are proofread according to the output results and the consistency of the output results in the multiple groups of token pools is self-checked, and then the interaction is performed.
2. The large language model intelligent interaction method based on memory tracing according to claim 1 is characterized in that: Each group of the token pool is stored by a large language model, and a corresponding mapping rule is established. The mapping rule includes: The number of tokens divided by the first input text; The number of characters in the token unit segmented by the first input text; The number of character intervals of the token units segmented by the first input text; Sort the tokens segmented by the first input text; And the preset segmentation rule at least includes any segmentation method in the mapping rule.
3. The large language model intelligent interaction method based on memory tracing according to claim 2 is characterized in that: The steps of performing the self-test include: Obtain the output results of each of the token pools, and if the output results are consistent under the preset conditions, output the results; If the output results of any of the token pools are inconsistent under the preset conditions, the first self-detection is performed on the corresponding large language model and the result is output.
4. The large language model intelligent interaction method based on memory tracing according to claim 1 is characterized in that: The specific steps for performing the first self-test are as follows: From the historical output results, the sequence units corresponding to the same number of tokens included in the probability discrete unit and the same probability between tokens are constructed as a sequence unit set; Generate a first input text including the sequence unit set, and assign a value to the first input text; Generate a second input text by removing the sequence unit set, and assign a value to the second input text; Performing output tests on the first input text and the second input text respectively to obtain a sample average value of the accuracy of the output results; If the sample mean value is within the preset confidence interval, output the recognition result; Otherwise, a second self-test is performed.
5. The large language model intelligent interaction method based on memory tracing according to claim 2 is characterized in that: The steps of performing the second self-test include: Obtain an inconsistent large language model, reconstruct the second input text into a third input text and store it, and mark the first question data when storing it; constructing a fourth input text including the second input text, The token sorting index mode and the number of tokens of the third input text are the same as those of the second input text. The fourth input text and the second input text have the same number of characters in the token and the same character spacing between tokens; Execute the outputs of S1-S4 on the third input text and the fourth input text respectively, and remove the output result of the large language model containing the first question data; If the output result of a certain text recognition model is inconsistent under the preset conditions, the second question data is marked to the large language model and returns to the first self-detection.
6. The large language model intelligent interaction method based on memory tracing according to claim 5 is characterized in that: If all of the large language models are inconsistent within a preset range, an interactive reset is initiated and error correction is performed.
7. The large language model intelligent interaction method based on memory tracing according to claim 6 is characterized in that: Proofreading each of the large language models in sequence according to the timestamp order in which the first query data and the second query data were generated; When the output result of the large language shows a mapping occurrence error, and when the total number and total type of mappings are both within a preset range, the mappings identified as errors in the query model are adjusted to mapping types within the preset range; When the output result in the large language is a historical error, the discrete probability unit with the highest frequency in other large language models in the previous interaction is written into the large language model, and a forced index and a forced starting unit are generated to execute step S3.
8. The large language model intelligent interaction method based on memory tracing according to claim 7 is characterized in that: The preset range includes: The threshold of the number of tokens; The threshold of the number of characters in a token unit; The threshold of the number of character intervals in a token unit; Threshold for token sorting; The mapping type, number of mappings, and threshold of the mapping occurrence rate of the response unit to the token; The threshold value for the number of discrete probability units with the highest frequency in the previous input.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the computer is adapted to implement the method according to any one of claims 1 to 8.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it is suitable for implementing the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Error correction method and device based on language model, equipment and storage medium
CN111428474A
Paper detection method and device, storage medium and terminal
CN117033555A