Text interaction method and device, equipment and storage medium
Through text generation and parsing models, combined with style parameter control, the problem of text processing logic in reinforcement learning in text interaction scenarios is solved, and the natural language expression and interactivity of agents in role-playing games are improved.
Patent Information
- Application Number
- CN202310189060.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-08-23
AI Technical Summary
Existing reinforcement learning solutions cannot be effectively applied to application scenarios involving text interaction, such as role-playing games, and cannot handle complex text logic and natural language expressions.
A reinforcement learning method is designed to convert the text actions of the reinforcement learning agent into natural language expressions through text generation and text parsing models, and parse the text actions of other participants into the state space state of the agent, using style parameters Control the actions output by the agent to match a specific style.
It realizes the effective application of reinforcement learning in text interaction application scenarios, improves the text interaction experience, and enhances the interaction and game experience between the agent and real players.
Smart Images

Figure CN118536493A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of text processing, and in particular to a text interaction method, device, equipment and storage medium. Background Art
[0002] Reinforcement Learning (RL) is a learning mechanism that learns how to map from state to behavior in order to maximize the reward. Reinforcement learning is used to describe and solve the problem of how an agent learns strategies to maximize rewards or achieve specific goals during its interaction with the environment. The reinforcement learning process is the process of continuous interaction between the agent and the environment. In the process of continuous interaction between the agent and the environment, the agent continuously optimizes the state-behavior correspondence through the feedback (rewards) given by the environment.
[0003] Figure 1 A schematic diagram showing how reinforcement learning works in a racing game.
[0004] See also Figure 1 The goal of the racing game is to lead the racing agent to reach the finish line as quickly as possible and avoid collisions with the track and obstacles (such as passing vehicles). The reinforcement learning process for the racing agent is as follows.
[0005] 1. Define the environment that the racing agent can observe as the observation state obs;
[0006] 2. Define the direction of the joystick that controls the car as the decision action: act;
[0007] 3. Define the reward function rwd, and explain that if you hit an obstacle, you will be punished, and if you can successfully reach the end, you will be rewarded according to the length of time;
[0008] 4. The racing agent obtains the observation state obs and the reward rwd of the previous step from the environment;
[0009] 5. The racing agent infers based on obs and outputs an action act;
[0010] 6. The action act updates the environment to obtain the new observation state obs and the new reward rwd;
[0011] 7. Repeat steps 4-6 until the game ends.
[0012] At present, reinforcement learning has mature solutions for application scenarios where intelligent agents interact with the environment based on non-text actions. For example, reinforcement learning has mature solutions for games such as Go, MOBA (Multiplayer Online Battle Arena), Texas Hold'em, and Atari. The common point of these application scenarios is that the action space of the intelligent agent only includes actions, not text, and therefore does not involve text processing logic.
[0013] When applying reinforcement learning to application scenarios involving text interaction, the process of interaction between the agent and the environment involves text processing logic, but existing reinforcement learning solutions do not involve text processing and therefore cannot be used in such scenarios.
[0014] Therefore, for application scenarios involving text interaction, such as role-playing games such as "Werewolf", "Close Your Eyes Before It's Dark", and "Avalon" that use interactive text to advance the game process, it is necessary to design an effective reinforcement learning solution. Summary of the invention
[0015] A technical problem to be solved by the present disclosure is how to design an effective reinforcement learning solution for application scenarios that require complex logical reasoning based on text.
[0016] According to a first aspect of the present disclosure, a text interaction method is provided, characterized in that the method involves multiple participants, at least one of the multiple participants is a reinforcement learning agent, and the method comprises: if the action selected by the reinforcement learning agent from the action space based on the state in the state space during any round of interaction includes a first text, then a second text obtained based on the first text is used as the text output by the reinforcement learning agent in the current round, wherein the second text has the same semantics as the first text and is more in line with natural language expression habits than the first text; if the action output by other participants during any round of interaction includes a third text, then the third text is parsed into the state in the state space of the reinforcement learning agent.
[0017] Optionally, the method further includes: selecting text having the same semantics as the first text from a predefined first text set as the second text.
[0018] Optionally, the method further includes: parsing the first text into a first logic tree; processing the first logic tree to obtain a second logic tree; and using text obtained by performing text conversion on the second logic tree as the second text.
[0019] Optionally, the method further includes: generating a second text based on the first text using a text generation model.
[0020] Optionally, parsing the third text into a state in the state space of the reinforcement learning agent includes: generating a fourth text based on the third text using a text parsing model, using the fourth text as a state in the state space of the reinforcement learning agent, and using the fourth text to characterize the sentence trunk logic of the third text.
[0021] Optionally, the method further includes: based on style parameters in the style space of the reinforcement learning agent, controlling the action output by the reinforcement learning agent so that the action output by the reinforcement learning agent matches the style parameters.
[0022] Optionally, the style parameters include speech style parameters and / or behavior style parameters, and based on the style parameters in the style space of the reinforcement learning agent, the actions output by the reinforcement learning agent are controlled, including: selecting a text generation model consistent with the speech style parameters from multiple text generation models, and using the selected text generation model to generate a second text matching the speech style parameters based on the first text, and / or based on the behavior style parameters, controlling the behavior actions output by the reinforcement learning agent so that the behavior actions output by the reinforcement learning agent match the behavior style parameters.
[0023] Optionally, there are multiple participants who are reinforcement learning agents, and multiple reinforcement learning agents playing the same type of role have different style parameters.
[0024] Optionally, the participants are players in a role-playing game that advances the game through actions and text expressions, the actions in the action space are divided into exclusive actions, speech texts, and public actions, and the states in the state space are divided into attribute states, basic states, and observation states.
[0025] Optionally, the reinforcement learning agent is a trained agent, or the reinforcement learning agent is an agent to be trained, and the reinforcement learning agent updates algorithm parameters by interacting with an environment simulator, and the environment simulator is used to provide an environment required for interaction for multiple participants.
[0026] According to a second aspect of the present disclosure, a text interaction device is provided, the device involving multiple participants, at least one of the multiple participants being a reinforcement learning agent, the device comprising: a first processing module, for using a second text obtained based on the first text as the text output by the reinforcement learning agent in the current round if the action selected by the reinforcement learning agent from the action space based on the state in the state space during any round of interaction includes a first text, wherein the second text has the same semantics as the first text and is more in line with natural language expression habits than the first text; and a second processing module, for parsing the third text into the state in the state space of the reinforcement learning agent if the action output by other participants during any round of interaction includes a third text.
[0027] Optionally, the first processing module selects text having the same semantics as the first text from a predefined first text set as the second text.
[0028] Optionally, the first processing module parses the first text into a first logic tree, processes the first logic tree to obtain a second logic tree, and uses the text obtained by performing text conversion on the second logic tree as the second text.
[0029] Optionally, the first processing module generates the second text based on the first text using a text generation model.
[0030] Optionally, the second processing module generates a fourth text based on the third text using a text parsing model, and uses the fourth text as a state in the state space of the reinforcement learning agent, and the fourth text is used to characterize the sentence trunk logic of the third text.
[0031] Optionally, the device further includes: a style control module, which is used to control the action output by the reinforcement learning agent based on the style parameters in the style space of the reinforcement learning agent, so that the action output by the reinforcement learning agent matches the style parameters.
[0032] Optionally, the style parameters include speech style parameters and / or behavior style parameters, the style control module selects a text generation model consistent with the speech style parameters from multiple text generation models, and uses the selected text generation model to generate a second text matching the speech style parameters based on the first text, and / or the style control module controls the behavior actions output by the reinforcement learning agent based on the behavior style parameters so that the behavior actions output by the reinforcement learning agent match the behavior style parameters.
[0033] Optionally, there are multiple participants who are reinforcement learning agents, and multiple reinforcement learning agents playing the same type of role have different style parameters.
[0034] Optionally, the participants are players in a role-playing game that advances the game through actions and text expressions, the actions in the action space are divided into exclusive actions, speech texts, and public actions, and the states in the state space are divided into attribute states, basic states, and observation states.
[0035] Optionally, the reinforcement learning agent is a trained agent, or the reinforcement learning agent is an agent to be trained, and the reinforcement learning agent updates algorithm parameters by interacting with an environment simulator, and the environment simulator is used to provide an environment required for interaction for multiple participants.
[0036] According to a third aspect of the present disclosure, a computing device is provided, comprising: a processor; and a memory on which executable codes are stored, and when the executable codes are executed by the processor, the processor executes the method described in the first aspect above.
[0037] According to a fourth aspect of the present disclosure, a computer program product is provided, comprising an executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the method as described in the first aspect above.
[0038] According to a fifth aspect of the present disclosure, a non-temporary machine-readable storage medium is provided, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first aspect above.
[0039] Therefore, the present disclosure uses the second text obtained based on the first text selected by the reinforcement learning agent as the text output by the reinforcement learning agent in the current round, and parses the third text output by other participants into the state in the state space of the reinforcement learning agent, so as to meet the text processing logic required by the reinforcement learning agent in the application scenario based on text interaction, thereby realizing the application of reinforcement learning in text interaction scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components in the exemplary embodiments of the present disclosure.
[0041] Figure 1 A schematic diagram showing how reinforcement learning works in a racing game.
[0042] Figure 2 A schematic flowchart of a text interaction method based on reinforcement learning according to an embodiment of the present disclosure is shown.
[0043] Figure 3 A schematic diagram showing the interaction of an agent with an environment simulator.
[0044] Figure 4 The overall process diagram of a role-playing game based on reinforcement learning is shown.
[0045] Figure 5 A schematic diagram of the interaction between intelligent agents is shown.
[0046] Figure 6 A schematic diagram of the interaction including real people is shown.
[0047] Figure 7A structural schematic diagram of a text interaction device according to an embodiment of the present disclosure is shown.
[0048] Figure 8 A schematic diagram of the structure of a computing device that can be used to implement the above-mentioned text interaction method according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0049] The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0050] This paper mainly designs an effective reinforcement learning solution for application scenarios involving text interaction.
[0051] Application scenarios involving text interaction can be role-playing games that advance the game process based on interactive text, such as but not limited to role-playing board games such as "Werewolf", "Close Your Eyes Before Dark", and "Avalon". Such games usually require multiple players to play multiple roles, and players advance the game process through actions and text expressions. For such role-playing games, one or more reinforcement learning agents can be trained using reinforcement learning algorithms. Different reinforcement learning agents can be trained for different roles. The same role can share the same reinforcement learning agent. During the process of training the reinforcement learning agent or after the reinforcement learning agent is trained, the reinforcement learning agent can play games with real players.
[0052] Application scenarios involving text interaction can also be other application scenarios that require human-computer dialogue. For example, service personnel in the service industry (such as sales personnel, customer service personnel, fund managers, etc.) need to communicate frequently with customers. In order to improve the communication skills of service personnel, reinforcement learning algorithms can be used to train intelligent training robots (i.e., reinforcement learning agents) that can simulate customers. Service personnel can improve their communication skills by talking with intelligent training robots.
[0053] There are multiple (at least two) participants in the application scenario involving text interaction. At least one of the multiple participants is a reinforcement learning agent. Multiple participants can achieve a predetermined goal through one or more rounds of interaction, such as multiple players can continuously interact based on text and behavior until the game ends. Among them, the reinforcement learning agent can generate actions in the action space based on the state in the state space, and the action updates the state in the state space after interacting with the environment.
[0054] A reinforcement learning agent can be an agent trained using a reinforcement learning algorithm. The reinforcement learning algorithm can be any of a value function-based method, a policy-based method, and an actor-critic method (Actor-Critic algorithm). As an example, a reinforcement learning agent can be learned using a PPO algorithm or an improved algorithm based on the PPO algorithm (such as an IPPO algorithm or a MAPPO algorithm). The PPO (Proximal Policy Optimization) algorithm has two network structures, a policy network (Actor network) and an evaluation network (Critic network). The input of the Actor network is the state, and the output is the action probability. The input of the Critic network is the state, and the output is the value of the state. The problem solved by the PPO algorithm is the reinforcement learning problem in discrete action space and continuous action space.
[0055] The reinforcement learning algorithm used by the reinforcement learning agent and the process of using the reinforcement learning algorithm to train the reinforcement learning agent are both mature technologies in the field and will not be described in detail in this disclosure.
[0056] Unlike general reinforcement learning tasks, the action space and state space of the reinforcement learning agent in the present disclosure contain text output and text input, respectively. The text in the action space of the reinforcement learning agent is usually a logical text with strong logic but weak language. In order to improve the interactive experience, it is necessary to convert the text actions selected by the reinforcement learning agent into text that is more in line with natural language expression habits. At the same time, the text output by other participants in the environment can be perceived by the reinforcement learning agent, thereby affecting the action selected by the reinforcement learning agent in the next round. Therefore, it is also necessary to parse the text output by other participants in the environment into states in the state space of the reinforcement learning agent.
[0057] In view of this, when reinforcement learning is applied to an application scenario based on text interaction, the present disclosure converts the text action selected by the reinforcement learning agent (i.e., the first text described below) into a more natural text (i.e., the second text described below), and on the other hand, parses the text action output by other participants (i.e., the third text described below) into a state in the state space of the reinforcement learning agent. Thus, by designing the two text processing steps of text generation and text parsing, the text processing logic required by the reinforcement learning agent in the application scenario based on text interaction can be met.
[0058] Figure 2 A schematic flowchart of a text interaction method based on reinforcement learning according to an embodiment of the present disclosure is shown.
[0059] Figure 2The method shown can be used in the application phase after the reinforcement learning agent is trained, and can also be used in the training phase of the reinforcement learning agent. That is, the reinforcement learning agent can be a pre-trained agent or an untrained agent (i.e., to be trained). During the training process, the reinforcement learning agent can update the algorithm parameters by interacting with the environment simulator, and the environment simulator is used to provide the environment required for the interaction of multiple participants.
[0060] Thus, it can be executed in the process of using the reinforcement learning agent after it is trained. Figure 2 The method shown can also be performed during the training of reinforcement learning agents Figure 2 The method shown. Figure 2 The method shown includes step S210 and step S220. The present disclosure does not limit the execution order of step S210 and step S220.
[0061] See also Figure 2 In step S210, if the action selected by the reinforcement learning agent from the action space based on the state in the state space during any round of interaction includes the first text, the second text obtained based on the first text is used as the text output by the reinforcement learning agent in the current round.
[0062] The action space is used to characterize the set of actions that the reinforcement learning agent can choose. The actions in the action space of the reinforcement learning agent include text actions and optionally behavioral actions. That is, the actions in the action space of the reinforcement learning agent can be divided into two categories: text actions and behavioral actions. Text actions refer to actions taken by the reinforcement learning agent in the form of output text, and the text output by the reinforcement learning agent can be perceived by other participants. Therefore, the text output by the reinforcement learning agent can also be called speech text. Behavioral actions refer to actions in non-text form. The behavioral actions output by the reinforcement learning agent can implicitly or explicitly affect other participants.
[0063] When designing the action space of a reinforcement learning agent, the action space can be designed based on the role played by the reinforcement learning agent, the purpose the role expects to achieve, the functions the role has, and other information. Taking the "Werewolf" game as an example, the identity of the reinforcement learning agent playing the player can be, but is not limited to, any of "werewolf", "witch", "villager", "prophet", and "guard". The actions in the action space can be divided into exclusive actions, speech texts, and public actions. Exclusive actions refer to actions that are bound to a specific identity and can only be performed by players with that identity (for example, exclusive actions for witches can include poisoning and saving people). Exclusive actions themselves may be open to other participants, or they may not be open to other participants but directly interact with the environment, implicitly affecting other players or agents. Speech text refers to the logic expressed by the agent based on the state space and the purpose of the game. Public actions refer to actions that all participants have and have the same process. Public actions can be open to all players, that is, public actions can be perceived by all players, such as voting.
[0064] The state space is used to represent the set of states observed by the reinforcement learning agent from the environment. During the continuous interaction between the reinforcement learning agent and the environment, the reinforcement learning agent can observe different states. The states in the state space can be the latest observed states. The states in the state space can include states that do not change after initialization, as well as states that change in real time based on the actions output by other participants during the interaction.
[0065] Taking role-playing games such as "Werewolf" as an example, the states in the state space of reinforcement learning agents can be divided into attribute states, basic states, and observation states. Attribute states are used to represent attribute information that does not change after the game starts (for example, it can include the role information of the agent and the role information of other participants that the agent can perceive), basic states are used to represent observation information that can be changed and determined during the game (such as the survival status of participants), and observation states are used to represent reasoning information generated based on the speech texts and / or actions of other players.
[0066] In each round of interaction, the reinforcement learning agent can select an action from the action space based on the state in the state space. If the action selected by the reinforcement learning agent includes a text action (i.e., the first text), the second text can be obtained based on the first text, and the second text is used as the text output by the reinforcement learning agent in the current round.
[0067] The first text reflects the logic expressed by the reinforcement learning agent according to the state in the state space and the purpose of interaction. That is, the first text is a logical text with strong logic and weak linguistics. The second text has the same semantics as the first text and is more in line with natural language expression habits than the first text. The second text can be regarded as a text obtained by expanding the first text based on the semantics represented by the first text.
[0068] For example, the first text could be "The probability that player No. 2 is a werewolf is 80%", and the second text could be "After looking around, I think it is very likely that player No. 2 has a bad identity", or "No. 2 is definitely a wolf, my judgment is not wrong, everyone follow me and vote No. 2 out!" This type of text is more in line with natural language expression.
[0069] By outputting the second text that is more in line with natural language expression habits than the first text as the speech text, the text output by the reinforcement learning agent is closer to real-person speech, thereby improving the text interaction experience. Taking the reinforcement learning agent that plays a role in the game as an example, since the speech of the reinforcement learning agent is closer to that of a real person, it can enrich the game while better introducing real-person players to participate in the game.
[0070] As an example, a text set can be predefined, and text with the same semantics as the first text can be selected from the text set as the second text. The text in the text set is a text that conforms to the natural language expression habits, such as "I know nothing, I think X is a bad person". One or more texts with the highest ranking can be selected from the text set by selecting and sorting, and output as the second text.
[0071] As an example, the first text can also be parsed into a first logic tree, and the first logic tree is processed to obtain a second logic tree. The text obtained by text conversion of the second logic tree is used as the state in the state space of the reinforcement learning agent. The first logic tree can be regarded as a tree representation result of the speech logic represented by the first text. The second logic tree can be an inference obtained by logical analysis of the first logic tree. For example, the first logic tree can be "No. x-(self-proclaimed)-prophet, No. x-(identified as a good person)-No. y", and the second logic tree can be "No. y is a good person". The text conversion module can be used to convert the second logic tree into a text that conforms to the natural language expression habits as the second text.
[0072] In step S220, if the actions output by other participants in any round of interaction include a third text, the third text is parsed into a state in the state space of the reinforcement learning agent.
[0073] Other participants can be real people or other reinforcement learning agents. The actions output by other participants can be text actions or behavioral actions. The text output by other participants (i.e., the third text) can be perceived by the reinforcement learning agent, thereby affecting the action selected by the reinforcement learning agent in the next round. Therefore, it is necessary to parse the third text into a state in the state space of the reinforcement learning agent so that the reinforcement learning agent can select an action based on the state in the next round.
[0074] Both step S210 and step S220 involve text conversion. The difference is that step S210 converts logical text with strong logic into more natural free text, while step S220 converts free text into logical text.
[0075] Considering that the second text obtained by the two text generation methods described above is relatively simple and fixed, and according to the characteristics of step S210 and step S210, text generation and text parsing can be regarded as two dual tasks. The present disclosure proposes that a text generation model and a text parsing model can be combined.
[0076] That is, a text generation model can be used to generate a second text based on a first text, and a text parsing model can be used to generate a fourth text based on a third text, and the fourth text can be used as a state in the state space of the reinforcement learning agent, where the fourth text is used to characterize the sentence trunk logic of the third text.
[0077] The text generation model can adopt a generative model structure in which both the model input and the model output are text, such as the Seq2Seq model based on the encoder-decoder architecture. The text generation model can include an encoder and a decoder. The encoder is used to encode the input text, and the decoder is used to decode the encoded result to obtain the output text.
[0078] The text parsing model can also adopt a generative model structure in which both the model input and the model output are text, such as the Seq2Seq model based on the encoder-decoder architecture. The text parsing model can include an encoder and a decoder. The encoder is used to encode the input text, and the decoder is used to decode the encoded result to obtain the output text. The encoder can adopt the BERT model structure. The output of the decoder can be a sequence of labels that constitute the backbone of the sentence.
[0079] When training the text generation model and the text parsing model, in order to solve the cold start problem, both the text generation model and the text parsing model can adopt a pre-trained model in a general field, so that it is only necessary to fine-tune the pre-trained model using sample data in the field where the reinforcement learning agent is located, without the need to retrain the model. A pre-trained model refers to a model that has been pre-trained using general domain data. For ease of distinction, the pre-trained model used by the text generation model can be referred to as the first pre-trained model. The pre-trained model used by the text parsing model can be referred to as the second pre-trained model. For example, the first pre-trained model can be gpt-3, and the second pre-trained model can be other Seq2Seq models.
[0080] The text generation model is used to convert logical text with strong logic into more natural free text, and the text parsing model is used to convert free text into logical text. Since the input and output of the text generation model and the text parsing model are exactly opposite, during the training process, the text generation model and the text parsing model can provide training data for each other.
[0081] Specifically, the first text and the second text can be assembled into a training corpus for training a text parsing model, and the third text and the fourth text can be assembled into a training corpus for training a text generation model. Thus, when the text generation model and the text parsing model are used in a text interaction process based on reinforcement learning, the text generation model and the text parsing model can be continuously optimized based on the corpus generated during the interaction process.
[0082] In summary, when reinforcement learning is applied to text interaction application scenarios, considering that the action space and state space of the reinforcement learning agent contain text output and text input respectively, the present disclosure converts the text action (i.e., the first text) selected by the reinforcement learning agent into a more natural text (i.e., the second text), and on the other hand, parses the text action output by other participants into the state in the state space of the reinforcement learning agent. Thus, the application of the reinforcement learning agent in text interaction application scenarios can be realized.
[0083] Usually the same character will use the same agent model. For example, there is only one model for the werewolf agent, but multiple players can have the werewolf identity at the same time in a game. In order to make the agent's performance more like a real person during the interaction, the same type of agent needs to have different styles. Therefore, an additional personality style generator is needed. The personality style generator provides diversity in the performance of the same agent. The performance of different instances of the same agent can be achieved in the following two ways: 1. Initialization means: use different parameters when initializing each agent; 2. Post-processing means: each agent contains a certain action mask to lower or increase the probability of certain actions.
[0084] The random initialization method is uncontrollable, and the post-processing methods are not rich in diversity. At the same time, these two methods cannot be well migrated to the new style space. To this end, the present disclosure proposes that the actions output by the reinforcement learning agent can be controlled based on the style parameters in the style space of the reinforcement learning agent, so that the actions output by the reinforcement learning agent conform to the style parameters.
[0085] The style parameters in the style space are used to characterize the style that the reinforcement learning agent is expected to have. In the case where there are multiple participants who are reinforcement learning agents, multiple reinforcement learning agents playing the same type of role can have different style spaces, that is, different style parameters.
[0086] As mentioned above, the actions output by the reinforcement learning agent may include text actions and behavioral actions. Therefore, the style parameters may also include speech style parameters and behavioral style parameters to respectively control the style of the text and behavior output by the reinforcement learning agent.
[0087] Taking speech style parameters as an example, multiple text generation models corresponding to different style types can be trained. For example, multiple training corpora belonging to the same style type can be used to train text generation models, so that the output text obtained by the text generation model based on the input text conforms to a certain style type. A text generation model consistent with the speech style parameters can be selected from multiple text generation models, and a second text conforming to the speech style parameters can be generated for the first text based on the selected text generation model.
[0088] Taking the behavior style parameters as an example, the behavior actions output by the reinforcement learning agent can be controlled based on the behavior style parameters so that the behavior actions output by the reinforcement learning agent conform to the behavior style parameters.
[0089] The following is an example of a role-playing game (such as Werewolf) that uses actions and text expressions to advance the game.
[0090] Figure 3A schematic diagram showing the interaction of an agent with an environment simulator.
[0091] See also Figure 3 , the agent can adopt the IPPO algorithm. The environment simulator is used to provide the game environment for the agent.
[0092] The action space of an agent can include exclusive actions, speech texts, and public actions (votes). The state space of an agent can include but is not limited to identity attributes (such as factions, roles, and styles), basic states (such as survival, voting, and associations), and observed states (such as speeches, actions, and conclusions).
[0093] Different roles use different agents. If different players have the same role, they can share agents. Taking the six-player Werewolf game as an example, agents can be divided into two categories: good agents and bad agents. Good agents can include villager agents, prophet agents, and guard agents. Bad agents can include werewolf agents.
[0094] Taking the Werewolf game with only 6 players (6 agents) as an example, it can include two agents playing the role of civilians, two agents playing the role of werewolves, one agent playing the role of a prophet, and one agent playing the role of a guard. Among them, all agents can use the IPPO algorithm or the MAPPO algorithm. Different players can share agents if they are the same role. Players of the same role share agents, which means that the strategy network used by players of the same role is the same. That is, a strategy network can be trained for a role, and the strategy network can provide decisions for all players under the role. For example, Werewolf Agent 1 can play Werewolf Player 1, Werewolf Agent 2 can play Werewolf Player 2, and the strategy networks used by Werewolf Agent 1 and Werewolf Agent 2 can be the same.
[0095] Figure 4 The overall process diagram of a role-playing game based on reinforcement learning is shown.
[0096] See also Figure 4 The overall framework includes 6 parts: simulation simulator, reinforcement learning agent, state space, action space, text logic processor and personality style generator. The relationship between these 6 parts is as follows.
[0097] The reinforcement learning agent contains a state space and an action space, and the reinforcement learning agent interacts with the simulator. Specifically, the agent generates actions in the action space based on the specific state in the state space, and the action interacts with the simulator (environment simulator) to update the state in the state space. For more information about the action space and state space, please refer to the above description.
[0098] Unlike other reinforcement learning tasks, the action space and state space of the agent in this embodiment contain text output and text input respectively. Therefore, it is necessary to use a text logic processor to parse the text in the action, and at the same time, parse the text in the state output by the simulation simulator into a specific state in the state space.
[0099] The text logic processor is mainly responsible for performing the following two operations: parsing the text output in the action space into the state result in the state space, and obtaining the corresponding text output action according to the state. There are the following solutions:
[0100] 1. Predefine a text set, such as: I know nothing, I think number X is a bad guy; then the text logic processor outputs one or more texts with the highest ranking by selection sorting
[0101] 2. Design a logic tree, for example: No. x-(self-proclaimed)-prophet, No. x-(identified as a good person)-No. y, then No. y is a good person. The input and output of the text logic processor are both logic trees, and then the text logic processing is completed through the conversion module of the logic tree and text. The advantage of this solution is that it is more stable when the logic chain is relatively short, but the disadvantage is that the design is complicated when the multi-order logic is used.
[0102] 3. Use a combination of text generation model and text parsing model. The speech texts of the first two are single and fixed. The combination of text generation model and text parsing model can use free text as a medium for transmitting information between players, enriching the game while also better introducing real players to participate.
[0103] In addition, since the intelligent agent needs to be diverse and needs to behave more like a real person when interacting with real people, an additional personality style generator is needed. The personality style generator provides diversity in the performance of the same intelligent agent. For multiple instances of a certain type of intelligent agent (different players of the same character), the personality style generator can make their final actions different from each other through different initialization or post-processing methods, showing different game styles.
[0104] For example, the personality style generator may adopt the following scheme.
[0105] 1. Initialization means. Each agent is initialized with different parameters. For example, the parameters of the policy network used by agents under the same role can be modified so that the parameters of the policy network used by different agents under the same role are different.
[0106] 2. Post-processing methods: You can set action masks for the agent to lower or increase the probability of certain actions occurring.
[0107] 3. Learn a certain style model and use model fusion to provide different outputs for each action of the agent from other agents. For example, you can train text generation models corresponding to different style types, and use a text generation model consistent with the target style to process the text actions selected by the agent according to the target style you expect the agent to have, and obtain a speech text that meets the target style.
[0108] Figure 5 A schematic diagram of the interaction between intelligent agents is shown.
[0109] See also Figure 5 , the text output by each agent will be synchronized to other agents, and at the same time, the output text of each agent will be updated to the state space of other agents.
[0110] Figure 6 A schematic diagram of the interaction including real people is shown.
[0111] See also Figure 6 ,When the agents are trained well enough, some of the agents can be replaced with real players because of their ability to process text.,In addition, the state space and action space of each agent not only contains the states and actions corresponding to the text, but can also,include other state information and action information.
[0112] The simulation simulator (i.e., environment simulator) can be designed as a finite state machine, and its four elements are defined as follows. 1. The current state refers to the global information of the game at the current moment, as well as the state of the exclusive information of each character; 2. Conditions, that is, executing a state migration. In this embodiment, after all the characters have completed all the actions of the current round in order, the state migration is carried out in the order of "first night - speaking on the second day - voting on the second day - second night - speaking on the third day..." The state migration corresponds to the step in reinforcement learning; 3. Actions, according to the different design of the intelligent agent and the certainty of the action, are divided into three parts: exclusive actions, speech texts, and public actions; 4. Sub-state, the new state to be migrated to after the conditions are met. "Sub-state" is relative to the "current state". Once the "sub-state" is activated, it will be transformed into a new "current state"
[0113] When all roles are ready, start the simulator to play the game. The process is as follows:
[0114] Step 1: Initialize the simulator, which may include initializing the action space of each character, initializing the state space of each character, initializing the agent network of each character, etc.
[0115] Step 2: Initialize the game, that is, start a new game. This may include clearing the cache, assigning new ID cards to each character, and other operations.
[0116] Step 3: cyclically execute the following steps a) to c).
[0117] a) Night stage: Each character performs corresponding operations in order according to the game rules;
[0118] b) Daytime presentation stage: Each character speaks in order;
[0119] c) Daytime action phase: Each character performs corresponding public actions according to the rules of the game.
[0120] If the game ending condition is not triggered, jump to step 4, otherwise jump to step 5.
[0121] Step 4: Update the status maintained by the simulator according to the record in step 3.
[0122] Step 5: After the current game is finished, post-processing operations are performed, including uploading and saving game records.
[0123] Step 6: If you want to continue the game, return to step 1, otherwise close the simulator.
[0124] In each round of interaction, the agent can update the algorithm parameters by interacting with the simulation simulator (ie, the environment). The process of updating the algorithm parameters by the agent interacting with the environment is a mature technology in this field and will not be described in detail.
[0125] The text interaction method disclosed in the present invention may also be implemented as a text interaction device. Figure 7 The structure diagram of the text interaction device according to an embodiment of the present disclosure is shown. The functional units of the text interaction device can be implemented by hardware, software, or a combination of hardware and software that implements the principles of the present disclosure. It can be understood by those skilled in the art that Figure 7 The functional units described can be combined or divided into sub-units to implement the principles of the above invention. Therefore, the description herein can support any possible combination, division, or further limitation of the functional units described herein. The following is a brief description of the functional units that the text interaction device can have and the operations that each functional unit can perform. For the details involved, please refer to the relevant description above, which will not be repeated here.
[0126] See also Figure 7 , the text interaction device 700 may include a first processing module 710 and a second processing module 720 .
[0127] The first processing module 710 is used to use a second text obtained based on the first text as the text output by the reinforcement learning agent in the current round if the action selected by the reinforcement learning agent from the action space based on the state in the state space during any round of interaction includes a first text, wherein the second text has the same semantics as the first text and is more in line with natural language expression habits than the first text.
[0128] The first processing module 710 can select a text with the same semantics as the first text from a predefined first text set as the second text. The first processing module 710 can also parse the first text into a first logic tree, process the first logic tree to obtain a second logic tree, and use the text obtained by text conversion of the second logic tree as the second text. The first processing module 710 can also generate the second text based on the first text using a text generation model.
[0129] The second processing module 720 is used to parse the third text into a state in the state space of the reinforcement learning agent if the actions output by other participants in any round of interaction include a third text.
[0130] The second processing module 720 can use the text parsing model to generate a fourth text based on the third text, and use the fourth text as a state in the state space of the reinforcement learning agent. The fourth text is used to represent the sentence trunk logic of the third text.
[0131] The text interaction device 700 may also include a style control module, which is used to control the action output by the reinforcement learning agent based on the style parameters in the style space of the reinforcement learning agent, so that the action output by the reinforcement learning agent matches the style parameters. The style parameters may include speech style parameters and / or behavior style parameters, and the style control module selects a text generation model consistent with the speech style parameters from multiple text generation models, and generates a second text matching the speech style parameters based on the first text using the selected text generation model, and / or the style control module controls the behavior action output by the reinforcement learning agent based on the behavior style parameters, so that the behavior action output by the reinforcement learning agent matches the behavior style parameters.
[0132] Figure 8 A schematic diagram of the structure of a computing device that can be used to implement the above-mentioned text interaction method according to an embodiment of the present disclosure is shown.
[0133] See also Figure 8 , the computing device 800 includes a memory 810 and a processor 820 .
[0134] The processor 820 may be a multi-core processor or may include multiple processors. In some embodiments, the processor 820 may include a general-purpose main processor and one or more special coprocessors, such as a graphics processing unit (GPU), a digital signal processor (DSP), etc. In some embodiments, the processor 820 may be implemented using a customized circuit, such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA).
[0135] The memory 810 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 820 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at run time. In addition, the memory 810 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 810 may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (e.g., DVD-ROM, double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and transient electronic signals transmitted wirelessly or wired.
[0136] The memory 810 stores executable codes, and when the executable codes are processed by the processor 820 , the processor 820 can execute the text interaction method mentioned above.
[0137] The text interaction method, apparatus and device according to the present invention have been described in detail above with reference to the accompanying drawings.
[0138] In addition, the method according to the present invention may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing the above steps defined in the above method of the present invention.
[0139] Alternatively, the present invention may also be implemented as a non-temporary machine-readable storage medium (or computer-readable storage medium, or machine-readable storage medium) on which executable code (or computer program, or computer instruction code) is stored. When the executable code (or computer program, or computer instruction code) is executed by a processor of an electronic device (or computing device, server, etc.), the processor executes the various steps of the above-mentioned method according to the present invention.
[0140] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or a combination of both.
[0141] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system and method according to multiple embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or code, and the part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0142] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terms used herein are selected to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A text interaction method, characterized in that: The method involves multiple participants, at least one of the multiple participants is a reinforcement learning agent, and the method includes: If the action selected by the reinforcement learning agent from the action space based on the state in the state space during any round of interaction includes the first text, a second text obtained based on the first text is used as the text output by the reinforcement learning agent in the current round, wherein the second text has the same semantics as the first text and is more in line with natural language expression habits than the first text; If the actions output by other participants during any round of interaction include a third text, the third text is parsed into a state in the state space of the reinforcement learning agent.
2. The method according to claim 1, characterized in that Also includes: A text having the same semantics as the first text is selected from a predefined first text set as the second text.
3. The method according to claim 1, characterized in that Also includes: Parsing the first text into a first logical tree; Processing the first logic tree to obtain a second logic tree; The text obtained by performing text conversion on the second logical tree is used as the second text.
4. The method according to claim 1, characterized in that: Also includes: The second text is generated based on the first text using a text generation model.
5. The method according to claim 1, characterized in that Parsing the third text into a state in the state space of the reinforcement learning agent includes: A fourth text is generated based on the third text using a text parsing model, and the fourth text is used as a state in the state space of the reinforcement learning agent. The fourth text is used to characterize the sentence trunk logic of the third text.
6. The method according to claim 1, characterized in that Also includes: Based on the style parameters in the style space of the reinforcement learning agent, the action output by the reinforcement learning agent is controlled so that the action output by the reinforcement learning agent matches the style parameters.
7. The method according to claim 6, characterized in that The style parameters include speech style parameters and / or behavior style parameters. Based on the style parameters in the style space of the reinforcement learning agent, controlling the action output by the reinforcement learning agent includes: A text generation model consistent with the speech style parameters is selected from multiple text generation models, and a second text matching the speech style parameters is generated based on the first text using the selected text generation model, and / or based on the behavior style parameters, the behavior actions output by the reinforcement learning agent are controlled so that the behavior actions output by the reinforcement learning agent match the behavior style parameters.
8. A text interaction device, characterized in that: The device involves multiple participants, at least one of the multiple participants is a reinforcement learning agent, and the device includes: A first processing module is configured to use a second text obtained based on the first text as the text output by the reinforcement learning agent in the current round if the action selected by the reinforcement learning agent from the action space based on the state in the state space during any round of interaction includes the first text, wherein the second text has the same semantics as the first text and is more in line with natural language expression habits than the first text; The second processing module is used to parse the third text into a state in the state space of the reinforcement learning agent if the actions output by other participants in any round of interaction include a third text.
9. A computing device comprising: processor; as well as A memory having executable codes stored thereon, which, when executed by the processor, causes the processor to execute the method according to any one of claims 1 to 7.
10. A non-transitory machine-readable storage medium having executable codes stored thereon, which, when executed by a processor of an electronic device, causes the processor to execute the method according to any one of claims 1 to 7.
Citation Information
Cited By
Optimization method for upstream data generating model adapted with downstream model
CN121638388B
