Oral text rewriting method and device based on anti-factual reasoning

Through a multi-level rewriting method based on counterfactual reasoning, the understanding and generation problems of the language model when dealing with colloquial problems are solved, more accurate and reliable professional text generation is achieved, and the practical application capabilities of the model are improved.

CN119558270AActive Publication Date: 2025-03-04RENMIN ZHONGKE (JINAN) INTELLIGENT TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510115591.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-03-04
Estimated Expiration
2045-01-24

AI Technical Summary

Technical Problem

When dealing with colloquialization problems, it is difficult for existing language models to accurately understand the intention of colloquial expression, resulting in the generated answers that do not match the facts or provide outdated knowledge, which affects the reliability of the model and the effectiveness of practical applications.

Method used

The colloquial text rewriting method based on counterfactual reasoning is adopted, and by constructing colloquial data sets and counterfactual reasoning models, using multi-level counterfactual modeling and loss function optimization, colloquial text is gradually rewritten, making it close to the semantics and style of professional texts.

Benefits of technology

It improves the accuracy and reliability of rewriting spoken texts, ensures that the generated professional text can more accurately reflect the user's intentions, and enhances the effectiveness of the model in practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119558270A_ABST
    Figure CN119558270A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a spoken text rewriting method and device based on anti-factual reasoning. The method comprises the following steps: constructing a spoken data set, wherein the spoken data set comprises a specialized text and a spoken text; constructing an anti-factual reasoning model, and training the anti-factual reasoning model according to a loss function of the anti-factual reasoning model by using the spoken data set to obtain a trained anti-factual reasoning model; and inputting the spoken text into the trained anti-factual reasoning model to obtain a rewritten specialized text. In this manner, rewriting of spoken text may be enabled to understand the intent of the spoken expression and to convert it into a language that can be understood by a professional vertical domain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention generally relates to the field of artificial intelligence technology, and more specifically, to a method and device for rewriting spoken text based on counterfactual reasoning. Background Art

[0002] In recent years, with the rapid progress of deep learning technology, large language models (LLMs) such as ChatGPT, LLaMa, and Qwen have gradually become stars in the field of artificial intelligence. These models have not only learned rich language representation and semantic understanding capabilities through pre-training on massive text data, but also achieved remarkable achievements in various tasks of natural language processing (NLP). They can understand and generate natural language, perform machine translation, text summarization, sentiment analysis and other complex tasks, and have greatly promoted the development of artificial intelligence technology.

[0003] However, despite the excellent performance of LLMs in processing language tasks, they still rely on large-scale high-quality corpora during training. Although these corpora provide rich language information, they lack direct perception of the real world. Especially in domain-specific question-answering tasks, LLMs may produce hallucinations, that is, generate information that is inconsistent with the facts, or provide outdated knowledge, which seriously affects the reliability of the model and its effectiveness in practical applications. To overcome these problems, researchers proposed a new method - Retrieval-Augmented Generation (RAG).

[0004] The core of the RAG method is that when a user asks a question, the system first searches the external knowledge base to find information fragments related to the question, and then aggregates these fragments for LLM reference to generate answers. In this process, the quality of the retrieval results directly determines the accuracy of the LLM's answers. Retrieval methods usually include keyword matching, semantic matching, or a combination of the two. However, the questions asked by users are often non-standardized and colloquial, which has significant semantic differences from the professional and standardized text in the knowledge base, posing a major challenge to the accuracy of retrieval.

[0005] In order to improve the accuracy of retrieval, researchers have proposed a variety of text rewriting technologies. These technologies aim to convert users' colloquial questions into a format that is closer to the professional text in the knowledge base, so that the retrieval system can match relevant information more accurately. However, most existing text rewriting methods focus on rewriting regular texts. They assume that the distribution of the text before and after the rewriting is similar, and do not take into account the particularity of colloquial texts. It can be seen that there are still great challenges in rewriting colloquial texts. Summary of the invention

[0006] According to an embodiment of the present invention, a colloquial text rewriting solution based on counterfactual reasoning is provided. This solution enables the rewriting of colloquial text to understand the intention of the colloquial expression and convert it into a language that can be understood by a professional vertical field.

[0007] In a first aspect of the present invention, a method for rewriting colloquial text based on counterfactual reasoning is provided. The method comprises:

[0008] Constructing a spoken language dataset, wherein the spoken language dataset includes professional texts and spoken language texts;

[0009] Constructing a counterfactual reasoning model, using a spoken language dataset, and training the counterfactual reasoning model according to a loss function of the counterfactual reasoning model to obtain a trained counterfactual reasoning model;

[0010] Input the colloquial text into the trained counterfactual reasoning model to obtain the rewritten professional text;

[0011] The counterfactual reasoning model includes at least two generation models arranged in sequence; and the structure of each generation model of the counterfactual reasoning model is the same; wherein the first generation model is used to rewrite the spoken text once and output the rewritten text; the remaining generation models in the counterfactual reasoning model are used to rewrite the rewritten text again and output the rewritten text.

[0012] Furthermore, if the spoken data set does not include context information, each generation model in the counterfactual reasoning model is a first encoding and decoding network or a first single decoding network.

[0013] Furthermore, the first encoding and decoding network includes:

[0014] The first embedding layer is used to embed words and position encode the input data and output first feature information;

[0015] The encoding layer is used to receive the first feature information and output the second feature information;

[0016] The second embedding layer is used to embed words and position encode the input data and output the encoded information;

[0017] The first decoding layer is used to receive the second feature information of the encoding layer and the encoded information of the second embedding layer, decode them, and output the rewritten text.

[0018] Furthermore, the first single decoding network comprises:

[0019] The fourth embedding layer is used to embed words and position encode the input data and output fifth feature information;

[0020] The second decoding layer is used to receive the fifth feature information for decoding and output the rewritten text.

[0021] Furthermore, if the spoken data set includes context information, each generative model in the counterfactual reasoning model is a second encoding-decoding network or a second single decoding network.

[0022] Furthermore, the second encoding and decoding network includes:

[0023] The first embedding layer is used to embed words and position encode the input data and output first feature information;

[0024] The third embedding layer is used to obtain context information for word embedding and position encoding, and output the third feature information;

[0025] The coding layer is used to receive the feature information obtained by fusing the first feature information and the third feature information, and output the fourth feature information;

[0026] The second embedding layer is used to embed words and position encode the input data and output the encoded information;

[0027] The first decoding layer is used to receive the fourth feature information of the encoding layer and the encoded information of the second embedding layer, decode them, and output the rewritten text.

[0028] Furthermore, the second single decoding network comprises:

[0029] The fourth embedding layer is used to embed words and position encode the input data and output fifth feature information;

[0030] The fifth embedding layer is used to obtain context information for word embedding and position encoding, and output sixth feature information;

[0031] The second decoding layer is used to receive the feature information obtained by merging the fifth feature information and the sixth feature information, perform decoding, and output the rewritten text.

[0032] Furthermore, the loss function of the counterfactual reasoning model is:

[0033] ;

[0034] in, is the first hyperparameter; is the second hyperparameter; is the third hyperparameter; is the loss function of the counterfactual reasoning model; To contrast learning loss; is the counterfactual consistency loss; is the counterfactual contrast loss.

[0035] Furthermore, the contrastive learning loss is:

[0036] ;

[0037] in, represents the cosine similarity function; Indicates that a pooling operation is performed on the output layer of the decoder to obtain a text embedding vector; represents the rewritten text output by the first generation model; A rewritten specialized text representing the output of the counterfactual reasoning model; Indicates specialized text;

[0038] The counterfactual consistency loss is:

[0039] ;

[0040] in, represents the cross entropy loss;

[0041] The counterfactual contrast loss is:

[0042] ;

[0043] in, Represents the boundary factor, which is dynamically updated during the training process and .

[0044] In a second aspect of the present invention, an electronic device is provided. The electronic device has at least one processor; and a memory connected to the at least one processor in communication; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the method of the first aspect of the present invention.

[0045] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The above and other features, advantages and aspects of the embodiments of the present invention will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:

[0047] Figure 1 A flowchart of a method for rewriting a spoken text based on counterfactual reasoning according to an embodiment of the present invention is shown;

[0048] Figure 2 A schematic diagram of a colloquial text rewriting method based on counterfactual reasoning according to an embodiment of the present invention is shown;

[0049] Figure 3 A schematic diagram of a coding and decoding network architecture according to an embodiment of the present invention is shown;

[0050] Figure 4 A schematic diagram of a single decoding network architecture according to an embodiment of the present invention is shown;

[0051] Figure 5 A block diagram of an exemplary electronic device capable of implementing embodiments of the present invention is shown;

[0052] Among them, 500 is an electronic device, 501 is a computing unit, 502 is a ROM, 503 is a RAM, 504 is a bus, 505 is an I / O interface, 506 is an input unit, 507 is an output unit, 508 is a storage unit, and 509 is a communication unit. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0054] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0055] Figure 1 A flow chart of a method for rewriting colloquial text based on counterfactual reasoning according to an embodiment of the present invention is shown.

[0056] The method includes:

[0057] S101. Build a spoken language dataset.

[0058] The spoken language data set includes at least professional text and spoken language text.

[0059] On the Internet, colloquial data is very common. For example, technical forums such as Zhihu and CSDN have special sections for users to ask their own questions or answer other people's questions. These questions are questions asked by real users and can be classified as colloquial data. This part of data can be easily collected. However, in vertical fields such as education, government affairs, and medical care, either the amount of data is small or it involves user privacy and is difficult to obtain. Therefore, building a colloquial dataset for vertical fields is a very important task.

[0060] In some embodiments, the spoken language dataset includes not only professional text and spoken language text, but also contextual information.

[0061] In this embodiment, the original data is the message data and the data captured from the forum discussion area of ​​the portal website on the Internet, including normal daily questions and messages, daily colloquial data, etc. In general, the captured data will be cleaned and only the questions raised by the user will be retained. A Few-Shot method (small sample) is used to construct a prompt word template. The constraints can be based on the colloquial sample and the given professional text, so that the LLM learns the colloquial questioning method and outputs the colloquial text corresponding to the given professional text to realize the construction of the colloquial data set. Then the output of the model is formatted according to the constraints, and multiple colloquial texts that follow the sample format can be obtained.

[0062] In intelligent question-answering in vertical fields, questions are often answered around a certain field. For example, in intelligent question-answering systems in the field of education, questions raised by users are usually related to educational knowledge. Therefore, introducing domain background knowledge (context information) into the model can provide additional information and constraints, reduce possible ambiguity or irrelevant content in the generated text, and generate text that is better consistent with the context and close to the target professional text. Domain knowledge data can be the knowledge base in the intelligent question-answering system, with no restrictions on data types, such as knowledge graphs and document libraries, and perform hybrid retrieval through keywords and semantics, using the retrieval results as context information.

[0063] When the spoken language dataset includes professional text, spoken language text and contextual information, it can be specifically expressed in a triple format.

[0064] S102: construct a counterfactual reasoning model, use the spoken language data set, and train the counterfactual reasoning model according to the loss function of the counterfactual reasoning model to obtain a trained counterfactual reasoning model.

[0065] In this embodiment, the counterfactual reasoning model includes at least two generation models arranged in sequence, for example, three generation models or five generation models.

[0066] like Figure 2 As shown, in this embodiment, the structure of each generation model of the counterfactual reasoning model is the same; the difference between different generation models is that the input / output data is different due to the different position order in the counterfactual reasoning model. For example, the first generation model used as the starting point obtains the colloquial text, and the colloquial text is rewritten once by the first generation model, and the rewritten text is output; the remaining generation models in the counterfactual reasoning model are used to rewrite the rewritten text again, and output the rewritten text. If the generation model is the last generation model, it is necessary to output the rewritten professional text.

[0067] In this embodiment, since there are two situations in which the spoken data set includes context information and does not include context information, the counterfactual reasoning model needs to be discussed separately for each situation.

[0068] As an implementation method in this embodiment, Figure 3 and Figure 4 As shown, if the spoken data set does not include context information, each generative model in the counterfactual reasoning model is a first encoding-decoding network or a first single decoding network.

[0069] Specifically, the first encoding and decoding network includes a first embedding layer Embedding, an encoding layer Encoder, a second embedding layer Embedding and a first decoding layer Decoder. The first embedding layer is used to embed and positionally encode the input data and output the first feature information. The input data of the model is represented by input text, that is, the colloquial text. The encoding layer Encoder is used to receive the first feature information and output the second feature information; the second embedding layer is used to embed and positionally encode the input data and output the encoded information. In the training stage, the input data of the second embedding layer is the specialized text, and in the inference stage, the input data of the second embedding layer is the start symbol, indicating the beginning of the sequence. The first decoding layer is used to receive the second feature information of the encoding layer and the encoded information of the second embedding layer for decoding and output the rewritten text. If the rewritten text is an intermediate text, it is recorded as text_rewrite1, and then text_rewrite1 is used as a new input and input into the encoding and decoding network of the next level until the rewritten specialized text text_rewrite2 is finally output.

[0070] The parameters between the embedding layers in each network are shared, and the parameters between the decoding layers are shared.

[0071] Specifically, the first single decoding network includes a fourth embedding layer and a second decoding layer. The fourth embedding layer is used to embed words and positionally encode the input data, and output the fifth feature information. The input data of the fourth embedding layer is generally a colloquial text; the second decoding layer is used to receive the fifth feature information for decoding, and output the rewritten text. If the rewritten text is an intermediate text, it is recorded as text_rewrite1, and then text_rewrite1 is used as a new input and input into the next level of single decoding network until the rewritten specialized text text_rewrite2 is finally output.

[0072] As another implementation method in this embodiment, Figure 3 and Figure 4 As shown, if the spoken data set includes context information, each generation model in the counterfactual reasoning model is a second encoding and decoding network or a second single decoding network.

[0073] Specifically, the second encoding and decoding network includes a first embedding layer Embedding, a third embedding layer Embedding, an encoding layer Encoder, a second embedding layer Embedding and a first decoding layer Decoder. The first embedding layer embeds and positions the input data, and outputs the first feature information; the third embedding layer obtains the context information context to embed and positions the word, and outputs the third feature information; the first feature information and the third feature information are fused to obtain the fused feature information; the encoding layer receives the feature information fused from the first feature information and the third feature information, and outputs the fourth feature information; the second embedding layer embeds and positions the input data, and outputs the encoded information; the first decoding layer receives the fourth feature information of the encoding layer and the encoded information of the second embedding layer, and decodes it, and outputs the rewritten text. If the rewritten text is an intermediate text, it is recorded as text_rewrite1, and then text_rewrite1 is used as a new input and input into the encoding and decoding network of the next level, until the rewritten specialized text text_rewrite2 is finally output.

[0074] In this embodiment, the fusion operation is:

[0075] ;

[0076] in, , , , represents the fused feature information, Represents the feature information of spoken text, Characteristic information representing the context, represents the query weight matrix in attention, represents the key weight matrix in attention, represents the value weight matrix in the attention matrix, represents the dimension of the query feature, Represents the normalized exponential function, and the calculation formula is: .

[0077] In this embodiment, the second single decoding network includes: a fourth embedding layer, a fifth embedding layer and a second decoding layer; wherein the fourth embedding layer embeds and positions the input data, and outputs the fifth feature information; the fifth embedding layer obtains the context information context to embed and positionally encode the input data, and outputs the sixth feature information; after obtaining the fifth feature information and the sixth feature information, the fifth feature information and the sixth feature information are fused to obtain the fused feature information; the second decoding layer receives the fused feature information of the fifth feature information and the sixth feature information, decodes it, and outputs the rewritten text. If the rewritten text is an intermediate text, it is recorded as text_rewrite1, and then text_rewrite1 is used as a new input and input into the next level of single decoding network until the rewritten specialized text text_rewrite2 is finally output.

[0078] Whether it is a single decoding network or an encoding and decoding network, the process of the fusion operation is the same.

[0079] The encoder-decoder network deeply understands the input sequence through the encoder and extracts rich semantic information. This enables the model to more accurately capture the intent and context of the input when generating output, and makes the text generated by the model based on counterfactual assumptions more consistent with the original semantics, which can effectively alleviate the semantic gap between spoken text and professional text.

[0080] The single decoding network omits the encoder, and the input sequence and output sequence are processed in the same module, avoiding the complexity of the model structure. During the reasoning process, only one forward propagation is required, and the reasoning efficiency is higher. Due to the simplification of the structure, the model can add a multi-order counterfactual reasoning structure. The use of multiple orders can enable the model to learn deep semantic information and improve the rewriting effect of the model.

[0081] S103, inputting the colloquial text into the trained counterfactual reasoning model to obtain a rewritten professional text.

[0082] like Figure 2 As shown, the generated model First, rewrite the colloquial text, record the rewritten text as text_rewrite1, and send text_rewrite1 as the counterfactual input to the generative model again (Note that the generative model and The parameters of the two generated rewritten texts are shared and belong to the same model), and the rewritten text is recorded as text_rewrite2. Based on the two generated rewritten texts and the known specialized text (recorded as text_groundtruth), a multi-task loss function is designed.

[0083] Specifically, the decoder of the generative model is used as the feature extractor of the text, and the last-token pooling method is adopted. In order to make the rewritten text maintain a high similarity in semantic features with the professional text, contrastive learning loss is adopted, as follows:

[0084] ;

[0085] in, represents the cosine similarity function, and the formula is ; It means to perform pooling operation on the output layer of the decoder to obtain the text embedding vector. This method adopts the last-token pooling method.

[0086] In order to make the rewritten text consistent with the professional text in some aspects (such as semantic content, important information, style, etc.), a counterfactual consistency loss is constructed. Specifically:

[0087] ;

[0088] in, represents the cross entropy loss; represents the rewritten text output by the first generation model; A rewritten specialized text representing the output of the counterfactual reasoning model; Indicates specialized text.

[0089] The cross entropy loss is expressed as:

[0090] ;

[0091] in, represents the distribution of real text, Represents the distribution of predicted text.

[0092] Based on the counterfactual hypothesis, the similarity between text_rewrite2 and professional text is forced to be higher than the similarity between text_rewrite1 and professional text, and the counterfactual contrast loss is constructed. Specifically:

[0093] in, represents the cosine similarity function, and the formula is ; It means to perform pooling operation on the output layer of the decoder to obtain the text embedding vector. This method adopts the last-token pooling method. , represents the boundary factor, which is dynamically updated during the training process. The update function is as follows:

[0094]

[0095] in, Indicates the initial , represents the current training round, Represents the total number of training rounds.

[0096] In summary, the total loss function is

[0097] ;

[0098] in, is the first hyperparameter; is the second hyperparameter; is the third hyperparameter; is the loss function of the counterfactual reasoning model; To contrast learning loss; is the counterfactual consistency loss; is the counterfactual contrast loss.

[0099] In this article, context information is an optional option. Using context information will have a positive impact on model learning, but the cost is that it will increase the amount of calculation. You can choose whether to use it based on the actual domain knowledge, which is more flexible. Context information is visible to the generative model but not to the loss function, so it does not directly affect the loss function. In other words, whether the generative model is an encoder-decoder network or a single decoder network, the total loss function is used as the loss function for training optimization.

[0100] According to an embodiment of the present invention, this article introduces multi-level counterfactual modeling based on the counterfactual reasoning hypothesis, that is, instead of a one-time rewriting, a multi-step progressive rewriting method is introduced. For example, this article uses two-level counterfactual modeling from colloquial language to formal language and then to professional language, so that the model can more clearly learn the contribution of language style, tone and grammar to professional expression, reducing the difficulty of model learning from "colloquial" to "professional".

[0101] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0102] In the technical solution of the present invention, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0103] According to an embodiment of the present invention, the present invention further provides an electronic device.

[0104] Figure 5 A schematic block diagram of an electronic device 500 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0105] The electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0106] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0107] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as methods S101 to S103. For example, in some embodiments, methods S101 to S103 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the methods S101 to S103 described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to execute methods S101 - S103 in any other appropriate manner (eg, by means of firmware).

[0108] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0109] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0110] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), 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 foregoing.

[0111] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0112] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0113] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0114] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0115] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for rewriting colloquial text based on counterfactual reasoning, characterized in that: include: Constructing a spoken language dataset, wherein the spoken language dataset includes professional texts and spoken language texts; Constructing a counterfactual reasoning model, using a spoken language dataset, and training the counterfactual reasoning model according to a loss function of the counterfactual reasoning model to obtain a trained counterfactual reasoning model; Input the colloquial text into the trained counterfactual reasoning model to obtain the rewritten professional text; The counterfactual reasoning model includes at least two generation models arranged in sequence; and the structure of each generation model of the counterfactual reasoning model is the same; wherein the first generation model is used to rewrite the spoken text once and output the rewritten text; the remaining generation models in the counterfactual reasoning model are used to rewrite the rewritten text again and output the rewritten text.

2. The method according to claim 1, characterized in that If the spoken data set does not include context information, each generative model in the counterfactual reasoning model is a first encoding-decoding network or a first single decoding network.

3. The method according to claim 2, characterized in that The first encoding and decoding network includes: The first embedding layer is used to embed words and position encode the input data and output first feature information; The encoding layer is used to receive the first feature information and output the second feature information; The second embedding layer is used to embed words and position encode the input data and output the encoded information; The first decoding layer is used to receive the second feature information of the encoding layer and the encoded information of the second embedding layer, decode them, and output the rewritten text.

4. The method according to claim 2, characterized in that: The first single decoding network comprises: The fourth embedding layer is used to embed words and position encode the input data and output fifth feature information; The second decoding layer is used to receive the fifth feature information for decoding and output the rewritten text.

5. The method according to claim 1, characterized in that If the spoken data set includes context information, each generative model in the counterfactual reasoning model is a second encoding-decoding network or a second single decoding network.

6. The method according to claim 5, characterized in that The second encoding and decoding network includes: The first embedding layer is used to embed words and position encode the input data and output first feature information; The third embedding layer is used to obtain context information for word embedding and position encoding, and output the third feature information; The coding layer is used to receive the feature information obtained by fusing the first feature information and the third feature information, and output the fourth feature information; The second embedding layer is used to embed words and position encode the input data and output the encoded information; The first decoding layer is used to receive the fourth feature information of the encoding layer and the encoded information of the second embedding layer, decode them, and output the rewritten text.

7. The method according to claim 5, characterized in that The second single decoding network comprises: The fourth embedding layer is used to embed words and position encode the input data and output fifth feature information; The fifth embedding layer is used to obtain context information for word embedding and position encoding, and output sixth feature information; The second decoding layer is used to receive the feature information obtained by merging the fifth feature information and the sixth feature information, perform decoding, and output the rewritten text.

8. The method according to claim 1, characterized in that The loss function of the counterfactual reasoning model is: ; in, is the first hyperparameter; is the second hyperparameter; is the third hyperparameter; is the loss function of the counterfactual reasoning model; To contrast learning loss; is the counterfactual consistency loss; is the counterfactual contrast loss.

9. The method according to claim 8, characterized in that The contrastive learning loss is: ; in, represents the cosine similarity function; Indicates that a pooling operation is performed on the output layer of the decoder to obtain a text embedding vector; represents the rewritten text output by the first generation model; A rewritten specialized text representing the output of the counterfactual reasoning model; Indicates specialized text; The counterfactual consistency loss is: ; in, represents the cross entropy loss; The counterfactual contrast loss is: ; in, Represents the boundary factor, which is dynamically updated during the training process and .

10. An electronic device comprising at least one processor; and a memory connected in communication with the at least one processor; characterized in that: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Text style migration method and device, electronic equipment and storage medium

    CN113822064A

  • Text processing method and device

    CN114357122A

  • Text style migration model training method and device and text style migration method and device

    CN114818728A

  • Multi-modal reasoning method and device based on large language model and knowledge graph

    CN118193684A

  • Large model fine tuning method of track domain knowledge base and scene adaptation system

    CN118606439A