Method, device, terminal and storage medium for generating plot text
By obtaining the plot context and character attribute values in visual novel games and using natural language processing models to generate the plot context, the problem of manually setting plot text increases the workload, and achieves the effect of flexible generation and improved player immersion.
Patent Information
- Application Number
- CN202210050963.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-01-17
AI Technical Summary
In the prior art, the plot text of visual novel games needs to be manually set, which increases the workload and difficulty of game production companies.
By obtaining the plot context and discrete values representing character attributes, obtaining the descriptive text corresponding to the discrete values, determining the candidate result words for the keywords, and using the natural language processing model to generate the plot context, human settings are reduced.
This eliminates the need to pre-set plot texts, reducing the workload of game production companies. It also enables flexible generation of plot texts, improving player immersion and user retention.
Smart Images

Figure CN114416921B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method, device, terminal, and storage medium for generating plot text. Background Art
[0002] In visual novel games, players influence the development of the story by interacting with numerous non-player characters (NPCs), thereby advancing the entire storyline.
[0003] The game's plot consists of multiple, interconnected storylines. The progression of the storyline is determined by the tasks players perform. Each task can lead to multiple plot developments, each corresponding to a specific storyline. However, these pre-set storylines require manual configuration, increasing the difficulty and workload of game development. Summary of the Invention
[0004] The embodiments of the present application provide a method, device, terminal, and storage medium for generating a plot text, which can flexibly generate a plot text.
[0005] This embodiment of the present application provides a method for generating a plot text, including:
[0006] Obtain the plot context and the discrete values used to represent the character attributes;
[0007] Obtaining a description text corresponding to the discrete value, wherein the description text includes keywords;
[0008] Determine the candidate result words corresponding to the keywords;
[0009] Generate the plot context corresponding to the plot context based on the candidate result words, the plot context and the description text.
[0010] The present application also provides a device for generating a plot text, including:
[0011] A first acquisition unit is used to acquire plot context and discrete values used to represent character attributes;
[0012] A second acquiring unit is configured to acquire a description text corresponding to the discrete value, wherein the description text includes keywords;
[0013] A determination unit, used to determine candidate result words corresponding to the keyword;
[0014] The plot text generating unit is used to generate the plot context corresponding to the plot context according to the candidate result words, the plot context and the description text.
[0015] In some embodiments, generating a plot context corresponding to the plot context based on the candidate result words, the plot context, and the description text includes:
[0016] Filter out the result words that meet the preset conditions from the candidate result words as the target result words;
[0017] Generate the plot context corresponding to the plot context based on the target result word, the plot context and the description text.
[0018] In some embodiments, selecting result words that meet preset conditions from candidate result words includes:
[0019] For each candidate result word, determine the probability that there is an implication relationship between the plot context and the result word;
[0020] The preset conditions include: the probability that there is an implication relationship between the plot context and the result word is greater than a preset threshold.
[0021] In some embodiments, determining the probability that there is an entailment relationship between the plot context and the result word includes:
[0022] Extract the word vectors corresponding to the plot context and the word vectors corresponding to the result words respectively;
[0023] Calculate the similarity between the word vector corresponding to the plot context and the word vector corresponding to the result word to obtain the similarity between the plot context and the result word;
[0024] Based on the similarity, the probability of the existence of an implication relationship between the plot context and the result word is determined.
[0025] In some embodiments, generating a plot context corresponding to the plot context based on the candidate result words, the plot context, and the description text includes:
[0026] Obtain additional information about the keyword based on each candidate result word and the probability corresponding to each candidate result word. The probability refers to the probability that there is an implication relationship between the plot context and the candidate result word.
[0027] Update keywords to additional information;
[0028] Determine the candidate result words corresponding to the updated keywords;
[0029] Generate a plot context corresponding to the plot context according to the candidate result words, the plot context and the description text.
[0030] In some embodiments, additional information about the keyword is obtained based on each candidate result word and the probability corresponding to each candidate result word, including:
[0031] The probability corresponding to each candidate result word is used as the weight of the corresponding candidate result word, and each candidate result word is multiplied by the corresponding weight and then summed up. The summed result is used as additional information of the keyword.
[0032] In some embodiments, obtaining plot context and discrete values used to represent character attributes includes:
[0033] Get input text;
[0034] Extract the text content in the first preset field from the input text as the plot context;
[0035] The text content in the second preset field is extracted from the input text as a discrete numerical value for representing the role attribute.
[0036] In some embodiments, the candidate result words are marked with a third preset field.
[0037] An embodiment of the present application also provides a terminal, including a memory storing multiple instructions; the processor loads instructions from the memory to execute the steps in any one of the story content generation methods provided in the embodiments of the present application.
[0038] An embodiment of the present application also provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in any of the story content generation methods provided in the embodiments of the present application.
[0039] The embodiment of the present application can obtain plot context and discrete numerical values used to represent character attributes; obtain descriptive text corresponding to the discrete numerical values, wherein the descriptive text includes keywords; determine candidate result words corresponding to the keywords; and generate plot context corresponding to the plot context based on the candidate result words, the plot context and the descriptive text.
[0040] In the present application, the corresponding plot context is generated based on the plot context and the discrete numerical values representing the character attributes. In this way, the present solution does not need to pre-set the plot text in the game, so the game company can reduce the production of plot text. At the same time, the plot text can also be flexibly generated based on the discrete numerical values representing the character attributes. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0042] Figure 1a This is a schematic diagram of the selection of existing plot texts.
[0043] Figure 1b This is a flow chart of the actual application process of the method for generating plot text provided in the embodiment of the present application;
[0044] Figure 1c 1 is a flow chart of a method for generating plot text provided in an embodiment of the present application;
[0045] Figure 2a This is a schematic diagram of the method for generating plot text provided in an embodiment of the present application being applied to a visual novel game;
[0046] Figure 2b This is a schematic diagram of the method for generating plot text provided in an embodiment of the present application.
[0047] Figure 3 This is a schematic diagram of the first structure of the device for generating plot text provided in an embodiment of the present application;
[0048] Figure 4 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0050] Embodiments of the present application provide a method, device, terminal, and storage medium for generating a plot text.
[0051] The plot text generation device can be integrated into an electronic device, such as a terminal or a server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, or personal computer (PC); the server can be a single server or a server cluster consisting of multiple servers.
[0052] In some embodiments, the plot text generation device can also be integrated into multiple electronic devices. For example, the plot text generation device can be integrated into multiple servers, and the story text generation method of the present application can be implemented by multiple servers.
[0053] In some embodiments, the server may also be implemented in the form of a terminal.
[0054] See also Figure 1a The current plot is obtained by the player completing tasks in the previous plot. Specifically, the plot text corresponding to the task performed is selected from the multiple plot texts corresponding to the previous plot as the plot text. For example, if there are two options A and B in the plot development, and options A and B correspond to two different plot developments, if the player chooses A, the plot text corresponding to A will appear in the plot development. ` and a `` Two options, a ` and a `` Corresponding to two different plot texts, if the player chooses B, the following plot text will be the plot text corresponding to B, and the plot text corresponding to plot A will appear in the plot development. ` and b `` Two options, b ` and b `` Corresponding to two different plot texts, A, B, a ` 、a `` 、b ` and b `` The corresponding plot text needs to be manually produced and input.
[0055] Since the plot text currently obtained through the above method requires the game production company to produce the plot text, which increases the workload of the game production company, the embodiment of the present application proposes to obtain the plot context and discrete numerical values used to represent character attributes; obtain the descriptive text corresponding to the discrete numerical values, wherein the descriptive text includes keywords; determine the candidate result words corresponding to the keywords; and generate the plot context corresponding to the plot context based on the candidate result words, the plot context and the descriptive text.
[0056] Then, refer to Figure 1b , obtain the descriptive text corresponding to the discrete value. For example, if the discrete value is a likeability of 0, the corresponding descriptive text may be "the NPC hates this player." Identify keywords in the descriptive text, where the keyword may be "hate." Obtain candidate results corresponding to "hate." These candidate results may include "angry," "end," and "kill." After screening, two keywords, such as "angry" and "end," are obtained. Then, based on "angry," "end," the previous plot context, and the fact that the NPC hates this player, flexibly generate the corresponding plot context.
[0057] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0058] In this embodiment, a method for generating plot text is provided, such as Figure 1c As shown, the specific process of the method for generating plot text can be as follows:
[0059] 110. Obtain plot context and discrete values used to represent character attributes.
[0060] The preceding plot text may be a story text preceding the following plot text. For example, the preceding plot text may be a plot text preceding the end of the game plot, or may be a plot text that has been played in the game.
[0061] The player character may be a character controlled by a player in the game.
[0062] Among them, non-player characters (NPCs) can be game characters that are not controlled by real players in the game.
[0063] Among them, character attributes can be used to describe characters in the game, for example, they can describe NPCs in the game, player characters in the game, and the interactions between player characters and NPCs.
[0064] Discrete values are numerical descriptions of the corresponding attributes of characters in the game. For example, discrete values can describe the intimacy between the player and the NPC, the duration of the chat interaction between the player and the NPC, the emotional distribution of the chat between the player and the NPC, or the NPC's current strength, agility, or money value.
[0065] For example, a discrete value can describe the affection between the player and an NPC. A value of 0 indicates that the NPC dislikes the player character, while a value of 5 indicates that the NPC likes the player character. Discrete values can specifically represent interactions between the player and the NPC, which can be positive, negative, or neutral. For example, discrete values can describe the NPC's affection, love, appreciation, loyalty, betrayal, or hatred for the player character, among other things.
[0066] For example, a task performed by the player character causes the NPC's favorability towards the player character to decrease, so that the plot includes the player character making the NPC cry.
[0067] In some embodiments, considering the information for generating the plot context from the input text, obtaining the plot context and the discrete numerical value for representing the character attribute includes:
[0068] Get input text;
[0069] Extract the text content in the first preset field from the input text as the plot context;
[0070] The text content in the second preset field is extracted from the input text as a discrete numerical value for representing the role attribute.
[0071] The input text may be text input into the plot generation model. For example, the input text may be all plot texts that have been broadcast before the current one and the current discrete value.
[0072] The first preset field can be used to locate the required plot context from the input text. For example, the first preset field can locate the plot text of the previous node of the plot context from all the plot texts that have been broadcast.
[0073] The second preset field can locate required data from the input text. For example, there are multiple values in the input text, and a discrete value representing a role attribute needs to be determined from the multiple values.
[0074] 120. Obtain a description text corresponding to the discrete value, wherein the description text includes keywords.
[0075] The description text may be text describing the current discrete value in the game.
[0076] Discrete values are used to quantify the current attributes of the characters in the game.
[0077] There's a mapping relationship between discrete values and descriptive text. When mapped to descriptive text, the discrete value can be a single number or a range of numbers. Alternatively, there can be a mapping relationship between a character's current attributes and descriptive text. For example, if a discrete value is used to represent an NPC's fondness for a player character, the mapping relationship between the discrete value and the descriptive text could be [0, NPC] hates the player, [1, NPC] has no feelings for the player, [2, NPC] is just friends with the player, and [3, NPC] likes the player. Alternatively, it could be [0, 20] - hostile relationship - the NPC hates the player, [20, 40] - neutral relationship - the NPC has no feelings for the player, [40, 60] - neutral relationship - the NPC is just friends with the player, and [60, 100] - neutral relationship - the NPC likes the player.
[0078] Keywords can be words that highlight character attributes in the descriptive text. There can be one or more keywords. For example, when a discrete value is used to represent the NPC's liking for the player character, the keywords could be "hate," "indifferent," "normal," "like," and so on.
[0079] For example, a task performed by the player character causes the NPC's affection for the player character to decrease, leading to the preceding plot text including the player character making the NPC cry. In this case, the following plot text needs to be generated to obtain the discrete value of the NPC's affection for the player character at this point. The resulting affection is "0". Based on the description text corresponding to a affection of "0", the result is "The NPC hates this player", where "hate" is the keyword.
[0080] 130. Determine candidate result words corresponding to the keywords.
[0081] The candidate result words can be words that have a directed relationship with the keyword. Directed relationships in the ConceptNet knowledge base are directional relationships. For example, if the keyword is "hate," starting from "hate," arrows point to words such as "angry," "end," and "kill." The arrows represent the directed relationship between the keyword and the associated word.
[0082] Among them, the candidate result words corresponding to the keywords can be determined by using a semantic knowledge base. The semantic knowledge base can be a knowledge base composed of relational knowledge, and relational knowledge is words with directed relationships. For example, the semantic knowledge base can be a ConceptNet knowledge base (a semantic network that helps computers understand human intentions) or a common sense knowledge base (KB for short). The ConceptNet knowledge base uses triples to store human common sense. For example, the triple "<read comics, Causes, interesting>" means that reading comics will make people feel interesting. Causes is a predefined directed relationship in the ConceptNet knowledge base.
[0083] For example, the keyword can be hate. Through the semantic knowledge base, searching for the keyword "hate" can obtain triplets such as "<hate, Causes, angry>", "<hate, Causes, end>" and "hate, Causes, kill>", that is, angry, end and kill are candidate result words corresponding to hate.
[0084] In some embodiments, in order to facilitate the generation of a plot context corresponding to a plot context based on the candidate result words, the method further includes:
[0085] The candidate result words are marked with the third preset field.
[0086] The third preset field is used to mark the candidate result word. For example, the third preset field may be a character identifier, and the character identifier may be a Roman numeral, a letter, a word, and so on.
[0087] For example, it is necessary to generate the corresponding plot context based on the candidate result words, the plot context and the description text. In order to accurately locate the candidate result words from the candidate result words, the plot context and the description text, the candidate result words can be marked through the third preset field, so that when the candidate result words are needed to generate the plot context, the candidate result words can be accurately extracted.
[0088] 140. Generate a plot context corresponding to the plot context based on the candidate result words, the plot context, and the description text.
[0089] Among them, the following plot can be a plot text that continues the previous plot.
[0090] The generation of the plot context can use an unsupervised natural language processing model, specifically the GPT-2 (Generative Pre-trained Transformers 2.0) model, the BERT (Bidirectional Encoder Representation from Transformers) model, and so on.
[0091] In some embodiments, considering that there are words in the candidate result words that are irrelevant to the plot context, thereby affecting the generation of the plot context, the plot context corresponding to the plot context is generated according to the candidate result words, the plot context, and the description text, including:
[0092] Filter out the result words that meet the preset conditions from the candidate result words as the target result words;
[0093] Generate the plot context corresponding to the plot context based on the target result word, the plot context and the description text.
[0094] Among them, the preset conditions can be used to limit candidate result words that do not conform to the game plot, so that the target result word is relevant to the plot context.
[0095] Among them, the preset conditions are set according to the game plot and no special settings are made here.
[0096] For example, the preset condition may be to select a candidate result word for which the probability of an implication relationship between the plot context and the result word is greater than 0.5. When the probability of an implication relationship between the plot context and the result word is greater than 0.5, then there is an implication relationship between the plot context and the result word. When the probability of an implication relationship between the plot context and the result word is less than 0.5 but greater than 0.3, then there is a neutral relationship between the plot context and the result word. When the probability of an implication relationship between the plot context and the result word is less than 0.3, then there is a contradictory relationship between the plot context and the result word.
[0097] Among them, the implication relationship refers to the existence of a directed reasoning relationship between a pair of texts. For example, if the semantics of the result word can be inferred from the semantics of the previous plot, then there is an implication relationship.
[0098] The target result word may be a word related to the meaning expressed by the semantics of the previous plot.
[0099] For example, the plot context may be a game plot that describes the warm life between characters, and the candidate result words include angry, ended, and killed. However, some of the candidate result words do not conform to the category of warm life, which may easily lead to an unreasonable plot and a sense of tearing. Therefore, the result words are filtered according to preset conditions, excluding the killing that does not conform to the plot context, leaving angry and ended.
[0100] In some embodiments, in order to filter out the result words that are consistent with the plot context from the candidate result words, the result words that meet the preset conditions are filtered out from the candidate result words, including:
[0101] For each candidate result word, determine the probability that there is an implication relationship between the plot context and the result word;
[0102] The preset conditions include: the probability that there is an implication relationship between the plot context and the result word is greater than a preset threshold.
[0103] The probability of an entailment relationship between the plot context and the result word may refer to the probability that the result word can be inferred from the plot context. The entailment relationship between the plot context and the result word can be obtained through recognizing textual entailment (RTE) in the natural language inference model.
[0104] For example, if the context is "A dog plays with a Frisbee in the snow," and the result word is "animal," then "dog" can be inferred to be "animal." Therefore, there is an entailment relationship between "A dog plays with a Frisbee in the snow" and "animal." The probability of an entailment relationship between the context and the result word can be determined by using a natural language inference (NLI) model to perform linguistic inference on the word vectors corresponding to the context and the result word, outputting the probability of an entailment relationship between the context and the result word. The NLI model determines the semantic relationship between two sentences or words.
[0105] A preset threshold can be used to exclude candidate result words with a low probability of an implication relationship between the plot context and the result word. When the probability of an implication relationship between the plot context and the result word is low, there may be a conflicting or neutral relationship between the plot context and the result word. For example, if the plot context is "A dog plays with a Frisbee in the snow," and the result word is "cat," there is a conflicting relationship. A neutral relationship means that the plot context and the result word are neither implication nor conflicting.
[0106] In some embodiments, in order to obtain the probability of an implication relationship between the plot context and the result word, and to determine the probability of an implication relationship between the plot context and the result word, the device is configured to:
[0107] Extract the corresponding word vectors of the plot context and result words respectively;
[0108] Calculate the similarity between the word vector corresponding to the plot context and the word vector corresponding to the result word to obtain the similarity between the plot context and the result word;
[0109] Based on the similarity, the probability of the existence of an implication relationship between the plot context and the result word is determined.
[0110] Similarity is used to represent the degree of similarity between two vectors. Similarity calculation can be done using the Euclidean distance algorithm, the Pearson correlation coefficient algorithm, the cosine similarity algorithm, the Tanimoto coefficient, and so on.
[0111] Among them, the similarity is normalized to obtain the probability that there is an implication relationship between the plot context and the result word.
[0112] In some embodiments, in order to improve the cohesion between the plot context and the plot context and make the content of the plot context less abrupt, the plot context corresponding to the plot context is generated based on the candidate result words, the plot context, and the description text, including:
[0113] Obtain additional information about the keyword based on each candidate result word and the probability corresponding to each candidate result word. The probability refers to the probability that there is an implication relationship between the plot context and the candidate result word.
[0114] Update keywords to additional information;
[0115] Determine the candidate result words corresponding to the updated keywords;
[0116] Generate the plot context corresponding to the plot context based on the candidate result words, the plot context and the description text.
[0117] The additional information can represent the candidate result word and the implicit relationship between the plot context and the candidate result word. For example, the additional information may include candidate result word A, candidate result word B, and candidate result word C, as well as the probability a that candidate result word A has an implicit relationship with the plot context, the probability b that candidate result word B has an implicit relationship with the plot context, and the probability c that candidate result word C has an implicit relationship with the plot context.
[0118] The updated keywords can be additional information. For example, if the keyword is keyword I, the additional information can be as follows: candidate result word A, candidate result word B, and candidate result word C. The updated keywords also include the probability a that candidate result word A has an implication relationship with the previous plot context, the probability b that candidate result word B has an implication relationship with the previous plot context, and the probability c that candidate result word C has an implication relationship with the previous plot context.
[0119] From the above, we can see that when the plot context is generated, candidate result word A, candidate result word B, candidate result word C, the probability a that there is an implication relationship between candidate result word A and the plot context, the probability b that there is an implication relationship between candidate result word B and the plot context, the probability c that there is an implication relationship between candidate result word C and the plot context, the plot context, and the description text are required.
[0120] In some embodiments, in order to consider that the probability corresponding to the candidate result word may affect the cohesion between the following plot and the previous plot, additional information about the keyword is obtained based on each candidate result word and the probability corresponding to each candidate result word, including:
[0121] The probability corresponding to each candidate result word is used as the weight of the corresponding candidate result word, and each candidate result word is multiplied by the corresponding weight and then summed up. The summed result is used as additional information of the keyword.
[0122] The weight can represent the proportion of the candidate result word in generating the plot context. For example, if the probability corresponding to candidate result word A is probability a, then the value a of probability a is used as the weight of candidate result word A, and so on.
[0123] For example, if the probability a is that there is an implication relationship between candidate result word A and the previous plot, then the weight of candidate result word A is a; if the probability b is that there is an implication relationship between candidate result word B and the previous plot, then the weight of candidate result word B is b; if the probability c is that there is an implication relationship between candidate result word C and the previous plot, then the weight of candidate result word C is c. The additional information of the keyword = keyword A*a+keyword B*b+keyword C*c.
[0124] The calculation method of additional information can also be:
[0125] According to the probability corresponding to each candidate result word, a probability vector is formed. The probability refers to the probability of the existence of the plot context and the candidate result word.
[0126] Extract the word vector of the candidate result word;
[0127] Place the word vector corresponding to the candidate result word into the preset vector space to obtain the space matrix of the vector space;
[0128] The probability vector is multiplied by the spatial matrix to obtain additional information, and the elements in the additional information are used to represent the relevance between the candidate result word and the keyword.
[0129] The probability vector is composed of the probability corresponding to each candidate result word. The probability vector may contain one element or multiple elements. The number of elements in the probability vector corresponds to the number of candidate result words.
[0130] The additional information may be a vector, and the elements in the vector may represent the relevance between the candidate result words and the keywords.
[0131] In some embodiments, the storyline context is displayed and / or played.
[0132] For example, in a visual novel game, after the plot context is generated, the plot context is displayed and can also be played in the form of voice.
[0133] In some embodiments, a game scene corresponding to the plot context is determined and displayed.
[0134] For example, in a visual novel game, generating a game scene that corresponds to the plot context and displaying the game scene helps increase the user's sense of immersion.
[0135] The plot text generation solution provided by the embodiment of the present application can be applied to various text generation scenarios. For example, taking a visual novel game, specifically the ending plot text of each chapter in the visual novel game as an example, obtain the plot context and the discrete numerical values used to represent the character attributes; obtain the description text corresponding to the discrete numerical values, wherein the description text includes keywords; determine the candidate result words corresponding to the keywords; and generate the plot context corresponding to the plot context based on the candidate result words, the plot context, and the description text. The solution provided by the embodiment of the present application can reduce the workload of setting the plot text, and can also flexibly generate the plot text.
[0136] As can be seen from the above, the embodiment of the present application can flexibly generate plot text. Therefore, this solution can enhance the player's immersion in the game and help improve user retention rate.
[0137] The method described in the above embodiment will be further described below.
[0138] The plot text generation scheme provided in the embodiment of the present application can be applied to various electronic game scenarios. For example, the method of the embodiment of the present application is described in detail using a visual novel game as an example.
[0139] In the scenario text generation solution provided in the embodiment of the present application, the current story text can be flexibly generated based on the scenario context and the discrete values representing the character attributes. Figure 2a ,The specific process of the plot text generation scheme is as follows:
[0140] (1) Obtaining discrete numerical values representing character attributes.
[0141] (2) According to the mapping relationship between the discrete numerical value and the description text, the description text corresponding to the discrete numerical value is obtained, and the description text includes keywords.
[0142] In some embodiments, the discrete value may specifically represent an interaction between the player and the NPC, and the interaction may specifically be a positive interaction, an opposing interaction, and a neutral interaction.
[0143] For example, discrete values can describe the NPC's degree of affection, liking, appreciation, loyalty, betrayal, hatred, etc. towards the player character.
[0144] For example, a discrete value is used to represent the NPC's liking for the player. The mapping relationship between the discrete value and the description text can be:
[0145] '0':'NPC hates this player, where hate is the keyword';
[0146] '1':'NPC has no feelings towards this player, where "no feelings" is the key word';
[0147] '2':'NPC and this player are ordinary friends, where ordinary is the keyword';
[0148] '3':'NPC likes this player, where "like" is the keyword'.
[0149] (3) Using the ConceptNet semantic knowledge base, determine the candidate result words corresponding to the keywords in the ConceptNet semantic knowledge base.
[0150] For example, when searching for the keyword "hate", triples such as "<hate, Causes, angry>" and "<hate, Causes, end>" can be obtained, thereby obtaining the associated words corresponding to hate (angry and end).
[0151] (4) Screening the candidate result words to obtain the target result words that meet the preset conditions.
[0152] In some embodiments, the plot context and each result word among the candidate result words are input into a natural language inference model, and three categories of probabilities are output, wherein the three categories of probabilities include a probability that there is an entailment relationship between the plot context and the result word;
[0153] Select associated words with a probability greater than a preset threshold from the candidate result words.
[0154] In some embodiments, each of the candidate result words is ranked according to the probability of an implication relationship between the plot context and the result word.
[0155] In some embodiments, the three categories of probabilities further include a probability that there is a conflicting relationship between the plot context and the result word, and a probability that there is a neutral relationship between the plot context and the result word.
[0156] The natural language inference task uses the open-source OCNLI (Original Chinese Natural Language Inference) dataset as training data, and the model used is roberta-wwm (Robust Optimizebert approach - Whole Word Masking, used to predict the probability of the next word). When calculating the entailment relationship, the preceding plot context and the candidate associated words are concatenated using a delimiter.
[0157] (5) See Figure 2b , the plot context, description text and target result words are input into the plot generation model to generate the plot context.
[0158] In some embodiments, the plot context, description text, and target result word are input into the plot generation model to generate the plot context, including:
[0159] Obtain additional information about the keyword based on each target result word and the probability corresponding to each target result word. The probability refers to the probability that there is an implication relationship between the plot context and the target result word.
[0160] Update keywords to additional information;
[0161] Determine the target result words corresponding to the updated keywords;
[0162] Generate the following plot context based on the target result word, the previous plot context, and the descriptive text.
[0163] The plot context and description text are input into Token Embeddings, and [CLS] is added at the beginning of the plot context. [SEP] is added between the plot context and the description text, as well as at the end of the description text, to indicate the beginning and end of the plot context. It also indicates the beginning and end of the relationship description text, making it easier for the plot generation model to recognize the plot context and relationship description text.
[0164] Among them, three Types are set in Type embedding to indicate the type of each token, among which "CTX" represents the token in the plot text; "CTL" represents the non-keyword token in the description text; and "KEY" represents the keyword token in the description text.
[0165] The plot generation model (roberta-wwm) adds a Consequence Embeddings field to introduce candidate result words corresponding to keywords. Specifically, for the keyword "hate," the result words s1, s2, ..., sm are retrieved from the ConceptNet semantic knowledge base (for example, the associated words "angry," "end," and "kill" are retrieved from the ConceptNet semantic knowledge base using the keyword "hate"). The probability p1, p2, ... pm of an implication relationship between the plot context and these result words is then calculated. Target result words whose probability of an implication relationship between the plot context and the result word exceeds a preset threshold are selected, and together they generate additional information about the keyword:
[0166] info=p1*s1+p2*s2+…+pm*sm
[0167] Among them, info is additional information, p is the probability that there is an implication relationship between the previous plot and these candidate result words, S is the candidate result word, and m is used to pair P with S.
[0168] Then info is used as the CON position in the Consequence Embeddings corresponding to the keyword.
[0169] As can be seen above, this application uses descriptive text representing discrete numerical values of character attributes to deeply explore the role of discrete numerical values in generating plot context. Using a semantic knowledge base, we introduce candidate result words that correspond to keywords and are consistent with human cognition. These candidate result words are then filtered to obtain target result words, ensuring that the generated plot context matches the current discrete numerical value. Based on the target result words, the plot context, and the descriptive text, the corresponding plot context is generated, improving the quality of the generated plot context.
[0170] To better implement the above method, embodiments of the present application further provide a device for generating plot text. The device can be integrated into an electronic device, such as a terminal or a server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, or other device; the server can be a single server or a server cluster consisting of multiple servers.
[0171] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the device for generating plot text as specifically integrated into a terminal as an example.
[0172] For example, Figure 3 As shown, the device for generating a plot text may include a first acquisition unit, a second acquisition unit, a determination unit, and a plot text generation unit, as follows:
[0173] (1) a first acquiring unit 310;
[0174] The first acquisition unit 310 is used to acquire plot context and discrete values used to represent character attributes.
[0175] (2) a second acquiring unit 320;
[0176] The second acquiring unit 320 is configured to acquire a description text corresponding to the discrete value, wherein the description text includes keywords.
[0177] (3) determining unit 330;
[0178] The determining unit 330 is configured to determine candidate result words corresponding to the keyword.
[0179] (4), plot text generation unit 340;
[0180] The plot text generating unit 340 is configured to generate a plot context corresponding to the plot context according to the candidate result words, the plot context and the description text.
[0181] In some embodiments, generating a plot context corresponding to the plot context based on the candidate result words, the plot context, and the description text includes:
[0182] Filter out the result words that meet the preset conditions from the candidate result words as the target result words;
[0183] Generate the plot context corresponding to the plot context based on the target result word, the plot context and the description text.
[0184] In some embodiments, selecting result words that meet preset conditions from candidate result words includes:
[0185] For each candidate result word, determine the probability that there is an implication relationship between the plot context and the result word;
[0186] The preset conditions include: the probability that there is an implication relationship between the plot context and the result word is greater than a preset threshold.
[0187] In some embodiments, determining the probability that there is an entailment relationship between the plot context and the result word includes:
[0188] Extract the word vectors corresponding to the plot context and the word vectors corresponding to the result words respectively;
[0189] Calculate the similarity between the word vector corresponding to the plot context and the word vector corresponding to the result word to obtain the similarity between the plot context and the result word;
[0190] Based on the similarity, the probability of the existence of an implication relationship between the plot context and the result word is determined.
[0191] In some embodiments, generating a plot context corresponding to the plot context based on the candidate result words, the plot context, and the description text includes:
[0192] Obtain additional information about the keyword based on each candidate result word and the probability corresponding to each candidate result word. The probability refers to the probability that there is an implication relationship between the plot context and the candidate result word.
[0193] Update keywords to additional information;
[0194] Determine the candidate result words corresponding to the updated keywords;
[0195] Generate the plot context corresponding to the plot context based on the candidate result words, the plot context and the description text.
[0196] In some embodiments, additional information about the keyword is obtained based on each candidate result word and the probability corresponding to each candidate result word, including:
[0197] The probability corresponding to each candidate result word is used as the weight of the corresponding candidate result word, and each candidate result word is multiplied by the corresponding weight and then summed up. The summed result is used as additional information of the keyword.
[0198] In some embodiments, obtaining plot context and discrete values used to represent character attributes includes:
[0199] Get input text;
[0200] Extract the text content in the first preset field from the input text as the plot context;
[0201] The text content in the second preset field is extracted from the input text as a discrete numerical value for representing the role attribute.
[0202] In some embodiments, the method further comprises:
[0203] The candidate result words are marked with the third preset field.
[0204] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can be found in the previous method embodiments and will not be repeated here.
[0205] As can be seen from the above, the plot text generation device of this embodiment obtains the plot context and discrete numerical values used to represent character attributes by the first acquisition unit; obtains the description text corresponding to the discrete numerical values by the second acquisition unit, wherein the description text includes keywords; determines the candidate result words corresponding to the keywords by the determination unit; and generates the plot text corresponding to the plot context according to the candidate result words, the plot context and the description text by the plot text generation unit.
[0206] Therefore, the embodiment of the present application can flexibly generate plot text.
[0207] Accordingly, an embodiment of the present application also provides an electronic device, which may be a terminal or a server, and the terminal may be a smart phone, tablet computer, laptop computer, touch screen, game console, personal computer, personal digital assistant (PDA) and other terminal devices.
[0208] like Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 400 includes a processor 410 having one or more processing cores, a memory 420 having one or more computer-readable storage media, and a computer program stored in the memory 420 and executable on the processor. The processor 410 is electrically connected to the memory 420. Those skilled in the art will understand that the electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0209] The processor 410 is the control center of the electronic device 400. It uses various interfaces and lines to connect various parts of the entire electronic device 400. By running or loading software programs and / or modules stored in the memory 420 and calling data stored in the memory 420, it executes various functions of the electronic device 400 and processes data, thereby monitoring the electronic device 400 as a whole.
[0210] In the embodiment of the present application, the processor 410 in the electronic device 400 loads instructions corresponding to one or more application processes into the memory 420 according to the following steps, and the processor 410 runs the application stored in the memory 420 to implement various functions:
[0211] Obtain the plot context and the discrete values used to represent the character attributes;
[0212] Obtaining description text corresponding to the discrete value, wherein the description text includes keywords;
[0213] Determine the candidate result words corresponding to the keywords;
[0214] Generate the plot context corresponding to the plot context based on the candidate result words, the plot context and the description text.
[0215] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0216] Optional, such as Figure 4 As shown, the electronic device 400 further includes: a touch screen 430, a radio frequency circuit 440, an audio circuit 450, an input unit 460, and a power supply 470. Among them, the processor 410 is electrically connected to the touch screen 430, the radio frequency circuit 440, the audio circuit 450, the input unit 460, and the power supply 470 respectively. Those skilled in the art will understand that Figure 4 The electronic device structure shown in the figure does not constitute a limitation to the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0217] The touch display screen 430 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 430 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. The touch panel can be used to collect the user's touch operations on or near it (such as the user uses any suitable object or accessory such as a finger, a stylus, etc. on the touch panel or near the touch panel) and generate corresponding operation instructions, and the operation instructions execute the corresponding program. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, 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 410, and can receive the command sent by the processor 410 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 410 to determine the type of touch event, and then the processor 410 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 430 to realize input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize input and output functions. That is, the touch display screen 430 can also be used as part of the input unit 460 to realize the input function.
[0218] In this embodiment of the present application, processor 410 executes a game application to generate a graphical user interface (GUI) on touchscreen display 430. The virtual scene on the GUI includes at least one skill control area, which includes at least one skill control. Touchscreen display 430 is used to present the GUI and receive user commands generated by operating the GUI.
[0219] The radio frequency circuit 440 may be used to transmit and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to transmit and receive signals with the network device or other electronic devices.
[0220] The audio circuit 450 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 450 can convert the received audio data into an electrical signal and transmit it to the speaker, which then converts it into a sound signal for output. On the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 450 and converted into audio data. The audio data is then output to the processor 410 for processing, and then sent to another electronic device through the radio frequency circuit 440, or the audio data is output to the memory 420 for further processing. The audio circuit 450 may also include an earphone jack to provide communication between external headphones and the electronic device.
[0221] The input unit 460 may be used to receive input numbers, character information, or user feature information (such as fingerprint, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
[0222] Power supply 470 is used to supply power to various components of electronic device 400. Optionally, power supply 470 can be logically connected to processor 410 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. Power supply 470 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0223] although Figure 4 Not shown in the figure, the electronic device 400 may further include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0224] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0225] As can be seen from the above, the electronic device provided in this embodiment can flexibly generate plot text.
[0226] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0227] To this end, an embodiment of the present application provides a computer-readable storage medium storing a plurality of computer programs, which can be loaded by a processor to execute any of the steps in generating a plot text provided in the embodiments of the present application. For example, the computer program can execute the following steps:
[0228] Obtain the plot context and the discrete values used to represent the character attributes;
[0229] Obtaining description text corresponding to the discrete value, wherein the description text includes keywords;
[0230] Determine the candidate result words corresponding to the keywords;
[0231] Generate the plot context corresponding to the plot context based on the candidate result words, the plot context and the description text.
[0232] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0233] The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0234] Since the computer program stored in the storage medium can execute the steps of generating any plot text provided in the embodiments of the present application, it can achieve the beneficial effects that can be achieved by any plot text generation method provided in the embodiments of the present application. Please refer to the previous embodiments for details and will not be repeated here.
[0235] The above describes in detail a method, device, storage medium, and electronic device for generating a plot text provided in an embodiment of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core ideas of the present application. At the same time, for those skilled in the art, based on the ideas of the present application, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present application.
Claims
1. A method for generating a plot text, characterized in that: The method comprises: Obtaining plot context and discrete values representing character attributes, wherein the character attributes are used to describe the character in the game, and the discrete values are used to quantify the attributes currently corresponding to the character in the game; According to the mapping relationship between the preset discrete values and the preset description texts, obtaining the description texts corresponding to the discrete values, wherein the description texts include keywords; Determining candidate result words corresponding to the keyword, wherein there is a directed relationship between the candidate result words and the keyword; The candidate result words, the plot context and the description text are input into a plot generation model to generate a plot context corresponding to the plot context.
2. The method according to claim 1, wherein The step of inputting the candidate result word, the plot context, and the description text into a plot generation model to generate a plot context corresponding to the plot context includes: Filtering out result words that meet preset conditions from the candidate result words as target result words; The target result word, the plot context and the description text are input into a plot generation model to generate a plot context corresponding to the plot context.
3. The method according to claim 2, wherein The step of selecting result words that meet preset conditions from the candidate result words includes: For each result word in the candidate result words, determining the probability that there is an entailment relationship between the plot context and the result word; The preset condition includes: the probability that there is an implication relationship between the plot context and the result word is greater than a preset threshold.
4. The method according to claim 3, wherein Determining the probability that there is an implication relationship between the plot context and the result word includes: Extract the word vector corresponding to the plot context and the word vector corresponding to the result word respectively; Calculate the similarity between the word vector corresponding to the plot context and the word vector corresponding to the result word to obtain the similarity between the plot context and the result word; According to the similarity, a probability of an implication relationship existing between the plot context and the result word is determined.
5. The method according to claim 1, wherein The step of inputting the candidate result word, the plot context, and the description text into a plot generation model to generate a plot context corresponding to the plot context includes: Obtaining additional information about the keyword based on each candidate result word and the probability corresponding to each candidate result word, wherein the probability refers to the probability that there is an implication relationship between the plot context and the candidate result word; Updating the keyword to the additional information; Determine the candidate result words corresponding to the updated keywords; Generate a plot context corresponding to the plot context according to the candidate result words, the plot context and the description text.
6. The method according to claim 5, wherein The obtaining of additional information of the keyword according to each candidate result word and the probability corresponding to each candidate result word includes: The probability corresponding to each candidate result word is used as the weight of the corresponding candidate result word, each candidate result word is multiplied by the corresponding weight and then summed up, and the obtained summation result is used as the additional information of the keyword.
7. The method according to claim 1, characterized in that The acquisition of plot context and discrete values used to represent character attributes includes: Get input text; Extracting the text content in the first preset field from the input text as the plot context; The text content in the second preset field is extracted from the input text as the discrete value for representing the role attribute.
8. The method according to claim 7, characterized in that The method further comprises: The candidate result word is marked with a third preset field.
9. A device for generating plot text, characterized in that: include: A first acquisition unit is configured to acquire plot context and discrete values representing character attributes, wherein the character attributes are used to describe the character in the game, and the discrete values are used to quantify the attributes currently corresponding to the character in the game; A second acquiring unit is configured to acquire a description text corresponding to a discrete value according to a mapping relationship between a preset discrete value and a preset description text, wherein the description text includes keywords; a determining unit, configured to determine a candidate result word corresponding to the keyword, wherein the candidate result word has a directed relationship with the keyword; The plot text generating unit is used to input the candidate result words, the plot context and the description text into the plot generation model to generate the plot context corresponding to the plot context.
10. A terminal, characterized in that: The system comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the method for generating a plot text according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the method for generating a plot text according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method for generating behavior sequence of non-player character and device thereof
CN113648660A
KR20200040396A