A method and device for style conversion of bullet text
By training the neural machine translation model and converting the barrage text style according to the video type, it solves the problems of low interest and poor user experience of the barrage text style converter in the existing technology, and achieves barrage text conversion that is more in line with the video content. Improved user experience.
Patent Information
- Application Number
- CN202010873008.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-26
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-08-26
Smart Images

Figure CN114118025B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method and device for style conversion of bullet text. Background Art
[0002] Text style transfer is one of the research directions in the field of natural language processing. At present, the research progress in this field is mainly focused on improving the effect of text style transfer, such as improving fluency, reducing information loss, etc., but ignores the specific application scenarios and needs of style converters in the industry. Summary of the invention
[0003] One purpose of the present application is to provide a method and device for style conversion of barrage text, so as to solve the problem in the prior art that barrage text cannot change style according to specific application scenarios, resulting in low interest and poor user experience.
[0004] According to one aspect of the present application, a method for style conversion of bullet text is provided, the method comprising:
[0005] Determine at least one parallel corpus corresponding to a style, wherein the parallel corpus includes an original barrage text and a target barrage text;
[0006] Determine the video type according to the video content where the original barrage text is located, train a neural machine translation model according to the parallel corpus and the video type, and obtain a style converter model;
[0007] The acquired user bullet text is input into the style converter model, and the bullet text after the style conversion is output.
[0008] Further, training a neural machine translation model according to the parallel corpus and the video type includes:
[0009] Using a neural machine translation model, the parallel corpus is encoded and converted into an input-output pair required by the neural machine translation model, wherein the input-output pair includes a data pair with the encoding of the original barrage text as input and the encoding of the target barrage text as output;
[0010] The input-output pair and the video type are input into the neural machine translation model for training to obtain a style converter model.
[0011] Further, inputting the input-output pair and the video type into the neural machine translation model for training includes:
[0012] Establishing a matching rule between the video type and each style converter model according to the parallel corpus;
[0013] Load the current neural machine translation model according to the current video type and matching rules;
[0014] The input-output pair is input into the current neural machine translation model for training to obtain a style converter model corresponding to the video type.
[0015] Furthermore, a matching rule between the video type and each style converter model is established according to the parallel corpus, including:
[0016] Determine the video content of the video where the parallel corpus is located, and calculate the video partition according to the video type of the video content;
[0017] A corresponding video partition is configured for each style converter model, and a matching rule between the style converter model and the video partition is established.
[0018] Furthermore, before inputting the acquired user bullet comment text into the style converter model, it includes:
[0019] Determine the current video type according to the content of the current video;
[0020] Calculate the video partition where the current video is located according to the current video type;
[0021] The corresponding style converter model is loaded according to the video partition.
[0022] Furthermore, the acquired user bullet text is input into the style converter model, and the bullet text after the style conversion is output, which also includes:
[0023] Get the bullet text entered by the user on the current video interface;
[0024] Loading a style converter model corresponding to the video type of the current video based on a conversion operation selected by a user;
[0025] The barrage text is encoded and input into the loaded style converter model for conversion, and the barrage text after the style conversion is displayed on the barrage.
[0026] Further, at least one parallel corpus corresponding to a style is determined, including any of the following:
[0027] Selecting at least one type of barrage text in a video as an original barrage text, and determining a target barrage text corresponding to each original barrage text;
[0028] Convert the selected bullet-screen text into the original bullet-screen text, and determine the target bullet-screen text corresponding to the original bullet-screen text by means of translation;
[0029] Create parallel corpora manually.
[0030] According to another aspect of the present application, a device for style conversion of bullet text is also provided, the device comprising:
[0031] A determination device, used to determine a parallel corpus corresponding to at least one style, wherein the parallel corpus includes an original barrage text and a target barrage text;
[0032] A training device, used to determine the video type according to the video content where the original barrage text is located, and train a neural machine translation model according to the parallel corpus and the video type to obtain a style converter model;
[0033] The conversion device is used to input the acquired user bullet text into the style converter model and output the bullet text after the style is converted.
[0034] According to another aspect of the present application, a device for style conversion of bullet text is also provided, the device comprising:
[0035] one or more processors; and
[0036] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of the method as described above.
[0037] According to another aspect of the present application, a computer-readable medium is provided, on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the method described above.
[0038] Compared with the prior art, the present application determines at least one parallel corpus corresponding to a style, wherein the parallel corpus includes the original barrage text and the target barrage text; determines the video type according to the video content where the original barrage text is located, trains the neural machine translation model according to the parallel corpus and the video type, and obtains the style converter model; inputs the acquired user barrage text into the style converter model, and outputs the barrage text after the style conversion. Thus, the corresponding style converter is loaded according to different video types, and the user's barrage is converted in real time, so that the barrage text information is more consistent with the video content, which can increase the fun and create a better user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0040] Figure 1 A schematic diagram of a method flow for style conversion of a bullet text provided according to one aspect of the present application is shown;
[0041] Figure 2 A schematic diagram showing training and calling style converters corresponding to different styles in one embodiment of the present application is shown;
[0042] Figure 3 A schematic diagram showing a specific practical application scenario in an embodiment of the present application is shown;
[0043] Figure 4 A schematic diagram showing a method of determining parallel corpora by transfer in one embodiment of the present application;
[0044] Figure 5 A schematic diagram of the structure of a device for style conversion of bullet text provided in yet another aspect of the present application is shown.
[0045] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0046] The present application is described in further detail below in conjunction with the accompanying drawings.
[0047] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (eg, a central processing unit (CPU)), an input / output interface, a network interface and a memory.
[0048] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0049] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, Phase-Change RAM (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of random access memory (RAM), Read-Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0050] Figure 1 A schematic flow chart of a method for style conversion of bullet text provided according to one aspect of the present application is shown, the method comprising: steps S11 to S13,
[0051] In step S11, a parallel corpus corresponding to at least one style is determined, wherein the parallel corpus includes an original barrage text and a target barrage text; here, the parallel corpus corresponding to each style is obtained, and the original barrage text and the target barrage text are determined, wherein the original barrage text is the original text entered by the user in the input box for entering the barrage in the video interface, and the target barrage text is the text of the style that the user wants to convert into; for example, the parallel corpus of the style is martial arts style, the original barrage text is, for example, "goodbye", and the target barrage text is "bye bye".
[0052] In step S12, the video type is determined according to the video content where the original barrage text is located, and the neural machine translation model is trained according to the parallel corpus and the video type to obtain a style converter model; here, different parallel corpus fields are different, and different style converter models are trained. When training to obtain a style converter model corresponding to the video type, the video where the original barrage text is located is determined, the video content of the video is obtained, and the video type to which the video content belongs is determined, so as to train the neural machine translation model according to the prepared parallel corpus and video type to obtain a style conversion model suitable for the video type, wherein the classification of video content can have different classification systems according to the classification standards and granularity, and in different video applications, the style converter model can be used to convert the style converter model into a style converter model suitable for the video type. The video content of the video may be different in the application program or video web page. For example, the categories in the video application A include: animation, drama, music, domestic creation, dance, game, knowledge, digital, life, ghost animal, fashion, information, entertainment, film and television, documentary, etc.; the upload channel of the video can be determined according to the classification information of the video content, and the video type can be determined according to any combination of the upload channel, video content title and video tags. For example, if the classification information of the video is film and television, the corresponding video content upload channel is found to be: film and television + film and television editing, and the tags are: Jin Yong, martial arts, film and television editing, rivers and lakes, classics, then the video type can be determined to be film and television Jin Yong style; for another example, the title of the video content is: [Jin Yong's Martial Arts Chronicles] Do you remember his thousand-year rivers and lakes? , and the upload channel is: animation + film and television editing, then the video type to which the video content belongs is animation Jin Yong style, and the trained style converter model is animation Jin Yong style. By integrating information such as uploaded channels, titles, and tags, a video-to-style mapping relationship can be established. That is, the comprehensive information is used to train a neural machine translation model and establish a style converter model suitable for the video type. This allows the corresponding style converter to be loaded according to the video type to which the video content currently being watched by the user belongs.
[0053] It should be noted that the neural machine translation model can adopt an open source neural translation model, such as THUMT (which adopts a transformer structure), which is a method of using a deep learning neural network to obtain the mapping relationship between natural languages.
[0054] In step S13, the acquired user bullet text is input into the style converter model, and the bullet text after style conversion is output. Here, the style converter model is loaded online, the user bullet text input by the user is encoded and input into the loaded style converter model, and the converted bullet text is output; for example, if the user bullet text is "My heart is full of tenderness", and the loaded style converter model is a martial arts style, the user bullet text can be encoded and input into the loaded style converter model, and the output bullet text is "My heart is full of tenderness", thereby increasing the fun and improving the user experience.
[0055] In one embodiment of the present application, in step S12, the parallel corpus is encoded using a neural machine translation model and converted into input-output pairs required by the neural machine translation model, wherein the input-output pairs include data pairs with the encoding of the original barrage text as input and the encoding of the target barrage text as output; the input-output pairs and the video type are input into the neural machine translation model for training to obtain a style converter model. Here, a parallel corpus is obtained, and a neural machine translation model is used to perform byte pair encoding on the parallel corpus, wherein byte pair encoding is a compression algorithm that processes words as word fragments to facilitate processing of non-appearing words; the parallel corpus is encoded using the post-file of BPE (Byte-Pair Encoding, double-byte encoding), and the encoding is a data format accepted by model training. The encoded parallel corpus is an input-output pair, which is a data pair with the encoding of the original barrage text as input and the encoding of the target barrage text as output. For example, input X: "Temujin knows that these close combat skills can only protect himself", and after encoding, "Temujin @@ knows @@ these @@ close@ ...
[0056] Continuing with the above embodiment, in step S12, a matching rule between the video type and each style converter model is established according to the parallel corpus; the current neural machine translation model is loaded according to the current video type and the matching rule; the input-output pair is input into the current neural machine translation model for training to obtain a style converter model corresponding to the video type. Here, multiple style converter models are trained according to parallel corpora in different fields, the applicable video type is determined according to the original barrage text in the parallel corpus, matching rules between the video type and the style converter model are established, the current neural machine translation model corresponding to the video type matched according to the matching rules is automatically loaded, the style conversion problem is converted into machine translation, the input-output pairs determined after encoding are input into the current neural machine translation model for training, and the trained model realizes style conversion, thereby realizing the training of the corresponding style converter model according to the characteristics of the video content.
[0057] Continuing with the above embodiment, when establishing matching rules, the video content of the video where the parallel corpus is located can be determined, and the video partition can be calculated according to the video type of the video content, wherein the video content includes the channel where the video is uploaded, label information, etc.; a corresponding video partition is configured for each style converter model, and a matching rule between the video partition is established. Here, the video content applicable to the parallel corpus is determined, and the video content includes the video-related information obtained after the user uploads the video, such as the title, label, uploaded channel, and post-processing information such as detailed introduction and image recognition. When determining the video type according to the video content, the upload channel of the video can be determined according to the classification information of the video content, and the video type can be determined according to any combination of the upload channel, the video content title, and the video label; thereby, the video where the original bullet text is located is collected, and the video partition is calculated according to the video type to which the collected video content belongs. For example, if the channel where the video is uploaded is "film and television" and the label information is "Swordsman", then the video type is determined to be film and television martial arts according to these video contents, and the calculated video partition is "film and television martial arts Jin Yong style". Each style converter is configured with an applicable video partition, and if the video partition matches the applicable scope of a converter, the style converter is automatically loaded.
[0058] In one embodiment of the present application, before the acquired user bullet text is input into the style converter model, the current video type is determined according to the content of the current video; the video partition where the current video is located is calculated according to the current video type; and the corresponding style converter model is loaded according to the video partition. Here, when the user watches the current video, the content of the current video is acquired, the current video type is determined according to the content of the video, and the video partition where the current video is located is calculated according to the current video type, so as to load the style converter model applicable to the video partition online according to the matching rule.
[0059] In one embodiment of the present application, the bullet text input by the user in the current video interface can also be obtained; based on the conversion operation selected by the user, a style converter model corresponding to the video type of the current video is loaded; the bullet text is input into the loaded style converter model for conversion, and the bullet text after the style conversion is displayed on the bullet. Here, the user enters the bullet text in the bullet input box in the current video interface and selects conversion, and based on the trigger operation of the conversion, a style converter model suitable for the video type of the current video is loaded, such as Figure 2 As shown in the figure, different style converters are trained offline using parallel corpora and different style requirements, so as to load corresponding style converters for different video types, and the user's bullet comments are converted in real time through the online style converter; the bullet comment text input by the user is encoded and input into the style converter model, and the output bullet comment text after style conversion is displayed in the bullet comment, as shown in the figure. Figure 3 As shown, the user enters "decades of history" in the barrage input box, clicks the convert button (here is the Jin Yongfeng button), calls the Jin Yongfeng style converter, and outputs the converted barrage text as "decades of past events", which is displayed in the barrage, thereby obtaining text information that is more in line with the video content, increasing interest, and creating a better user experience.
[0060] In one embodiment of the present application, a parallel corpus corresponding to at least one style is determined, including any of the following: selecting a barrage text in at least one video type as the original barrage text, and determining a target barrage text corresponding to each original barrage text; converting the selected barrage text as the original barrage text, and determining the target barrage text corresponding to the original barrage text by translation; and establishing a parallel corpus manually. Here, when obtaining parallel corpora corresponding to a variety of styles, the barrage text in an existing video type can be selected as the original barrage text, and the target barrage text required by the user corresponding to each original barrage text can be determined; it can also be obtained by translation, such as translating the target text Y into English as text M, where M is the intermediate text, and then translating text M into English to obtain text X, wherein text X and text Y are similar in semantics, but different in style, so that a parallel corpus with text X as the original text and text Y as the target text can be obtained, such as Figure 4 As shown in , taking "my heart is filled with thousands of tender feelings" as the original barrage text, the target barrage text "my heart is filled with thousands of tender feelings" is obtained through translation and transit; it can also be established manually, such as obtaining the original text sent by the user, sampling and distributing it to the manual team, and the team members rewrite it into the target style text based on the original text. For example, the original text is "goodbye" and the target style text is "Jin Yong", then it is rewritten into "goodbye" through manual experience and knowledge reserves, then "goodbye"-"goodbye" becomes a sample in the Jin Yong style corpus, and high-quality parallel corpus can be obtained manually.
[0061] In addition, an embodiment of the present application also provides a computer-readable medium on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the aforementioned method for style conversion of barrage text.
[0062] Corresponding to the method described above, the present application also provides a terminal, which includes a terminal capable of executing the above Figure 1 Or the modules or units of the method steps described in each embodiment, these modules or units can be implemented by hardware, software or a combination of hardware and software, and this application is not limited. For example, in one embodiment of this application, a device for style conversion of bullet text is also provided, and the device includes:
[0063] one or more processors; and
[0064] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of the method as described above.
[0065] For example, the computer readable instructions, when executed, cause the one or more processors to:
[0066] Determine at least one parallel corpus corresponding to a style, wherein the parallel corpus includes an original barrage text and a target barrage text;
[0067] Determine the video type according to the video content where the original barrage text is located, train a neural machine translation model according to the parallel corpus and the video type, and obtain a style converter model;
[0068] The acquired user bullet text is input into the style converter model, and the bullet text after the style conversion is output.
[0069] Figure 5 A structural schematic diagram of a device for style conversion of a barrage text provided by another aspect of the present application is shown, the device comprising: a determination device 11, a training device 12 and a conversion device 13, wherein the determination device 11 is used to determine a parallel corpus corresponding to at least one style, wherein the parallel corpus includes an original barrage text and a target barrage text; the training device 12 is used to determine a video type according to the video content of the original barrage text, train a neural machine translation model according to the parallel corpus and the video type, and obtain a style converter model; the conversion device 13 is used to input the acquired user barrage text into the style converter model, and output the barrage text after the style is converted.
[0070] It should be noted that the contents executed by the determination device 11, the training device 12 and the conversion device 13 are respectively the same or correspondingly the same as the contents in the above steps S11, S12 and S13, and for the sake of brevity, they are not repeated here.
[0071] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0072] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0073] In addition, a part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. The program instruction for calling the method of the present application may be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium, and / or stored in a working memory of a computer device that runs according to the program instruction. Here, according to an embodiment of the present application, a device is included, the device including a memory for storing computer program instructions and a processor for executing program instructions, wherein, when the computer program instruction is executed by the processor, the device is triggered to run the method and / or technical solution based on the aforementioned multiple embodiments according to the present application.
[0074] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
Claims
1. A method for style conversion of bullet text, wherein: The method comprises: Determine at least one parallel corpus corresponding to a style, wherein the parallel corpus includes an original barrage text and a target barrage text; Determine the video type according to the video content where the original barrage text is located, train a neural machine translation model according to the parallel corpus and the video type, and obtain a style converter model; The acquired user bullet text is input into the style converter model, and the bullet text after the style conversion is output.
2. The method according to claim 1, wherein: Training a neural machine translation model according to the parallel corpus and the video type includes: Using a neural machine translation model, the parallel corpus is encoded and converted into an input-output pair required by the neural machine translation model, wherein the input-output pair includes a data pair with the encoding of the original barrage text as input and the encoding of the target barrage text as output; The input-output pair and the video type are input into the neural machine translation model for training to obtain a style converter model.
3. The method according to claim 2, wherein: Inputting the input-output pair and the video type into the neural machine translation model for training, including: Establishing a matching rule between the video type and each style converter model according to the parallel corpus; Load the current neural machine translation model according to the current video type and matching rules; The input-output pair is input into the current neural machine translation model for training to obtain a style converter model corresponding to the video type.
4. The method according to claim 3, wherein: A matching rule between the video type and each style converter model is established according to the parallel corpus, including: Determine the video content of the video where the parallel corpus is located, and calculate the video partition according to the video type of the video content; A corresponding video partition is configured for each style converter model, and a matching rule between the style converter model and the video partition is established.
5. The method according to any one of claims 1 to 4, wherein: Before inputting the acquired user bullet text into the style converter model, it includes: Determine the current video type according to the content of the current video; Calculate the video partition where the current video is located according to the current video type; The corresponding style converter model is loaded according to the video partition.
6. The method according to any one of claims 1 to 4, wherein: The acquired user bullet text is input into the style converter model, and the bullet text after the style conversion is output, further comprising: Get the bullet text entered by the user on the current video interface; Loading a style converter model corresponding to the video type of the current video based on a conversion operation selected by a user; The barrage text is encoded and input into the loaded style converter model for conversion, and the barrage text after the style conversion is displayed on the barrage.
7. The method according to any one of claims 1 to 4, wherein: Identify at least one parallel corpus corresponding to the style, including any of the following: Selecting at least one type of barrage text in a video as an original barrage text, and determining a target barrage text corresponding to each original barrage text; Convert the selected bullet-screen text into the original bullet-screen text, and determine the target bullet-screen text corresponding to the original bullet-screen text by means of translation; Create parallel corpora manually.
8. A device for converting the style of bullet text, wherein: The device comprises: A determination device, used to determine a parallel corpus corresponding to at least one style, wherein the parallel corpus includes an original barrage text and a target barrage text; A training device, used to determine the video type according to the video content where the original barrage text is located, and train a neural machine translation model according to the parallel corpus and the video type to obtain a style converter model; The conversion device is used to input the acquired user bullet text into the style converter model and output the bullet text after the style is converted.
9. A device for converting the style of bullet text, wherein: The device comprises: one or more processors; and A memory storing computer readable instructions which, when executed, cause the processor to perform the operations of the method as claimed in any one of claims 1 to 7.
10. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1 to 7.
