Text generation method and device based on large language model
By using target summary and target memory information as prompt words in the large language model and combining historical records, the problem of poor ideas during the reflection process of large language model is solved, and the correlation and accuracy of the generated results are improved.
Patent Information
- Application Number
- CN202411151506.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2025-01-07
AI Technical Summary
The ideas generated by the large language model during the reflection process are of poor quality and cannot meet expectations.
By inputting the target summary and target memory information as prompt words into the large language model, target text for the current interactive content is generated, and information from history is combined to improve the quality of the generated results.
The quality of generated ideas is improved, making it strongly correlated with the current interactive content, and the basis information is generated by calling the large language model multiple times to ensure the authenticity and accuracy of the output.
Smart Images

Figure CN119272728A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a text generation method and device based on a large language model. Background Art
[0002] Large Language Model (LLM) is widely used in various scenarios because of its powerful problem-solving ability for different tasks. In the process of interacting with LLM, LLM will reflect to generate ideas about the interactive content based on the content that has been interacted. For example, the generated ideas include the focus of the interactive content, the evaluation of the interactive content, and the new content extended from the interactive content. The reflection process of LLM can be understood as the process of summarizing and / or expanding the interactive content to produce results (ideas) using LLM. However, after the reflection process of the large language model, the ideas generated often do not meet expectations and the quality of the ideas generated is poor. Summary of the invention
[0003] The purpose of the embodiment of the present invention is to provide a method and device for generating text based on a large language model to improve the quality of ideas generated by the large language model. The specific technical solution is as follows:
[0004] In a first aspect of an embodiment of the present invention, a text generation method based on a large language model is first provided. The method is applicable to a server in which a large language model for generating text content is deployed. The method includes:
[0005] Determine a target summary according to current interaction content between target objects, wherein the target summary represents the semantics of the current interaction content;
[0006] Extracting target memory information corresponding to the target object and related to the target summary from the stored historical memory information, the historical memory information including a first result obtained by summarizing and / or expanding historical interaction content using the large language model;
[0007] The target summary and the target memory information are input into the large language model as a first prompt word to generate a target text for the current interactive content, wherein the target text for the current interactive content includes a second result obtained by summarizing and / or expanding the current interactive content using the large language model.
[0008] In one embodiment of the present invention, the target text of the current interactive content also includes basis information of the large language model generating the second result, and the basis information is information that can indicate the authenticity of the large language model generating the second result; the step of inputting the target summary and the target memory information as the first prompt word into the large language model to generate the target text for the current interactive content includes:
[0009] Inputting the target summary and the target memory information into the large language model as a first prompt word, and generating a second result obtained by summarizing and / or expanding the current interaction content by the large language model;
[0010] The second result is input into the large language model as a second prompt word to obtain basis information of the large language model generating the second result.
[0011] In one embodiment of the present invention, the step of inputting the target summary and the target memory information as the first prompt word into the large language model to generate a target text for the current interactive content includes:
[0012] The target summary and the first target memory information are input into the large language model as a first prompt word to generate a target text of the current interaction content including a first number of second results, wherein the first number increases as the number of interactions between the target objects increases.
[0013] In one embodiment of the present invention, the method is applied to a virtual character interaction scenario, and the target summary and the target memory information are input into the large language model as a first prompt word to generate a target text for the current interaction content, including:
[0014] Acquiring environmental information of the virtual environment in which the virtual character is located;
[0015] The environmental information, the target summary, and the target memory information are input into the large language model as a first prompt word to generate a target text related to the environmental information for the current interactive content.
[0016] In a second aspect of an embodiment of the present invention, a text generation device based on a large language model is further provided, the device being applicable to a server, wherein a large language model for generating text content is deployed in the server, and the device comprising:
[0017] A target summary determination module, configured to determine a target summary according to current interaction content between target objects, wherein the target summary represents the semantics of the current interaction content;
[0018] a target memory information extraction module, configured to extract target memory information corresponding to the target object and related to the target summary from the stored historical memory information, wherein the historical memory information includes a first result obtained by summarizing and / or expanding historical interaction content using the large language model;
[0019] A target text generation module is used to input the target summary and the target memory information as a first prompt word into the large language model to generate a target text for the current interactive content, wherein the target text of the current interactive content includes a second result obtained by summarizing and / or expanding the current interactive content using the large language model.
[0020] In one embodiment of the present invention, the target text also includes basis information of the large language model generating the second result, and the basis information is information that can indicate the authenticity of the second result generated by the large language model; the target text generation module includes a second result generation submodule and a basis information acquisition submodule;
[0021] The second result generating submodule is used to input the target summary and the target memory information as the first prompt word into the large language model, and generate a second result obtained by the large language model summarizing and / or expanding the current interaction content;
[0022] The submodule for obtaining the basis information is used to input the second result as a second prompt word into the large language model to obtain the basis information of the large language model generating the second result.
[0023] In one embodiment of the present invention, the target text generation module is specifically used to: input the target summary and the first target memory information as the first prompt word into the large language model, and generate a target text of the current interaction content containing a first number of second results, wherein the first number increases as the number of interactions between the target objects increases.
[0024] In one embodiment of the present invention, the device is applied to a virtual character interaction scenario, and the target text generation module is specifically used to: obtain environmental information of the virtual environment in which the virtual character is located; input the environmental information, the target summary, and the target memory information as the first prompt word into the large language model to obtain the target text of the current interaction content related to the environmental information.
[0025] In a third aspect of an embodiment of the present invention, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; the memory is used to store computer programs; and the processor is used to implement any of the above-mentioned text generation methods based on a large language model when executing the program stored in the memory.
[0026] In another aspect of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned text generation methods based on a large language model is implemented.
[0027] In yet another aspect of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned methods for generating text based on a large language model.
[0028] In the technical solution provided by the embodiment of the present invention, the target summary and target memory information are input as prompt words into the large language model, and the large language model generates a target text for the current interactive content, and the target text includes a second result obtained by expanding and / or summarizing the current interactive content using the large language model. Since the target summary can represent the semantics of the current interactive content, the second result (idea) included in the target text generated by the large language model has a strong correlation with the current interactive content, and since the target text is generated not only based on the target summary of the current interactive content, but also combined with the target memory information of the historical records, the reference information when generating the target text is richer, and the quality of the second result (idea) included in the generated target text is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0030] Figure 1 A schematic diagram of a flow chart of a first LLM-based text generation method provided in an embodiment of the present invention;
[0031] Figure 2 A schematic flow chart of a second LLM-based text generation method provided in an embodiment of the present invention;
[0032] Figure 3 A schematic diagram of a flow chart of a third LLM-based text generation method provided in an embodiment of the present invention;
[0033] Figure 4 A schematic diagram of a fourth LLM-based text generation method provided in an embodiment of the present invention;
[0034] Figure 5 A flowchart of a text generation method based on LLM provided in an embodiment of the present invention;
[0035] Figure 6 A schematic diagram of the structure of a text generation device based on LLM provided in an embodiment of the present invention;
[0036] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field based on the present invention belong to the scope of protection of the present invention.
[0038] LLM is widely used in various scenarios because of its strong problem-solving ability for different tasks. In the process of interacting with LLM, LLM will reflect to generate ideas about the interactive content based on the content that has been interacted. For example, the generated ideas include the focus of the interactive content, the evaluation of the interactive content, and the new content extended from the interactive content. The reflection process of LLM can be understood as the process of summarizing and / or expanding the interactive content to produce results (ideas) using LLM. However, after the reflection process of the large language model, the ideas generated often do not meet expectations, and the quality of the ideas generated is poor.
[0039] In order to solve the above problems, an embodiment of the present invention provides a text generation method and device based on LLM.
[0040] See also Figure 1 , is a flow chart of the first LLM-based text generation method provided by an embodiment of the present invention. The method is applicable to a server, in which an LLM for generating text content is deployed. The method can also be applicable to an agent based on the LLM. The embodiment of the present invention does not specifically limit the execution subject of the method. For ease of description, the following description is made with the server as the execution subject. The above method includes steps S101-S103.
[0041] S101, determining a target summary according to current interaction content between target objects.
[0042] The target object is the object currently interacting. The target object may be a user or a server carrying LLM. Then, the interaction between target objects may be an interaction between a user and a server carrying LLM, or between servers carrying LLM and servers carrying LLM.
[0043] The target summary represents the semantics of the current interaction content between the target objects, and can also be understood as the key content of the current interaction content between the target objects. When the target objects interact, the current interaction content between the target objects can be obtained, and the target summary is determined by extracting the key content of the current interaction content between the target objects.
[0044] In one embodiment of the present invention, a target summary can be determined from the current interaction content between target objects based on preset rules. Specifically, the rules are set based on the grammatical structure, semantic role or specific keywords of the sentence. By using these preset rules, sentences containing important information, core ideas or summaries are extracted from the current interaction content between target objects as the target summary.
[0045] In another embodiment of the present invention, a target summary can be determined from the current interaction content between target objects based on a machine learning method. Specifically, a large amount of training data is used to train a large model with a key content extraction function, or an existing large model with a key content extraction function is used, and the current interaction content between target objects is input into the large model, and the output of the large model is the target summary.
[0046] S102, extracting target memory information related to the target summary corresponding to the target object from the stored historical memory information.
[0047] The above historical memory information includes the results obtained by summarizing and / or expanding the historical conversation content between different objects using LLM. At the same time, the historical memory information can also include the historical conversation content between different objects. Through the above historical memory information, combined with a specific memory mechanism, LLM can effectively reflect on and apply previous strategies, allowing it to learn from past experience to adapt to unfamiliar scenarios.
[0048] LLM summarizes and / or expands the interactive content, which can also be understood as LLM reflecting on the interactive content, that is, using LLM's summarizing and refining capabilities to summarize and / or expand a section of interactive content at a high level, generating results such as the key points of the interactive content, new content extended from the interactive content, and evaluation of the interactive content. Based on the reflection process, LLM gains experience from successful output results and lessons from failed output results to improve its generalization ability.
[0049] The above historical memory information can be divided into short-term memory information and long-term memory information. Short-term memory information is memory information that will be deleted after a period of time. Common short-term memory information includes the results obtained by LLM summarizing and / or expanding the historical interaction content between different objects, key fragments in the historical interaction content between different objects, etc. Long-term memory information is memory information that will not be deleted for a long time. Common long-term memory information includes background knowledge base and private information (such as home address).
[0050] The above historical memory information can be vectorized and stored based on the embedding function of LLM. Specifically, through the embedding technology, the historical memory information is mapped into a vector, so that the semantically similar historical memory information is close in position in the vector space, thereby improving the retrieval efficiency of the historical memory information. The above historical memory information can also be stored based on the Retrieval Augmented Generation (RAG) technology. Specifically, the historical memory information is vectorized through the text-to-quantity interface, and the vectorized historical memory information is stored in an external knowledge base. The use of RAG technology can store historical memory information with a large amount of data, thereby effectively expanding the knowledge base of LLM and improving the accuracy of LLM generation results.
[0051] Since the stored historical memory information includes the interaction content between different objects and the first result obtained by LLM summarizing and / or expanding the historical interaction content between different objects, the server can extract the target memory information corresponding to the above-mentioned target object and related to the target summary from the stored historical memory information. Specifically, when storing the historical memory information, the historical memory information of each object can be bound and stored with the identifier of each object, so that the historical memory information corresponding to the target object can be determined based on the identifier of the target object.
[0052] In one embodiment of the present invention, the server may adopt a retrieval algorithm, first using the target object as the main search term, extracting historical memory information corresponding to the target object from the stored historical memory information, and then using the target summary as the main search term, extracting target memory information related to the target summary from the historical memory information of the target object.
[0053] In another embodiment of the present invention, the server may adopt a retrieval algorithm, first taking the target object as the main search term, extracting the historical memory information corresponding to the target object from the stored historical memory information, and then identifying the semantics of the target historical memory information, and taking the historical memory information with the same or similar semantics as the target summary as the target memory information.
[0054] S103, inputting the target summary and the target memory information into the LLM as the first prompt word to generate a target text for the current interactive content, wherein the target text for the current interactive content includes a second result obtained by summarizing and / or expanding the current interactive content using the LLM.
[0055] The first prompt is the input of LLM. In addition to the target summary and target memory information, the first prompt may also include other content. For example, the first prompt may also include background knowledge information associated with the target summary, the output format rules of LLM, etc. Based on the prompt of background knowledge information, the situation where the output results generated are of poor quality due to the lack of knowledge of the relevant field by LLM can be reduced. Based on the prompt of the output format of the LLM model, the language used in the output results generated by LLM, the form of the output results, etc. can be limited.
[0056] The target text for the current interactive content is the output result generated by LLM. The target text for the current interactive content includes the second result obtained by LLM summarizing and / or expanding the current interactive content. The second result can be: the focus of the current interactive content, the evaluation of the current interactive content, the new content extended from the current interactive content, etc. The number of the second results can be one or more.
[0057] The target text of the above-mentioned current interactive content may also include: the basis information of LLM generating the above-mentioned second result. The basis information is information that can indicate the authenticity of the second result generated by LLM. The basis information may be directly obtained from the current interactive content and / or historical memory information, or may be inferred from the current interactive content and / or historical memory information. The number of basis information may be one or more. In this way, the second result generated by LLM and the basis information for generating the second result may be used as a target text.
[0058] For example, for the current interactive content, LLM summarizes and / or expands the current interactive content to obtain three second results: second result 1, second result 2, and second result 3. Second result 1 is obtained based on information a, second result 2 is obtained based on information a and information b, and second result 3 is obtained based on information c. See Table 1, which is a schematic diagram of the correspondence between a second result and basis information provided by an embodiment of the present invention.
[0059] Table 1
[0060] Second result Based on information Second result 1 Based on information a Second result 2 Based on information a, based on information b Second result 3 Based on information c
[0061] Based on this, LLM can generate three target texts for the current interactive content, namely target text 1 {second result 1, based on information a}, target text 2 {second result 2, based on information a, based on information b}, and target text 3 {second result 3, based on information c}.
[0062] In one embodiment of the present invention, the server inputs the target summary and target memory information as the first prompt word into the LLM, and the LLM performs a reflection process, i.e., summarizes and / or expands the current interactive content and generates an output result, i.e., a target text for the current interactive content.
[0063] In one embodiment of the present invention, the server stores the target text of the current interactive content generated by the LLM as historical memory information to provide a basis for the subsequent LLM reflection process.
[0064] To facilitate understanding, the solution of the embodiment of the present invention is described below with reference to a specific example.
[0065] The following interaction process takes place between user A and server B carrying LLM.
[0066] User A: What’s the weather like today?
[0067] Server B: It's raining today.
[0068] User A: What is the temperature today?
[0069] Server B: Today's temperature is 25 degrees.
[0070] The target objects are user A and electronic device B, the above interaction content is the current interaction content between the target objects, and the target summary determined from the current interaction content is: it is raining today, and the temperature today is 25 degrees.
[0071] The target memory information corresponding to the target object and related to the target summary is extracted from the stored historical memory information: rainy days are very suitable for eating hot pot.
[0072] Input the target summary and target memory information into LLM, and LLM generates 4 target texts for the current interactive content, namely target text 1 {It is raining today}, target text 2 {The temperature today is 25 degrees}, target text 3 {It is suitable to eat hot pot on rainy days}, and target text 4 {It is suitable to watch movies on rainy days}. Among them, target text 1, target text 2 and target text 3 are obtained by summarizing the current interactive content, and target text 4 is the new content expanded from the current interactive content.
[0073] In the technical solution provided by the embodiment of the present invention, the target summary and target memory information are input into the LLM as prompt words, and the LLM generates a target text for the current interactive content, and the target text includes a second result obtained by expanding and / or summarizing the current interactive content using a large language model. Since the target summary can represent the semantics of the current interactive content, the second result (idea) included in the target text generated by the large language model has a strong correlation with the current interactive content, and since the target text is generated not only based on the target summary of the current interactive content, but also combined with the target memory information of the historical records, the reference information when generating the target text is richer, and the quality of the second result (idea) included in the generated target text is higher.
[0074] In another embodiment of the present invention, the target text of the current interactive content also includes the basis information for LLM to generate the second result, see Figure 2 , which is a flow chart of a second LLM-based text generation method provided in an embodiment of the present invention, the method includes steps S201-S204, wherein S201-S202 are the same as the aforementioned S101-S102, and S203-S204 are the detailed steps of the aforementioned S103.
[0075] S203, inputting the target summary and the target memory information into the LLM as the first prompt word, and generating a second result obtained by the LLM summarizing and / or expanding the current interactive content.
[0076] As can be seen from the foregoing, the target text of the current interactive content in the embodiment of the present invention may include the second result obtained by summarizing and / or expanding the current interactive content by LLM, and the basis information of LLM generating the second result. Since the requirement of simultaneously obtaining the second result and the basis information of LLM generating the second result by calling LLM once is relatively complex, the prompt words input to LLM are very demanding, and often satisfactory output results cannot be obtained. Therefore, in order to ensure that LLM can generate a higher quality target text for the current interactive content, including the second result and the basis information of LLM generating the second result, the embodiment of the present invention can execute steps S203-S204.
[0077] In one embodiment of the present invention, the electronic device calls LLM for the first time, and inputs the target summary and target memory information determined above as the first prompt word into LLM. LLM executes a reflection process, that is, LLM summarizes and / or expands the current interaction content and generates a second result, that is, the idea about the current interaction content.
[0078] S204: Input the second result as a second prompt word into the LLM to obtain basis information for LLM to generate the second result.
[0079] In one embodiment of the present invention, the electronic device calls the LLM for the second time, and uses the idea of the current interactive content generated by the first call to the LLM as the second prompt word, which is input into the LLM to generate basis information of the idea of the current interactive content. In addition to the idea of the current interactive content, the second prompt word may also include other information, such as the output format rules of the LLM. The embodiment of the present invention does not limit the content of the second prompt word.
[0080] Continuing with the above example of the interaction process between user A and server B, the basis information is explained.
[0081] LLM generated 4 target texts, namely target text 1 {It is raining today}, target text 2 {The temperature today is 25 degrees}, target text 3 {Rainy days are suitable for eating hot pot}, and target text 4 {Rainy days are suitable for watching movies}.
[0082] The second result in target text 1 is directly obtained based on the answer of server B: it is raining today. Therefore, the answer of electronic device B: it is raining today can be used as the basis information corresponding to the idea in target text 1, and the basis information can be put into target text 1. The second result in target text 4 is a new content expanded based on the answer of server B in the historical memory information: it is suitable to eat hot pot on rainy days. Therefore, the answer of electronic device B in the historical memory information: it is suitable to eat hot pot on rainy days can be used as the basis information corresponding to the second result in target text 4, and the basis information can be put into target text 4.
[0083] From the above, it can be seen that in the embodiment of the present invention, when the target text of the current interactive content output by LLM includes the second result obtained by LLM summarizing and / or expanding the current interactive content and the basis information for LLM to generate the second result, LLM is called twice to split the originally more complex prompt word into two relatively simple prompt words, thereby further improving the quality of the target text for the current interactive content generated by LLM.
[0084] In another embodiment of the present invention, see Figure 3 , is a flow chart of a third method for generating text based on LLM provided by an embodiment of the present invention. The method includes steps S301-S303, wherein S301-S302 are the same as the aforementioned S101-S102, and S303 is a refinement of the aforementioned S103.
[0085] S303, input the target summary and the first target memory information into the LLM as the first prompt word, and generate a target text of the current interaction content including a first number of second results, where the first number increases as the number of interactions between the target objects increases.
[0086] In the process of LLM summarizing and / or expanding the current interaction content between target objects, it relies heavily on the target memory information extracted from the historical memory information, which corresponds to the target summary between the target objects. Because when the target objects just start to interact with each other, there is little or even no target memory information. The number of target texts generated by LLM containing the second result of the current interaction content is set. Based on the target memory information with very little information, the multiple target texts generated are often of serious homogeneity in quality, and are even useless target texts. Storing such seriously homogenized or even useless target texts in the historical memory information will also seriously reduce the accuracy of memory, and the subsequent target texts generated based on such contaminated historical memory information are mostly useless, thus creating a vicious circle. Therefore, in order to generate a higher quality target text for the current interaction content, step S303 can be executed in an embodiment of the present invention.
[0087] The first number is the number of target texts generated by LLM for the current interactive content. The first number increases as the number of interactions between target objects increases. The increment step each time can be the same value. For example, if the increment step is set to 1, the first number increases by 1 as the number of interactions between target objects increases. The increment step can also be set to a different value each time. For example, the increment step can be set to increase exponentially. The embodiment of the present invention does not limit the increment method of the first number.
[0088] In one embodiment of the present invention, the first number may increase as the number of interactions between target objects increases, and stop increasing after reaching the maximum number that the server's device performance can load. In this way, LLM can generate enough target texts for the current interactive content, thereby obtaining experience and lessons from these target texts to improve its generalization ability.
[0089] In one embodiment of the present invention, the first number can increase as the number of interactions between target objects increases, and the increase stops when the first number reaches a preset threshold number. The above-mentioned preset threshold number can be a value set according to actual needs, and the preset threshold number can be 5 or 10. The number of target texts generated by LLM for the current interactive content is not the more the better. If the first number is allowed to increase as the number of interactions between target objects increases, the first number will become a very large value. In this way, LLM will generate multiple target texts for the current interactive content. Among these multiple target texts, there will inevitably be target texts with serious homogeneity, wasting the computing resources of LLM. Therefore, in an embodiment of the present invention, a preset threshold number is set to control the number of target texts generated by LLM for the current interactive content.
[0090] In one embodiment of the present invention, the electronic device calls LLM to summarize and / or expand the current interactive content during the reflection process of the previous preset number of times, and obtains a target text for the current interactive content containing a first number of second results. When the first number increases to a preset threshold, the increment stops. During the reflection process other than the previous preset number of times, the server calls LLM to summarize and expand the current interactive content, and obtains a reflection result of the current interactive content containing a preset threshold number of ideas.
[0091] Among them, the above preset number is set according to actual needs, and the preset number can be 5 times, 10 times, etc. Specifically, the preset number can be set according to the amount of target memory information related to the target summary corresponding to the target object in the historical memory information. During the continuous interaction of the target objects, the server will store the interaction information between the target objects and the second result generated by the summary and / or expansion of the interaction content by LLM as historical memory information. As the number of interactions between the target objects increases, the amount of target memory information related to the target summary corresponding to the target object in the historical memory information will also increase. The electronic device can set the preset number based on whether the amount of information of the target memory information is greater than a preset threshold.
[0092] For example, assuming that the preset number is 4, the first number starts to increase from 1, and the preset threshold number is 5, in the first reflection process, the electronic device calls LLM to summarize and / or expand the current interaction content, and obtains a target text containing 1 second result, and the target objects continue to interact with each other. In the second reflection process, the electronic device calls LLM to summarize and / or expand the current interaction content, and obtains a target text containing 2 second results, and the target objects continue to interact with each other. In the third reflection process, the electronic device calls LLM to summarize and / or expand the current interaction content, and obtains a target text containing 4 second results, and the target objects continue to interact with each other. In the fourth reflection process, the electronic device calls LLM to summarize and / or expand the current interaction content, and obtains a target text containing 5 second results, and the target objects continue to interact with each other. In subsequent reflection processes, the electronic device calls LLM to reflect on the current interaction content, and obtains a target text containing 5 second results.
[0093] As can be seen from the above, the embodiment of the present invention adopts a slow start method. When the target object initially interacts, LLM is called to obtain a target text of the current interactive content containing a smaller number of second results. The number of generated target texts increases with the increase in the number of interactions of the target object. In this way, when the amount of information is small, less target text is generated, and when the amount of information increases, more target text is generated, which effectively reduces the generation of invalid target text. It can be seen that the technical solution provided by the embodiment of the present invention enables LLM to generate higher quality target text for the current interactive content, and at the same time, reduces the generation of repeated and useless target texts.
[0094] In another embodiment of the present invention, the above-mentioned LLM-based text generation method is applied to a virtual character interaction scenario. Figure 4 , which is a flow chart of a fourth LLM-based text generation method provided in an embodiment of the present invention, the method comprises steps S401-S404, wherein S401-S402 are the same as the aforementioned S101-S102, and S403-S404 are the detailed steps of the aforementioned S103.
[0095] S403, obtaining environmental information of the virtual environment where the virtual character is located.
[0096] In one embodiment of the present invention, the current application scenario is a virtual character interaction scenario. There are multiple virtual characters in the virtual character interaction scenario. The virtual characters can communicate with each other. In the process of communication between two virtual characters, each virtual character corresponds to an LLM, which is used to process the other party's speech and generate a response.
[0097] Specifically, the virtual character can be an Agent based on LLM. The virtual character is a non-player character (NPC) in the game world, that is, Agent NPC. The developer only needs to write the necessary world view scripts and personality settings for each Agent NPC. Different Agent NPCs will communicate autonomously when they meet. In this way, the iteration and progress of the game process are entirely left to the Agent NPC and the player.
[0098] In one embodiment of the present invention, the environmental information is the environmental information of the virtual scene where the virtual character is located, and the environmental information may include time information, weather information, information of virtual objects contained in the virtual scene, etc. The virtual character (Agent NPC) has the ability to perceive the environmental information of itself. Specifically, the virtual character can determine its own position coordinates based on the map built into the virtual scene, and perceive weather information, virtual objects and other information within the preset range of its own coordinates, and use this information as environmental information. The virtual character can also send the acquired environmental information to the electronic device, or the electronic device can directly acquire the environmental information.
[0099] S404: Input the environment information, target summary, and target memory information into the LLM as the first prompt word to generate a target text related to the environment information for the current interactive content.
[0100] In one embodiment of the present invention, virtual characters conduct conversations with each other, and after receiving conversations from other virtual characters, each virtual character generates a response to the conversation through LLM.
[0101] When virtual characters meet for the first time, they can have a preset conversation based on a pre-written world view script and the personality of the virtual character. Then, based on the content of the first conversation, LLM can generate a response to the conversation.
[0102] In one embodiment of the present invention, when an interaction occurs between two virtual characters, that is, a conversation is generated, the server can determine a target summary from the conversation and target memory information from historical memory information, and input the previously acquired environmental information, target summary, and target memory information into the LLM as the first prompt word to generate a target text related to the environmental information for the current interactive content.
[0103] From the above, it can be seen that in an embodiment of the present invention, the environmental information of the virtual character is input into the LLM as a prompt word. In this way, the target text obtained based on the LLM, which includes the second result obtained by summarizing and / or expanding the current interactive content using LLM, has a high correlation with the environment in which the virtual character is located, and the target text including the second result is of higher quality.
[0104] See also Figure 5 , is a flowchart of a text generation method based on LLM provided in an embodiment of the present invention. Figure 5 , the overall process of the LLM-based text generation method provided in an embodiment of the present invention is described.
[0105] When an interaction occurs between target objects, that is, a conversation occurs between target objects, a target summary is determined based on the content of the conversation, and target memory information corresponding to the target object and related to the target summary is extracted from the historical memory information stored in the storage module based on the target summary, and the target memory information and the target summary are input into the LLM as the first prompt word, and the LLM outputs an idea (second result) for the current interaction content, and the idea of the current interaction content is input into the LLM as the second prompt word, and the LLM outputs basis information for generating the idea (second result) of the current interaction content, and the idea of the current interaction content (second result) and the basis information for generating the idea of the current interaction content are used as the reflection result (target text) of the current interaction content, and the reflection result (target text) is stored in the storage module as the historical memory information.
[0106] In the technical solution provided by the embodiment of the present invention, the target summary and target memory information are input as prompt words into the large language model, and the large language model generates a target text for the current interactive content, and the target text includes a second result obtained by expanding and / or summarizing the current interactive content using the large language model. Since the target summary can represent the semantics of the current interactive content, the second result (idea) included in the target text generated by the large language model has a strong correlation with the current interactive content, and since the target text is generated not only based on the target summary of the current interactive content, but also combined with the target memory information of the historical records, the reference information when generating the target text is richer, and the quality of the second result (idea) included in the generated target text is higher.
[0107] Corresponding to the aforementioned LLM-based text generation method, an embodiment of the present invention further provides an LLM-based text generation device, which is suitable for a server, and an LLM for generating text content is deployed in the server.
[0108] See also Figure 6 , is a schematic diagram of the structure of a text generation device based on LLM provided by an embodiment of the present invention, the device comprising:
[0109] A target summary determination module 601 is used to determine a target summary according to the current interaction content between target objects, wherein the target summary represents the semantics of the current interaction content;
[0110] A target memory information extraction module 602 is used to extract target memory information corresponding to the target object and related to the target summary from the stored historical memory information, wherein the historical memory information includes a first result obtained by summarizing and / or expanding historical interaction content using the LLM;
[0111] The target text generation module 603 is used to input the target summary and the target memory information as the first prompt word into the LLM to generate a target text for the current interactive content. The target text of the current interactive content includes a second result obtained by summarizing and / or expanding the current interactive content using the large language model.
[0112] In the technical solution provided by the embodiment of the present invention, the target summary and target memory information are input as prompt words into the large language model, and the large language model generates a target text for the current interactive content, and the target text includes a second result obtained by expanding and / or summarizing the current interactive content using the large language model. Since the target summary can represent the semantics of the current interactive content, the second result (idea) included in the target text generated by the large language model has a strong correlation with the current interactive content, and since the target text is generated not only based on the target summary of the current interactive content, but also combined with the target memory information of the historical records, the reference information when generating the target text is richer, and the quality of the second result (idea) included in the generated target text is higher.
[0113] In one embodiment of the present invention, the target text also includes basis information of the large language model generating the second result, and the basis information is information that can indicate the authenticity of the second result generated by the large language model; the target text generation module includes a second result generation submodule and a basis information acquisition submodule;
[0114] The second result generating submodule is used to input the target summary and the target memory information as the first prompt word into the LLM, and generate a second result obtained by the LLM summarizing and / or expanding the current interactive content;
[0115] The basis information obtaining submodule is used to input the second result as a second prompt word into the LLM to obtain the basis information for the LLM to generate the second result.
[0116] As can be seen from the above, in the embodiment of the present invention, when the target text of the current interactive content output by the LLM includes the second result obtained by the LLM summarizing and / or expanding the current interactive content and the basis information for the LLM to generate the second result, the LLM is called twice to split the originally more complex prompt word into two relatively simple prompt words, thereby further improving the quality of the target text for the current interactive content generated by the LLM. In one embodiment of the present invention, the target text generation module is specifically used to:
[0117] The target summary and the first target memory information are input into the large language model as a first prompt word to generate a target text of the current interaction content including a first number of second results, wherein the first number increases as the number of interactions between the target objects increases.
[0118] As can be seen from the above, the embodiment of the present invention adopts a slow start method. When the target object initially interacts, LLM is called to obtain a target text of the current interactive content containing a smaller number of second results. The number of generated target texts increases with the increase in the number of interactions of the target object. In this way, when the amount of information is small, less target text is generated, and when the amount of information increases, more target text is generated, which effectively reduces the generation of invalid target text. It can be seen that the technical solution provided by the embodiment of the present invention enables LLM to generate higher quality target text for the current interactive content, and at the same time, reduces the generation of repeated and useless target texts.
[0119] In one embodiment of the present invention, the device is applied to a virtual character interaction scenario, and the target text generation module is specifically used to: obtain environmental information of the virtual environment in which the virtual character is located; input the environmental information, the target summary, and the target memory information as the first prompt word into the large language model to obtain the target text of the current interaction content related to the environmental information.
[0120] From the above, it can be seen that in an embodiment of the present invention, the environmental information of the virtual character is input into the LLM as a prompt word. In this way, the target text obtained based on the LLM and containing the second result obtained by summarizing and expanding the current interactive content using the LLM has a high correlation with the environment in which the virtual character is located, and the obtained target text containing the second result is of higher quality.
[0121] The embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.
[0122] Memory 703, used for storing computer programs;
[0123] The processor 701 is used to implement the text generation method based on the large language model described in any of the above embodiments when executing the program stored in the memory 703. The communication bus mentioned in the above terminal can be a peripheral component interconnect standard (Peripheral Component Interconnect, referred to as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, referred to as EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0124] The communication interface is used for communication between the above terminal and other devices.
[0125] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0126] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0127] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the text generation method based on a large language model described in any of the above embodiments is implemented.
[0128] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is executed on a computer, the computer executes the text generation method based on a large language model described in any one of the above embodiments.
[0129] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0130] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0131] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, electronic device embodiment, and computer storage medium embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0132] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A text generation method based on a large language model, characterized in that: The method is applicable to a server, in which a large language model for generating text content is deployed, and the method comprises: Determine a target summary according to current interaction content between target objects, wherein the target summary represents the semantics of the current interaction content; Extracting target memory information corresponding to the target object and related to the target summary from the stored historical memory information, the historical memory information including a first result obtained by summarizing and / or expanding historical interaction content using the large language model; The target summary and the target memory information are input into the large language model as a first prompt word to generate a target text for the current interactive content, wherein the target text for the current interactive content includes a second result obtained by summarizing and / or expanding the current interactive content using the large language model.
2. The method according to claim 1, characterized in that The target text of the current interactive content also includes basis information of the large language model generating the second result, where the basis information is information that can indicate the authenticity of the second result generated by the large language model; The step of inputting the target summary and the target memory information as the first prompt word into the large language model to generate a target text for the current interactive content includes: Inputting the target summary and the target memory information into the large language model as a first prompt word, and generating a second result obtained by summarizing and / or expanding the current interaction content by the large language model; The second result is input into the large language model as a second prompt word to obtain basis information of the large language model generating the second result.
3. The method according to claim 1, characterized in that The step of inputting the target summary and the target memory information as the first prompt word into the large language model to generate a target text for the current interactive content includes: The target summary and the first target memory information are input into the large language model as a first prompt word to generate a target text of the current interaction content including a first number of second results, wherein the first number increases as the number of interactions between the target objects increases.
4. The method according to claim 1, characterized in that: The method is applied to a virtual character interaction scenario, wherein the target summary and the target memory information are input into the large language model as a first prompt word to generate a target text for the current interaction content, including: Acquiring environmental information of the virtual environment in which the virtual character is located; The environmental information, the target summary, and the target memory information are input into the large language model as a first prompt word to generate a target text related to the environmental information for the current interactive content.
5. A text generation device based on a large language model, characterized in that: The device is applicable to a server, in which a large language model for generating text content is deployed, and the device includes: A target summary determination module, configured to determine a target summary according to current interaction content between target objects, wherein the target summary represents the semantics of the current interaction content; a target memory information extraction module, configured to extract target memory information corresponding to the target object and related to the target summary from the stored historical memory information, wherein the historical memory information includes a first result obtained by summarizing and / or expanding historical interaction content using the large language model; A target text generation module is used to input the target summary and the target memory information as a first prompt word into the large language model to generate a target text for the current interactive content, wherein the target text of the current interactive content includes a second result obtained by summarizing and / or expanding the current interactive content using the large language model.
6. The device according to claim 5, characterized in that The target text also includes basis information of the large language model generating the second result, wherein the basis information is information that can indicate the authenticity of the second result generated by the large language model; The target text generation module includes a second result generation submodule and an information obtaining submodule; The second result generating submodule is used to input the target summary and the target memory information as the first prompt word into the large language model, and generate a second result obtained by the large language model summarizing and / or expanding the current interaction content; The submodule for obtaining the basis information is used to input the second result as a second prompt word into the large language model to obtain the basis information of the large language model generating the second result.
7. The device according to claim 5, characterized in that The target text generation module is specifically used for: The target summary and the first target memory information are input into the large language model as a first prompt word to generate a target text of the current interaction content including a first number of second results, wherein the first number increases as the number of interactions between the target objects increases.
8. The device according to claim 5, characterized in that The device is applied to a virtual character interaction scenario, and the target text generation module is specifically used for: Acquire environmental information of the virtual environment where the virtual character is located; input the environmental information, the target summary, and the target memory information into the large language model as a first prompt word to obtain a target text of the current interactive content related to the environmental information.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 4 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 4 are implemented.
Citation Information
Cited By
Information processing method and device and question and answer interaction method and device
CN121166878A