Text generation method and device based on large language model, equipment and medium
By using the method of searching and planning prompt templates in large language models, the problem of difficult relevance of search content is solved, and more relevant and accurate answer text is generated.
Patent Information
- Application Number
- CN202411690237.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-25
AI Technical Summary
When existing large language models deal with the relevance of the retrieved content, it is difficult to avoid the answers deviating from the topic, resulting in the generated content being inaccurate or unrelated.
By obtaining the target question text entered by the user, retrieve relevant text paragraphs from the pre-constructed dataset, and using a large language model to generate initial answer text. Generate planning instructions based on the initial planning word elements and the answer text. If the instructions indicate that the answer does not meet the preset conditions, a second round of iteration is performed, and the supplementary text paragraphs are retrieved and the answer text is updated until the preset conditions are met.
Improve the ability of large language models to pay attention to relevant information during content generation, maintain the relevance of outputs and improve the correctness of facts, and avoid answering questions that deviate from the topic.
Smart Images

Figure CN119691110A_ABST
Abstract
Description
Background Art
[0002] In Large Language Model (LLM), Retrieval-Augmented Generation (RAG) is a method that combines retrieval and generation techniques to improve the quality and factual accuracy of model-generated content. This method is particularly suitable for knowledge-intensive tasks such as question answering, summary generation, and fact checking. Specifically, the RAG workflow can be divided into the following steps:
[0003] (1) Query generation: When the model receives a user input (such as a question), it first generates one or more queries, which are used to retrieve information from an external knowledge base.
[0004] (2) Document retrieval: Using the generated query, the model searches for the most relevant documents in a predefined document set through a retrieval system (e.g., a search engine based on an inverted index). This retrieval process may be based on traditional information retrieval techniques or more advanced deep learning methods such as neural network retrievers.
[0005] (3) Information integration: The retrieved document or its summary is integrated into the model’s input. This is usually achieved through simple concatenation, where the original input and the retrieved document content are provided to the model together.
[0006] (4) Content generation: The model uses the augmented input that incorporates external information to generate the final output. This step involves complex natural language processing techniques, and the model needs to reasonably utilize the retrieved information while retaining the context of the input question.
[0007] RAG can significantly improve the factuality and relevance of content by incorporating accurate retrieved information directly into the generation process. This is particularly valuable for applications that require a lot of external factual support, such as generating detailed answers or providing detailed explanations. In addition, the RAG approach also helps alleviate some problems faced by large language models, such as generating biases or producing inaccurate answers without sufficient context. By directly citing the exact source of information, RAG can provide more objective and verifiable output.
[0008] In the related art, LLM has significant problems in factual accuracy when dealing with a large number of potentially unreliable or off-topic external information sources. Existing RAG methods often have difficulty in handling the relevance of the retrieval content, which may lead to deviation from the topic and inaccurate or irrelevant answers.
[0009] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0010] The present disclosure provides a text generation method, apparatus, device and medium based on a large language model, which at least to some extent overcomes the problem of answers deviating from the topic due to the difficulty in handling the relevance of the search content in the related art.
[0011] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0012] According to one aspect of the present disclosure, a text generation method based on a large language model is provided, comprising: obtaining a target question text input by a user; retrieving at least one text paragraph related to the target question text from a pre-constructed data set; generating a first answer text based on the large language model according to a predetermined planning prompt template, the target question text and at least one text paragraph related to the target question text; generating planning indication information according to initial planning words and the first answer text, wherein the planning indication information comprises a first indication mark and a second indication mark, the first indication mark being used to indicate that the first answer text does not meet a preset condition, and the second indication mark being used to indicate that the first answer text does not meet a preset condition. Indicates that the first answer text meets the preset conditions; if the planning indication information is the first indication identifier, a supplementary text paragraph is retrieved from the data set, and a second answer text is obtained by combining a predetermined answer prompt template, the first answer text and the planning word element updated based on the first answer text, wherein the answer prompt template is used to guide the generation of an answer text related to the question text information, and the second answer text is the answer text generated during the second round of iteration, and the second round of iteration is the next round of iteration of the first round of iteration; based on the second answer text, the planning indication information is updated until the planning indication information is the second indication identifier, and the generated answer text is output.
[0013] In some embodiments, before obtaining the target question text input by the user, the method also includes: obtaining an initial historical text consisting of multiple groups of question-answer pairs; filtering the initial historical text according to a preset level to generate a coarse-grained historical text; generating multiple planned word units based on the coarse-grained historical text, wherein each planned word unit corresponds to a group of question-answer pairs; based on the multiple planned word units, filtering out fine-grained historical texts related to each planned word unit from the coarse-grained historical text; and constructing a data set based on the initial historical text, the multiple planned word units, the coarse-grained historical text and the fine-grained historical text.
[0014] In some embodiments, after constructing a data set based on the initial historical text, the multiple planned word units, the coarse-grained historical text and the fine-grained historical text, the method further includes: training a planning prompt template according to a first sample in the pre-constructed data set, wherein the first sample includes at least: a question text and multiple planned word units in the initial historical text; training an answer prompt template according to a second sample in the pre-constructed data set, wherein the second sample includes at least: a question text, multiple planned word units and a coarse-grained historical text in the initial historical text.
[0015] In some embodiments, planning instruction information is generated based on the initial planning word element and the first answer text, including: converting the initial planning word element and the first answer text into a matrix form, and calculating a similarity matrix; normalizing the similarity matrix to obtain a normalized similarity matrix value; and generating planning instruction information based on the normalized similarity matrix value.
[0016] In some embodiments, after generating planning indication information according to the initial planning word element and the first answer text, the method further includes: if the planning indication information is a second indication identifier, directly generating an answer text.
[0017] In some embodiments, if the planning indication information is a first indication identifier, a supplementary text paragraph is retrieved from the data set, and a second answer text is obtained by combining a predetermined answer prompt template, the first answer text, and a planning word unit updated based on the first answer text, including: after excluding at least one text paragraph related to the target question text in the pre-constructed data set, according to the target question text, retrieving at least one supplementary text paragraph related to the target question text; obtaining the second answer text according to a predetermined answer prompt template, at least one supplementary text paragraph related to the target question text, the first answer text, and a planning word unit updated based on the first answer text.
[0018] According to another aspect of the present disclosure, a text generation device based on a large language model is also provided, including: a question text information acquisition module, used to obtain a target question text input by a user; a text paragraph set retrieval module, used to retrieve at least one text paragraph related to the target question text from a pre-constructed data set; a first answer text generation module, used to generate a first answer text based on the large language model according to a predetermined planning prompt template, the target question text and at least one text paragraph related to the target question text; a planning indication information prediction module, used to generate planning indication information according to an initial planning word and the first answer text, wherein the planning indication information includes a first indication identifier and a second indication identifier, and the first indication identifier is used to indicate that the first answer text does not meet Preset condition, the second indication mark is used to indicate that the first answer text meets the preset condition; a second answer text generation module is used to retrieve a supplementary text paragraph from the data set if the planning indication information is the first indication mark, and combine a predetermined answer prompt template, the first answer text and the planning word element updated based on the first answer text to obtain a second answer text, wherein the answer prompt template is used to guide the generation of an answer text related to the question text information, and the second answer text is the answer text generated during the second round of iteration, and the second round of iteration is the next round of iteration of the first round of iteration; an answer text output module is used to update the planning indication information based on the second answer text until the planning indication information is the second indication mark, and output the generated answer text.
[0019] According to another aspect of the present disclosure, an electronic device is also provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned large language model-based text generation methods by executing the executable instructions.
[0020] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for generating text based on a large language model described above is implemented.
[0021] According to another aspect of the present disclosure, a computer program product is provided, including: a computer program or instructions, which implement any of the above-mentioned text generation methods based on a large language model when executed by a processor.
[0022] The text generation method, device, equipment and medium based on a large language model provided in the embodiments of the present disclosure, based on the target question text input by the user, retrieves the text paragraphs related to the target question text from the pre-built data set, and then generates the first answer text through the large language model in combination with the planning prompt template, and generates the planning indication information according to the initial planning word element and the first answer text. If the planning indication information is the first indication identifier, it is necessary to retrieve the supplementary text paragraph from the data set, and combine the answer prompt template, the first answer text and the updated planning word element to obtain the second answer text, and then update the planning indication information based on the second text until the indication information is the second indication identifier, and output the final generated answer text. The embodiments of the present disclosure can improve the ability of the large language model to focus on relevant information during the content generation process, maintain the relevance of the output and improve the correctness of the facts.
[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0025] Figure 1 A flow chart of a text generation method based on a large language model in an embodiment of the present disclosure is shown;
[0026] Figure 2 A schematic diagram of optimizing a planning loss function by learning multi-task prompt words in an embodiment of the present disclosure is shown;
[0027] Figure 3 A schematic diagram of optimizing the answer loss function by learning multi-task prompt words in an embodiment of the present disclosure is shown;
[0028] Figure 4 A schematic diagram of an LLM iteration framework in an embodiment of the present disclosure is shown;
[0029] Figure 5 Another flowchart of a text generation method based on a large language model in an embodiment of the present disclosure is shown;
[0030] Figure 6 A schematic diagram of iterative generation of answer text in an LLM in an embodiment of the present disclosure is shown;
[0031] Figure 7A schematic diagram of a text generation device based on a large language model in an embodiment of the present disclosure is shown;
[0032] Figure 8 A schematic diagram of the structure of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0033] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0034] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0035] For ease of understanding, before introducing the embodiments of the present disclosure, several terms involved in the embodiments of the present disclosure are first explained as follows:
[0036] RAG: Retrieval-Augmented Generation, is a technique that uses external information sources to enhance the output of language models. It retrieves relevant information from a large document library before generating answers, and then incorporates the retrieved information into the model's generation process, making the output more accurate and informative.
[0037] LLM: Large Language Model, a large language model, is a language model consisting of an artificial neural network with many parameters (usually billions of weights or more), trained on a large amount of unlabeled text using self-supervised learning or semi-supervised learning.
[0038] SP: Soft Prompt, soft prompt words, refers to guiding the model to generate text that meets specific requirements by inputting a parameterizable prompt template into the model. The characteristic of this prompt method is that the parameters in the prompt template can be adjusted according to specific tasks and requirements to achieve the best generation effect.
[0039] Token: A word is the basic unit of text before it is processed by the model. It can be a word, a phrase, or part of a grammatical component.
[0040] The specific implementation of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0041] Figure 1 A flow chart of a text generation method based on a large language model in an embodiment of the present disclosure is shown. Figure 1 As shown, the text generation method based on a large language model provided in the embodiment of the present disclosure includes the following steps:
[0042] S102, obtaining the target question text input by the user.
[0043] In one embodiment of the present disclosure, a user inputs a target question text to be answered into the large language model LLM, and the target question text may be a text paragraph consisting of one sentence or multiple sentences. It should be noted that the present disclosure embodiment does not specifically limit the form of the target question text input by the user.
[0044] S104, retrieving at least one text paragraph related to the target question text from a pre-constructed data set.
[0045] In one embodiment of the present disclosure, since the coarse-grained documents provided in the existing data set usually contain paragraphs that deviate from the topic, it is not conducive to generating an answer text related to the target question text. Therefore, the present embodiment pre-filters the initial historical text and generates coarse-grained text and fine-grained text, and then generates corresponding planning words, and constructs a data set based on the text and planning words obtained above. After receiving the target question text input by the user, LLM retrieves at least one text paragraph related to the target question text from the pre-constructed data set so that LLM outputs the answer text.
[0046] S106, generating a first answer text based on a large language model according to a predetermined planning prompt template, a target question text, and at least one text paragraph related to the target question text.
[0047] In one embodiment of the present disclosure, in the initial stage, a planning prompt template is pre-trained based on a frozen LLM, and the planning prompt template (i.e., planning prompt words) is used to guide the model to generate an answer plan before answering the question, providing a logical structure and content framework for the answer. According to the predetermined planning prompt template, the target question text input by the user and at least one text paragraph related to the target question text are input into the LLM to obtain a first answer text, which is the answer text generated by the first iteration of the LLM.
[0048] S108, generating planning indication information according to the initial planning word element and the first answer text, wherein the planning indication information includes a first indication identifier and a second indication identifier, the first indication identifier is used to indicate that the first answer text does not satisfy a preset condition, and the second indication identifier is used to indicate that the first answer text satisfies the preset condition.
[0049] In one embodiment of the present disclosure, the initial planning word element may be generated from a pre-constructed data set, and after the initial planning word element and the first answer text are matrixed, a similarity matrix is calculated, and the obtained values are normalized to generate planning indication information. The planning indication information may include a first indication identifier and a second indication identifier, wherein the first indication identifier and the second indication identifier may both be represented by logical identifiers, and the preset condition may be a preset value or any other judgment condition that can represent the accuracy of the first answer text. The present disclosure embodiment does not specifically limit the form of the above-mentioned indication identifier and the content of the preset condition.
[0050] S110, if the planning indication information is the first indication identifier, a supplementary text paragraph is retrieved from the data set, and a second answer text is obtained by combining a predetermined answer prompt template, a first answer text and a planning word unit updated based on the first answer text, wherein the answer prompt template is used to guide the generation of an answer text related to the question text information, and the second answer text is an answer text generated in a second round of iteration, and the second round of iteration is the next round of iteration of the first round of iteration.
[0051] In one embodiment of the present disclosure, if the planning indication information is the first indication mark, it indicates that the accuracy of the first answer text is low and does not meet the requirements of the preset conditions, and a supplementary search is required. After excluding the above text paragraphs related to the target question text from the data set, the supplementary text paragraphs are retrieved from the updated data set, and the second answer text is obtained according to the predetermined answer prompt template, the first answer text, and the planning word element obtained after updating the first answer text.
[0052] S112, based on the second answer text, update the planning indication information until the planning indication information is the second indication identifier, and output the generated answer text.
[0053] In one embodiment of the present disclosure, based on the second answer text generated by LLM during the second round of iteration, the planning indication information is updated in combination with the updated planning word elements. If the planning indication information is the second indication identifier, iteration still needs to be continued until the updated planning indication information is the second indication identifier, and the answer text obtained at this time is output as the final answer text.
[0054] As can be seen from the above, the disclosed embodiment retrieves text paragraphs related to the target question text from a pre-constructed data set based on the target question text input by the user, and then generates a first answer text through a large language model in combination with a planning prompt template, and generates planning indication information based on the initial planning word element and the first answer text. If the planning indication information is a first indication identifier, it is necessary to retrieve a supplementary text paragraph from the data set, and combine the answer prompt template, the first answer text and the updated planning word element to obtain a second answer text, and then update the planning indication information based on the second text until the indication information is a second indication identifier, and output the final generated answer text. The disclosed embodiment can improve the ability of a large language model to focus on relevant information during the content generation process, maintain the relevance of the output and improve the correctness of the facts.
[0055] In one embodiment of the present disclosure, before the above S102, the method also includes: obtaining an initial historical text consisting of multiple groups of question-answer pairs; filtering the initial historical text according to a preset level to generate a coarse-grained historical text; generating multiple planned word units based on the coarse-grained historical text, wherein each planned word unit corresponds to a group of question-answer pairs; based on the multiple planned word units, filtering out fine-grained historical texts related to each planned word unit from the coarse-grained historical text; and constructing a data set based on the initial historical text, the multiple planned word units, the coarse-grained historical text and the fine-grained historical text.
[0056] In one embodiment of the present disclosure, since the coarse-grained documents provided in the current existing data sets usually contain a large number of paragraphs that deviate from the topic, it is not conducive to LLM to generate answer texts related to the question text. Therefore, in the embodiment of the present disclosure, after the paragraphs are filtered at the sentence level, the text paragraphs related to the planning word and the corresponding answer paragraph can be selected for training.
[0057] Specifically, firstly, document collection is performed, and a large number of documents covering multiple fields are collected from reliable sources as initial historical texts, and the documents are made to exist in the form of question and answer pairs; the collected initial historical texts can be preprocessed by a first preset filtering method to obtain a coarse-grained historical text, and the first preset filtering method can be a paragraph-level filtering method; the coarse-grained historical texts are further processed, and multiple planning words can be generated based on preset rules, statistics or deep learning, etc.; combined with the generated multiple planning words, the coarse-grained historical texts are filtered by a second preset filtering method to obtain a fine-grained historical text, and the second preset filtering method can be a sentence-level filtering method, and the coarse-grained historical texts are divided into sentences by a natural language processing tool, and then the relevance between each sentence and each planning word and the answer paragraph is evaluated by using natural language processing technology, and deduplication and screening are performed to obtain a fine-grained historical text; finally, a data set is constructed based on the initial historical text, multiple planning words, coarse-grained historical texts and fine-grained historical texts. The data set obtained by the above method in the embodiment of the present disclosure can improve the relevance and accuracy of the answer text generated by LLM.
[0058] It should be noted that the reason for using sentence-level filtering in the embodiments of the present disclosure is to ensure the consistency of answers in the answer generation stage. The above-mentioned preset filtering methods for generating coarse-grained historical texts and fine-grained historical texts can be selected according to actual conditions, and it only needs to meet the requirement that the filtering method for generating fine-grained historical texts is finer than the filtering method for coarse-grained historical texts. In the denoising process, sentence-level filtering is an efficient choice that can improve the clarity and relevance of answers at a lower computational cost. However, for specific task requirements, phrase-level or word-level filtering can further improve the accuracy and conciseness of answers, so the filtering level can be flexibly selected according to the characteristics of the task. When the prerequisites are met, the embodiments of the present disclosure do not specifically limit the preset filtering methods for generating coarse-grained historical texts and fine-grained historical texts.
[0059] It should be noted that the embodiments of the present disclosure do not specifically limit the natural language processing tools and natural language processing technologies used above.
[0060] In one embodiment of the present disclosure, during the dataset construction phase, planning tokens are pre-generated tokens used to guide LLM on how to answer question structures, which can guide LLM to learn how to use fine-grained evidence, thereby improving the accuracy and relevance of LLM in the answering phase, and serving as labels and training references. The methods of pre-generating planning tokens may include, but are not limited to, offline generation, proofreading and prediction of pre-trained models, and preset training labels.
[0061] In one embodiment of the present disclosure, after constructing a data set based on an initial historical text, multiple planned word units, coarse-grained historical text, and fine-grained historical text, the method further includes: training a planning prompt template according to a first sample in the pre-constructed data set, wherein the first sample includes at least: a question text and multiple planned word units in the initial historical text; and training an answer prompt template according to a second sample in the pre-constructed data set, wherein the second sample includes at least: a question text, multiple planned word units, and coarse-grained historical text in the initial historical text.
[0062] In one embodiment of the present disclosure, multi-task prompt word optimization is a key innovation to improve the performance of LLM. This method enables LLM to handle multiple tasks simultaneously, such as plan generation and answer generation, by introducing learnable prompt words (i.e., prompt templates), without large-scale modification of LLM itself. The core of multi-task prompt word optimization is to use shared soft prompts and task-specific low-rank matrices to adapt to the needs of different tasks. In the "retrieval-planning-generation" framework, the plan loss function (Plan Loss Function) and the answer loss function (Answer Loss Function) play a vital role in this framework. Among them, the planning loss function focuses on optimizing the performance of LLM in the planning stage, that is, generating plan tags related to the content to be answered next, that is, planning words. These planning words serve as guidance in the answer stage to help LLM select relevant document paragraphs; the answer loss function is committed to optimizing the output of the answer stage, ensuring that LLM can generate accurate, relevant and comprehensive answers based on the plan and retrieved information. The planning loss function and the answer loss function work in coordination through multi-task learning, further optimizing the performance of LLM in complex generation tasks, making it more advantageous in knowledge-intensive application scenarios. During training, LLM simultaneously learns planning and answering tasks by minimizing the weighted sum of these two loss functions. The disclosed embodiments not only improve the performance of the model on a single task, but also enhance the synergy between tasks, enabling LLM to more effectively utilize the retrieved information and generate more accurate and relevant answers.
[0063] In one embodiment of the present disclosure, different components in the pre-constructed data set can be used to simultaneously train the planning prompt template and the answer prompt template, and different parts of the same data instance can be masked to guide the learning of the corresponding tasks. For the training of the planning stage, the word-grams other than the actual planning word-grams are masked to guide the LLM to focus on the planning generation; for the training of the answer stage, the word-grams that do not belong to the answer are excluded from the loss calculation.
[0064] Specifically, Figure 2FIG. 1 shows a schematic diagram of optimizing a planning loss function by learning multi-task prompt words in an embodiment of the present disclosure, such as Figure 2 As shown, in the LLM planning stage, the planning stage prompt words (i.e., the above-mentioned planning prompt template), the input question (i.e., the question text in the initial historical text), and multiple planning word units ( Figure 2 The information of the questions (not shown) and responses (including the context of relevant answers, irrelevant answer text, and accurate answer text) is integrated and input into the LLM, so that the LLM generates text paragraphs related to accurate answers and accurate answers in the planning stage. The prompt words in the planning stage are combined with the input questions to generate an input sequence, which is passed to the LLM to generate predicted planning words. The difference between the predicted planning words and the pre-generated planning words is evaluated to update the planning loss function.
[0065] It should be noted that the above-mentioned planning stage prompt words, input questions, multiple planning words, irrelevant answer texts and accurate answer texts can all be obtained from a pre-trained data set.
[0066] Specifically, Figure 3 FIG. 4 is a schematic diagram showing a method of optimizing the answer loss function by learning multi-task prompt words in an embodiment of the present disclosure. Figure 3 As shown, in the LLM answering stage, the answering stage prompt words (i.e., the above-mentioned answer prompt template), the input question (i.e., the question text), and multiple planning word units ( Figure 3 The input question, planning word unit, relevant answer context and answer prompt word are combined to generate an input sequence, which is passed to LLM to generate the answer text. The difference between the answer text and the accurate answer is evaluated to update the answer loss function.
[0067] It should be noted that the prompt words in the answering stage, the input question, multiple planned word units, irrelevant answer texts and accurate answer texts can all be obtained from a pre-trained data set.
[0068] In one embodiment of the present disclosure, learnable prompt templates (i.e., planning prompt templates and answer prompt templates) specifically used for the planning stage and the answering stage are pre-trained to enhance the model's ability to handle dual tasks simultaneously. In the prompt template training stage, different components of the samples are selected from a pre-constructed data set for training, so that the frozen LLM can acquire planning and answering capabilities without any modification to the model itself. Among them, the planning prompt template is used to help the model understand the task structure, step sequence, or other procedural requirements. This prompt will guide the model to pay more attention to the operation sequence and strategy part of the task; the answer prompt template is directly used to generate prompts for task output, by guiding the model to focus on the results or answers of the task. The answer prompt template generally combines task-specific content requirements to generate direct answers.
[0069] In one embodiment of the present disclosure, since different tasks may have similar structures and requirements, planning hints and answer hints are combined in the same shared low-rank space through the decomposition of low-rank matrices, so that the model can focus on task planning and answer generation at the same time, thereby improving the overall task adaptability.
[0070] In one embodiment of the present disclosure, the above S108 includes: converting the initial planning word and the first answer text into a matrix form, and calculating a similarity matrix; normalizing the similarity matrix to obtain a normalized similarity matrix value; and generating planning indication information according to the normalized similarity matrix value.
[0071] In one embodiment of the present disclosure, the planning indication information can be determined based on whether the normalized similarity matrix value meets the preset threshold. If the normalized similarity matrix value does not meet the preset threshold, that is, does not meet the preset condition, it can indicate that the relevance of the first answer text is poor, and the planning indication information is the first indication mark; if the normalized similarity hurricane value meets the preset threshold, that is, meets the preset condition, it can indicate that the relevance of the first answer text is good, and the planning indication information is the second indication mark. It should be noted that the above-mentioned preset threshold can be set according to actual conditions, and the embodiment of the present disclosure does not specifically limit the value of the preset threshold.
[0072] In one embodiment of the present disclosure, after the above S108, the method further includes: if the planning indication information is a second indication identifier, directly generating a reply text.
[0073] In one embodiment of the present disclosure, if the planning indication information is the second indication mark, it indicates that the first answer text meets the preset conditions, that is, the relevance of the first answer text is high, and the first answer text can be directly output as the final answer text without entering the iterative process.
[0074] In one embodiment of the present disclosure, the above S110 includes: after excluding at least one text paragraph related to the target question text in the pre-constructed data set, retrieving at least one supplementary text paragraph related to the target question text according to the target question text; obtaining the second answer text according to a predetermined answer prompt template, at least one supplementary text paragraph related to the target question text, the first answer text and the planned word element updated based on the first answer text.
[0075] Figure 4 A schematic diagram of an LLM iteration framework in an embodiment of the present disclosure is shown. Figure 4 As shown, the question text is input into the LLM, and the first answer text is generated by combining the predetermined planning prompt template and the historical generated content; the planning instruction information ( Figure 4 ); if the planning indication information indicates that the relevance of the first answer text is poor, it is necessary to further search from the pre-constructed data set to obtain a newly generated supplementary text paragraph; then add the supplementary text paragraph to the LLM, and combine the predetermined answer prompt template, the first answer text and the planning word unit updated according to the first answer text ( Figure 4 According to the updated planning word and the second answer text, the updated planning indication information is generated. If the updated planning indication information indicates that the relevance of the second answer text is good ( Figure 4 (not shown), the second answer text is output as the final answer text.
[0076] In one embodiment of the present disclosure, the predetermined planning prompt template and answer prompt template are pre-trained based on the frozen LLM, which can ensure that the model performs more stably and efficiently on specific tasks, and improve the stability, efficiency and adaptability of the model to specific tasks. In this framework, the planning prompt template is used to guide the model to generate an answer plan before answering the question, that is, to provide a logical structure and content framework for the answer, and the answer prompt template is used to actually generate specific answer content.
[0077] In one embodiment of the present disclosure, the historical generated content may include but is not limited to answers to previous conversation rounds, background information related to questions, key points or summaries, and completed task segments, etc. The historical generated content can provide contextual information during multiple rounds of iterations to ensure that the LLM can maintain the consistency and coherence of the answer text when generating a new answer text.
[0078] In one embodiment of the present disclosure, during the retrieval phase of LLM, the system first receives user input (e.g., a question) and then generates one or more queries. These queries are used to retrieve relevant documents or information passages from a pre-built dataset. This helps LLM to accurately generate queries that are highly relevant to the question and efficiently retrieve the most relevant information from big data.
[0079] In one embodiment of the present disclosure, in the planning stage of LLM, after relevant information is retrieved, the system generates a set of planning words. As an intermediate layer, the planning words are used to guide subsequent content generation, ensuring that the generated content can focus on the topics that users are most concerned about, while excluding the interference of irrelevant or secondary information. At this time, since the large model has pre-generated planning words, corresponding coarse-grained documents and answer paragraphs, the LLM can select sentences related to planning and answers from the documents as fine-grained evidence, which is further used to train the fine-grained evidence utilization ability of the LLM. The planning stage effectively guides the selection of information and the structure of content, thereby generating more accurate and closely related answers.
[0080] In one embodiment of the present disclosure, in the answering stage of LLM, the system uses the planning words generated in the planning stage to select and organize the retrieved information, and then generates a target answer based on the selected information. The technology of effectively combining planning words with relevant information is used to produce accurate, coherent and information-rich output.
[0081] Figure 5 Another flowchart of a text generation method based on a large language model in an embodiment of the present disclosure is shown. Figure 5 As shown, the method includes:
[0082] S501, generating planning word units according to a pre-built data set.
[0083] S502: Input the user's question text into LLM.
[0084] S503: Retrieve at least one text paragraph related to the question text according to the question text input by the user.
[0085] S504, initializing the answer text.
[0086] S505: Generate a first answer text according to a predetermined planning prompt template, a question text, and at least one text paragraph related to the question text.
[0087] S506, converting the planning word and the first answer text into a matrix form, calculating the similarity matrix, performing normalization processing, obtaining the normalized similarity matrix value, and generating planning indication information.
[0088] In one embodiment of the present disclosure, the planning indication information includes a first indication identifier and a second indication identifier, the first indication identifier indicating that the first answer text does not meet the preset conditions, that is, the relevance of the first answer text is poor; the second indication identifier indicates that the second answer text meets the preset conditions, that is, the relevance of the second answer text is good.
[0089] S5071: If the planning indication information is the first indication identifier, it is necessary to retrieve a supplementary text paragraph from a data set excluding at least one text paragraph related to the question text.
[0090] S5072, generating a second answer text according to a predetermined answer prompt template, the first answer text and the planned word units updated according to the first answer text.
[0091] S5073, based on the second answer text, update the planning indication information. If the planning indication information is the second indication identifier, execute S509; if the planning indication information is still the first indication identifier, execute S5071.
[0092] S5081: If the planning indication information is the second indication identifier, the first answer text is used as the final answer text.
[0093] S509, output the generated answer text.
[0094] As can be seen from the above, the disclosed embodiment retrieves text paragraphs related to the target question text from a pre-constructed data set based on the target question text input by the user, and then generates a first answer text through a large language model in combination with a planning prompt template, and generates planning indication information based on the initial planning word element and the first answer text. If the planning indication information is a first indication identifier, it is necessary to retrieve a supplementary text paragraph from the data set, and combine the answer prompt template, the first answer text and the updated planning word element to obtain a second answer text, and then update the planning indication information based on the second text until the indication information is a second indication identifier, and output the final generated answer text. The disclosed embodiment can improve the ability of a large language model to focus on relevant information during the content generation process, maintain the relevance of the output and improve the correctness of the facts.
[0095] It should be noted that the above S504 can be executed at any position before S505, and the embodiment of the present disclosure does not specifically limit the execution time of S504.
[0096] In one embodiment of the present disclosure, the answer text generated by the LLM may include a preset termination mark, such as <eos>(End of Sequence), the preset end mark is synchronized with the planning instruction information. That is, if the planning instruction information is the first instruction mark, the answer text does not contain <eos>Mark, at this time, LLM needs to continue to search for supplementary text paragraphs and execute the iterative process; if the planning instruction information is the second instruction mark, the answer text contains <eos>Mark, LLM directly outputs the answer text. It should be noted that <eos>As a machine language, it helps to automatically execute iterations or generate processes in model calculations. The preset termination mark can select other marks according to actual conditions or let the machine and the staff know the mark of the termination of the model iteration. The embodiment of the present disclosure does not specifically limit the form of the preset termination mark.
[0097] In one embodiment of the present disclosure, the above-mentioned second answer text can be an answer text fragment generated by LLM based on the supplementary text paragraph, that is, the answer text generated after each round of iteration can essentially be an answer text fragment generated based on the supplementary retrieved text paragraph. Before outputting the final answer text, the answer text fragment generated after each round of iteration can be added to the first answer text to constitute the final answer text.
[0098] In one embodiment of the present disclosure, the schematic diagram of the above-mentioned iterative process S5071-S5073 can be shown by Figure 6 express. Figure 6 FIG. 4 shows a schematic diagram of iterative generation of answer text in an LLM in an embodiment of the present disclosure, such as Figure 6 As shown, the supplementary text paragraph and the first answer text are input into the LLM, the initial planned word-gram is updated by the first answer text to obtain the updated planned word-gram, and then the second answer text is generated by the updated planned word-gram, the first answer text and the supplementary text paragraph. At this time, the updated planned word-gram, the second answer text and the first answer text are output.
[0099] In one embodiment of the present disclosure, content generation in related technologies often directly relies on the internal knowledge of the model or simple keyword triggers, which can easily generate information that is irrelevant to the query or factually inaccurate. The disclosed embodiment first generates a series of planned word elements based on the retrieved information. These word elements provide structure and guidance for the subsequent content generation stage, ensuring the relevance and accuracy of the content, and significantly improving the target focus and logical coherence of the generated content. In an iterative manner, information retrieval and content generation are continuously re-performed according to the context of the generated content. This process ensures that the generated content can continuously self-correct and optimize, adapt to complex user needs and dynamically changing information environments, and enable the model to show higher adaptability and accuracy when processing long or complex knowledge-intensive queries.
[0100] In one embodiment of the present disclosure, through iterative retrieval and generation, the "retrieval-planning-generation" framework can more accurately adjust its output to match complex queries and continuously updated information sources, thereby significantly improving the relevance of content and user satisfaction.
[0101] Based on the same inventive concept, the present disclosure also provides a text generation device based on a large language model, as described in the following embodiments. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0102] Figure 7 A schematic diagram of a text generation device based on a large language model in an embodiment of the present disclosure is shown. Figure 7 As shown, the device includes: a question text information acquisition module 701, a text paragraph set retrieval module 702, a first answer text generation module 703, a planning indication information prediction module 704, a second answer text generation module 705 and an answer text output module 706.
[0103] Among them, the question text information acquisition module 701 is used to obtain the target question text input by the user; the text paragraph set retrieval module 702 is used to retrieve at least one text paragraph related to the target question text from a pre-constructed data set; the first answer text generation module 703 is used to generate a first answer text based on a large language model according to a predetermined planning prompt template, the target question text and at least one text paragraph related to the target question text; the planning indication information prediction module 704 is used to generate planning indication information according to the initial planning word element and the first answer text, wherein the planning indication information includes a first indication mark and a second indication mark, the first indication mark is used to indicate that the first answer text does not meet the preset condition, and the second indication mark is used to indicate that the first answer text does not meet the preset condition. The indication mark is used to indicate that the first answer text meets the preset conditions; the second answer text generation module 705 is used to retrieve the supplementary text paragraph from the data set if the planning indication information is the first indication mark, and combine the predetermined answer prompt template, the first answer text and the planning word element updated based on the first answer text to obtain the second answer text, wherein the answer prompt template is used to guide the generation of the answer text related to the question text information, and the second answer text is the answer text generated in the second round of iteration, and the second round of iteration is the next round of iteration of the first round of iteration; the answer text output module 706 is used to update the planning indication information based on the second answer text until the planning indication information is the second indication mark, and output the generated answer text.
[0104] As can be seen from the above, the disclosed embodiment retrieves text paragraphs related to the target question text from a pre-constructed data set based on the target question text input by the user, and then generates a first answer text through a large language model in combination with a planning prompt template, and generates planning indication information based on the initial planning word element and the first answer text. If the planning indication information is a first indication identifier, it is necessary to retrieve a supplementary text paragraph from the data set, and combine the answer prompt template, the first answer text and the updated planning word element to obtain a second answer text, and then update the planning indication information based on the second text until the indication information is a second indication identifier, and output the final generated answer text. The disclosed embodiment can improve the ability of a large language model to focus on relevant information during the content generation process, maintain the relevance of the output and improve the correctness of the facts.
[0105] In one embodiment of the present disclosure, the device also includes: a data set construction module 707, which is used to obtain an initial historical text composed of multiple groups of question-answer pairs; filter the initial historical text according to a preset level to generate a coarse-grained historical text; generate multiple planned word units based on the coarse-grained historical text, wherein each planned word unit corresponds to a group of question-answer pairs; based on the multiple planned word units, filter out fine-grained historical texts related to each planned word unit from the coarse-grained historical text; and construct a data set based on the initial historical text, multiple planned word units, the coarse-grained historical text and the fine-grained historical text.
[0106] In one embodiment of the present disclosure, the device also includes: a prompt template training module 708, which is used to train a planning prompt template based on a first sample in a pre-constructed data set, wherein the first sample at least includes: a question text and multiple planning words in an initial historical text; and train an answer prompt template based on a second sample in a pre-constructed data set, wherein the second sample at least includes: a question text, multiple planning words and a coarse-grained historical text in the initial historical text.
[0107] In one embodiment of the present disclosure, the above-mentioned planning indication information prediction module 704 is also used to convert the initial planning word and the first answer text into a matrix form, and calculate the similarity matrix; normalize the similarity matrix to obtain the normalized similarity matrix value; generate planning indication information according to the normalized similarity matrix value.
[0108] In one embodiment of the present disclosure, the above-mentioned answer text output module 706 is also used to directly generate an answer text if the planning indication information is the second indication identifier.
[0109] In one embodiment of the present disclosure, the above-mentioned second answer text generation module 705 is also used to exclude at least one text paragraph related to the target question text in the pre-constructed data set, and then retrieve at least one supplementary text paragraph related to the target question text according to the target question text; and obtain the second answer text according to a predetermined answer prompt template, at least one supplementary text paragraph related to the target question text, the first answer text and the planned word element updated based on the first answer text.
[0110] It should be noted that the examples and application scenarios implemented by the modules in the above-mentioned device embodiment are the same as those of the corresponding steps in the method embodiment, but are not limited to the contents disclosed in the above-mentioned method embodiment. It should be noted that the above-mentioned modules as part of the device can be executed in a computer system such as a set of computer executable instructions.
[0111] Those skilled in the art will appreciate that various aspects of the present disclosure may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation that combines hardware and software aspects, which may be collectively referred to herein as a "circuit", "module" or "system".
[0112] Based on the same inventive concept, an electronic device is also provided in an embodiment of the present disclosure, the electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned methods for generating text based on a large language model by executing the executable instructions. Since the principle of solving the problem in the electronic device embodiment is similar to that in the above-mentioned method embodiment, the implementation of the electronic device embodiment can refer to the implementation of the above-mentioned method embodiment, and the repeated parts will not be repeated.
[0113] Refer to the following Figure 8 The electronic device 800 according to this embodiment of the present disclosure is described. Figure 8 The electronic device 800 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0114] like Figure 8 As shown, the electronic device 800 is in the form of a general computing device. The components of the electronic device 800 may include but are not limited to: at least one processing unit 810, at least one storage unit 820, and a bus 830 connecting different system components (including the storage unit 820 and the processing unit 810).
[0115] The storage unit stores program codes, which can be executed by the processing unit 810, so that the processing unit 810 executes the steps described in the above “exemplary method” section of this specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 810 may execute the following steps of the above method embodiment: obtaining a target question text input by a user; retrieving at least one text paragraph related to the target question text from a pre-constructed data set; generating a first answer text based on a large language model according to a predetermined planning prompt template, the target question text and at least one text paragraph related to the target question text; generating planning indication information according to the initial planning word unit and the first answer text, wherein the planning indication information includes a first indication identifier and a second indication identifier, the first indication identifier is used to indicate that the first answer text does not meet a preset condition, and the second indication identifier is used to indicate that the first answer text meets the preset condition; if the planning indication information is the first indication identifier, retrieving a supplementary text paragraph from the data set, and combining the predetermined answer prompt template, the first answer text and the planning word unit updated based on the first answer text to obtain a second answer text, wherein the answer prompt template is used to guide the generation of an answer text related to the question text information, and the second answer text is an answer text generated in a second round of iteration, and the second round of iteration is the next round of iteration of the first round of iteration; based on the second answer text, updating the planning indication information until the planning indication information is the second indication identifier, and outputting the generated answer text.
[0116] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 8201 and / or a cache memory unit 8202 , and may further include a read-only memory unit (ROM) 8203 .
[0117] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0118] Bus 830 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0119] The electronic device 800 may also communicate with one or more external devices 840 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 800, and / or communicate with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 850. Furthermore, the electronic device 800 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 860. As shown, the network adapter 860 communicates with other modules of the electronic device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0120] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0121] Based on the same inventive concept, a computer-readable storage medium is also provided in the embodiment of the present disclosure, on which a computer program is stored, and when the computer program is executed by a processor, any of the above-mentioned methods for generating text based on a large language model is implemented. Since the principle of solving the problem in the embodiment of the computer-readable storage medium is similar to that in the above-mentioned method embodiment, the implementation of the embodiment of the computer-readable storage medium can refer to the implementation of the above-mentioned method embodiment, and the repeated parts will not be repeated.
[0122] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0123] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0124] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0125] In specific implementations, program codes for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0126] Based on the same inventive concept, a computer program product is also provided in the embodiments of the present disclosure, including a computer program product, including: a computer program or an instruction, wherein when the computer program or the instruction is executed by a processor, the text generation method based on a large language model in any one of the above method embodiments is implemented. Since the principle of solving the problem in the computer program product embodiment is similar to that in the above method embodiment, the implementation of the computer program product embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0127] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0128] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0129] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0130] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.< / eos> < / eos> < / eos> < / eos>
Claims
1. A text generation method based on a large language model, characterized in that: include: Get the target question text entered by the user; Retrieving at least one text paragraph related to the target question text from a pre-constructed data set; Generate a first answer text based on the large language model according to a predetermined planning prompt template, the target question text and at least one text paragraph related to the target question text; Generate planning indication information according to the initial planning word element and the first answer text, wherein the planning indication information includes a first indication mark and a second indication mark, the first indication mark is used to indicate that the first answer text does not meet the preset condition, and the second indication mark is used to indicate that the first answer text meets the preset condition; If the planning indication information is a first indication mark, a supplementary text paragraph is retrieved from the data set, and a second answer text is obtained by combining a predetermined answer prompt template, the first answer text, and a planning word unit updated based on the first answer text, wherein the answer prompt template is used to guide the generation of an answer text related to the question text information, and the second answer text is an answer text generated in a second round of iteration, and the second round of iteration is the next round of iteration of the first round of iteration; Based on the second answer text, the planning indication information is updated until the planning indication information is a second indication identifier, and the generated answer text is output.
2. The text generation method based on a large language model according to claim 1, characterized in that: Before obtaining the target question text input by the user, the method further includes: Obtaining an initial historical text consisting of multiple sets of question-answer pairs; Filtering the initial historical text according to a preset level to generate a coarse-grained historical text; Generate a plurality of planned word units according to the coarse-grained historical text, wherein each planned word unit corresponds to a set of question-answer pairs; Based on the multiple planned word units, filter out fine-grained historical texts related to each planned word unit from the coarse-grained historical texts; A data set is constructed based on the initial historical text, the plurality of planned word-grams, the coarse-grained historical text and the fine-grained historical text.
3. The text generation method based on a large language model according to claim 2, characterized in that: After constructing a data set based on the initial historical text, the plurality of planned word units, the coarse-grained historical text, and the fine-grained historical text, the method further includes: Training a planning prompt template according to a first sample in a pre-constructed data set, wherein the first sample at least includes: a question text and a plurality of planning tokens in an initial historical text; The answer prompt template is trained according to a second sample in the pre-constructed data set, wherein the second sample at least includes: a question text in the initial historical text, a plurality of planned word units and a coarse-grained historical text.
4. The text generation method based on a large language model according to claim 1, characterized in that: Generate planning instruction information according to the initial planning word element and the first answer text, including: Convert the initial planning word unit and the first answer text into a matrix form and calculate the similarity matrix; Normalizing the similarity matrix to obtain a normalized similarity matrix value; Planning indication information is generated according to the normalized similarity matrix value.
5. The text generation method based on a large language model according to claim 1, characterized in that: After generating planning instruction information according to the initial planning word element and the first answer text, the method further includes: If the planning indication information is the second indication identifier, a response text is directly generated.
6. The text generation method based on a large language model according to claim 1, characterized in that: If the planning indication information is a first indication mark, a supplementary text paragraph is retrieved from the data set, and a second answer text is obtained by combining a predetermined answer prompt template, the first answer text, and a planning word unit updated based on the first answer text, including: After excluding at least one text paragraph related to the target question text in the pre-constructed data set, searching at least one supplementary text paragraph related to the target question text according to the target question text; A second answer text is obtained according to a predetermined answer prompt template, at least one supplementary text paragraph related to the target question text, a first answer text and a planned word unit updated based on the first answer text.
7. A text generation device based on a large language model, characterized in that: include: A question text information acquisition module is used to obtain the target question text input by the user; A text paragraph set retrieval module, used to retrieve at least one text paragraph related to the target question text from a pre-built data set; A first answer text generating module, configured to generate a first answer text based on the large language model according to a predetermined planning prompt template, the target question text and at least one text paragraph related to the target question text; A planning indication information prediction module, used to generate planning indication information according to an initial planning word element and the first answer text, wherein the planning indication information includes a first indication mark and a second indication mark, the first indication mark is used to indicate that the first answer text does not meet a preset condition, and the second indication mark is used to indicate that the first answer text meets a preset condition; A second answer text generation module, for retrieving a supplementary text paragraph from the data set if the planning indication information is a first indication identifier, and combining a predetermined answer prompt template, the first answer text, and a planning word unit updated based on the first answer text to obtain a second answer text, wherein the answer prompt template is used to guide the generation of an answer text related to the question text information, and the second answer text is an answer text generated in a second round of iteration, and the second round of iteration is the next round of iteration of the first round of iteration; The answer text output module is used to update the planning indication information based on the second answer text until the planning indication information is a second indication identifier, and output the generated answer text.
8. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the text generation method based on a large language model as described in any one of claims 1 to 6 by executing the executable instructions.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text generation method based on a large language model described in any one of claims 1 to 6 is implemented.
10. A computer program product comprising: A computer program or instruction, characterized in that when the computer program or instruction is executed by a processor, it implements the text generation method based on a large language model as described in any one of claims 1 to 6.
Citation Information
Cited By
Response information generation method, question answering system and electronic equipment
CN120780817A
Business rule generation method and system, electronic equipment, medium and program product
CN121880423A
Business rule generation method, system, electronic device, medium and program product
CN121880423B