Text content derivation method, device, computer readable medium and electronic device
By identifying and utilizing the causal content in the original text content and determining the ending framework of the text structure, the problem of story logic in the existing technology is solved, and the generated derivative text is more in line with causal logic and fluent.
Patent Information
- Application Number
- CN202110164573.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-05
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2041-02-05
AI Technical Summary
The existing text creation platform that automatically generates stories fails to effectively consider the logical relationship of the story content, resulting in the problem of story logic being blocked.
By obtaining the original text content, the causal content related to the original conditions is identified, and the ending framework of the text structure is determined based on these causal contents, and derivative text that conforms to the causal logic is generated.
On the premise of ensuring the consistency between the derived text and the original text, the generated derived text is more in line with the causal logic and increases the fluency of expression.
Smart Images

Figure CN113569539B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, computer-readable medium and electronic device for deriving text content. Background Art
[0002] With the accumulation of massive text data and the development of deep learning technology, there are now some text creation platforms that can automatically generate stories. These creation platforms can write appropriate sequels based on given backgrounds and conditions. The conditional text generation models based on these creation platforms can be widely used in the creation of novels, essays, poems and other genres, as well as in product recommendation articles, news releases and other scenarios. They have broad application prospects and huge economic value. Related technologies generally directly generate story content based on the premise of the original story and the concatenation of counterfactual conditions. This method does not take into account the logical relationship of the story content, which may cause the problem of illogical story. Summary of the invention
[0003] The embodiments of the present application provide a method, device, computer-readable medium and electronic device for deriving text content, which can make the generated derivative text more consistent with causal logic and increase the fluency of expression while ensuring the consistency of the derived text with the original text content, at least to a certain extent.
[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0005] According to one aspect of an embodiment of the present application, a method for deriving text content is provided, comprising: obtaining original text content, the original text content including a premise, an original condition, and an original ending; based on the original text content and a counterfactual condition corresponding to the original condition, identifying causal content related to the original condition from the original ending; based on the original ending and the causal content in the original ending, determining an ending frame of a text structure representing the original ending; based on a sequence consisting of the premise, the counterfactual condition, and the ending frame, generating a counterfactual ending corresponding to the original ending.
[0006] According to one aspect of an embodiment of the present application, a device for deriving text content is provided, including: an acquisition unit, used to acquire original text content, wherein the original text content includes a premise, an original condition, and an original ending; an identification unit, used to identify causal content related to the original condition from the original ending based on the original text content and the counterfactual condition corresponding to the original condition; a framework unit, used to determine an ending framework of a text structure representing the original ending based on the original ending and the causal content in the original ending; an ending unit, used to generate a counterfactual ending corresponding to the original ending based on a sequence consisting of the premise, the counterfactual condition, and the ending framework; and a text unit, used to merge the premise, the counterfactual condition, and the counterfactual ending to generate a derivative text corresponding to the original text content.
[0007] In some embodiments of the present application, based on the aforementioned scheme, the recognition unit includes: a format unit, used to format the original text content and generate a text sequence corresponding to the original text content; an identification unit, used to add set text identifiers at positions in the text sequence corresponding to the premise, the original condition, the original ending, and the counterfactual condition corresponding to the original condition, to generate a tag sequence; wherein the text identifier is used to represent the attribute information corresponding to the premise, the original condition, the original ending, and the counterfactual condition, respectively; a causal unit, used to identify the composition of the original ending in the tag sequence and determine the causal content in the original ending related to the original condition.
[0008] In some embodiments of the present application, based on the aforementioned scheme, the causal unit is configured as follows: based on a preset fully connected network, fully connecting the original ending in the text sequence to generate a vector corresponding to the original ending; performing logistic regression processing on the vector to determine the probability distribution of the words in the original ending corresponding to the causal content; based on the probability distribution, determining the causal content from the words in the original ending.
[0009] In some embodiments of the present application, based on the aforementioned scheme, the text content derivation device further includes: a sample acquisition unit, used to acquire a first text content sample and a second text content sample, wherein the first ending in the first text content sample and the second ending in the second text content sample have the same background content, and the background content includes content that is unrelated to the original condition in the text content sample; a sequence unit, used to generate a first sequence based on the first text content sample and a second sequence based on the second text content sample; a prediction unit, used to identify the first ending in the first sequence and the second ending in the first sequence respectively through a preset fully connected network, and determine the predicted background content and predicted causal content therein; a comparison unit, used to compare the first ending with the second ending to determine the actual background content and the actual causal content; an updating unit, used to update the parameters of the fully connected network based on a first comparison result between the predicted background content and the actual background content, and a second comparison result between the predicted causal content and the actual causal content, wherein the fully connected network is used to identify the composition of the original ending in the tag sequence and determine the causal content in the original ending that is related to the original condition.
[0010] In some embodiments of the present application, based on the aforementioned scheme, the updating unit is used to: compare the predicted background content with the actual background content to generate the first comparison result; compare the predicted causal content with the actual causal content to generate the second comparison result; based on the background content weight corresponding to the first comparison result and the causal content weight corresponding to the second comparison result, weighted sum the first comparison result and the second comparison result to obtain the loss value of the fully connected network; based on the loss value of the fully connected network, update the parameters of the fully connected network.
[0011] In some embodiments of the present application, based on the aforementioned scheme, the framework unit is used to: replace the causal content in the original ending by setting an identifier, and determine the ending frame of the text structure representing the original ending.
[0012] In some embodiments of the present application, based on the aforementioned scheme, the ending unit includes: an identification unit, used to obtain text identifiers corresponding to the premise, the counterfactual condition, and the ending frame respectively; an encoding unit, used to encode the premise, the counterfactual condition, and the ending frame based on the text identifiers corresponding to the premise, the counterfactual condition, and the ending frame respectively, to obtain derived text content corresponding to the derived text sequence; a decoding unit, used to decode the derived text content based on a decoder to generate a counterfactual ending corresponding to the original ending.
[0013] In some embodiments of the present application, based on the aforementioned scheme, the decoding unit is configured to: decode the derived text content based on the decoder to generate the candidate causal content corresponding to the counterfactual condition in the ending frame of the derived text sequence; determine the distribution probability corresponding to the candidate causal content based on the correspondence between the counterfactual condition and the candidate causal content; select the derived causal content from the candidate causal content based on the distribution probability; merge the derived causal content and the ending frame to generate a counterfactual ending relative to the original ending.
[0014] In some embodiments of the present application, based on the aforementioned scheme, the text content derivation device is also used to: obtain sequence samples to be trained and actual counterfactual endings corresponding to the sequence samples; decode the sequence samples based on a set decoder to generate predicted counterfactual endings corresponding to the sequence samples; determine the loss function of the decoder based on the comparison result between the actual counterfactual ending and the predicted counterfactual ending; and update the parameters in the decoder based on the loss function.
[0015] In some embodiments of the present application, based on the aforementioned scheme, the text content derivation device is also used to: compare the derived text content with the original text content to determine the target text part of the derived text content that has changed on the basis of the original text content; display the derived text content and the target text part therein in an interface based on a set display method; and modify the derived text content in response to a modification instruction triggered for the target text part.
[0016] In some embodiments of the present application, based on the aforementioned scheme, the original text content includes speech text corresponding to the speech audio; the derivation device of the text content is also used to: perform audio conversion on the derived text generated based on the speech text to generate a derived speech audio corresponding to the derived text; based on the identification of the speech audio, store the derived speech audio in a corpus.
[0017] In some embodiments of the present application, based on the aforementioned scheme, the original text content includes voice text corresponding to the voice audio; the derivative device of the text content is also used to: obtain the premise sentence triggered by the user; match the premise sentence with the voice audio in the corpus to determine the target voice audio corresponding to the premise sentence; use the target voice audio as the reply sentence corresponding to the premise sentence, and play the reply sentence.
[0018] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for deriving text content as described in the above embodiment is implemented.
[0019] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to implement the text content deriving method as described in the above embodiments.
[0020] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the text content derivation method provided in the above-mentioned various optional implementations.
[0021] In the technical solutions provided in some embodiments of the present application, based on the counterfactual conditions corresponding to the acquired original text content and the original conditions, the causal content related to the original conditions is identified from the original ending in the original text content, and then based on the original ending and the causal content therein, the ending frame of the text structure representing the original ending is determined, so as to generate a counterfactual ending corresponding to the original ending and having a logical relationship with the causal content based on the sequence composed of the premise, the counterfactual conditions and the ending frame. The counterfactual ending generated in this embodiment is generated based on the causal content in the original text content on the basis of the original ending. On the premise that the causal content is consistent with the original text content, the generated counterfactual ending is more in line with the causal logic, thereby increasing the fluency of expression.
[0022] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0024] Figure 1 A schematic diagram showing an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied;
[0025] Figure 2 A system for implementing text content derivation according to an embodiment of the present application is schematically shown;
[0026] Figure 3 A flowchart schematically shows a method for deriving text content according to an embodiment of the present application;
[0027] Figure 4 A schematic diagram schematically shows the composition of an original text according to an embodiment of the present application;
[0028] Figure 5 A schematic diagram schematically shows a composition structure of an original text according to an embodiment of the present application;
[0029] Figure 6 A schematic diagram schematically shows a method of identifying causal content from original text according to an embodiment of the present application;
[0030] Figure 7 A schematic diagram of generating an ending frame according to an embodiment of the present application is schematically shown;
[0031] Figure 8 A flowchart for identifying causal content from original text according to an embodiment of the present application is schematically shown;
[0032] Fig. 9 A schematic diagram of generating an ending frame based on a fully connected network according to an embodiment of the present application is schematically shown;
[0033] Fig.10 Schematically shows a flowchart of training a fully connected network according to an embodiment of the present application;
[0034] Fig.11 A schematic diagram of training a fully connected network according to an embodiment of the present application is schematically shown;
[0035] Fig.12 Schematically shows a flow chart of generating a counterfactual ending according to an embodiment of the present application;
[0036] Fig.13 A schematic diagram of generating a counterfactual ending according to an embodiment of the present application is schematically shown;
[0037] Fig.14 A schematic diagram showing a comparison between an original text and a derived text according to an embodiment of the present application is shown;
[0038] Fig.15 A schematic diagram of visualization of a derived text according to an embodiment of the present application is schematically shown;
[0039] Fig.16 A schematic diagram of generating a corpus according to an embodiment of the present application is schematically shown;
[0040] Fig.17 A block diagram schematically shows a device for deriving text content according to an embodiment of the present application;
[0041] Fig.18 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0042] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0043] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0044] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0045] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0046] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. Artificial intelligence software technology mainly includes several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0047] The key technologies of speech technology include automatic speech recognition technology (ASR), speech synthesis technology (TTS) and voiceprint recognition technology. Enabling computers to listen, see, speak and feel is the development direction of human-computer interaction in the future, among which speech has become one of the most promising ways of human-computer interaction in the future. Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0048] In the embodiments of the present application, the original text content can be processed based on speech technology and natural language processing technology to obtain a derivative text corresponding to the original text content, for example, a related derivative story can be generated based on the original story, or a related derivative speech can be generated based on the original speech, and so on.
[0049] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.
[0050] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0051] The solution provided in the embodiments of the present application involves artificial intelligence speech technology, natural language processing, and machine learning technologies, which are specifically described through the following embodiments:
[0052] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown.
[0053] like Figure 1 As shown, the system architecture may include terminal devices (such as Figure 1 The embodiment of the present invention is a network 104 and a server 105. The network 104 is a medium for providing a communication link between the terminal device and the server 105. The network 104 may include various connection types, such as a wired communication link, a wireless communication link, etc.
[0054] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.
[0055] The user can use the terminal device to interact with the server 105 through the network 104 to receive or send messages, etc. The server 105 can be a server that provides various services. For example, the user uploads the original text content and the counterfactual ending corresponding to the original ending in the original text content to the server 105 using the terminal device. The server 105 obtains the original text content, and based on the original text content and the counterfactual condition corresponding to the original condition, identifies the causal content related to the original condition from the original ending; based on the original ending and the causal content in the original ending, determines the ending frame of the text structure representing the original ending; based on the sequence consisting of the premise, the counterfactual condition and the ending frame, generates the counterfactual ending corresponding to the original ending.
[0056] The above scheme, based on the acquired original text content and the counterfactual conditions corresponding to the original conditions, identifies the causal content related to the original conditions from the original ending in the original text content, and then determines the ending frame of the text structure representing the original ending based on the original ending and the causal content therein, so as to generate a counterfactual ending corresponding to the original ending and having a logical relationship with the causal content based on the sequence composed of the premise, the counterfactual conditions and the ending frame. The counterfactual ending generated in this embodiment is generated based on the causal content in the original text content on the basis of the original ending. On the premise that the causal content is consistent with the original text content, the generated counterfactual ending is more in line with the causal logic, thereby increasing the fluency of expression.
[0057] It should be noted that the text content derivation method provided in the embodiment of the present application is generally executed by the server 105, and accordingly, the text content derivation device is generally set in the server 105. However, in other embodiments of the present application, the terminal device may also have similar functions as the server, so as to execute the text content derivation scheme provided in the embodiment of the present application.
[0058] Figure 2 A system for implementing text content derivation is provided in an embodiment of the present application.
[0059] like Figure 2As shown, the mobile phone 206 is the execution subject, wherein the portable computer 201, the tablet computer 202, the server 203, and the cloud platform 205 are all used to store the original text content, or to store the derivative text generated based on the original text content. In this embodiment, the mobile phone 206 can obtain the original text content from the portable computer 201, the tablet computer 202, or the server 203 through the network 204, and based on the original text content and the counterfactual condition corresponding to the original condition, identify the causal content related to the original condition from the original ending; based on the original ending and the causal content in the original ending, determine the ending frame of the text structure representing the original ending; based on the sequence composed of the premise, the counterfactual condition, and the ending frame, generate the counterfactual ending corresponding to the original ending.
[0060] The implementation details of the technical solution of the embodiment of the present application are described in detail below:
[0061] Figure 3 A flowchart of a method for deriving text content according to an embodiment of the present application is shown. The method for deriving text content can be executed by a server, which can be Figure 3 Refer to the server shown in Figure 3 As shown, the text content derivation method at least includes steps S310 to S340, which are described in detail as follows:
[0062] In step S310, the original text content is obtained, and the original text content includes a premise, an original condition, and an original ending.
[0063] In one embodiment of the present application, the original text content is first obtained. The original text content in the embodiment of the present application includes the premise, the original condition and the original ending. In addition, it can also include information such as modified attributes and identifiers of the original text content.
[0064] For example, Figure 4 and Figure 5 As shown, the original text content in this embodiment includes premise, original condition and original ending. Among them, the premise is "Mary likes flowers", the original condition is "One day she went to the park", and the original ending is "She happily smelled the fragrance of the flowers in the field. She picked some flowers and took them home. She put the flowers in a vase with water." Furthermore, in order to reflect the causal relationship in the original text content in the embodiment of the present application, in the original condition, "park" is the keyword in the original condition, and "field" and "pick" are the keywords in the original ending. In this way, the correlation between the text content and the text logic are reflected.
[0065] In step S320, based on the original text content and the counterfactual condition corresponding to the original condition, causal content related to the original condition is identified from the original ending.
[0066] In one embodiment of the present application, after the original text content is obtained, based on the premise, original condition and original ending in the original text content, and the counterfactual condition corresponding to the original condition, the causal content related to the original condition is identified from the original ending.
[0067] Specifically, the counterfactual condition in this embodiment is used to represent a condition corresponding to the original condition. For example, some elements in the counterfactual condition are different from those in the original condition, or other language elements are different, and so on.
[0068] For example, the original condition is "one day she went to the park", and its corresponding counterfactual condition is "one day she went to the flower shop". The counterfactual condition in this embodiment can be directly obtained or generated based on the original condition. The specific generation process is to determine the replaceable elements from the original condition, replace the replaceable elements with other alternative elements, and then obtain the anti-causal condition.
[0069] Specifically, in this embodiment, when identifying causal content from the original ending, predictions can be made based on the premises, original conditions, original endings, and counterfactual conditions in the original text content, and then the causal content in the original ending can be determined, which facilitates the subsequent generation of a structure for determining the ending based on the causal content, thereby improving the logical correlation between the ending and the conditions.
[0070] like Figure 6 As shown, the original text content obtained in this embodiment is: "Mary likes flowers, and one day she went to the park. She happily smelled the fragrance of the flowers in the field. She picked some flowers and took them home. She put the flowers in a vase with water." It includes premise p: the premise is "Mary likes flowers", the original condition is "One day she went to the park", and the original ending is "She happily smelled the fragrance of the flowers in the field. She picked some flowers and took them home. She put the flowers in a vase with water." Combined with the counterfactual condition "One day she went to the flower shop", it can be determined that the causal content in the original ending is "field, pick".
[0071] In step S330, based on the original ending and the causal content in the original ending, an ending frame representing the text structure of the original ending is determined.
[0072] In one embodiment of the present application, after the causal content in the original ending is determined, the causal content in the original ending is deleted, or the causal content is replaced by other set identifiers to determine the ending frame of the text structure representing the original ending.
[0073] In one embodiment of the present application, the causal content in the original ending can be replaced by setting a mark to determine the ending frame of the text structure representing the original ending. The set mark can be a space, a carriage return, etc., or other character marks, etc.
[0074] like Figure 7 As shown in the figure, after determining that the causal content in the original ending is "field, picking", the causal content is replaced by a space. After that, the ending frame corresponding to the original ending is "She happily sniffed the fragrance of the flowers in ___. She __ some flowers and took them home. She put the flowers in a vase with water."
[0075] By using the above-mentioned method of generating the ending frame, a fixed ending content in the original text content can be obtained, and then a derivative ending related to the original text content can be obtained based on the ending frame.
[0076] In step S340, based on the sequence of premise, counterfactual condition and ending frame, a counterfactual ending corresponding to the original ending is generated.
[0077] In one embodiment of the present application, after generating the ending frame of the original ending, the sequence consisting of the premise, counterfactual condition and ending frame is encoded to generate an encoding sequence of the derivative text corresponding to the original text content, that is, the derivative text corresponding to the original text content. The derivative text in this embodiment is used to represent text related to the original text content, and the derivative text can be used as corpus information of the database, etc.; then decoding is performed based on the encoding sequence to generate the counterfactual ending corresponding to the original ending.
[0078] The counterfactual ending in this embodiment is generated based on the ending frame of the original ending, and is related to the original ending content, but different from the original ending. By generating a counterfactual ending corresponding to the original ending based on the premise, counterfactual condition and ending frame, the obtained counterfactual ending is more consistent with the logic of the original text content, thereby enhancing the readability of the text content.
[0079] The above scheme, based on the acquired original text content and the counterfactual conditions corresponding to the original conditions, identifies the causal content related to the original conditions from the original ending in the original text content, and then determines the ending frame of the text structure representing the original ending based on the original ending and the causal content therein, so as to generate a counterfactual ending corresponding to the original ending and having a logical relationship with the causal content based on the sequence composed of the premise, the counterfactual conditions and the ending frame. The counterfactual ending generated in this embodiment is generated based on the causal content in the original text content on the basis of the original ending. On the premise that the causal content is consistent with the original text content, the generated counterfactual ending is more in line with the causal logic, thereby increasing the fluency of expression.
[0080] In one embodiment of the present application, the process of generating a counterfactual ending based on the original text content and the counterfactual conditions corresponding to the original conditions is divided into two stages: the skeleton stage Sketch and the reformed stage Customize. Among them, in the Sketch stage, sequence annotation is performed based on the reformed bidirectional encoder representation (Bidirectional Encoder Representationsfrom Transformers, BERT) to predict which words in the original ending are causal content and which are background content. After replacing the causal content with spaces, the ending framework is obtained. In the Customize stage, the premise, counterfactual conditions and ending framework are used as input, and the generative pre-training model (Generative Pre-Training 2, GPT-2) is used to generate the counterfactual story ending. The specific instructions are as follows:
[0081] In one embodiment of the present application, the process of identifying the causal content related to the original condition from the original ending based on the original text content and the counterfactual condition corresponding to the original condition in step S320 includes steps S3210 to S3230, which are described in detail as follows:
[0082] Step S3210, formatting the original text content to generate a text sequence corresponding to the original text content;
[0083] Step S3220, adding a set text identifier to the positions corresponding to the premise, the original condition, the original ending, and the counterfactual condition corresponding to the original condition in the text sequence, to generate a tag sequence; wherein the text identifier is used to represent the attribute information corresponding to the premise, the original condition, the original ending, and the counterfactual condition respectively;
[0084] Step S3230, identifying the composition of the original ending in the tag sequence, and determining the causal content in the original ending that is related to the original condition.
[0085] The ending of a story can be divided into two parts, background content and causal content, which are related to the premise and condition of the story respectively. Distinguishing between background content and causal content is the goal of this stage. In order to extract an appropriate ending framework, it is modeled as a sequence labeling task, where each word in the story ending has a label to indicate whether it is background content or causal content. With the help of pre-trained BERT, rich contextual information can be included for each word. With BERT as the basic structure and initial model, the premise p, condition c, counterfactual condition c' and story ending e are connected as the input context, and predict which words in the story ending are causal words.
[0086] Furthermore, after obtaining the causal content, the original BERT can be fine-tuned by applying classification tasks to each word in the causal content to make the BERT model more accurate.
[0087] Specifically, Fig. 9 As shown, the Sketch stage in this embodiment includes three steps: input formatting, sequence tagging, and expression. Among them, the input formatting step is used to convert the original text content into an input sequence. In order to help BERT distinguish different parts of the story, some set text identifiers are added between them, marked as [·]. For example, [PRE] represents the premise, [CON1] represents the original text condition, [CON2] represents the counterfactual condition, and represents the original ending. Therefore, the obtained tag sequence can be expressed as S = {[PRE]p[CON1]c[CON2]c' e}, where p, c, c', e correspond to specific text content respectively. For the expression step, the input sequence S is input into the BERT model to obtain the last layer expression R = {r1, ···, rNr}, where ri represents the i-th word in the input sequence, and Nr represents the length of the input sequence.
[0088] In one embodiment of the present application, Fig.10 As shown, the text content derivation method also includes a training process for a fully connected network, which mainly includes the following steps S3240 to S3280, which are described in detail as follows:
[0089] Step S3240, obtaining a first text content sample and a second text content sample, wherein a first ending in the first text content sample and a second ending in the second text content sample have the same background content, and the background content includes content that is irrelevant to original conditions in the text content samples;
[0090] Step S3250, generating a first sequence based on the first text content sample, and generating a second sequence based on the second text content sample;
[0091] Step S3260, identifying the first ending in the first sequence and the second ending in the first sequence respectively through a preset fully connected network, and determining the predicted background content and the predicted causal content therein;
[0092] Step S3270, comparing the first ending with the second ending to determine the actual background content and the actual cause and effect content;
[0093] Step S3280, based on the first comparison result between the predicted background content and the actual background content, and the second comparison result between the predicted causal content and the actual causal content, update the parameters of the fully connected network.
[0094] In the embodiment of the present application, in the process of training the fully connected network, the first text content sample and the second text content sample are first obtained, wherein the first ending in the first text content sample and the second ending in the second text content sample have the same background content, and the background content includes content that is unrelated to the original condition in the text content sample, and then a first sequence is generated based on the first text content sample, and a second sequence is generated based on the second text content sample, wherein an original ending and a counterfactual ending pair {e, e'} are respectively included, and the skeleton can be approximately represented by using the longest common subsequence between them. The largest common part of the two endings is regarded as the background content e_bg, and the rest of each ending is regarded as the causal content of the original ending (e_causal) and the counterfactual ending (e'_causal), respectively. In this way, the labels of each word in the two endings can be obtained, and they are used to train the model in the Sketch stage, and the predicted background content and predicted causal content in the ending are predicted, and then the parameters of the fully connected network will be updated based on the first comparison result between the predicted background content and the actual background content, and the second comparison result between the predicted causal content and the actual causal content.
[0095] Specifically, in step S3280, based on the first comparison result between the predicted background content and the actual background content, and the second comparison result between the predicted causal content and the actual causal content, the process of updating the parameters of the fully connected network specifically includes: comparing the predicted background content with the actual background content to generate a first comparison result; comparing the predicted causal content with the actual causal content to generate a second comparison result; based on the background content weight corresponding to the first comparison result and the causal content weight corresponding to the second comparison result, taking the weighted sum of the first comparison result and the second comparison result to obtain the loss value of the fully connected network; based on the loss value of the fully connected network, updating the parameters of the fully connected network.
[0096] like Fig.11As shown, in this embodiment, in the Sketch stage, after the original ending is identified, the causal words in the identified causal content are marked as 0, the background words in the background content are marked as 1, and each word in the story ending has its corresponding label. Then, taking the original story as an example, the premise p, conditions c and c', and the original ending e are used as the input sequence of BERT for the sequence labeling task. In the counterfactual story generation task, in order to minimize the changes during data labeling, the causal words obtained are much fewer than the background words. Therefore, a weighted cross entropy loss is adopted, and a larger weight is assigned to the causal words to overcome the data imbalance problem. The specific formula for calculating the loss value is as follows:
[0097]
[0098] Among them, Ne~Nr represents the length of the original end, λ is the weight controlling the loss of the two types of labels; log p1(l i =0|S) and log p1(l i =1|S) Each word in the original ending corresponds to the probability distribution of the causal content. In this embodiment, by calculating the loss value in the above manner, the distribution of the causal content and the background content can be balanced, and the training accuracy of the fully connected network can be improved.
[0099] In step S3230, the composition of the original ending in the tag sequence is identified to determine the causal content related to the original condition in the original ending, including steps S3231 to S3233, which are described in detail as follows:
[0100] Step S3231, based on a preset fully connected network, fully connect the original endings in the text sequence to generate a vector corresponding to the original endings;
[0101] Step S3232, performing logistic regression processing on the vector to determine the probability distribution of the words in the original ending corresponding to the causal content;
[0102] Step S3233, based on the probability distribution, determine the causal content from the original ending words.
[0103] In one embodiment of the present application, in the sequence labeling step, only the original ending part is input into a fully connected layer, which projects each expression into a two-dimensional vector. In addition, a logistic regression function, such as a softmax function, is applied to obtain the probability distribution of each word in the original ending corresponding to the causal content:
[0104] p1(l i |S)=softmax(Wr i +b)
[0105] Among them, Wr iand b are the trainable parameters of the fully connected layer, and S represents the original text;
[0106]
[0107] Among them, Ne represents the starting word index of the story ending e, and e_causal represents the set of causal word indices in the original ending. Since the original ending and the counterfactual ending are symmetrical, they can be interchanged and the counterfactual condition and ending can be used as the original ending, thus doubling the training examples and enhancing the training effect.
[0108] The process of generating a counterfactual ending corresponding to the original ending based on the sequence of premise, counterfactual condition and ending frame in step S340 specifically includes steps S3410 to S3430:
[0109] Step S3410, obtaining text identifiers corresponding to the premise, counterfactual condition, and ending frame respectively;
[0110] Step S3420, encoding the premise, the counterfactual condition, and the ending frame based on the text identifiers corresponding to the premise, the counterfactual condition, and the ending frame, to obtain the derived text content corresponding to the derived text sequence;
[0111] Step S3430, decoding the derived text content based on the decoder to generate a counterfactual ending corresponding to the original ending.
[0112] like Fig.13 As shown, in the Customize stage of this embodiment, the fill-in-the-blank task is completed based on the ending skeleton k to generate a counterfactual ending consistent with the counterfactual condition. In this embodiment, the text identifiers corresponding to the premise, counterfactual condition, and ending frame are obtained, namely [PRE], [CON], and [SKE]; then, based on the text identifiers corresponding to the premise, counterfactual condition, and ending frame, the premise, counterfactual condition, and ending frame are encoded to obtain the derived text content corresponding to the derived text sequence, that is, the premise p, counterfactual condition c' and skeleton k are connected in series and separated by special marks. The resulting derived text sequence is {[PRE]p[CON]c'[SKE]k}, and the concatenated content is used as the input sequence of the GPT2 model, and its target is the true counterfactual ending e'. Finally, the derived text content is decoded based on the decoder to generate the counterfactual ending corresponding to the original ending.
[0113] Specifically, in step S3430, the derived text content is decoded based on the decoder to generate the counterfactual ending corresponding to the derived text sequence, including steps S3431 to S3434, which are described in detail as follows:
[0114] Step S3431: Decode the derivative text content based on the decoder to generate candidate causal content corresponding to the counterfactual condition in the ending frame of the derivative text sequence;
[0115] Step S3432: Determine the distribution probability corresponding to the candidate causal content based on the correspondence between the counterfactual condition and the candidate causal content;
[0116] Step S3433: Select derivative causal content from the candidate causal content based on the distribution probability;
[0117] Step S3434: Combine the derivative causal content and the ending frame to generate a counterfactual ending relative to the original ending.
[0118] In this embodiment, the symbol in the derivative sequence can be regarded as the start symbol of the decoding process. Then, through the GPT2 model, based on the correspondence between the counterfactual condition and the candidate causal content, the distribution probability corresponding to the candidate causal content is determined as:
[0119] p2(y t |x,y<t)=GPT2(x,y<t)
[0120] Among them, y_t is used to represent the t-th word in the original ending e_t or the counterfactual ending e'_t, y<t represents the words between the text identifier and the t-th word, x represents the word before the text identifier , and GPT2(z) is a function that obtains the distribution of the current step output of GPT2 with z as the input. The distribution probability is calculated in the above manner, and then the derivative causal content corresponding to the larger or largest distribution probability is selected. Finally, the derivative causal content and the ending frame are combined to generate a counterfactual ending relative to the original ending, improving the relevance between the counterfactual ending and the counterfactual cause and effect.
[0121] Furthermore, the specific process of training the decoder in this embodiment is as follows: Obtain the sequence samples to be trained and the actual counterfactual endings corresponding to the sequence samples; Decode the sequence samples based on the set decoder to generate predicted counterfactual endings corresponding to the sequence samples; Determine the loss function of the decoder based on the comparison result between the actual counterfactual ending and the predicted counterfactual ending; Update the parameters in the decoder based on the loss function.
[0122] Specifically, during the training process, two training instances are constructed for a pair of original and counterfactual stories, such as {[PRE]p[CON]c'[SKE]k} for generating the counterfactual ending e', and {{PRE]p[CON]c[SKE]k} for generating the original ending e. At this stage, [CON] is used to mark the original and counterfactual conditions, and is used to mark the original and counterfactual endings. In this way, the GPT2 model can learn to copy background words from the skeleton, and then generate appropriate words in the air under the guidance of one condition without being disturbed by another condition.
[0123] When calculating the loss in the Customize stage, it is calculated using the following formula:
[0124]
[0125] Among them, e′ t is the tth word at the end of the counterfactual, e′ <t represents the word before the tth word, and m is the length of the counterfactual word.
[0126] In this embodiment, the causal structure in the original story and the counterfactual story is used to divide the original ending into causal content and background content. When the conditions change, the part of the ending that remains unchanged is called background content, and the part that changes with the conditions is called causal content. The two-stage counterfactual story generation model proposed in the present invention removes the causal content in the original ending through BERT sequence annotation in the first stage to obtain the ending framework (background content), and fills the skeleton based on the counterfactual conditions through GPT-2 in the second stage to obtain a complete counterfactual story ending.
[0127] like Fig.14 As shown, in this embodiment, a derivative text similar to the original story, i.e., a counterfactual story, is generated based on the information in the original story in the above manner. The counterfactual story includes the premise and ending framework of the original story, but changes the counterfactual conditions in the original story, and generates its corresponding counterfactual ending based on the counterfactual conditions. The causal relationship between the premise, conditions, and ending of the story is used to extract the ending framework in the first stage, and the skeleton is filled in the second stage based on the counterfactual conditions, which effectively avoids the problem that the existing method easily copies the original story ending and causes inconsistency, improves the consistency and logical relevance of the generated counterfactual ending and the counterfactual conditions, and increases the coherence and fluency of the counterfactual story.
[0128] like Fig.15As shown, in this embodiment, after the derived text content is generated, the derived text content can be compared with the original text content to determine the target text part of the derived text content that has changed based on the original text content; based on the set display method, the derived text content and the target text part therein are displayed in the interface; in response to the modification instruction triggered for the target text part, the derived text content is modified.
[0129] The set display mode may be to bold or display the changed target text portion in other colors.
[0130] The above scheme can avoid errors or ambiguities in the generated derivative text by adding a human modification process, thereby increasing the accuracy and readability of the derived text through human modification.
[0131] like Fig.16 As shown, the original text content in this embodiment includes speech text corresponding to speech audio, and at least one derivative text is generated based on the speech text, and the derived text generated based on the speech text is converted into audio to generate a derived speech audio corresponding to the derived text; after compressing at least one derived speech audio, the derived speech audio is stored in a corpus based on the identification of the speech audio.
[0132] In the application scenario of intelligent question and answer, first obtain the premise sentence triggered by the user; match the premise sentence with the voice audio in the corpus to determine the target voice audio corresponding to the premise sentence; use the target voice audio as the reply sentence corresponding to the premise sentence and play the reply sentence. In this way, intelligent question and answer can be performed based on a pre-built corpus containing rich voice text, thereby improving the application rate of text data and voice data.
[0133] The following describes an apparatus embodiment of the present application, which can be used to execute the method for deriving text content in the above-mentioned embodiment of the present application. It is understandable that the apparatus can be a computer program (including program code) running in a computer device, for example, the apparatus is an application software; the apparatus can be used to execute the corresponding steps in the method provided in the embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the embodiment of the method for deriving text content described above in the present application.
[0134] Fig.17 A block diagram of a device for deriving text content according to an embodiment of the present application is shown.
[0135] Reference Fig.17As shown, according to an embodiment of the present application, a text content derivation device 1700 includes: an acquisition unit 1710, used to acquire original text content, wherein the original text content includes a premise, an original condition, and an original ending; an identification unit 1720, used to identify causal content related to the original condition from the original ending based on the original text content and the counterfactual condition corresponding to the original condition; a framework unit 1730, used to determine an ending framework of the text structure representing the original ending based on the original ending and the causal content in the original ending; an ending unit 1740, used to generate a counterfactual ending corresponding to the original ending based on a sequence consisting of the premise, the counterfactual condition, and the ending framework.
[0136] In some embodiments of the present application, based on the above solution, the identification unit 1720 includes:
[0137] A format unit, used for formatting the original text content to generate a text sequence corresponding to the original text content; an identification unit, used for adding set text identifiers at positions corresponding to the premise, the original condition, the original ending and the counterfactual condition corresponding to the original condition in the text sequence, to generate a tag sequence; wherein the text identifier is used to represent the attribute information corresponding to the premise, the original condition, the original ending and the counterfactual condition respectively; a causal unit, used for identifying the composition of the original ending in the tag sequence, and determining the causal content in the original ending related to the original condition.
[0138] In some embodiments of the present application, based on the aforementioned scheme, the causal unit is configured as follows: based on a preset fully connected network, fully connecting the original ending in the text sequence to generate a vector corresponding to the original ending; performing logistic regression processing on the vector to determine the probability distribution of the words in the original ending corresponding to the causal content; based on the probability distribution, determining the causal content from the words in the original ending.
[0139] In some embodiments of the present application, based on the aforementioned scheme, the text content derivation device 1700 further includes: a sample acquisition unit, used to acquire a first text content sample and a second text content sample, wherein the first ending in the first text content sample and the second ending in the second text content sample have the same background content, and the background content includes content that is unrelated to the original conditions in the text content sample; a sequence unit, used to generate a first sequence based on the first text content sample and a second sequence based on the second text content sample; a prediction unit, used to identify the first ending in the first sequence and the second ending in the first sequence respectively through a preset fully connected network, and determine the predicted background content and predicted causal content therein; a comparison unit, used to compare the first ending with the second ending to determine the actual background content and the actual causal content; an updating unit, used to update the parameters of the fully connected network based on a first comparison result between the predicted background content and the actual background content, and a second comparison result between the predicted causal content and the actual causal content.
[0140] In some embodiments of the present application, based on the aforementioned scheme, the updating unit is used to: compare the predicted background content with the actual background content to generate the first comparison result; compare the predicted causal content with the actual causal content to generate the second comparison result; based on the background content weight corresponding to the first comparison result and the causal content weight corresponding to the second comparison result, weighted sum the first comparison result and the second comparison result to obtain the loss value of the fully connected network; based on the loss value of the fully connected network, update the parameters of the fully connected network.
[0141] In some embodiments of the present application, based on the aforementioned scheme, the framework unit 1730 is used to: replace the causal content in the original ending by setting an identifier, and determine the ending frame of the text structure representing the original ending.
[0142] In some embodiments of the present application, based on the aforementioned scheme, the ending unit 1740 includes: an identification unit, used to obtain text identifiers corresponding to the premise, the counterfactual condition, and the ending frame respectively; an encoding unit, used to encode the premise, the counterfactual condition, and the ending frame based on the text identifiers corresponding to the premise, the counterfactual condition, and the ending frame respectively, to obtain derived text content corresponding to the derived text sequence; a decoding unit, used to decode the derived text content based on a decoder to generate a counterfactual ending corresponding to the original ending.
[0143] In some embodiments of the present application, based on the aforementioned scheme, the decoding unit configuration 1700 is: based on the decoder, the derived text content is decoded to generate the candidate causal content corresponding to the counterfactual condition in the ending frame of the derived text sequence; based on the correspondence between the counterfactual condition and the candidate causal content, the distribution probability corresponding to the candidate causal content is determined; based on the distribution probability, the derived causal content is selected from the candidate causal content; the derived causal content and the ending frame are merged to generate a counterfactual ending relative to the original ending.
[0144] In some embodiments of the present application, based on the aforementioned scheme, the text content derivation device 1700 is also used to: obtain sequence samples to be trained and actual counterfactual endings corresponding to the sequence samples; decode the sequence samples based on a set decoder to generate predicted counterfactual endings corresponding to the sequence samples; determine the loss function of the decoder based on the comparison result between the actual counterfactual ending and the predicted counterfactual ending; and update the parameters in the decoder based on the loss function.
[0145] In some embodiments of the present application, based on the aforementioned scheme, the text content derivation device 1700 is also used to: compare the derived text content with the original text content to determine the target text part of the derived text content that has changed on the basis of the original text content; display the derived text content and the target text part therein in the interface based on the set display method; and modify the derived text content in response to a modification instruction triggered for the target text part.
[0146] In some embodiments of the present application, based on the aforementioned scheme, the original text content includes speech text corresponding to the speech audio; the derivation device of the text content is also used to: perform audio conversion on the derived text generated based on the speech text to generate a derived speech audio corresponding to the derived text; based on the identification of the speech audio, store the derived speech audio in a corpus.
[0147] In some embodiments of the present application, based on the aforementioned scheme, the original text content includes voice text corresponding to the voice audio; the derivative device of the text content is also used to: obtain the premise sentence triggered by the user; match the premise sentence with the voice audio in the corpus to determine the target voice audio corresponding to the premise sentence; use the target voice audio as the reply sentence corresponding to the premise sentence, and play the reply sentence.
[0148] Fig.18 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0149] It should be noted that Fig.18 The computer system 1800 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0150] like Fig.18 As shown, the computer system 1800 includes a central processing unit (CPU) 1801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1802 or the program loaded from the storage part 1808 to the random access memory (RAM) 1803, such as executing the method described in the above embodiment. In RAM 1803, various programs and data required for system operation are also stored. CPU 1801, ROM 1802 and RAM 1803 are connected to each other through bus 1804. Input / output (I / O) interface 1805 is also connected to bus 1804.
[0151] The following components are connected to the I / O interface 1805: an input section 1806 including a keyboard, a mouse, etc.; an output section 1807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1808 including a hard disk, etc.; and a communication section 1809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1809 performs communication processing via a network such as the Internet. A drive 1810 is also connected to the I / O interface 1805 as needed. A removable medium 1811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1810 as needed so that a computer program read therefrom is installed into the storage section 1808 as needed.
[0152] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1809, and / or installed from a removable medium 1811. When the computer program is executed by a central processing unit (CPU) 1801, various functions defined in the system of the present application are executed.
[0153] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0154] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the 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 box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession 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 box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0155] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0156] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the above-mentioned various optional implementations.
[0157] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.
[0158] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0159] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0160] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0161] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for deriving text content, characterized in that: include: Obtaining original text content, wherein the original text content includes premise, original condition, and original ending; Formatting the original text content to generate a text sequence corresponding to the original text content; Adding set text identifiers at positions corresponding to the premise, the original condition, the original ending, and the counterfactual condition corresponding to the original condition in the text sequence to generate a tag sequence; wherein the text identifier is used to represent the attribute information corresponding to the premise, the original condition, the original ending, and the counterfactual condition respectively; Identifying the composition of the original ending in the tag sequence and determining the causal content in the original ending related to the original condition; The causal content in the original ending is replaced by setting a marker to determine an ending frame of the text structure representing the original ending; Obtaining text identifiers corresponding to the premise, the counterfactual condition, and the ending frame respectively; Based on the text identifiers corresponding to the premise, the counterfactual condition, and the ending frame, respectively, the premise, the counterfactual condition, and the ending frame are encoded to obtain the derived text content corresponding to the derived text sequence; The derived text content is decoded based on a decoder to generate a counterfactual ending corresponding to the original ending.
2. The method according to claim 1, characterized in that Identifying the composition of the original ending in the tag sequence and determining the causal content in the original ending related to the original condition includes: Based on a preset fully connected network, fully connect the original endings in the text sequence to generate a vector corresponding to the original endings; Performing logistic regression on the vector to determine the probability distribution of the words in the original ending corresponding to the causal content; Based on the probability distribution, the causal content is determined from the original ending words.
3. The method according to claim 1, characterized in that The method further comprises: Acquire a first text content sample and a second text content sample, wherein a first ending in the first text content sample and a second ending in the second text content sample have the same background content, and the background content includes content that is unrelated to original conditions in the text content samples; generating a first sequence based on the first text content sample, and generating a second sequence based on the second text content sample; Recognize the first ending in the first sequence and the second ending in the first sequence respectively through a preset fully connected network to determine the predicted background content and the predicted causal content therein; Compare the first ending with the second ending to determine the actual background content and the actual cause and effect content; Based on a first comparison result between the predicted background content and the actual background content, and a second comparison result between the predicted causal content and the actual causal content, the parameters of the fully connected network are updated, and the fully connected network is used to identify the composition of the original ending in the tag sequence and determine the causal content in the original ending that is related to the original condition.
4. The method according to claim 3, characterized in that Based on a first comparison result between the predicted background content and the actual background content, and a second comparison result between the predicted causal content and the actual causal content, updating parameters of the fully connected network includes: Comparing the predicted background content with the actual background content to generate the first comparison result; Comparing the predicted causal content with the actual causal content to generate the second comparison result; Based on the background content weight corresponding to the first comparison result and the causal content weight corresponding to the second comparison result, a weighted sum of the first comparison result and the second comparison result is performed to obtain a loss value of the fully connected network; Based on the loss value of the fully connected network, the parameters of the fully connected network are updated.
5. The method according to claim 1, characterized in that Decoding the derived text content based on a decoder to generate a counterfactual ending corresponding to the original ending includes: Decoding the derived text content based on a decoder to generate candidate causal content corresponding to the counterfactual condition in the ending frame of the derived text sequence; Based on the correspondence between the counterfactual condition and the causal content to be selected, determining the distribution probability corresponding to the causal content to be selected; Based on the distribution probability, selecting derived causal content from the candidate causal content; The derived causal content and the ending frame are merged to generate a counterfactual ending relative to the original ending.
6. The method according to claim 5, characterized in that The method further comprises: Obtaining sequence samples to be trained and actual counterfactual endings corresponding to the sequence samples; Decoding the sequence sample based on a set decoder to generate a predicted counterfactual ending corresponding to the sequence sample; Determining a loss function of the decoder based on a comparison result between the actual counterfactual ending and the predicted counterfactual ending; Based on the loss function, parameters in the decoder are updated.
7. The method according to claim 1, characterized in that The method further comprises: Comparing the derived text content with the original text content to determine a target text portion in which the derived text content has changed based on the original text content; Based on the set display mode, the derived text content and the target text part thereof are displayed in the interface; In response to a modification instruction triggered for the target text portion, the derived text content is modified.
8. The method according to claim 1, characterized in that The original text content includes a speech text corresponding to the speech audio; the method further includes: Converting the derived text generated based on the voice text into audio to generate derived voice audio corresponding to the derived text; Based on the identification of the speech audio, the derived speech audio is stored in a corpus.
9. The method according to claim 8, characterized in that The method further comprises: Get the premise statement triggered by the user; Matching the premise sentence with the speech audio in the corpus to determine the target speech audio corresponding to the premise sentence; The target voice audio is used as a reply sentence corresponding to the premise sentence, and the reply sentence is played.
10. A text content derivative device, characterized in that: include: An acquisition unit, used to acquire original text content, wherein the original text content includes a premise, an original condition, and an original ending; The recognition unit is used to format the original text content to generate a text sequence corresponding to the original text content; add set text identifiers at positions corresponding to the premise, the original condition, the original ending, and the counterfactual condition corresponding to the original condition in the text sequence to generate a tag sequence; wherein the text identifier is used to represent the attribute information corresponding to the premise, the original condition, the original ending, and the counterfactual condition; recognize the composition of the original ending in the tag sequence, and determine the causal content related to the original condition in the original ending; A framework unit, used to replace the causal content in the original ending by setting an identifier, and determine an ending framework of the text structure representing the original ending; An ending unit is used to obtain text identifiers corresponding to the premise, the counterfactual condition, and the ending frame respectively; based on the text identifiers corresponding to the premise, the counterfactual condition, and the ending frame respectively, the premise, the counterfactual condition, and the ending frame are encoded to obtain derived text content corresponding to the derived text sequence; based on the decoder, the derived text content is decoded to generate a counterfactual ending corresponding to the original ending.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the text content deriving method according to any one of claims 1 to 9.
12. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement the text content deriving method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Court viewpoint automatic generation method guided by causality deviation removal model
CN112307726A
Method for synthesising self-learning system for knowledge acquistition for retrieval systems
CN1628298A