Method and device for generating reply text, electronic device and storage medium
By predicting semantically continuous word groups in a large language model and concatenating words with high confidence, the problem of slow traditional text generation speed is solved, achieving faster response text generation and high text generation efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
- Filing Date
- 2024-05-21
- Publication Date
- 2026-06-16
AI Technical Summary
Traditional large language models are slow in text generation, and using additional generation models leads to complex model structures and cumbersome training processes, resulting in high costs.
By predicting multiple semantically continuous word groups in each word generation process, and identifying target words with a confidence level not less than a threshold from these groups, which are then appended to the end of the generated text, the system iterates through the process to finally obtain the response text.
It accelerates the generation of response text, simplifies the model structure, improves generation efficiency, and does not require adjustments to the target language model structure, thus exhibiting high versatility.
Smart Images

Figure CN118503378B_ABST
Abstract
Claims
1. A method of generating a reply text, characterized by, The method includes: For the i-th vocabulary generation process, the target language model is used to predict the question text and the first text to obtain the first vocabulary group. The target language model is used to output the response text for the question text based on the input question text. The first text is the intermediate response text for the question text obtained after the (i-1)-th vocabulary generation process. The first vocabulary group includes multiple words with consecutive semantics, where i is a positive integer not less than 1. Starting from the first word in the first vocabulary group, continuously acquire at least one target word with a confidence level not less than the confidence threshold; By appending the at least one target word to the end of the first text, a second text is obtained; If the second text satisfies the iteration termination condition, the second text is determined as the response text to the question text; If the second text does not meet the iteration termination condition, vocabulary generation continues iteratively based on the question text and the second text until the answer text to the question text is obtained.
2. The reply text generating method according to claim 1, characterized by, The first vocabulary group contains k words, where k is a positive integer greater than 1; for the i-th vocabulary generation process, the first vocabulary group is obtained by predicting the question text and the first text based on the target language model, including: For the i-th word generation process, k-1 placeholders are added to the end of the first text. The placeholders are used to occupy space at the end of the first text and indicate the word position. When the word to be predicted is the nth word in the first word group, the target language model is used to predict the question text, the first text, and the first n-1 placeholders to obtain the nth word in the first word group. The nth word is semantically continuous with the words corresponding to the first text and the first n-1 placeholders, where n is a positive integer not less than 1 and not greater than k.
3. The method of claim 1, wherein, The number of words in the first vocabulary group is k, where k is a positive integer greater than 1; the step of continuously acquiring at least one target word with a confidence level not less than a confidence threshold, starting from the first word in the first vocabulary group, includes: If the confidence scores of the first m words in the first vocabulary group are all not less than the confidence threshold, then when the confidence score of the (m+1)th word in the first vocabulary group is less than the confidence threshold, the first m words in the first vocabulary group are determined as the at least one target word, where m is a positive integer not less than 1 and not greater than k; or... If the confidence scores of the first m words in the first vocabulary group are not less than the confidence threshold, then when the m-th word in the first vocabulary group is the last word in the first vocabulary group, the first m words in the first vocabulary group are determined as the at least one target word.
4. The method of claim 1, wherein, The number of words in the first vocabulary group is k, where k is a positive integer greater than 1; the step of continuously acquiring at least one target word with a confidence level not less than a confidence threshold, starting from the first word in the first vocabulary group, includes: If the p-th word and the q-th word in the first vocabulary group are the same, starting from the first word in the first vocabulary group, at least one target word with a confidence level not less than the confidence level threshold is continuously obtained from the first p words in the first vocabulary group, where p is a positive integer not less than 1 and less than k, and q is a positive integer greater than p and not greater than k.
5. The method for generating response text according to claim 1, characterized in that, The iterative process of generating vocabulary based on the question text and the second text until the answer text to the question text is obtained includes: For the (i+1)th word generation process, the question text and the second text are predicted based on the target language model to obtain a second word group, which includes multiple words with consecutive meanings. If the confidence scores of multiple words in the second vocabulary group are all less than the target threshold, the second text is determined as the response text to the question text, and the target threshold is not greater than the confidence threshold.
6. The method for generating response text according to any one of claims 1-5, characterized in that, The iterative process of generating vocabulary based on the question text and the second text until the answer text to the question text is obtained includes: For the (i+1)th word generation, the question text and the second text are predicted based on the target language model to obtain a second word group, which includes multiple words with consecutive semantics. Starting from the first word in the second vocabulary group, continuously acquire at least one target word with a confidence level not less than the confidence threshold; At least one target word from the second vocabulary group is appended to the end of the second text to obtain the third text; If the number of words in the third text is not less than a certain threshold, the third text is determined as the response text to the question text.
7. The method for generating response text according to any one of claims 1-5, characterized in that, The iterative process of generating vocabulary based on the question text and the second text until the answer text to the question text is obtained includes: For the (i+1)th word generation process, the question text and the second text are predicted based on the target language model to obtain a second word group, which includes multiple words with consecutive meanings. If the confidence level of the first word in the second vocabulary group is less than the confidence level threshold, the first word is appended to the end of the second text to obtain the third text; When the number of iterations reaches the iteration threshold, the third text is determined as the response text to the question text.
8. The method for generating response text according to claim 7, characterized in that, The method further includes: If the number of iterations does not reach the iteration threshold, vocabulary generation continues based on the question text and the third text until the answer text to the question text is obtained.
9. The method for generating response text according to any one of claims 1-5, characterized in that, The training methods for the target language model include: Construct a target training dataset, wherein each piece of training data in the target training dataset includes a question sample and a target response sample corresponding to the question sample, and the target response sample includes at least one target word; For each round of training, any training data is input into the language model to be updated for prediction, and the predicted text of the question sample in the training data is output. Based on the target response sample in the training data and the predicted text, the language model to be updated is trained to obtain the target language model.
10. The method for generating response text according to claim 9, characterized in that, The construction of the target training dataset includes: Based on the initial training dataset, the language model to be adjusted is fine-tuned to obtain the adjusted language model. Each piece of initial training data in the initial training dataset includes a question sample and an initial response sample. The initial response sample includes at least one word. Input any initial training data into the adjusted language model for prediction, and output the target response sample of the question sample in the initial training data; The training data consisting of the question samples and the target response samples is added to the target training dataset.
11. An apparatus for generating response text, characterized in that, The device includes: The prediction unit is configured to predict the question text and the first text based on the target language model for the i-th word generation process to obtain a first word group. The target language model is used to output the response text for the question text based on the input question text. The first text is the intermediate response text for the question text obtained after the (i-1)-th word generation process. The first word group includes multiple words with consecutive semantics, where i is a positive integer not less than 1. The acquisition unit is configured to continuously acquire at least one target word with a confidence level not less than a confidence threshold, starting from the first word in the first vocabulary group; A splicing unit is configured to splice the at least one target word to the end of the first text to obtain a second text; The prediction unit is further configured to determine the second text as the response text to the question text if the second text satisfies the iteration termination condition; The prediction unit is further configured to continue iterating word generation based on the question text and the second text if the second text does not meet the iteration termination condition, until the answer text to the question text is obtained.
12. An electronic device, characterized in that, The electronic device includes: One or a first number of processors; Memory used to store the executable program code of the processor; The processor is configured to execute the program code to implement the method for generating response text as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is enabled to perform the method for generating response text as described in any one of claims 1 to 10.
14. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method for generating response text as described in any one of claims 1 to 10.