Conversation text generation method, related device, equipment and storage medium
Through the dialogue generation model, NPC dialogues in open-world games are automatically generated, which solves the problems of large manpower consumption and low dialogue freedom in the existing technology, and achieves efficient and diversified dialogue generation.
Patent Information
- Application Number
- CN202411944405.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-25
AI Technical Summary
When developing NPC dialogues in open world games, existing technology requires a lot of manpower to write dialogue logic and lines, resulting in high resource consumption and low dialogue freedom.
Through a dialogue text generation method, the dialogue generation model is used to automatically generate lines that conform to the NPC's character design based on the dialogue text input by the player, the NPC object setting information and knowledge information input by the player.
Save labor costs, improve development efficiency, increase freedom and diversity of dialogues, and reduce dialogue repetition and singularity.
Smart Images

Figure CN119886339A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method for generating a dialogue text, related devices, equipment and storage medium. Background Art
[0002] As open world games continue to develop, the number and complexity of non-player characters (NPCs) in the game are also increasing. The characteristic of open world games is that players can explore and interact in a highly free environment, among which dialogue between players and NPCs is a very important part of such games.
[0003] Currently, developers need to enumerate the possible dialogue needs of players in specific scenarios, and set several speaking buttons in the dialogue scene to realize the selection of dialogue content. NPC will give fixed feedback based on the dialogue content selected by the player. In order to make the dialogue content richer, developers will also write several sets of lines and select a dialogue text from them based on certain rules to feedback to the player.
[0004] However, the inventors have found that the current solutions have at least the following problems: For the fixed dialogue solution, on the one hand, it relies on a large amount of manpower to formulate dialogue logic and write character lines for each NPC, resulting in a large consumption of development resources. On the other hand, the player's input is fixed, resulting in a low degree of dialogue freedom. In response to the above problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a method for generating dialogue text, related devices, equipment and storage medium, which can automatically generate lines that are consistent with the NPC character setting, which not only saves labor costs but also improves development efficiency.
[0006] In view of this, the present application provides, on one hand, a method for generating a dialogue text, comprising:
[0007] In response to an interactive operation between a first virtual object and a second virtual object, a first dialogue text corresponding to the first virtual object is obtained, wherein the first virtual object is a virtual object controlled by a real user, the second virtual object is a virtual object not controlled by a real user, and the first dialogue text is derived from input by the real user;
[0008] Obtaining object setting information of the second virtual object, wherein the object setting information includes enumerable parameters, and the enumerable parameters are used to describe optional information related to the virtual object;
[0009] Acquiring knowledge information corresponding to the second virtual object, wherein the knowledge information is used to describe background knowledge that the virtual object needs to follow in the virtual scene;
[0010] Based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object, a second dialogue text corresponding to the second virtual object is generated through a dialogue generation model.
[0011] On the other hand, the present application provides a dialogue text generation device, comprising:
[0012] an acquisition module, configured to acquire a first dialogue text corresponding to the first virtual object in response to an interactive operation between the first virtual object and the second virtual object, wherein the first virtual object is a virtual object controlled by a real user, the second virtual object is a virtual object not controlled by a real user, and the first dialogue text is derived from an input of the real user;
[0013] The acquisition module is further used to acquire object setting information of the second virtual object, wherein the object setting information includes enumerable parameters, and the enumerable parameters are used to describe optional information related to the virtual object;
[0014] The acquisition module is further used to acquire knowledge information corresponding to the second virtual object, wherein the knowledge information is used to describe background knowledge that the virtual object needs to follow in the virtual scene;
[0015] A generation module is used to generate a second dialogue text corresponding to the second virtual object through a dialogue generation model based on the first dialogue text, object setting information of the second virtual object and knowledge information corresponding to the second virtual object.
[0016] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0017] The object setting information also includes at least one of a non-enumerable parameter and a temporary variable:
[0018] Among them, the non-enumerable parameters are used to describe the non-selectable information related to the virtual object, and the temporary variables are used to describe the information involved in the virtual object in the current period.
[0019] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0020] An acquisition module, specifically used to acquire a query embedding vector through a text encoding model based on the first dialogue text and the object setting information of the second virtual object;
[0021] Calculate the similarity between the query embedding vector and each entity embedding vector in the K entity embedding vectors to obtain K vector similarities, where each vector similarity in the K vector similarities represents the similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1;
[0022] If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, then N entity embedding vectors are determined according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K;
[0023] According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
[0024] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0025] The acquisition module is further used to acquire historical interaction information between the first virtual object and the second virtual object, wherein the historical interaction information includes at least one round of historical dialogue, and each round of historical dialogue includes the historical dialogue of the first virtual object and the historical dialogue of the second virtual object;
[0026] The generation module is specifically used to generate a second dialogue text corresponding to the second virtual object through a dialogue generation model based on the first dialogue text, the object setting information of the second virtual object, the knowledge information corresponding to the second virtual object, and the historical interaction information between the first virtual object and the second virtual object.
[0027] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0028] An acquisition module, specifically configured to acquire a query embedding vector through a text encoding model based on the first dialogue text, the object setting information of the second virtual object, and the historical interaction information between the first virtual object and the second virtual object;
[0029] Calculate the similarity between the query embedding vector and each entity embedding vector in the K entity embedding vectors to obtain K vector similarities, where each vector similarity in the K vector similarities represents the similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1;
[0030] If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, then N entity embedding vectors are determined according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K;
[0031] According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
[0032] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0033] An acquisition module is specifically used to use the entity embedding vector corresponding to the largest vector similarity among at least one vector similarity as N entity embedding vectors; or,
[0034] The entity embedding vector corresponding to each vector similarity in at least one vector similarity is used as N entity embedding vectors.
[0035] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0036] An acquisition module, specifically used to acquire N entity description information according to the N entity embedding vectors, wherein each entity description information corresponds to an entity embedding vector;
[0037] The N entity description information is used as the knowledge information corresponding to the second virtual object.
[0038] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0039] The acquisition module is also used to acquire K entities for the virtual scene;
[0040] The acquisition module is also used to obtain entity description information corresponding to each entity in the K entities;
[0041] The acquisition module is also used to obtain the entity embedding vector corresponding to each entity in the K entities through the text encoding model based on the entity description information corresponding to the entity.
[0042] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0043] A generating module, specifically used to construct a target prompt text according to the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object;
[0044] Calling the dialogue generation model to encode the target prompt text to obtain a first encoding vector corresponding to each text unit in the target prompt text;
[0045] Call the dialogue generation model to perform attention calculation on the first encoding vector corresponding to each text unit to obtain the second encoding vector corresponding to each text unit;
[0046] The dialogue generation model is called to predict the second encoding vector corresponding to each text unit to obtain the second dialogue text corresponding to the second virtual object.
[0047] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0048] A generation module is specifically used to call the dialogue generation model, perform text encoding on the target prompt text, and obtain a text encoding vector corresponding to each text unit in the target prompt text;
[0049] Calling the dialogue generation model to positionally encode the target prompt text, and obtaining a position encoding vector corresponding to each text unit in the target prompt text;
[0050] The text encoding vector corresponding to each text unit in the target prompt text is added to the position encoding vector to obtain a first encoding vector corresponding to each text unit in the target prompt text.
[0051] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0052] A generation module is specifically used to call the dialogue generation model, and calculate h attention score matrices according to the first encoding vector corresponding to each text unit, where h is an integer greater than or equal to 1;
[0053] Normalize the h attention score matrices to obtain h attention weight matrices;
[0054] The first encoding vector corresponding to each text unit is weighted and summed according to h attention weight matrices to obtain the second encoding vector corresponding to each text unit.
[0055] In one possible design, in another implementation of another aspect of the embodiment of the present application, the dialogue text generation device further includes a determination module and a training module;
[0056] The acquisition module is further used to acquire training samples, wherein the training samples include object setting information of the virtual training object, a first dialogue sample provided by a player, a set of historical dialogue samples between the virtual training object and the player, knowledge information corresponding to the virtual training object, and a second dialogue sample of the virtual training object;
[0057] The generation module is further used to generate a predicted dialogue text of the virtual training object through a dialogue generation model based on the object setting information of the virtual training object, the first dialogue sample provided by the player, the set of historical dialogue samples between the virtual training object and the player, and the knowledge information corresponding to the virtual training object;
[0058] A determination module, configured to determine a loss value based on a second dialogue sample of the virtual training object and a predicted dialogue text of the virtual training object;
[0059] The training module is used to train the dialogue generation model using the loss value.
[0060] In one possible design, in another implementation of another aspect of the embodiment of the present application,
[0061] An acquisition module, specifically used to construct a target prompt sample according to the object setting information of the virtual training object, the first dialogue sample, the historical dialogue sample set and the knowledge information corresponding to the virtual training object;
[0062] Based on the target prompt sample, a second dialogue sample of the virtual training object is obtained through the large language model.
[0063] In one possible design, in another implementation of another aspect of the embodiment of the present application, the conversation text generation device further includes a detection module and a control module;
[0064] A detection module, configured to detect the second dialogue text after generating a second dialogue text corresponding to the second virtual object through a dialogue generation model based on the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object, to obtain a text detection result;
[0065] A control module, configured to control the second virtual object to output the second dialogue text if the text detection result indicates that the second dialogue text satisfies the dialogue output condition;
[0066] The control module is also used to control the second virtual object to output a third dialogue text if the text detection result indicates that the second dialogue text does not meet the dialogue output condition, wherein the third dialogue text is a pre-set fallback text.
[0067] Another aspect of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned methods when executing the computer program.
[0068] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the above-mentioned methods are implemented.
[0069] Another aspect of the present application provides a computer program product, including a computer program, which implements the above-mentioned methods when executed by a processor.
[0070] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0071] In an embodiment of the present application, a method for generating a dialogue text is provided. In an open world game, a player can have a dialogue with other NPCs in a virtual scene. Taking the case where a player controls a first virtual object, when the player interacts with a second virtual object (i.e., a certain NPC), a first dialogue text can be provided. Based on this, in combination with the first dialogue text provided by the player, the object setting information and knowledge information corresponding to the second virtual object, a second dialogue text for the second virtual object can be generated using a dialogue generation model. In the above manner, the developer pre-configures the NPC's object setting information and the background knowledge to be followed in the virtual scene, and then combines the dialogue content provided by the player to automatically generate lines that conform to the NPC's personality, which not only saves labor costs, but also improves development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 This is a schematic diagram of an open world game applied in an embodiment of the present application;
[0073] Figure 2 This is a schematic diagram of an application to intelligent customer service in an embodiment of the present application;
[0074] Figure 3 This is a schematic diagram of an embodiment of the present application applied to a voice assistant;
[0075] Figure 4 A schematic diagram of an implementation environment of the method for generating a dialogue text in an embodiment of the present application;
[0076] Figure 5 A flowchart of a method for generating a dialogue text in an embodiment of the present application;
[0077] Figure 6 A schematic diagram of the interaction between a player and an NPC in an embodiment of the present application;
[0078] Figure 7 A schematic diagram of the structure of the method for generating a dialogue text in an embodiment of the present application;
[0079] Figure 8 A schematic diagram of position encoding of text in an embodiment of the present application;
[0080] Fig. 9 A schematic diagram of a multi-head attention mechanism in an embodiment of the present application;
[0081] Fig.10 A schematic diagram of a conversation text generating device in an embodiment of the present application;
[0082] Fig.11 A schematic diagram of the structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0083] The embodiments of the present application provide a method for generating dialogue text, related devices, equipment and storage media. Developers only need to pre-configure the object setting information of the NPC and provide the content input by the player to automatically generate lines that are consistent with the NPC's personality, which not only saves labor costs but also improves development efficiency.
[0084] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "corresponding to" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0085] It is understandable that in the specific implementation of the present application, when data related to conversation text, basic information, behavior data, voice data, etc. are applied to specific products or technologies, user permission or consent is required. That is, before collecting the user's relevant data, the user can be prompted to collect their relevant data through a prompt interface, a prompt pop-up window, or a prompt voice. The step of collecting user-related data is only started after obtaining the user's permission or consent. In other words, all user data collected by this application is collected with the user's consent and authorization, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0086] Intelligent conversation plays an important role in people's lives. It breaks the limitations of time and space, allowing people to obtain information and help anytime and anywhere. Intelligent conversation also provides people with personalized services, that is, providing exclusive advice and guidance based on each person's needs and preferences. Integrating intelligent conversation into life can make information acquisition more efficient and service experience better, greatly improving the convenience and quality of people's lives.
[0087] Nowadays, the way of intelligent dialogue is showing a trend of diversification. Service providers can provide users with different types of virtual objects to reply to questions raised by users, and the content of these replies is often related to the characteristics of the virtual objects. For example, some virtual objects will show enthusiastic characteristics in the reply content, and some virtual objects will show cold characteristics in the reply content. For developers, it is necessary to write the dialogue text in advance. This is not only inefficient but also costly. Using artificial intelligence (AI) to generate reply content requires a separate model to be developed for each virtual object, which not only consumes a lot of manpower, time and money, but also brings great inconvenience in the maintenance and debugging stages.
[0088] Based on this, the embodiment of the present application provides a method for generating a dialogue text, which has strong versatility (i.e., only one model is needed to predict the output dialogue of any virtual object) and freedom (i.e., the user can input any dialogue), and the model deployment difficulty is low (i.e., only one model is needed). It can be seen that the method provided by the present application not only saves development resources, but also facilitates the expansion and updating of dialogues. In addition, the background can also collect the user's satisfaction with the reply content for continuous improvement and optimization of the model.
[0089] Before introducing the specific method of the present application, the application scenario of the present application is first exemplified. It should be noted that the following application scenario is only for illustration and is not limited thereto.
[0090] 1. Applied to open world games;
[0091] Open world games (e.g., small independent games, massively multiplayer online role playing games (MMORPGs), etc.) have been very popular among players in recent years. With the continuous development of open world games, the number and complexity of NPCs in the game are also increasing. The characteristic of open world games is that players can explore and interact in a highly free environment, among which the dialogue between players and NPCs is a very important part of such games. Generally speaking, the experience of players' dialogue with NPCs is mainly affected by two aspects, namely, the quality of NPC lines and the freedom of dialogue.
[0092] Specifically, we first construct a batch of NPCs for training based on the game's worldview, and then enumerate the corresponding dialogue writing strategies and fill in the prompt framework based on the configured NPC personality, gender, and occasion. Then we randomly call the NPCs for training and traverse different dialogue scenes multiple times to construct a large amount of dialogue data containing different NPCs in different occasions, which is used for further training on the base model to obtain a dialogue generation model.
[0093] For example, see Figure 1 , Figure 1 This is a schematic diagram of an open world game in an embodiment of the present application. As shown in the figure, suppose a player asks an NPC "how to get a magic book". Thus, the NPC's reply content is generated by calling the dialogue generation model.
[0094] It can be seen that the method provided in this application can be used as a general solution for generating a large number of common NPCs and minor NPC lines in open world games. In practical applications, the dialogue generation model takes the various parameters of the current NPC, the text provided by the player, and the historical dialogue records as input, and outputs diversified and personalized NPC lines. It solves the high cost and long cycle problems caused by developing a model for each NPC, and greatly reduces the difficulty of subsequent development, maintenance, and expansion, bringing new possibilities for the development of open world games.
[0095] 2. Applied to intelligent customer service;
[0096] Intelligent customer service can quickly handle a large number of user inquiries and provide answers to common questions within seconds. Compared with manual customer service, which may require waiting in line, intelligent customer service greatly saves users' time and can provide services to users without time constraints. In order to improve users' favorability towards intelligent customer service, you can also create or select an intelligent customer service to reply based on the user's relevant information.
[0097] Specifically, we first construct a batch of virtual customer service agents for training, and based on the configured virtual customer service agents' personality, gender, chat style, etc., we enumerate the corresponding reply writing strategies and fill them into the prompt framework. Then, we construct a large number of reply contents containing different virtual customer service agents for further training on the base model, thus obtaining a dialogue generation model.
[0098] For example, see Figure 2 , Figure 2This is a schematic diagram of the intelligent customer service in the embodiment of the present application. As shown in the figure, the background selects a virtual customer service based on the user's basic information (e.g., age, gender, geographic location, etc.), historical interaction records (e.g., questions consulted, products or services purchased, etc.), and behavior data (e.g., browsing path, dwell time, etc.). Assume that the player asks the virtual customer service "What will the weather be like tomorrow?", and thus, the reply content of the virtual customer service is generated by calling the dialogue generation model.
[0099] 3. Applied to voice assistants;
[0100] Voice assistants play a positive role in people's daily life, work and study. Users can not only control smart homes through voice assistants, but also query information through voice assistants. The input speed of voice commands is usually faster than manual input, so voice assistants can save users' operation time. In order to enhance the fun of users' interaction with voice assistants, a virtual object can be randomly assigned to interact with users.
[0101] Specifically, we first construct a batch of virtual objects for training, and then enumerate the corresponding reply writing strategies and fill in the prompt frame based on the configured virtual objects' personality, gender, chat mode, etc. Then we construct a large number of reply contents containing different virtual objects for further training on the base model, thus obtaining a dialogue generation model.
[0102] For example, see Figure 3 , Figure 3 This is a schematic diagram of a voice assistant in an embodiment of the present application. As shown in the figure, the background randomly selects a virtual object to reply. Assuming that the player gives the voice assistant an instruction of "set an alarm at 8 o'clock tomorrow morning", the reply content of the virtual object is generated by calling the dialogue generation model.
[0103] It should be noted that the above application scenarios are only examples, and the dialogue text generation method provided in this embodiment can also be applied to other scenarios, which are not limited here.
[0104] The method provided in this application can be applied to Figure 4The implementation environment shown in the figure includes a terminal 401 and a server 402, and the terminal 401 and the server 402 can communicate with each other through a network 403. The network 403 uses standard communication technology and / or protocols, usually the Internet, but can also be any network, including but not limited to Bluetooth, local area network (LAN), metropolitan area network (MAN), wide area network (WAN), mobile, dedicated network or any combination of virtual private networks. In some embodiments, customized or dedicated data communication technology can be used to replace or supplement the above data communication technology.
[0105] The terminal 401 involved in this application includes but is not limited to mobile phones, tablet computers, laptop computers, desktop computers, intelligent voice interaction devices, virtual reality devices, smart home appliances, vehicle terminals, aircraft, etc. Among them, the client is deployed on the terminal 401, and the client can be run on the terminal 401 in the form of a browser, or in the form of an independent application (application, APP) or a small program, etc.
[0106] The server 402 involved in this application can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence (AI) platforms. It should be noted that this application uses the configuration of the dialogue generation model deployed on the server 402 as an example for explanation. In some embodiments, the configuration of the dialogue generation model can also be deployed on the terminal 401. In some embodiments, part of the configuration of the dialogue generation model is deployed on the terminal 401, and part of the configuration is deployed on the server 402.
[0107] In combination with the above implementation environment, in step A1, the user controls the first virtual object, and when the user inputs the first dialogue text, it indicates that the first virtual object interacts with the second virtual object (i.e., NPC). In step A2, the terminal 401 sends the first dialogue text input by the user to the server 402 through the network 403. In step A3, the server 402 obtains the object setting information of the second virtual object. In step A4, the server 402 obtains the knowledge information corresponding to the second virtual object. In step A5, the server 402 calls the dialogue generation model, processes the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object, and obtains the second dialogue text. In step A6, the server 402 sends the second dialogue text to the terminal 401 through the network 403. In step A7, the second dialogue text of the second virtual object is displayed.
[0108] Combined with the above introduction, the following will introduce the method for generating the dialogue text in this application. Please refer to Figure 5 The method for generating the dialogue text in the embodiment of the present application can be completed independently by the terminal, independently by the server, or in cooperation between the terminal and the server. The present application provides:
[0109] S501, in response to an interactive operation between a first virtual object and a second virtual object, obtaining a first dialogue text corresponding to the first virtual object, wherein the first virtual object is a virtual object controlled by a real user, the second virtual object is a virtual object not controlled by a real user, and the first dialogue text is derived from input of the real user;
[0110] In one or more embodiments, taking the user controlling the first virtual object as an example, the first virtual object may be an explicit object (i.e., a virtual object displayed on the interface) or an implicit object (i.e., a virtual object not displayed on the interface). The second virtual object may be an NPC, wherein the NPC may be a character in a virtual scene, or a creature (e.g., an animal, a plant, etc.) or an object (e.g., a table, a vehicle, etc.) in a virtual scene.
[0111] Specifically, for ease of understanding, see Figure 6 , Figure 6 This is a schematic diagram of the interaction between the player and the NPC in the embodiment of the present application, such as Figure 6As shown in Figure (A), 601 is used to indicate the NPC "Zhang San", and 602 is used to indicate the dialogue control for "Zhang San". 603 is used to indicate the NPC "Li Si", and 604 is used to indicate the dialogue control for "Li Si". 605 is used to indicate the NPC "Lao Ying", and 606 is used to indicate the dialogue control for "Lao Ying". Assuming that the user (i.e., the real user) clicks the dialogue control indicated by 602, that is, triggering the interaction operation between the first virtual object and the second virtual object, at this time, the second virtual object is "Zhang San" indicated by 601. Thus, the display is as follows Figure 6 The interface shown in Figure (B) is shown in Figure 607. 607 is used to indicate the first dialogue text input by the user, wherein the user can directly input the first dialogue text, or the user can input a voice instruction and convert the voice instruction into the first dialogue text.
[0112] It should be noted that the term "in response to" in this application is used to indicate the conditions or states on which the execution of an operation depends, and one or more operations can be executed when certain conditions or states are met. These operations can be real-time or have a certain delay.
[0113] S502: Obtain object setting information of a second virtual object, wherein the object setting information includes enumerable parameters, and the enumerable parameters are used to describe optional information related to the virtual object;
[0114] In one or more embodiments, based on the interactive operation triggered by the user, object setting information of the second virtual object is obtained, wherein the object setting information includes but is not limited to enumerable parameters, and the enumerable parameters can reflect the basic information of the virtual object, and maintain the standardization and consistency of the description through clear labels.
[0115] Specifically, for ease of understanding, please refer to Table 1, which is a schematic diagram of various enumerable parameters.
[0116] Table 1
[0117]
[0118] The enumerable parameters corresponding to the persona information describe the basic information of the virtual object, which is used to help the model understand the basic role positioning of the virtual object and to influence the generated dialogue content. For example, how should an arrogant person speak when he is angry; how should an old man speak; how should a person who is about to step onto the battlefield respond to a joke from a player.
[0119] S503, acquiring knowledge information corresponding to the second virtual object, wherein the knowledge information is used to describe background knowledge that the virtual object needs to follow in the virtual scene;
[0120] In one or more embodiments, based on the interactive operation triggered by the user, the knowledge information corresponding to the second virtual object can also be obtained. The knowledge information represents the background knowledge that the virtual object needs to follow in the virtual scene, that is, the development team plans the macro background to ensure that the content is framed in this background.
[0121] Specifically, taking the virtual scene as a game scene as an example, the knowledge information of the second virtual object includes a world view and a story script. The world view includes the basic background and knowledge points for the game scene (for example, eating a certain fruit in the game will make you run faster). The knowledge information will help the virtual object better answer questions raised by the user. The basic background includes entity knowledge, character knowledge, and character relationships.
[0122] It should be noted that entity knowledge is detailed information about specific things, places, and events in the game scene. These detailed information helps the model take into account the specific details and historical background of the game scene when generating the dialogue content of the virtual objects, making the dialogue content more realistic and consistent. Character knowledge covers the background story, personality traits, and historical relationships of the virtual objects. This detailed background information helps the dialogue generation model take into account the unique personality and experience of each virtual object when generating the dialogue content, making the generated dialogue content more in line with the settings and scene requirements of the virtual objects. Character relationships refer to the relationship network between virtual objects, including relationship information such as relatives, friends, and enemies. By understanding the relationships between virtual objects, the dialogue generation model can generate more reasonable and interactive dialogues.
[0123] It should be noted that the present application does not limit the execution order between step S502 and step S503.
[0124] S504: Generate a second dialogue text corresponding to the second virtual object through a dialogue generation model based on the first dialogue text, object setting information of the second virtual object, and knowledge information corresponding to the second virtual object.
[0125] In one or more embodiments, a target prompt text (i.e., prompt) can be constructed based on the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object. The target prompt text is used as the input of the dialogue generation model, and the second dialogue text corresponding to the second virtual object is generated by the dialogue generation model.
[0126] For details, please refer again to Figure 6, taking the first dialogue text as "Who are you, what are you doing" as an example, a target prompt text can be constructed as "Zhang San is a lively and cheerful girl, now 10 years old, a primary school student with excellent academic performance... The player asks, who are you, what are you doing, please output Zhang San's dialogue." The second dialogue text is obtained through the dialogue generation model. Figure 6 As shown in the middle (C) figure, 608 is used to indicate the first dialogue text, and 609 is used to indicate the second dialogue text.
[0127] It should be noted that the dialogue generation model involved in this application can be obtained by further training on the base model. The base model can adopt a large language model (LLM), where LLM is a natural language processing model based on deep learning that can understand and generate natural language text. At present, the mainstream LLM architecture basically adopts a transformer structure based on a decoder module. Transformer relies on a self-attention mechanism to calculate the representation of its input and output.
[0128] In an embodiment of the present application, a method for generating dialogue text is provided. In the above manner, the developer pre-configures rich object setting information and knowledge information, and then combines the dialogue content provided by the player. The model can understand the current situation of the virtual object in a wider context, and automatically generate dialogue content that is more accurate and richer than the scene and character setting. Since these tedious tasks can be completed in a shorter time, the development time and labor costs are greatly reduced. Each virtual object has its own unique language habits, life style and personality. Combining the object setting information to predict the dialogue content can avoid monotonous and repetitive dialogues.
[0129] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, the object setting information further includes at least one of a non-enumerable parameter and a temporary variable:
[0130] Among them, the non-enumerable parameters are used to describe the non-selectable information related to the virtual object, and the temporary variables are used to describe the information involved in the virtual object in the current period.
[0131] In one or more embodiments, a method of using non-enumerable parameters and temporary variables as object setting information is introduced. As can be seen from the above embodiments, the object setting information includes not only enumerable parameters, but also at least one of non-enumerable parameters and temporary variables.
[0132] Specifically, for ease of understanding, please refer to Table 2, which is a schematic diagram of various types of non-enumerable parameters.
[0133] Table 2
[0134] Parameter Type Non-enumerable parameters (example) Task Description Admitted to magic school... experience He was once a valiant knight with extraordinary talents... Relationships He has two good friends, one is Jack and the other is Tom... Lifestyle He likes old things, and there is an old record player on his desk... Things you like / dislike I like walking and fishing, but I don’t like running… Social Style Often hosts parties and is good at setting the mood... Long-term goals Learn 10 skills
[0135] Among them, non-enumerable parameters can provide more detailed information, help to have a more comprehensive understanding of virtual objects, and add rich details to the description of virtual objects.
[0136] For ease of understanding, please refer to Table 3, which is a schematic diagram of various temporary variables.
[0137] Table 3
[0138] Parameter Type Temporary variables (example) Short-term goals Find 3 red gems mood Desperate to find gems
[0139] Among them, temporary variables can describe the current key information and real-time status of virtual objects, providing important support for game operation, logic processing and user experience.
[0140] Secondly, in the embodiment of the present application, a method of using non-enumerable parameters and temporary variables as object setting information is provided. Through the above method, the introduction of non-enumerable parameters can enrich the overall image of the virtual object and help guide the dialogue generation model to generate more diverse dialogue content. The introduction of temporary variables helps guide the dialogue generation model to generate dialogue content that is more in line with the current state of the virtual object.
[0141] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, obtaining the knowledge information corresponding to the second virtual object specifically includes:
[0142] Based on the first dialogue text and the object setting information of the second virtual object, obtaining a query embedding vector through a text encoding model;
[0143] Calculate the similarity between the query embedding vector and each entity embedding vector in the K entity embedding vectors to obtain K vector similarities, where each vector similarity in the K vector similarities represents the similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1;
[0144] If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, then N entity embedding vectors are determined according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K;
[0145] According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
[0146] In one or more embodiments, a method for obtaining knowledge information based on entity retrieval is introduced. It can be seen from the above embodiments that entity retrieval of input content can obtain entity description information corresponding to similar entities. Based on this, these entity description information are used as knowledge information to achieve the purpose of enriching the context. In the entity retrieval process, in order to improve the retrieval efficiency and accuracy, a retrieval scheme based on embedding vectors is introduced. That is, using deep learning technology, entities are mapped into high-dimensional vectors, thereby achieving efficient similarity calculation and fast retrieval.
[0147] Specifically, first, a target query text is constructed based on the first dialogue text and the object setting information of the second virtual object. For example, the target query text is "Zhang San is a lively and cheerful girl. Her academic performance is very good. She met the player at the entrance of the village. The player said, who are you and what are you doing?" Based on this, the target query text is used as the input of the text encoding model, and the query embedding vector is output through the text encoding model. Then, the query embedding vector is respectively calculated for similarity with the K entity embedding vectors to obtain the vector similarity between the query embedding vector and each entity embedding vector. Among them, the greater the vector similarity, the more similar the two embedding vectors are.
[0148] If at least one vector similarity among the K vector similarities is greater than or equal to a similarity threshold (e.g., 0.9), the entity embedding vector corresponding to it is determined according to the at least one vector similarity. Since the entity embedding vector corresponds to an entity description information, the knowledge information corresponding to the second virtual object is generated by combining the entity description information corresponding to the N entity embedding vectors.
[0149] It should be noted that the text encoding model involved in this application can be an LLM, or an embeddings from language models model, or a generative pretrained transformer (GPT), or a bidirectional encoder representations from transformers model, which is not limited here.
[0150] Secondly, in the embodiment of the present application, a method for obtaining knowledge information based on entity retrieval is provided. In the above method, entity retrieval is performed using the first dialogue text and object setting information to obtain knowledge information of similar entities. Based on this, the knowledge information of similar entities is used as the basis for generating dialogue content, so that the model can take into account a wider range of background factors, thereby helping to generate high-quality dialogue texts, ensuring the rationality, coherence and diversity of the dialogue content, and enhancing the realism, immersion and interactivity of the game.
[0151] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, another optional embodiment provided by the embodiment of the present application may further include:
[0152] Acquire historical interaction information between the first virtual object and the second virtual object, wherein the historical interaction information includes at least one round of historical dialogue, and each round of historical dialogue includes a historical dialogue of the first virtual object and a historical dialogue of the second virtual object;
[0153] Based on the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object, generating a second dialogue text corresponding to the second virtual object through a dialogue generation model specifically includes:
[0154] Based on the first dialogue text, object setting information of the second virtual object, knowledge information corresponding to the second virtual object, and historical interaction information between the first virtual object and the second virtual object, a second dialogue text corresponding to the second virtual object is generated through a dialogue generation model.
[0155] In one or more embodiments, a method of generating a dialogue text by combining historical dialogues is introduced. As can be seen from the aforementioned embodiments, if at least one round of historical dialogues has occurred between the first virtual object and the second virtual object, the historical interaction information including at least one round of historical dialogues is also used as the basis for constructing the target prompt text. That is, based on the first dialogue text, the object setting information, knowledge information and historical interaction information of the second virtual object, a target prompt text for predicting the second dialogue text is constructed.
[0156] It should be noted that if the number of dialogue rounds generated between the first virtual object and the second virtual object exceeds a threshold number of rounds (for example, 3 rounds), the most recent 3 rounds of historical dialogues may be taken as model input.
[0157] It is understandable that historical interaction information includes short-term interaction information and long-term interaction information, wherein short-term interaction information includes several rounds of historical dialogues between the user and the virtual object (for example, the last three rounds of historical dialogues between the first virtual object and the second virtual object). Long-term interaction information includes the world view and story script extracted from the memory bank, for example, the relevant data that the first virtual object and the second virtual object have participated in a task together,
[0158] Specifically, taking the virtual scene as a game scene as an example, for ease of understanding, please refer to Figure 7 , Figure 7 This is an architectural diagram of the method for generating dialogue text in an embodiment of the present application. As shown in the figure, in the model reasoning stage, different virtual objects are pointed to by different virtual object identifiers, and the historical dialogue between the user and the virtual object is obtained through context input.
[0159] Among them, the attribute library includes the object setting information corresponding to each virtual object, so that the dialogue generation model has an understanding of game knowledge comparable to that of humans. Among them, the attribute library includes various attributes that are enumerated or generated using prompts, ensuring that all enumerable parameters are covered and the object setting information of virtual objects is as rich and diverse as possible. The memory library is divided by virtual objects and is associated with users. The memory library is divided in the form of "virtual object_X×user_X". That is, each user and each virtual object can have a unique interactive memory. For example, "virtual object_A×user_B" represents the interactive memory between virtual object A and user B. The knowledge base is divided by virtual objects, and the knowledge information of each virtual object includes a worldview and a story script.
[0160] After obtaining the first dialogue text, the knowledge information of the second virtual object, and the historical interaction information between the first virtual object and the second virtual object, the target prompt text can be composed in combination with the object setting information of the second virtual object and input into the dialogue generation model, which generates the corresponding reply, that is, obtains the second dialogue text.
[0161] Figure 7 The architecture shown can be widely used in various NPCs in open world games, greatly improving the problems of empty, featureless and uniform dialogues due to the difficulty of independent development. This application also shows great convenience in expanding the gameplay (for example, adding short-term and long-term goals of NPCs), just by adding more optional configuration slots, constructing data and fine-tuning the model.
[0162] Secondly, in the embodiment of the present application, a method for generating a dialogue text by combining historical dialogues is provided. In the above manner, since the historical dialogue provides background information for the current dialogue, the model can better understand the topic and intention of the dialogue, provide more clues for predicting the current dialogue, and thus generate more accurate and coherent responses. In addition, by analyzing historical dialogues, the user's preferences and dialogue style can also be understood, thereby increasing user satisfaction. It can be seen that the present application provides an efficient and flexible solution for generating dialogues between users and virtual objects.
[0163] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, obtaining the knowledge information corresponding to the second virtual object specifically includes:
[0164] Based on the first dialogue text, the object setting information of the second virtual object, and the historical interaction information between the first virtual object and the second virtual object, obtaining a query embedding vector through a text encoding model;
[0165] Calculate the similarity between the query embedding vector and each entity embedding vector in the K entity embedding vectors to obtain K vector similarities, where each vector similarity in the K vector similarities represents the similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1;
[0166] If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, then N entity embedding vectors are determined according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K;
[0167] According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
[0168] In one or more embodiments, another method of acquiring knowledge information based on entity retrieval is introduced. As can be seen from the above embodiments, entity retrieval of input content can obtain entity description information corresponding to similar entities. Based on this, these entity description information are used as knowledge information to achieve the purpose of enriching context.
[0169] Specifically, first, based on the first dialogue text, the object setting information of the second virtual object, and the historical interaction information between the first virtual object and the second virtual object, a target query text is constructed. For example, the target query text is "Zhang San is a lively and cheerful girl. Her academic performance is very good. She met the player at the entrance of the village. The player said, who are you and what are you doing. Previously, the player used the magic wand provided by Zhang San to complete the clearance task. The player once asked Zhang San what object was needed to pass the level, and Zhang San replied that a magic wand was needed. " Based on this, the target query text is used as the input of the text encoding model, and the query embedding vector is output through the text encoding model. Then, the query embedding vector is respectively calculated for similarity with the K entity embedding vectors to obtain the vector similarity between the query embedding vector and each entity embedding vector.
[0170] If at least one vector similarity among the K vector similarities is greater than or equal to a similarity threshold (e.g., 0.9), the entity embedding vector corresponding to it is determined according to the at least one vector similarity. Since the entity embedding vector corresponds to an entity description information, the knowledge information corresponding to the second virtual object is generated by combining the entity description information corresponding to the N entity embedding vectors.
[0171] Again, in the embodiment of the present application, another method of obtaining knowledge information based on entity retrieval is provided. In the above method, entity retrieval is performed using the first dialogue text, object setting information, and historical interaction information to obtain knowledge information of similar entities. Based on this, the knowledge information of similar entities is used as the basis for generating dialogue content, so that the model can take into account a wider range of background factors, thereby helping to generate high-quality dialogue texts, ensuring the rationality, coherence, and diversity of the dialogue content, and enhancing the realism, immersion, and interactivity of the game.
[0172] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, determining N entity embedding vectors according to at least one vector similarity specifically includes:
[0173] The entity embedding vector corresponding to the largest vector similarity among at least one vector similarity is used as N entity embedding vectors; or,
[0174] The entity embedding vector corresponding to each vector similarity in at least one vector similarity is used as N entity embedding vectors.
[0175] In one or more embodiments, two methods of determining entity embedding vectors are introduced. As can be seen from the above embodiments, in the actual retrieval process, the target query text is first input into the text encoding model to generate a corresponding query embedding vector.
[0176] Specifically, the vector similarity between the query embedding vector and each entity embedding vector is calculated respectively. The following will take the vector similarity as cosine similarity as an example to illustrate that the similarity between the query embedding vector and the entity embedding vector can be calculated in the following way:
[0177]
[0178] Among them, cosine similarity(A,B) represents the cosine similarity between the query embedding vector and the entity embedding vector. A represents the query embedding vector. B represents the entity embedding vector.
[0179] Exemplarily, for ease of understanding, please refer to Table 4, which is an illustration of the vector similarity between the query embedding vector and the K entity embedding vectors.
[0180] Table 4
[0181] entity Entity Embedding Vector Vector Similarity Li Si (0.1,0.3,0.7,……,0.9) 0.75 apple (0.2,0.3,0.1,……,0.1) 0.96 village (0.7,0.4,0.5,……,0.2) 0.92 magician (0.6,0.6,0.1,……,0.5) 0.30 companion (0.1,0.2,0.7,……,0.8) 0.03 squirrel (0.9,0.8,0.7,……,0.4) 0.78
[0182] Assuming the similarity threshold is 0.9, based on Table 4, it can be seen that the vector similarity between the query embedding vector and the entity embedding vector corresponding to "apple" is greater than the similarity threshold, and the vector similarity between the query embedding vector and the entity embedding vector corresponding to "village" is greater than the similarity threshold.
[0183] One way is to use the entity embedding vector corresponding to the maximum vector similarity (i.e., (0.2, 0.3, 0.1, ..., 0.1)) as the N entity embedding vectors, in which case N = 1. Another way is to use all entity embedding vectors with vector similarity greater than or equal to the similarity threshold (i.e., (0.2, 0.3, 0.1, ..., 0.1) and (0.7, 0.4, 0.5, ..., 0.2)) as the N entity embedding vectors, in which case N = 2.
[0184] It should be noted that in practical applications, vector similarity can also be the reciprocal of the Euclidean distance (i.e., the smaller the Euclidean distance, the greater the vector similarity), or the reciprocal of the Manhattan distance (i.e., the smaller the Manhattan distance, the greater the vector similarity), or the Pearson correlation coefficient, etc., which is not limited here.
[0185] Again, in the embodiment of the present application, two methods for determining entity embedding vectors are provided. In the above method, if the corresponding entity embedding vector is determined based on the maximum vector similarity, an accurate match can be achieved. If the entity embedding vector is determined based on all vector similarities greater than or equal to the similarity threshold, the richness of the information can be improved.
[0186] Optionally, in the above Figure 5On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, obtaining the knowledge information corresponding to the second virtual object according to the N entity embedding vectors specifically includes:
[0187] Obtain N entity description information according to the N entity embedding vectors, where each entity description information corresponds to an entity embedding vector;
[0188] The N entity description information is used as the knowledge information corresponding to the second virtual object.
[0189] In one or more embodiments, a method for obtaining knowledge information based on entity retrieval is introduced. As can be seen from the above embodiments, each entity embedding vector is obtained by text encoding the entity description information, so the corresponding N entity description information can be obtained based on the N entity embedding vectors.
[0190] Specifically, for ease of understanding, please refer to Table 5, which is a schematic diagram of the relationship between entities, entity description information and their corresponding entity embedding vectors.
[0191] Table 5
[0192]
[0193]
[0194] In combination with the contents shown in Table 4 and Table 5, assuming that the N entity embedding vectors include the entity embedding vector corresponding to “apple” and the entity embedding vector corresponding to “village”, the entity description information corresponding to “apple” and the entity description information corresponding to “village” are used as the knowledge information corresponding to the second virtual object.
[0195] Again, in an embodiment of the present application, a method for obtaining knowledge information based on entity retrieval is provided. Through the above method, it is possible to quickly locate which entity embedding vectors are similar to the query embedding vector, and use the entity description information corresponding to the similar entity embedding vector as the knowledge information of the predicted object (i.e., the second virtual object). In this way, the predicted knowledge information can be more in line with the actual situation.
[0196] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, another optional embodiment provided by the embodiment of the present application may further include:
[0197] Get K entities for the virtual scene;
[0198] Obtain entity description information corresponding to each of the K entities;
[0199] For each of the K entities, based on the entity description information corresponding to the entity, the entity embedding vector corresponding to the entity is obtained through the text encoding model.
[0200] In one or more embodiments, a method for constructing an entity embedding vector is introduced. As can be seen from the above embodiments, a virtual scene usually contains a large number of entities. Taking the virtual scene as a game scene as an example, the entity includes but is not limited to various characters, objects, places, character relationships and concepts in the game scene.
[0201] Specifically, taking the virtual scene including K entities as an example, the developer can pre-configure a corresponding entity description information for each entity. Among them, the entity description information is a detailed description of an entity. Including the basic attributes, characteristics, status, relationships, etc. of the entity, which are used to fully understand the entity. As shown in Table 5 above, for each of the K entities, the corresponding entity description information is converted into an embedded representation (that is, an entity embedding vector is obtained) through the text encoding model. After the input text is processed by text encoding, a high-dimensional embedding of a fixed length is obtained, which represents the meaning of the entity in the semantic space.
[0202] It is worth noting that in order to improve retrieval accuracy, the query embedding vector and each entity embedding vector can be normalized to ensure that the length of each embedding vector is consistent, that is, embedding vectors of different dimensions have the same scale when compared and calculated, making the similarity calculation more stable and reliable.
[0203] It is understandable that text encoding models can adopt language models pre-trained with large-scale corpora, which can capture rich semantic information of text and represent it as high-dimensional vectors, that is, obtain embedded representations.
[0204] Again, in the embodiment of the present application, a method for constructing an entity embedding vector is provided. Through the above method, developers can configure entity description information for entities in virtual scenes according to their needs to provide rich entity knowledge and object relationships, so that the dialogue content output by the dialogue generation model contains a deep background and storyline. The interaction and relationship network between virtual objects are fully considered to make the dialogue more complex and in-depth.
[0205] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object, a second dialogue text corresponding to the second virtual object is generated by a dialogue generation model, specifically including:
[0206] constructing a target prompt text according to the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object;
[0207] Calling the dialogue generation model to encode the target prompt text to obtain a first encoding vector corresponding to each text unit in the target prompt text;
[0208] Call the dialogue generation model to perform attention calculation on the first encoding vector corresponding to each text unit to obtain the second encoding vector corresponding to each text unit;
[0209] The dialogue generation model is called to predict the second encoding vector corresponding to each text unit to obtain the second dialogue text corresponding to the second virtual object.
[0210] In one or more embodiments, a method for generating a second dialogue text based on a dialogue generation model is introduced. As can be seen from the above embodiments, in the process of using the dialogue generation model to infer the dialogue text, first, a target prompt text needs to be constructed, taking the target prompt text including the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object as an example, and then, the target prompt text is used as the input of the dialogue generation model, and the dialogue generation model outputs the corresponding reply text of the second virtual object (i.e., the second dialogue text).
[0211] The following is an introduction to the processing of the dialogue generation model.
[0212] 1. Text preprocessing;
[0213] First, convert the target prompt text into a format that the model can process, that is, split the target prompt text into text units (for example, words, subwords, or characters). Then, add special tags at least at the beginning and end of the tokenized text sequence to help the model better understand the input structure. Finally, convert the integer index corresponding to the tag into a tensor form. If the sequence length is inconsistent, the dimension needs to be adjusted and padded according to the model requirements to ensure that the input meets the input specifications of the model.
[0214] 2. Coding processing;
[0215] First, the input integer index sequence is converted into a dense vector representation through the word embedding layer provided by the dialogue generation model. The integer index corresponding to each token is used as the index to find the corresponding vector in the pre-trained embedding matrix. Next, each text unit can be positionally encoded, thereby obtaining the first encoding vector corresponding to each text unit.
[0216] 3. Reasoning Processing;
[0217] First, each first encoding vector is calculated based on the multi-head attention mechanism to obtain the second encoding vector corresponding to each text unit. Then, each second encoding vector is input into the feedforward neural network, which will independently perform nonlinear transformation on each text unit to further extract and integrate features and enhance the expression ability of the model.
[0218] 4. Prediction output;
[0219] The output layer provided by the dialogue generation model generates a second dialogue text corresponding to the second virtual object based on the second encoding vector corresponding to each text unit. The output layer can be a linear layer, that is, the output vector of the last layer is converted into a probability distribution on the vocabulary. The next word or text segment is predicted based on the output probability distribution.
[0220] Secondly, in the embodiment of the present application, a method for generating a second dialogue text based on a dialogue generation model is provided. In the above manner, since the design of the dialogue generation model is highly flexible and extensible, it can be adjusted and optimized according to different game requirements and backgrounds. Developers can configure parameter slots and enumeration values as needed, and the dialogue generation model can automatically adapt and generate diversified dialogue texts.
[0221] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, calling the dialogue generation model, encoding the target prompt text, and obtaining the first encoding vector corresponding to each text unit in the target prompt text specifically includes:
[0222] Calling the dialogue generation model to perform text encoding on the target prompt text, and obtaining a text encoding vector corresponding to each text unit in the target prompt text;
[0223] Calling the dialogue generation model to positionally encode the target prompt text, and obtaining a position encoding vector corresponding to each text unit in the target prompt text;
[0224] The text encoding vector corresponding to each text unit in the target prompt text is added to the position encoding vector to obtain a first encoding vector corresponding to each text unit in the target prompt text.
[0225] In one or more embodiments, a method for generating a first encoding vector based on position encoding is introduced. It can be seen from the above embodiments that in the process of text preprocessing, the target prompt text needs to be split into several text units, and the following will be explained by taking the text unit as a "word" as an example.
[0226] Specifically, for ease of understanding, see Figure 8 , Figure 8This is a schematic diagram for position encoding of text in an embodiment of the present application. As Figure 8 shown in Figure (A), taking the target prompt text "Zhang San loves singing" as an example, assume that the word vector dimension (d_model) of each text unit is 4, and assume that the maximum input sequence length is 5 (i.e., the position index ranges from 0 to 4). Exemplarily, perform text encoding on the target prompt text to obtain the text encoding vector corresponding to each text unit. For example, the text encoding vector corresponding to the text unit "San" is [0.1, 0.2, 0.6, 0].
[0227] Based on this, the sine function encoding and cosine function encoding can be used to calculate the position encoding vector corresponding to the i-th text unit, that is:
[0228] PE pos,2i = sin(pos / 10000 2i / d_model ); Formula (2)
[0229] PE pos,2i+1 = cos(pos / 10000 2i / d_model ); Formula (3)
[0230] where PE represents the position encoding. pos represents the position of the current text unit in the target prompt text. i represents the dimension index. d_model represents the word vector dimension. The sine (sin) is used for even positions. The cosine (cos) is used for odd positions.
[0231] As Figure 8 shown in Figure (B), taking the text unit "San" as an example, when i = 0:
[0232] Based on Formula (2),
[0233] Based on Formula (3),
[0234] When i = 1:
[0235] Based on Formula (2),
[0236] Based on Formula (3),
[0237] Thus, the position encoding vector corresponding to the text unit "San" is [0.841, 0.540, 0.0001, 0.9999].
[0238] As Figure 8 shown in Figure (C), adding the text encoding vector corresponding to the text unit "San" and the position encoding vector, the first encoding vector corresponding to the text unit "San" can be obtained.
[0239] It should be noted that, in practical applications, it is necessary to perform similar processing on each text unit in the target prompt text, thereby obtaining the first encoding vector corresponding to each text unit.
[0240] Again, in the embodiment of the present application, a method for generating a first encoding vector based on position encoding is provided. Through the above method, position information can be added to each text unit in the target prompt text, helping the dialogue generation model to identify the relative position relationship between each text unit, so as to distinguish the grammatical and semantic differences of each text unit in the target prompt text. Thereby improving the model's text comprehension and generation capabilities.
[0241] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, calling the dialogue generation model, performing attention calculation on the first encoding vector corresponding to each text unit, and obtaining the second encoding vector corresponding to each text unit specifically includes:
[0242] Call the dialogue generation model and calculate h attention score matrices according to the first encoding vector corresponding to each text unit, where h is an integer greater than or equal to 1;
[0243] Normalize the h attention score matrices to obtain h attention weight matrices;
[0244] The first encoding vector corresponding to each text unit is weighted and summed according to h attention weight matrices to obtain the second encoding vector corresponding to each text unit.
[0245] In one or more embodiments, a method for generating a second encoding vector based on an attention mechanism is introduced. As can be seen from the above embodiments, each text unit corresponds to a first encoding vector, and each first encoding vector can integrate the relationship information between text units through the attention mechanism to output a new vector sequence.
[0246] It should be noted that this application uses a multi-head attention mechanism as an example for explanation. The multi-head attention machine is an extension of the self-attention mechanism. It replicates multiple self-attention layers, and each layer learns a different representation subspace. In this way, multiple aspects of the sequence can be paid attention to at the same time, improving the model's expressive power and ability to capture long-distance dependencies. Among them, the self-attention mechanism can capture long-distance dependencies in the input sequence. It calculates the relationship between each text unit and other text units in the sequence to form a weight distribution, and then uses these weights to weighted sum the input to obtain a new representation.
[0247] Specifically, for ease of understanding, see Fig. 9 , Fig. 9 This is a schematic diagram of the multi-head attention mechanism in the embodiment of the present application. As shown in the figure, assuming that the first encoding vector of the i-th text unit is represented by x i , whose corresponding dimension is d_model. First, the query vector (query, Q), key vector (key, K) and value vector (value, V) are obtained through linear transformation. Assuming the number of heads is h, each head will have a corresponding weight matrix. For each head, the scaled dot product attention is used to calculate the attention output result, that is:
[0248]
[0249] Among them, Q i K represents the query vector of the i-th head. i V represents the key vector of the i-th head. i Represents the value vector of the i-th head. k Indicates the dimension of the key vector. Represents the attention score matrix corresponding to the i-th head. The softmax function is used to normalize the attention score to obtain the i-th attention weight matrix The i-th attention weight matrix is weighted and summed with the i-th value vector to obtain the attention output result of the i-th head.
[0250] Based on this, the attention output results of the h heads are concatenated and mapped back to the original dimension through a linear transformation to obtain the second encoding vector corresponding to each text unit.
[0251] Again, in an embodiment of the present application, a method for generating a second encoding vector based on an attention mechanism is provided. Through the above method, attention calculation is performed on the first encoding vector corresponding to each text unit, which can automatically focus on the key parts of the input data during information processing, thereby improving the accuracy of text prediction. In addition, the attention mechanism can quickly locate key content and reduce the processing of irrelevant content, thereby improving the utilization efficiency of computing resources and enabling the model to process data faster and obtain results.
[0252] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, another optional embodiment provided by the embodiment of the present application may further include:
[0253] Acquire training samples, wherein the training samples include object setting information of the virtual training object, a first dialogue sample provided by a player, a set of historical dialogue samples between the virtual training object and the player, knowledge information corresponding to the virtual training object, and a second dialogue sample of the virtual training object;
[0254] Based on the object setting information of the virtual training object, the first dialogue sample provided by the player, the set of historical dialogue samples between the virtual training object and the player, and the knowledge information corresponding to the virtual training object, a dialogue generation model is used to generate a predicted dialogue text of the virtual training object;
[0255] determining a loss value according to the second dialogue sample of the virtual training object and the predicted dialogue text of the virtual training object;
[0256] Use the loss value to train the dialogue generation model.
[0257] In one or more embodiments, a method for training a dialogue generation model is introduced. As can be seen from the aforementioned embodiments, training a dialogue generation model requires a large number of training samples, each of which includes object setting information configured by a developer for a virtual training object (e.g., NPC), a first dialogue sample provided by a player (e.g., developer), a set of historical dialogue samples between the virtual training object and the player (e.g., developer), knowledge information of the virtual training object, and a second dialogue sample of the virtual training object. The second dialogue sample of the virtual training object belongs to a real label.
[0258] Specifically, a full fine-tuning method can be used to adjust all the parameters of the model to make it perform better on specific tasks. A pre-trained language model is selected as the basic model of the dialogue generation model, and all its parameters are loaded. These parameters will be adjusted during the fine-tuning process. The large number of training samples used in this application belong to a supervised dataset, which includes input data (i.e., object setting information of the virtual training object, the first dialogue sample provided by the player, the historical dialogue sample set between the virtual training object and the player, and the knowledge information corresponding to the virtual training object) and the corresponding real label (i.e., the second dialogue sample of the virtual training object). By adjusting the tokenizer and the word embedding layer of the model, special tokens are added (for example, padding markers [PAD], sentence end markers, sentence start markers <s>, unknown word tag <unk>The adjusted tokenizer and word embedding layers ensure that the model can correctly handle special symbols in the input data.
[0259] Based on this, the object setting information of the virtual training object in the training sample, the first dialogue sample provided by the player, the historical dialogue sample set between the virtual training object and the player, and the knowledge information corresponding to the virtual training object are used as the input of the dialogue generation model, and the predicted dialogue text is output through the dialogue generation model. The predicted dialogue text is used as the "predicted value" and the second dialogue sample of the virtual training object is used as the "true value". The loss function (for example, the cross entropy loss function at the character level) can be used to optimize the match between the "predicted value" and the "true value". The loss function guides the update of the model parameters by calculating the difference between the model prediction result and the actual label (that is, the loss value). All model parameters participate in the training and are updated through the back propagation and gradient descent algorithms. During the training process, the performance indicators of the model are recorded to ensure the stability and effect of the model during the training process. Through these measures, the full amount of fine-tuning of the model is achieved, making it perform better on specific tasks.
[0260] It should be noted that in the training configuration, custom training arguments are used, including learning rate, batch size, and number of training steps. In order to improve training efficiency and reduce video memory usage, mixed precision training technology can also be enabled, which is not limited here.
[0261] Secondly, in the embodiment of the present application, a method for training a dialogue generation model is provided. Through the above method, the dialogue generation model gradually learns what kind of dialogue text should be generated under different user inputs, different personas, different scenarios and different conditions by learning a large number of training samples. During the training process, by continuously adjusting the model parameters and repeatedly iterating and optimizing the generation effect of the model, it is ensured that the output dialogue content is more natural, rich and fits the actual situation.
[0262] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, obtaining a training sample specifically includes:
[0263] constructing a target prompt sample according to the object setting information of the virtual training object, the first dialogue sample, the historical dialogue sample set, and the knowledge information corresponding to the virtual training object;
[0264] Based on the target prompt sample, a second dialogue sample of the virtual training object is obtained through the large language model.
[0265] In one or more embodiments, a method for constructing training samples is introduced. It can be seen from the aforementioned embodiments that before training the dialogue generation model, a certain number of training samples need to be constructed first. Each training sample includes object setting information configured for a virtual training object (e.g., NPC) (including enumerable parameters such as personality, age, place of birth, gender, non-enumerable parameters such as personal description, life style, appearance, core goals, experience, role relationships, and temporary variables such as short-term goals and role attitudes). Each training sample also includes a first dialogue sample provided by a player (e.g., a developer), and knowledge information corresponding to the virtual training object obtained through entity retrieval, to assist in generating dialogue texts that are more in line with the worldview and more realistic. In addition, in order for the model to recognize the referential relationship of the context and have memory, the training sample should also include a set of historical dialogue samples.
[0266] Specifically, in practical applications, it is also necessary to plan the prompt framework, write the overall response strategy for different object setting information, and the response strategy for specific dialogue scenarios. At the same time, specify the entity description information that needs to be accessed when constructing data for each dialogue scenario. Next, randomly select attributes from the attribute library in various dialogue scenarios to construct the object setting information of the virtual training object, and then fill it into the constructed prompt framework to generate the target prompt sample. Based on this, call a reliable interface (for example, GPT4) to predict the target prompt sample to generate the dialogue lines between the player and the virtual training object (that is, obtain the second dialogue sample of the virtual training object). Finally, post-process it into a training sample. That is, each training sample contains the first dialogue sample input by the player, a set of historical dialogue samples, and the object setting information of the virtual training object.
[0267] It should be noted that the training samples are highly extensible and can meet various types of dialogue requirements by configuring more parameter slots. Taking the virtual scene as the game scene as an example, for example, for an NPC who needs to ask the player for directions, the need to ask for directions is temporary, not long-term. Therefore, an optional configuration slot "short-term goal" can be added to write this requirement into the prompt when constructing the training sample, and the "short-term goal" of the input variable can be marked accordingly, so that the model can correctly present this content in the dialogue when it receives this parameter later. It can be seen that the model learns the preset object setting information and the dialogue strategy under the scene, and can generate game lines that meet the game design requirements, role setting requirements, and correct input feedback after configuring any object setting information.
[0268] Again, in an embodiment of the present application, a method for constructing training samples is provided. Through the above method, more object setting information related to virtual objects is configured in the model training process, so that the model can more accurately grasp the similarities and differences between the settings of virtual objects, and correctly return lines that conform to the relevant attributes of the objects in different scenarios, solving the problem of empty, featureless, and convergent lines due to the difficulty of independent development. By pre-constructing distinctive training samples, the present application enables the model to make accurate and character-reflecting responses to the diversified parameter variables of virtual objects in actual reasoning, further enriching the content and details of the dialogue and enhancing the user experience. In addition, the present application is also highly scalable and can meet various types of dialogue needs by configuring more parameter slots for virtual objects.
[0269] Optionally, in the above Figure 5 On the basis of one or more corresponding embodiments, in another optional embodiment provided by the embodiment of the present application, after generating the second dialogue text corresponding to the second virtual object through the dialogue generation model based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object, the method may further include:
[0270] Detecting the second dialogue text to obtain a text detection result;
[0271] If the text detection result indicates that the second dialogue text meets the dialogue output condition, controlling the second virtual object to output the second dialogue text;
[0272] If the text detection result indicates that the second dialogue text does not meet the dialogue output condition, the second virtual object is controlled to output the third dialogue text, wherein the third dialogue text is a pre-set fallback text.
[0273] In one or more embodiments, a method for filtering the second dialogue text is introduced. It can be seen from the aforementioned embodiments that after deploying the dialogue generation model, building the pipeline, and launching the application, it is also possible to collect and evaluate bad cases, debug common problems, update the world view, embed external models (e.g., security models, intent models), etc. In order to optimize the actual performance of the dialogue generation model and ensure its stability and availability, it is also necessary to embed a security model in the actual process. The following will take the detection of the second dialogue text as an example for explanation.
[0274] Specifically, the security model is called to detect the second dialogue text to obtain a text detection result. If the text detection result indicates that the second dialogue text does not involve sensitive content, it is determined that the second dialogue text meets the dialogue output condition, thereby controlling the second virtual object to output the second dialogue text. If the second dialogue text includes malicious keywords or belongs to a low security level, it is determined that the second dialogue text does not meet the dialogue output condition, thereby controlling the second virtual object to output a third dialogue text, and the third dialogue text is a pre-set fallback copy (for example, "Sorry, I can't reply to you").
[0275] It should be noted that in one design, the security model maintains a list of malicious keywords. If the text contains malicious keywords, the dialogue output condition is not met. In another design, the security model is machine learning, and the security level is output through the security model. If the security level is lower than the level threshold, the dialogue output condition is not met.
[0276] Secondly, in the embodiment of the present application, a method for filtering the second dialogue text is provided. Through the above method, the text output by the dialogue generation model is detected using the security model, thereby ensuring the security and legality of the output content, thereby maintaining a healthy communication environment.
[0277] The following is a detailed description of the dialog text generation device in this application. Fig.10 , Fig.10 This is a schematic diagram of an embodiment of a conversation text generation device in an embodiment of the present application. The conversation text generation device 100 includes:
[0278] The acquisition module 1001 is used to acquire a first dialogue text corresponding to the first virtual object in response to an interactive operation between the first virtual object and the second virtual object, wherein the first virtual object is a virtual object controlled by a real user, the second virtual object is a virtual object not controlled by a real user, and the first dialogue text is derived from input of the real user;
[0279] The acquisition module 1001 is further used to acquire object setting information of the second virtual object, wherein the object setting information includes enumerable parameters, and the enumerable parameters are used to describe optional information related to the virtual object;
[0280] The acquisition module 1001 is further used to acquire knowledge information corresponding to the second virtual object, wherein the knowledge information is used to describe the background knowledge that the virtual object needs to follow in the virtual scene;
[0281] The generation module 1002 is used to generate a second dialogue text corresponding to the second virtual object through a dialogue generation model based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object.
[0282] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0283] The object setting information also includes at least one of a non-enumerable parameter and a temporary variable:
[0284] Among them, the non-enumerable parameters are used to describe the non-selectable information related to the virtual object, and the temporary variables are used to describe the information involved in the virtual object in the current period.
[0285] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0286] An acquisition module 1001 is specifically configured to acquire a query embedding vector through a text encoding model based on the first dialogue text and the object setting information of the second virtual object;
[0287] Calculate the similarity between the query embedding vector and each entity embedding vector in the K entity embedding vectors to obtain K vector similarities, where each vector similarity in the K vector similarities represents the similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1;
[0288] If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, then N entity embedding vectors are determined according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K;
[0289] According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
[0290] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0291] The acquisition module 1001 is further used to acquire historical interaction information between the first virtual object and the second virtual object, wherein the historical interaction information includes at least one round of historical dialogue, and each round of historical dialogue includes the historical dialogue of the first virtual object and the historical dialogue of the second virtual object;
[0292] Generation module 1002 is specifically used to generate a second dialogue text corresponding to the second virtual object through a dialogue generation model based on the first dialogue text, object setting information of the second virtual object, knowledge information corresponding to the second virtual object, and historical interaction information between the first virtual object and the second virtual object.
[0293] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0294] An acquisition module 1001 is specifically configured to acquire a query embedding vector through a text encoding model based on the first dialogue text, the object setting information of the second virtual object, and the historical interaction information between the first virtual object and the second virtual object;
[0295] Calculate the similarity between the query embedding vector and each entity embedding vector in the K entity embedding vectors to obtain K vector similarities, where each vector similarity in the K vector similarities represents the similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1;
[0296] If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, then N entity embedding vectors are determined according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K;
[0297] According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
[0298] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0299] The acquisition module 1001 is specifically configured to use the entity embedding vector corresponding to the largest vector similarity among at least one vector similarity as N entity embedding vectors; or,
[0300] The entity embedding vector corresponding to each vector similarity in at least one vector similarity is used as N entity embedding vectors.
[0301] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0302] The acquisition module 1001 is specifically configured to acquire N entity description information according to the N entity embedding vectors, wherein each entity description information corresponds to one entity embedding vector;
[0303] The N entity description information is used as the knowledge information corresponding to the second virtual object.
[0304] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0305] The acquisition module 1001 is also used to acquire K entities for the virtual scene;
[0306] The acquisition module 1001 is also used to acquire entity description information corresponding to each entity in the K entities;
[0307] The acquisition module 1001 is also used to obtain the entity embedding vector corresponding to each entity in the K entities through the text encoding model based on the entity description information corresponding to the entity.
[0308] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0309] The generating module 1002 is specifically used to construct a target prompt text according to the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object;
[0310] Calling the dialogue generation model to encode the target prompt text to obtain a first encoding vector corresponding to each text unit in the target prompt text;
[0311] Call the dialogue generation model to perform attention calculation on the first encoding vector corresponding to each text unit to obtain the second encoding vector corresponding to each text unit;
[0312] The dialogue generation model is called to predict the second encoding vector corresponding to each text unit to obtain the second dialogue text corresponding to the second virtual object.
[0313] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0314] The generation module 1002 is specifically used to call the dialogue generation model, perform text encoding on the target prompt text, and obtain a text encoding vector corresponding to each text unit in the target prompt text;
[0315] Calling the dialogue generation model to positionally encode the target prompt text, and obtaining a position encoding vector corresponding to each text unit in the target prompt text;
[0316] The text encoding vector corresponding to each text unit in the target prompt text is added to the position encoding vector to obtain a first encoding vector corresponding to each text unit in the target prompt text.
[0317] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0318] The generation module 1002 is specifically used to call the dialogue generation model, and calculate h attention score matrices according to the first encoding vector corresponding to each text unit, where h is an integer greater than or equal to 1;
[0319] Normalize the h attention score matrices to obtain h attention weight matrices;
[0320] The first encoding vector corresponding to each text unit is weighted and summed according to h attention weight matrices to obtain the second encoding vector corresponding to each text unit.
[0321] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application, the dialogue text generation device 100 further includes a determination module 1003 and a training module 1004;
[0322] The acquisition module 1001 is further used to acquire training samples, wherein the training samples include object setting information of the virtual training object, a first dialogue sample provided by a player, a set of historical dialogue samples between the virtual training object and the player, knowledge information corresponding to the virtual training object, and a second dialogue sample of the virtual training object;
[0323] The generation module 1002 is further used to generate a predicted dialogue text of the virtual training object through a dialogue generation model based on the object setting information of the virtual training object, the first dialogue sample provided by the player, the set of historical dialogue samples between the virtual training object and the player, and the knowledge information corresponding to the virtual training object;
[0324] A determination module 1003, configured to determine a loss value according to a second dialogue sample of the virtual training object and a predicted dialogue text of the virtual training object;
[0325] The training module 1004 is used to train the dialogue generation model using the loss value.
[0326] Optionally, in the above Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application,
[0327] The acquisition module 1001 is specifically used to construct a target prompt sample according to the object setting information of the virtual training object, the first dialogue sample, the historical dialogue sample set and the knowledge information corresponding to the virtual training object;
[0328] Based on the target prompt sample, a second dialogue sample of the virtual training object is obtained through the large language model. Fig.10 On the basis of the corresponding embodiment, in another embodiment of the dialogue text generation device 100 provided in the embodiment of the present application, the dialogue text generation device 100 further includes a detection module 1005 and a control module 1006;
[0329] A detection module 1005 is used to detect the second dialogue text after generating the second dialogue text corresponding to the second virtual object through the dialogue generation model based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object, to obtain a text detection result;
[0330] A control module 1006, configured to control the second virtual object to output the second dialogue text if the text detection result indicates that the second dialogue text meets the dialogue output condition;
[0331] The control module 1006 is further used to control the second virtual object to output a third dialogue text if the text detection result indicates that the second dialogue text does not meet the dialogue output condition, wherein the third dialogue text is a pre-set fallback text.
[0332] The embodiment of the present application further provides a computer device, which may be a terminal or a server. For example, the computer device is a terminal. Fig.11 For the sake of convenience, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. In the embodiments of the present application, the terminal is taken as an example for explanation:
[0333] Fig.11 FIG. 1 is a block diagram showing a partial structure of a mobile phone related to a terminal provided in an embodiment of the present application. Fig.11 The mobile phone includes: a radio frequency (RF) circuit 1110, a memory 1120, an input unit 1130, a display unit 1140, a sensor 1150, an audio circuit 1160, a mobile hotspot (wireless fidelity, WiFi) module 1170, a processor 1180, and a power supply 1190. Those skilled in the art can understand that Fig.11 The mobile phone structure shown in the figure does not constitute a limitation on the mobile phone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0334] Combine the following Fig.11 A detailed introduction to the various components of the mobile phone:
[0335] The RF circuit 1110 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 1180 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 1110 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 1110 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to the global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short messaging service (SMS), etc.
[0336] The memory 1120 can be used to store software programs and modules. The processor 1180 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1120. The memory 1120 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1120 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0337] The input unit 1130 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit 1130 may include a touch panel 1131 and other input devices 1132. The touch panel 1131, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 1131 or near the touch panel 1131 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 1131 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 1180, and can receive and execute the command sent by the processor 1180. In addition, the touch panel 1131 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 1131, the input unit 1130 may also include other input devices 1132. Specifically, the other input devices 1132 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a mouse, a joystick, etc.
[0338] The display unit 1140 can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 1140 may include a display panel 1141. Optionally, the display panel 1141 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 1131 may cover the display panel 1141. When the touch panel 1131 detects a touch operation on or near it, it is transmitted to the processor 1180 to determine the type of touch event. Subsequently, the processor 1180 provides a corresponding visual output on the display panel 1141 according to the type of touch event. Although in Fig.11 In the embodiment, the touch panel 1131 and the display panel 1141 are used as two independent components to realize the input and output functions of the mobile phone, but in some embodiments, the touch panel 1131 and the display panel 1141 can be integrated to realize the input and output functions of the mobile phone.
[0339] The mobile phone may also include at least one sensor 1150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1141 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 1141 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0340] The audio circuit 1160, the speaker 1161, and the microphone 1162 can provide an audio interface between the user and the mobile phone. The audio circuit 1160 can transmit the received audio data to the speaker 1161 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 1162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1160 and converted into audio data, and then the audio data is output to the processor 1180 for processing, and then sent to another mobile phone through the RF circuit 1110, or the audio data is output to the memory 1120 for further processing.
[0341] WiFi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the WiFi module 1170. It provides users with wireless broadband Internet access. Fig.11 A WiFi module 1170 is shown, but it is understandable that it is not an essential component of the mobile phone and can be omitted as needed without changing the essence of the invention.
[0342] The processor 1180 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. It executes various functions of the mobile phone and processes data by running or executing software programs and / or modules stored in the memory 1120 and calling data stored in the memory 1120. Optionally, the processor 1180 may include one or more processing units; optionally, the processor 1180 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1180.
[0343] The mobile phone also includes a power supply 1190 (such as a battery) for supplying power to various components. Optionally, the power supply can be logically connected to the processor 1180 through a power management system, thereby managing functions such as charging, discharging, and power consumption management through the power management system.
[0344] Although not shown, the mobile phone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0345] The steps performed by the terminal in the above embodiment can be based on the Fig.11 The terminal structure shown.
[0346] A computer-readable storage medium is also provided in an embodiment of the present application, on which a computer program is stored. When the computer program is executed by a processor, the steps of the methods described in the above embodiments are implemented.
[0347] A computer program product is also provided in an embodiment of the present application, including a computer program, which, when executed by a processor, implements the steps of the methods described in the above embodiments.
[0348] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0349] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0350] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0351] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0352] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0353] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a server or terminal device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store computer programs.
[0354] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.< / unk> < / s>
Claims
1. A method for generating a dialogue text, characterized in that: include: In response to an interactive operation between a first virtual object and a second virtual object, obtaining a first dialogue text corresponding to the first virtual object, wherein the first virtual object is a virtual object controlled by a real user, the second virtual object is a virtual object not controlled by a real user, and the first dialogue text is derived from input by the real user; Obtaining object setting information of the second virtual object, wherein the object setting information includes enumerable parameters, and the enumerable parameters are used to describe optional information related to the virtual object; Acquire knowledge information corresponding to the second virtual object, wherein the knowledge information is used to describe background knowledge that the virtual object needs to follow in the virtual scene; Based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object, a second dialogue text corresponding to the second virtual object is generated through the dialogue generation model.
2. The generation method according to claim 1, characterized in that: The object setting information also includes at least one of a non-enumerable parameter and a temporary variable: The non-enumerable parameter is used to describe non-selectable information related to the virtual object, and the temporary variable is used to describe information related to the virtual object in the current period.
3. The generation method according to claim 1, characterized in that: The acquiring the knowledge information corresponding to the second virtual object includes: Based on the first dialogue text and the object setting information of the second virtual object, obtaining a query embedding vector through a text encoding model; Performing similarity calculations on the query embedding vector and each of the K entity embedding vectors to obtain K vector similarities, wherein each vector similarity in the K vector similarities represents a degree of similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1; If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, determining N entity embedding vectors according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K; According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
4. The generation method according to claim 1, characterized in that: The method further comprises: Acquire historical interaction information between the first virtual object and the second virtual object, wherein the historical interaction information includes at least one round of historical dialogue, and each round of historical dialogue includes a historical dialogue of the first virtual object and a historical dialogue of the second virtual object; The step of generating a second dialogue text corresponding to the second virtual object by using the dialogue generation model based on the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object includes: Based on the first dialogue text, object setting information of the second virtual object, knowledge information corresponding to the second virtual object, and historical interaction information between the first virtual object and the second virtual object, a second dialogue text corresponding to the second virtual object is generated through the dialogue generation model.
5. The generation method according to claim 4, characterized in that: The acquiring the knowledge information corresponding to the second virtual object includes: Based on the first dialogue text, the object setting information of the second virtual object, and the historical interaction information between the first virtual object and the second virtual object, obtaining a query embedding vector through a text encoding model; Performing similarity calculations on the query embedding vector and each of the K entity embedding vectors to obtain K vector similarities, wherein each vector similarity in the K vector similarities represents a degree of similarity between the query embedding vector and an entity embedding vector, and K is an integer greater than or equal to 1; If at least one vector similarity among the K vector similarities is greater than or equal to the similarity threshold, determining N entity embedding vectors according to the at least one vector similarity, where N is an integer greater than or equal to 1 and less than or equal to K; According to the N entity embedding vectors, knowledge information corresponding to the second virtual object is obtained.
6. The generation method according to claim 3 or 5, characterized in that: The determining N entity embedding vectors according to the at least one vector similarity comprises: The entity embedding vector corresponding to the largest vector similarity among the at least one vector similarity is used as the N entity embedding vectors; or, The entity embedding vector corresponding to each vector similarity in the at least one vector similarity is used as the N entity embedding vectors.
7. The generation method according to claim 3 or 5, characterized in that: The acquiring, according to the N entity embedding vectors, knowledge information corresponding to the second virtual object includes: Obtain N entity description information according to the N entity embedding vectors, wherein each entity description information corresponds to an entity embedding vector; The N entity description information is used as the knowledge information corresponding to the second virtual object.
8. The generation method according to claim 3 or 5, characterized in that: The method further comprises: Acquire K entities for the virtual scene; Obtain entity description information corresponding to each of the K entities; For each entity of the K entities, based on the entity description information corresponding to the entity, an entity embedding vector corresponding to the entity is obtained through the text encoding model.
9. The generation method according to any one of claims 1 to 8, characterized in that: The step of generating a second dialogue text corresponding to the second virtual object by using the dialogue generation model based on the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object includes: constructing a target prompt text according to the first dialogue text, the object setting information of the second virtual object, and the knowledge information corresponding to the second virtual object; Calling the dialogue generation model to encode the target prompt text to obtain a first encoding vector corresponding to each text unit in the target prompt text; Calling the dialogue generation model, performing attention calculation on the first encoding vector corresponding to each text unit, and obtaining a second encoding vector corresponding to each text unit; The dialogue generation model is called to predict the second encoding vector corresponding to each text unit to obtain the second dialogue text corresponding to the second virtual object.
10. The generation method according to claim 9, characterized in that: The calling of the dialogue generation model to encode the target prompt text to obtain a first encoding vector corresponding to each text unit in the target prompt text includes: Calling the dialogue generation model to perform text encoding on the target prompt text to obtain a text encoding vector corresponding to each text unit in the target prompt text; Calling the dialogue generation model to perform position encoding on the target prompt text to obtain a position encoding vector corresponding to each text unit in the target prompt text; The text encoding vector corresponding to each text unit in the target prompt text is added to the position encoding vector to obtain a first encoding vector corresponding to each text unit in the target prompt text.
11. The generation method according to claim 9, characterized in that: The calling of the dialogue generation model to perform attention calculation on the first encoding vector corresponding to each text unit to obtain the second encoding vector corresponding to each text unit includes: Calling the dialogue generation model, and calculating h attention score matrices according to the first encoding vector corresponding to each text unit, where h is an integer greater than or equal to 1; Normalizing the h attention score matrices to obtain h attention weight matrices; The first encoding vector corresponding to each text unit is weightedly summed according to the h attention weight matrices to obtain a second encoding vector corresponding to each text unit.
12. The generation method according to any one of claims 1 to 11, characterized in that: The method further comprises: Acquire training samples, wherein the training samples include object setting information of a virtual training object, a first dialogue sample provided by a player, a set of historical dialogue samples between the virtual training object and the player, knowledge information corresponding to the virtual training object, and a second dialogue sample of the virtual training object; Based on the object setting information of the virtual training object, the first dialogue sample provided by the player, the set of historical dialogue samples between the virtual training object and the player, and the knowledge information corresponding to the virtual training object, the dialogue generation model generates a predicted dialogue text of the virtual training object; determining a loss value according to the second dialogue sample of the virtual training object and the predicted dialogue text of the virtual training object; The dialogue generation model is trained using the loss value.
13. The generation method according to claim 12, characterized in that: The obtaining of training samples comprises: constructing a target prompt sample according to the object setting information of the virtual training object, the first dialogue sample, the historical dialogue sample set, and the knowledge information corresponding to the virtual training object; Based on the target prompt sample, a second dialogue sample of the virtual training object is obtained through a large language model.
14. The generation method according to any one of claims 1 to 13, characterized in that: After generating the second dialogue text corresponding to the second virtual object through the dialogue generation model based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object, the method further includes: Detecting the second dialogue text to obtain a text detection result; If the text detection result indicates that the second dialogue text meets the dialogue output condition, controlling the second virtual object to output the second dialogue text; If the text detection result indicates that the second dialogue text does not meet the dialogue output condition, the second virtual object is controlled to output a third dialogue text, wherein the third dialogue text is a pre-set fallback text.
15. A dialogue text generation device, characterized in that: include: an acquisition module, configured to acquire a first dialogue text corresponding to a first virtual object in response to an interactive operation between a first virtual object and a second virtual object, wherein the first virtual object is a virtual object controlled by a real user, the second virtual object is a virtual object not controlled by a real user, and the first dialogue text is derived from an input of the real user; The acquisition module is further used to acquire object setting information of the second virtual object, wherein the object setting information includes enumerable parameters, and the enumerable parameters are used to describe optional information related to the virtual object; The acquisition module is further used to acquire knowledge information corresponding to the second virtual object, wherein the knowledge information is used to describe background knowledge that the virtual object needs to follow in the virtual scene; A generation module is used to generate a second dialogue text corresponding to the second virtual object through the dialogue generation model based on the first dialogue text, the object setting information of the second virtual object and the knowledge information corresponding to the second virtual object.
16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the generation method according to any one of claims 1 to 14 are implemented.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the generation method according to any one of claims 1 to 14 are implemented.
18. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the generation method according to any one of claims 1 to 14 are implemented.
Citation Information
Cited By
Children AI dialogue generation method and system based on IP role personalization, and storage medium
CN120492596A
Virtual character behavior control method and device, electronic equipment and medium
CN121457621A