Lyrics generation method, device, electronic device and storage medium

By obtaining the subject and format attribute information of the lyrics, determining the input sequence and generating the lyric content, the problem of low lyrics in the prior art is solved, and high-quality and high matching lyric generation is achieved.

CN114186545BActive Publication Date: 2025-02-25BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111328718.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-10
Publication Date
2025-02-25
Estimated Expiration
2041-11-10

AI Technical Summary

Technical Problem

When the prior art automatically generates lyrics, it is difficult to perform joint control of multiple attributes at the same time, resulting in a low quality of generated lyrics.

Method used

By obtaining the subject words and lyric format attribute information of the lyrics to be generated, the input sequence is determined and the language model is input, the output sequence is obtained, and the lyric content corresponding to the subject words and lyric format attribute information is determined based on the output sequence.

Benefits of technology

Improves the quality of generated lyrics and matches multiple control attributes, and enhances the accuracy of lyrics content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114186545B_ABST
    Figure CN114186545B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a lyric generation method, device, electronic device and storage medium, the method comprising: obtaining a subject word and lyric format attribute information corresponding to the lyrics to be generated; determining an input sequence according to the subject word and lyric format attribute information, and inputting the input sequence into a language model; obtaining an output sequence of the language model; and determining the lyric content corresponding to the subject word and lyric format attribute information according to the output sequence. The present disclosure controls the generated lyric content based on multiple control attributes such as subject words and lyric format attribute information, thus improving the quality of the generated lyrics compared to the control of a single attribute, and improving the matching of the generated lyric content with multiple control attributes compared to the multi-stage cascade method, thereby improving the accuracy of the lyric content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of Internet technology, and in particular to a lyrics generation method, device, electronic device and storage medium. Background Art

[0002] In the related art, when automatically generating lyrics, only a single attribute such as a keyword can be controlled, and multiple attributes cannot be controlled simultaneously. Some lyrics generation systems can achieve similar functions of multiple attribute joint control through a multi-stage cascade method. However, such lyrics generation systems often consume a lot of resources and may cause problems such as error accumulation, resulting in a low match between the generated lyrics and multiple attributes, that is, the generated lyrics are of low quality. Summary of the invention

[0003] The present disclosure provides a lyrics generation method, device, electronic device and storage medium to at least solve the problem of low quality of lyrics generated in the related art. The technical solution of the present disclosure is as follows:

[0004] According to a first aspect of an embodiment of the present disclosure, a method for generating lyrics is provided, comprising:

[0005] Obtaining the subject words and lyrics format attribute information corresponding to the lyrics to be generated;

[0006] Determine an input sequence according to the subject words and the lyrics format attribute information, and input the input sequence into a language model;

[0007] Obtaining an output sequence of the language model;

[0008] According to the output sequence, the lyrics content corresponding to the subject word and the lyrics format attribute information is determined.

[0009] Optionally, before determining the input sequence according to the subject words and the lyrics format attribute information, the method further includes:

[0010] Obtain similar keywords of the subject word;

[0011] Determining an input sequence according to the subject words and the lyrics format attribute information, and inputting the input sequence into a language model, including:

[0012] Based on the attribute tags respectively corresponding to the subject words, similar keywords and lyrics format attribute information, the subject words, similar keywords and lyrics format attribute information are spliced ​​into an input sequence, and the input sequence is input into a language model.

[0013] Optionally, obtaining similar keywords of the subject word includes:

[0014] Obtaining a word vector of the subject word;

[0015] Determine the similarity between the word vector of the keyword in the word vector library and the word vector of the subject word;

[0016] The preset number of keywords with the highest similarity are determined as similar keywords of the subject word.

[0017] Optionally, the step of obtaining the subject words and lyrics format attribute information corresponding to the lyrics to be generated includes:

[0018] Obtaining a keyword corresponding to the lyrics to be generated input by a user;

[0019] Acquire at least one lyrics format attribute template corresponding to the subject word, and display the at least one lyrics format attribute template;

[0020] The lyrics format attribute template selected by the user from the at least one lyrics format attribute template is obtained, and the lyrics format attribute information corresponding to the selected lyrics format attribute template is determined as the lyrics format attribute information corresponding to the lyrics to be generated.

[0021] Optionally, the step of obtaining the subject words and lyrics format attribute information corresponding to the lyrics to be generated includes:

[0022] The theme word and the lyrics format attribute information input by the user are obtained through the lyrics attribute configuration interface, and the theme word and the lyrics format attribute information corresponding to the lyrics to be generated are obtained.

[0023] Optionally, also include:

[0024] Acquire sample lyrics, wherein the sample lyrics include sample keywords, sample lyrics format attributes and lyrics content annotations;

[0025] Based on the attribute tags corresponding to the subject words, the lyrics format attribute information and the lyrics content, the sample subject words, the sample lyrics format attributes and the lyrics content annotations are spliced ​​into a sample sequence;

[0026] The sample sequence is input into an initial language model to obtain an output sequence result, and the parameters of the initial language model are adjusted according to the output sequence result and the sample sequence to obtain a trained language model.

[0027] Optionally, when the initial language model predicts the i+1th character of the lyrics content in the sample sequence based on the sample sequence, it predicts the i+1th character based on the sample keyword, the sample lyrics format attributes and the first i characters annotated with the lyrics content, to obtain an output sequence result including the sample keyword, the sample lyrics format attributes and the lyrics content prediction results, wherein i is a natural number, the minimum value is 0, and the maximum value plus 1 is the number of characters in the lyrics content.

[0028] Optionally, before splicing the sample subject words, sample lyric format attributes and lyric content annotations into a sample sequence based on the attribute tags corresponding to the subject words and the lyric format attribute information, the method further includes:

[0029] Obtain sample similar keywords corresponding to the sample subject words;

[0030] Based on the attribute tags corresponding to the subject words, the lyrics format attributes and the lyrics content, the sample subject words, the sample lyrics format attributes and the lyrics content annotations are spliced ​​into a sample sequence, including:

[0031] Based on the attribute tags corresponding to the subject words, similar keywords, lyrics format attribute information and lyrics content respectively, the sample subject words, sample similar keywords, sample lyrics format attributes and lyrics content annotations are spliced ​​into a sample sequence.

[0032] Optionally, in the sample sequence, the arrangement of the lyrics content annotations is reverse order within a sentence and normal order between sentences, the arrangement of the sample subject words is reverse order, and the arrangement of the sample similar keywords is reverse order.

[0033] Optionally, determining the lyrics content corresponding to the subject word and the lyrics format attribute information according to the output sequence includes:

[0034] According to the attribute tags corresponding to the lyrics content, the lyrics content arranged in reverse order within the sentence and in normal order between sentences is obtained from the output sequence;

[0035] The lyrics content arranged in reverse order within a sentence and in normal order between sentences is processed in reverse order within the sentence to obtain lyrics content corresponding to the subject word and lyrics format attribute information.

[0036] According to a second aspect of an embodiment of the present disclosure, there is provided a lyrics generating device, comprising:

[0037] An attribute acquisition module is configured to acquire the subject words and lyrics format attribute information corresponding to the lyrics to be generated;

[0038] An input sequence determination module is configured to determine an input sequence according to the subject words and the lyrics format attribute information, and input the input sequence into a language model;

[0039] An output sequence acquisition module, configured to execute acquisition of an output sequence of the language model;

[0040] The lyrics content determination module is configured to determine the lyrics content corresponding to the subject word and the lyrics format attribute information according to the output sequence.

[0041] Optionally, the device further comprises:

[0042] A similar keyword acquisition module is configured to acquire similar keywords of the subject word;

[0043] The input sequence determination module is configured to perform:

[0044] Based on the attribute tags respectively corresponding to the subject words, similar keywords and lyrics format attribute information, the subject words, similar keywords and lyrics format attribute information are spliced ​​into an input sequence, and the input sequence is input into a language model.

[0045] Optionally, the similar keyword acquisition module includes:

[0046] A word vector acquisition unit, configured to acquire the word vector of the subject word;

[0047] A similarity determination unit is configured to determine the similarity between the word vector of the keyword in the word vector library and the word vector of the subject word;

[0048] The similar keyword determining unit is configured to determine a preset number of keywords with the highest similarity as similar keywords of the subject word.

[0049] Optionally, the attribute acquisition module includes:

[0050] A theme word acquisition unit, configured to acquire a theme word corresponding to the lyrics to be generated input by a user;

[0051] A format template display unit is configured to obtain at least one lyrics format attribute template corresponding to the subject word and display the at least one lyrics format attribute template;

[0052] The format attribute acquisition unit is configured to acquire the lyrics format attribute template selected by the user from the at least one lyrics format attribute template, and determine the lyrics format attribute information corresponding to the selected lyrics format attribute template as the lyrics format attribute information corresponding to the lyrics to be generated.

[0053] Optionally, the attribute acquisition module includes:

[0054] The attribute acquisition unit is configured to acquire the subject word and the lyrics format attribute information input by the user through the lyrics attribute configuration interface, and obtain the subject word and the lyrics format attribute information corresponding to the lyrics to be generated.

[0055] Optionally, the device further comprises:

[0056] A sample lyrics acquisition module is configured to execute acquisition of sample lyrics, wherein the sample lyrics include sample subject words, sample lyrics format attributes and lyrics content annotations;

[0057] A lyrics sequence splicing module is configured to perform attribute labeling corresponding to the subject words, the lyrics format attribute information and the lyrics content, and splice the sample subject words, the sample lyrics format attributes and the lyrics content annotation into a sample sequence;

[0058] The model training module is configured to input the sample sequence into the initial language model to obtain an output sequence result, and adjust the parameters of the initial language model according to the output sequence result and the sample sequence to obtain a trained language model.

[0059] Optionally, when the initial language model predicts the i+1th character of the lyrics content in the sample sequence based on the sample sequence, it predicts the i+1th character based on the sample keyword, the sample lyrics format attributes and the first i characters annotated with the lyrics content, to obtain an output sequence result including the sample keyword, the sample lyrics format attributes and the lyrics content prediction results, wherein i is a natural number, the minimum value is 0, and the maximum value plus 1 is the number of characters in the lyrics content.

[0060] Optionally, the device further comprises:

[0061] A keyword sample acquisition module is configured to execute acquisition of sample similar keywords corresponding to the sample subject words;

[0062] The lyrics sequence splicing module is configured to perform:

[0063] Based on the attribute tags corresponding to the subject words, similar keywords, lyrics format attribute information and lyrics content respectively, the sample subject words, sample similar keywords, sample lyrics format attributes and lyrics content annotations are spliced ​​into a sample sequence.

[0064] Optionally, in the sample sequence, the arrangement of the lyrics content annotations is reverse order within a sentence and normal order between sentences, the arrangement of the sample subject words is reverse order, and the arrangement of the sample similar keywords is reverse order.

[0065] Optionally, the lyrics content determination module includes:

[0066] A lyrics content acquisition unit is configured to execute attribute marking corresponding to the lyrics content, and acquire lyrics content arranged in reverse order within a sentence and in normal order between sentences from the output sequence;

[0067] The lyrics content conversion unit is configured to perform a reverse order processing on the lyrics content arranged in reverse order within a sentence and in normal order between sentences, so as to obtain lyrics content corresponding to the subject word and lyrics format attribute information.

[0068] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0069] processor;

[0070] a memory for storing instructions executable by the processor;

[0071] The processor is configured to execute the instructions to implement the lyrics generation method as described in the first aspect.

[0072] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the lyrics generation method as described in the first aspect.

[0073] According to a fifth aspect of an embodiment of the present disclosure, there is provided a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the lyrics generation method described in the first aspect is implemented.

[0074] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0075] The disclosed embodiment obtains the subject words and the lyrics format attribute information corresponding to the lyrics to be generated, determines the input sequence according to the subject words and the lyrics format attribute information, inputs the input sequence into the language model, obtains the output sequence of the language model, and determines the lyrics content corresponding to the subject words and the lyrics format attribute information according to the output sequence. Since the generated lyrics content is controlled based on multiple control attributes such as the subject words and the lyrics format attribute information, the quality of the generated lyrics can be improved compared to the control of a single attribute, and the matching of the generated lyrics content with multiple control attributes can be improved compared to the multi-stage cascade method, thereby improving the accuracy of the lyrics content.

[0076] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0078] Figure 1 is a flow chart of a method for generating lyrics according to an exemplary embodiment;

[0079] Figure 2 is a block diagram of a lyrics generating device according to an exemplary embodiment;

[0080] Figure 3It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0081] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0082] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0083] Attribute-controllable lyrics generation belongs to the field of text generation research. It is an interesting and challenging task in both academia and industry, and has attracted the attention of many researchers in recent years. The controllable attributes of lyrics are generally divided into content attribute control and format attribute control. This task has also been expanded from the initial single content attribute control of the subject word to the multi-attribute joint control of the subject word and the lyrics format, which is convenient for subsequent combination with melody. This demand puts forward advanced requirements for technology. In order to generate high-quality lyrics, the embodiments of the present disclosure provide the following technical solutions.

[0084] Figure 1 is a flowchart of a method for generating lyrics according to an exemplary embodiment. Figure 1 As shown, the lyrics generation method can be used in electronic devices such as mobile phones, computers, servers, etc., and includes the following steps.

[0085] In step S11, the subject words and lyrics format attribute information corresponding to the lyrics to be generated are obtained.

[0086] The lyrics format attribute information includes the total number of lyrics sentences and the number of words in each sentence.

[0087] When a user wants to generate a lyric, he can provide the subject word and the lyric format attribute information corresponding to the lyric to be generated. The obtained subject word and lyric format attribute information can be used together to control the generation of the lyric content.

[0088] In an exemplary embodiment, the method of obtaining the subject word and the lyrics format attribute information corresponding to the lyrics to be generated includes: obtaining the subject word corresponding to the lyrics to be generated input by the user; obtaining at least one lyrics format attribute template corresponding to the subject word, and displaying the at least one lyrics format attribute template; obtaining the lyrics format attribute template selected by the user from the at least one lyrics format attribute template, and determining the lyrics format attribute information corresponding to the selected lyrics format attribute template as the lyrics format attribute information corresponding to the lyrics to be generated.

[0089] The lyrics format attribute template is a template including lyrics format attribute information, and the lyrics format attribute information in each lyrics format attribute template is different.

[0090] A keyword configuration interface can be set up, and a keyword corresponding to the lyrics to be generated input by the user can be obtained through the keyword configuration interface. After the keyword is obtained, at least one lyrics format attribute template corresponding to the keyword can be obtained from the correspondence between the preset keyword and the lyrics format attribute template, and the at least one lyrics format attribute template can be displayed. The user can select a lyrics format attribute template from the at least one displayed lyrics format attribute template, thereby obtaining the lyrics format attribute template selected by the user from the at least one lyrics format attribute template, and determining the lyrics format attribute information corresponding to the selected lyrics format attribute template as the lyrics format attribute information corresponding to the lyrics to be generated. By displaying at least one corresponding lyrics format attribute template after obtaining the keyword, the corresponding lyrics format attribute information can be quickly and accurately obtained.

[0091] In another exemplary embodiment, the obtaining of the subject words and lyrics format attribute information corresponding to the lyrics to be generated includes: obtaining the subject words and lyrics format attribute information input by the user through a lyrics attribute configuration interface to obtain the subject words and lyrics format attribute information corresponding to the lyrics to be generated.

[0092] In response to the user's lyrics generation instruction, a lyrics attribute configuration interface is displayed. Through the lyrics attribute configuration interface, the user can input the subject word and lyrics format attribute information of the lyrics to be generated, so that the electronic device executing the lyrics generation method obtains the subject word and lyrics format attribute information corresponding to the lyrics to be generated. Through the lyrics attribute configuration interface, the user can flexibly set the subject word and lyrics format attribute information.

[0093] In step S12, an input sequence is determined according to the subject words and the lyrics format attribute information, and the input sequence is input into a language model.

[0094] Among them, the language model can be a model obtained by training the pre-trained language model GPT2 using lyrics samples.

[0095] The subject words and lyrics format attribute information are spliced ​​into an input sequence. When splicing the subject words and lyrics format attribute information, the splicing can be based on the number of bits occupied by the subject words and lyrics format attribute information in the input sequence; or, the attribute tags corresponding to the subject words and lyrics format attribute information can be pre-set. When splicing the subject words and lyrics format attribute information into an input sequence, the attribute tags corresponding to the subject words and lyrics format attribute information are spliced ​​into the input sequence at the same time. It can start with the attribute tag and the corresponding attribute (subject word or lyrics format attribute information) is followed by the attribute tag, and then the next attribute tag and the corresponding attribute are spliced. After splicing the subject words and lyrics format attribute information to obtain the input sequence, the input sequence is input into the language model.

[0096] In an exemplary embodiment, before determining the input sequence according to the subject word and the lyrics format attribute information, the method further includes: obtaining similar keywords of the subject word;

[0097] According to the subject words and the lyrics format attribute information, an input sequence is determined, and the input sequence is input into a language model, including: based on the attribute tags corresponding to the subject words, similar keywords and the lyrics format attribute information, the subject words, similar keywords and the lyrics format attribute information are spliced ​​into an input sequence, and the input sequence is input into the language model.

[0098] After obtaining the subject word, similar keywords of the subject word can be obtained from the database, and similar keywords of the subject word can be obtained based on similarity, and the similarity can be text similarity or word vector similarity. After obtaining similar keywords of the subject word, the subject word, similar keywords and lyrics format attribute information are spliced ​​into an input sequence at the same time. The subject word, similar keywords and lyrics format attribute information are respectively generated as control attributes for different lyrics, so that based on the attribute tags corresponding to the subject word, similar keywords and lyrics format attribute information, the subject word, similar keywords and lyrics format attribute information are spliced ​​into an input sequence, and the input sequence is input into the language model.

[0099] The attribute tag can be used as a prefix tag when splicing into an input sequence. The lyrics format attribute information includes two parts, namely the total number of lyrics sentences and the number of words in each sentence. Each part corresponds to an attribute tag. "[number]" can be used as the attribute tag for the total number of lyrics sentences, and "[template]" can be used as the attribute tag for the number of words in each sentence. For example, when the total number of lyrics sentences is 17, the total number of lyrics sentences to be generated can be expressed as "lyric number= [number]

[17] ", where [number] is the prefix mark of the total number of lyrics sentences, and the following

[17] indicates that the specific value is 17 sentences; the number of words in each sentence can be expressed as "lyric template =[template][7][7][8][7][7]…[4]”, where [template] is the prefix mark of the number of words in each sentence, and the following sequence represents the specific value.

[0100] You can use "[theme]" as the attribute tag of the theme word. For example, the theme word of lyrics can be expressed as "lyric theme = [theme] See you soon", where [theme] is the prefix tag of the subject word, followed by specific content information, and the subject word content is processed in reverse order. "[keyword]" can be used as an attribute tag for similar keywords. For example, similar keywords can be expressed as "lyric keyword =[keyword]We met each other not long ago, do you remember me?" [keyword] is the prefix mark of similar keywords, followed by the splicing of multiple similar keywords related to the subject.

[0101] After the above processing, the input sequence composed of the subject words, similar keywords and lyrics format attribute information can be expressed as “x1,…,x N =lyric number ;lyric template ;lyric them ;lyric keyword ", where the symbol ";" indicates sequence splicing and N indicates the sequence length.

[0102] By splicing similar keywords of the subject words into the input sequence, similar keywords can assist in the understanding of the subject words and provide some relevant images to help generate lyrics, thereby improving the relevance between the generated lyrics content and the subject words.

[0103] In an exemplary embodiment, obtaining similar keywords of the subject word includes: obtaining the word vector of the subject word; determining the similarity between the word vector of the keyword in the word vector library and the word vector of the subject word; and determining a preset number of keywords with the highest similarity as similar keywords of the subject word.

[0104] The word vector of the subject word can be determined by a word vector model, and the similarity between the word vector of the subject word and the word vector of the keyword in the word vector library can be calculated, and a preset number of keywords with the highest similarity can be screened out, and these keywords are determined as similar keywords of the subject word. The preset number can be, for example, 5.

[0105] Based on the word vector similarity, similar keywords with similar semantics to the theme words can be obtained, further improving the relevance of the generated lyrics content with the theme words.

[0106] In step S13, the output sequence of the language model is obtained.

[0107] By processing the input sequence through the language model, lyrics content corresponding to the subject words and lyrics format attribute information can be generated and output in the form of a sequence, so that the output sequence of the language model can be obtained. When the language model predicts the lyrics content based on the input sequence, it first predicts the first character of the lyrics content based on the input sequence, and then predicts the second character of the lyrics content based on the input sequence and the first character of the predicted lyrics content, and then predicts the third character of the lyrics content based on the input sequence and the first two characters of the predicted lyrics content, and so on, until all characters of the lyrics content are predicted, the lyrics content corresponding to the subject words and lyrics format attribute information is obtained, and an output sequence including the subject words, lyrics format attribute information and lyrics content is generated.

[0108] In step S14, the lyrics content corresponding to the subject word and the lyrics format attribute information is determined according to the output sequence.

[0109] The output sequence of the language model includes lyrics content corresponding to the subject words and lyrics format attribute information, so that the lyrics content corresponding to the subject words and lyrics format attribute information can be extracted from the output sequence. The attribute tags of the lyrics content can be set in advance, and the attribute tags of the lyrics content can be identified in the output sequence, so that the lyrics content can be extracted from the output sequence based on the attribute tags of the lyrics content. Among them, the attribute tags of the lyrics content can include prefix tags and suffix tags. For example, "[START]" and " " can be used as prefix tags and suffix tags of the lyrics content, respectively, so that the content between the prefix tag "[START]" and the suffix tag " " can be extracted in the output sequence to obtain the lyrics content corresponding to the subject words and lyrics format attribute information.

[0110] There may be multiple candidate lyric contents in the output sequence of the language model. For example, four candidate lyric contents may be given and displayed. The user may select one candidate lyric content from them, obtain the candidate lyric content selected by the user, and use the candidate lyric content selected by the user as the final lyric content.

[0111] The lyric generation method provided by this exemplary embodiment obtains the subject words and lyric format attribute information corresponding to the lyrics to be generated, determines the input sequence according to the subject words and the lyric format attribute information, inputs the input sequence into a language model, obtains the output sequence of the language model, and determines the lyric content corresponding to the subject words and the lyric format attribute information according to the output sequence. Since the generated lyric content is controlled based on multiple control attributes such as the subject words and the lyric format attribute information, the quality of the generated lyrics can be improved compared to the control of a single attribute, and the matching of the generated lyric content with multiple control attributes can be improved compared to the multi-stage cascade method, thereby improving the accuracy of the lyric content.

[0112] On the basis of the above technical solution, the method also includes: obtaining sample lyrics, the sample lyrics including sample keywords, sample lyrics format attributes and lyrics content annotations; based on the attribute tags corresponding to the keywords, lyrics format attribute information and lyrics content, splicing the sample keywords, sample lyrics format attributes and lyrics content annotations into a sample sequence; inputting the sample sequence into an initial language model to obtain an output sequence result, and adjusting the parameters of the initial language model according to the output sequence result and the sample sequence to obtain a trained language model.

[0113] The initial language model is a pre-trained language model GPT2, and the GPT2 model used may have 12 layers, a hidden layer dimension of 768, and a self-attention mechanism head number of 12. In the process of training the initial language model, the AdamW optimizer can be used to optimize the parameters, and the language model can be implemented based on PyTorch.

[0114] Obtain sample lyrics including sample keywords, sample lyrics format attributes and lyrics content annotations, and perform serialization processing on the sample lyrics, that is, based on the attribute tags corresponding to the keywords, lyrics format attribute information and lyrics content, respectively, splice the sample keywords, sample lyrics format attributes and lyrics content annotations into a sample sequence. The attribute tags of the lyrics content may include prefix tags and suffix tags, which facilitates the distinction of the lyrics content. After processing multiple sample lyrics to obtain multiple sample sequences, the sample sequences can be used to train the initial language model, that is, input the sample sequences into the initial language model, obtain the output results of the initial language model, obtain the output sequence results, and adjust the parameters of the language model based on the difference between the output sequence results and the sample sequence until the training is completed. During the training process, the negative log-likelihood function is used as the loss function, that is, the negative log-likelihood function between the output sequence results is minimized. The AdamW optimizer is used to optimize the parameters of the model so that the difference between the output sequence results and the sample sequence converges to obtain a trained language model.

[0115] By training the initial language model with sample lyrics including sample keywords, sample lyrics format attributes and lyrics content annotations, the trained language model can be obtained, which can better generate lyrics content corresponding to the keyword and lyrics format attribute information, thereby improving the quality of the generated lyrics content.

[0116] Among them, when the initial language model predicts the i+1th character of the lyrics content in the sample sequence based on the sample sequence, it predicts the i+1th character based on the sample keyword, the sample lyrics format attributes and the first i characters annotated with the lyrics content, and obtains an output sequence result including the sample keyword, the sample lyrics format attributes and the lyrics content prediction results, wherein i is a natural number, the minimum value is 0, and the maximum value plus 1 is the number of characters in the lyrics content. After the entire sample sequence is input into the initial language model, the language model starts to predict from the first character of the lyrics content based on the sample subject words and sample lyrics format attributes in the sample sequence. After predicting the first character of the lyrics content, the second character of the lyrics content is predicted based on the sample subject words, sample lyrics format attributes and the first character of the lyrics content annotation in the sample sequence. Then, the third character of the lyrics content is predicted based on the sample subject words, sample lyrics format attributes and the first two characters of the lyrics content annotation in the sample sequence. And so on. When predicting the i+1th character of the lyrics content, the i+1th character is predicted based on the sample subject words, sample lyrics format attributes and the first i characters of the lyrics content annotation. After each character obtains a prediction result, the prediction results of all characters of the lyrics content constitute the lyrics content prediction results, and the sequence composed of the sample subject words, sample lyrics format attributes and lyrics content prediction results is the output sequence result. The accuracy of language model training can be improved by using sample keywords, sample lyrics format attributes and the first i characters annotated with the lyrics content to predict the i+1th character, rather than using the predicted first i characters to predict the i+1th character.

[0117] On the basis of the above technical solution, before the sample subject words, sample lyric format attributes and lyric content annotations are spliced ​​into a sample sequence based on the attribute tags corresponding to the subject words and the lyric format attribute information, the method further includes: obtaining sample similar keywords corresponding to the sample subject words;

[0118] Based on the attribute tags corresponding to the subject words, the lyrics format attribute information and the lyrics content, the sample subject words, the sample lyrics format attributes and the lyrics content annotations are spliced ​​into a sample sequence, including: based on the attribute tags corresponding to the subject words, similar keywords, the lyrics format attribute information and the lyrics content, the sample subject words, the sample similar keywords, the sample lyrics format attributes and the lyrics content annotations are spliced ​​into a sample sequence.

[0119] The word vector of the sample subject word can be determined, and the similarity between the word vector of the keyword in the word vector library and the word vector of the sample subject word can be determined, and a preset number of keywords with the highest similarity can be obtained, and these keywords can be determined as sample similar keywords corresponding to the sample subject word. Based on the attribute tags corresponding to the subject word, similar keywords, lyrics format attribute information and lyrics content, the sample subject word, sample similar keywords, sample lyrics format attributes and lyrics content annotations are spliced ​​into a sample sequence. The attribute tags of the lyrics content can include prefix tags and suffix tags. Lyrics can be used content represents the lyrics content sequence, then the sample sequence can be expressed as: x1,…,x M =lyric number ;lyric template ;lyric theme ;lyric keyword ;lyric content , M represents the length of the sample sequence.

[0120] By splicing sample similar keywords corresponding to sample subject words into the sample sequence, sample similar keywords can assist in the understanding of sample subject words and provide some relevant images to help generate lyrics, so that the language model can learn the relevance between the lyrics content and subject words and improve the quality of generated lyrics.

[0121] In the sample sequence, the arrangement of the lyrics content annotation is reverse order within the sentence and normal order between sentences, the arrangement of the sample subject words is reverse order, and the arrangement of the sample similar keywords is reverse order. Using the lyrics content arrangement method of reverse order within the sentence and normal order between sentences, the last character of each sentence of lyrics is placed in the front position in reverse order, and the importance of rhyme is emphasized through the characteristics of the language model. In this way, the rhyme information in the lyrics can be learned. Experiments have shown that this method can indeed generate lyrics with appropriate rhymes and improve the quality of generated lyrics.

[0122] In order to ensure that the generated lyrics content conforms to the specified lyrics format attribute information, the number of words in each sentence of the lyrics in the lyrics format attribute information can be inserted into the lyrics content sequence, for example, it can be placed at the beginning of each sentence of the lyrics. This can serve as an information guide, thereby promoting the language model's learning and understanding of the lyrics format attribute information.

[0123] The language model trained in the above way is an end-to-end model, which can achieve the control of lyrics attributes while ensuring the relevance of the subject words and lyrics content and having smooth rhymes. To a certain extent, it can meet the current market and academic research needs for lyrics attribute control, and assist music creation by generating high-quality lyrics.

[0124] On the basis of the above technical solution, the lyrics content corresponding to the theme word and the lyrics format attribute information is determined according to the output sequence, including: according to the attribute mark corresponding to the lyrics content, the lyrics content arranged in reverse order within the sentence and in normal order between sentences is obtained from the output sequence; the lyrics content arranged in reverse order within the sentence and in normal order between sentences is processed in reverse order within the sentence to obtain the lyrics content corresponding to the theme word and the lyrics format attribute information.

[0125] The output sequence of the language model is obtained. The format of the output sequence is the same as the format of the above-mentioned lyrics sequence. After obtaining the output sequence of the language model, the attribute tags corresponding to the lyrics content in the output sequence are identified. After the prefix tags and suffix tags corresponding to the lyrics content are identified, the content between the prefix tags and the suffix tags is extracted. The content is the lyrics content arranged in reverse order within the sentence and in normal order between sentences. At this time, the lyrics content arranged in reverse order within the sentence and in normal order between sentences is processed in reverse order within the sentence, that is, each sentence in the lyrics content is identified based on punctuation marks, and each sentence is processed in reverse order within the sentence respectively. The order between the sentences remains unchanged, and the lyrics content corresponding to the subject words and the lyrics format attribute information is obtained. The lyrics content in the output sequence of the language model is arranged in reverse order within the sentence and in normal order between sentences, which can highlight the importance of rhyme, ensure that the lyrics have appropriate rhyme to reflect the beauty of rhythm and rhyme, and further improve the quality of the generated lyrics.

[0126] Figure 2 is a block diagram of a lyric generation device according to an exemplary embodiment. Figure 2 The device includes an attribute acquisition module 21, an input sequence determination module 22, an output sequence acquisition module 23 and a lyrics content determination module 24.

[0127] The attribute acquisition module 21 is configured to execute acquisition of subject words and lyrics format attribute information corresponding to the lyrics to be generated;

[0128] The input sequence determination module 22 is configured to determine the input sequence according to the subject words and the lyrics format attribute information, and input the input sequence into the language model;

[0129] The output sequence acquisition module 23 is configured to execute acquisition of the output sequence of the language model;

[0130] The lyrics content determination module 24 is configured to determine the lyrics content corresponding to the subject word and the lyrics format attribute information according to the output sequence.

[0131] Optionally, the device further comprises:

[0132] A similar keyword acquisition module is configured to acquire similar keywords of the subject word;

[0133] The input sequence determination module is configured to perform:

[0134] Based on the attribute tags respectively corresponding to the subject words, similar keywords and lyrics format attribute information, the subject words, similar keywords and lyrics format attribute information are spliced ​​into an input sequence, and the input sequence is input into a language model.

[0135] Optionally, the similar keyword acquisition module includes:

[0136] A word vector acquisition unit, configured to acquire the word vector of the subject word;

[0137] A similarity determination unit is configured to determine the similarity between the word vector of the keyword in the word vector library and the word vector of the subject word;

[0138] The similar keyword determining unit is configured to determine a preset number of keywords with the highest similarity as similar keywords of the subject word.

[0139] Optionally, the attribute acquisition module includes:

[0140] A theme word acquisition unit, configured to acquire a theme word corresponding to the lyrics to be generated input by a user;

[0141] A format template display unit is configured to obtain at least one lyrics format attribute template corresponding to the subject word and display the at least one lyrics format attribute template;

[0142] The format attribute acquisition unit is configured to acquire the lyrics format attribute template selected by the user from the at least one lyrics format attribute template, and determine the lyrics format attribute information corresponding to the selected lyrics format attribute template as the lyrics format attribute information corresponding to the lyrics to be generated.

[0143] Optionally, the attribute acquisition module includes:

[0144] The attribute acquisition unit is configured to acquire the subject word and the lyrics format attribute information input by the user through the lyrics attribute configuration interface, and obtain the subject word and the lyrics format attribute information corresponding to the lyrics to be generated.

[0145] Optionally, the device further comprises:

[0146] A sample lyrics acquisition module is configured to execute acquisition of sample lyrics, wherein the sample lyrics include sample subject words, sample lyrics format attributes and lyrics content annotations;

[0147] A lyrics sequence splicing module is configured to perform attribute labeling corresponding to the subject words, the lyrics format attribute information and the lyrics content, and splice the sample subject words, the sample lyrics format attributes and the lyrics content annotations into a sample sequence;

[0148] The model training module is configured to input the sample sequence into the initial language model to obtain an output sequence result, and adjust the parameters of the initial language model according to the output sequence result and the sample sequence to obtain a trained language model.

[0149] Optionally, when the initial language model predicts the i+1th character of the lyrics content in the sample sequence based on the sample sequence, it predicts the i+1th character based on the sample keyword, the sample lyrics format attributes and the first i characters annotated with the lyrics content, to obtain an output sequence result including the sample keyword, the sample lyrics format attributes and the lyrics content prediction results, wherein i is a natural number, the minimum value is 0, and the maximum value plus 1 is the number of characters in the lyrics content.

[0150] Optionally, the device further comprises:

[0151] A keyword sample acquisition module is configured to execute acquisition of sample similar keywords corresponding to the sample subject words;

[0152] The lyrics sequence splicing module is configured to perform:

[0153] Based on the attribute tags corresponding to the subject words, similar keywords, lyrics format attribute information and lyrics content respectively, the sample subject words, sample similar keywords, sample lyrics format attributes and lyrics content annotations are spliced ​​into a sample sequence.

[0154] Optionally, in the sample sequence, the arrangement of the lyrics content annotations is reverse order within a sentence and normal order between sentences, the arrangement of the sample subject words is reverse order, and the arrangement of the sample similar keywords is reverse order.

[0155] Optionally, the lyrics content determination module includes:

[0156] A lyrics content acquisition unit is configured to execute attribute marking corresponding to the lyrics content, and acquire lyrics content arranged in reverse order within a sentence and in normal order between sentences from the output sequence;

[0157] The lyrics content conversion unit is configured to perform a reverse order processing on the lyrics content arranged in reverse order within a sentence and in normal order between sentences, so as to obtain lyrics content corresponding to the subject word and lyrics format attribute information.

[0158] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0159] Figure 3 3 is a block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 300 may be provided as a server or a computer. Figure 3 The electronic device 300 includes a processing component 322, which further includes one or more processors, and a memory resource represented by a memory 332 for storing instructions executable by the processing component 322, such as an application. The application stored in the memory 332 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 322 is configured to execute instructions to perform the above-mentioned lyrics generation method.

[0160] The electronic device 300 may also include a power supply component 326 configured to perform power management of the electronic device 300, a wired or wireless network interface 350 configured to connect the electronic device 300 to a network, and an input / output (I / O) interface 358. The electronic device 300 may operate based on an operating system stored in the memory 332, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.

[0161] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 332 including instructions, and the above instructions can be executed by the processing component 322 of the electronic device 300 to complete the above lyrics generation method. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0162] In an exemplary embodiment, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the above-mentioned lyrics generation method is implemented.

[0163] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0164] It should be understood that the present invention is not limited to the exact construction that has 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 invention is limited only by the appended claims.

Claims

1. A lyrics generation method, characterized in that: include: Obtaining subject words and lyrics format attribute information corresponding to the lyrics to be generated, wherein the lyrics format attribute information includes the total number of lyrics sentences and the number of words in each sentence; Determine an input sequence according to the subject words and the lyrics format attribute information, and input the input sequence into a language model, wherein the language model is trained using a sample sequence, wherein the sample sequence at least includes lyrics content annotations, and the lyrics content annotations are arranged in reverse order within a sentence and in normal order between sentences, and the last character of each sentence of the lyrics is placed in the front position in reverse order; Acquire an output sequence of the language model, wherein the output sequence includes lyrics content arranged in reverse order within a sentence and in normal order between sentences; Determining the lyrics content corresponding to the theme word and the lyrics format attribute information according to the output sequence, at least comprising: performing a reverse order processing on each sentence, while keeping the order between the sentences unchanged, to obtain the lyrics content corresponding to the theme word and the lyrics format attribute information; The step of obtaining the subject words and the lyrics format attribute information corresponding to the lyrics to be generated includes: Obtaining a keyword corresponding to the lyrics to be generated input by a user; Acquire at least one lyrics format attribute template corresponding to the subject word, and display the at least one lyrics format attribute template; The lyrics format attribute template selected by the user from the at least one lyrics format attribute template is obtained, and the lyrics format attribute information corresponding to the selected lyrics format attribute template is determined as the lyrics format attribute information corresponding to the lyrics to be generated.

2. The method according to claim 1, characterized in that Before determining the input sequence according to the subject words and the lyrics format attribute information, the method further includes: Obtain similar keywords of the subject word; Determining an input sequence according to the subject words and the lyrics format attribute information, and inputting the input sequence into a language model, including: Based on the attribute tags respectively corresponding to the subject words, similar keywords and lyrics format attribute information, the subject words, similar keywords and lyrics format attribute information are spliced ​​into an input sequence, and the input sequence is input into a language model.

3. The method according to claim 2, characterized in that Obtain similar keywords to the subject word, including: Obtaining a word vector of the subject word; Determine the similarity between the word vector of the keyword in the word vector library and the word vector of the subject word; The preset number of keywords with the highest similarity are determined as similar keywords of the subject word.

4. The method according to any one of claims 1 to 3, characterized in that: The step of obtaining the subject words and the lyrics format attribute information corresponding to the lyrics to be generated includes: The theme word and the lyrics format attribute information input by the user are obtained through the lyrics attribute configuration interface, and the theme word and the lyrics format attribute information corresponding to the lyrics to be generated are obtained.

5. The method according to claim 1, characterized in that: Also includes: Acquire sample lyrics, wherein the sample lyrics include sample keywords, sample lyrics format attributes and lyrics content annotations; Based on the attribute tags corresponding to the subject words, the lyrics format attribute information and the lyrics content, the sample subject words, the sample lyrics format attributes and the lyrics content annotations are spliced ​​into a sample sequence; The sample sequence is input into an initial language model to obtain an output sequence result, and the parameters of the initial language model are adjusted according to the output sequence result and the sample sequence to obtain a trained language model.

6. The method according to claim 5, characterized in that When the initial language model predicts the i+1th character of the lyrics content in the sample sequence based on the sample sequence, the i+1th character is predicted based on the sample subject words, the sample lyrics format attributes and the first i characters annotated with the lyrics content, and an output sequence result including the sample subject words, the sample lyrics format attributes and the lyrics content prediction results is obtained, wherein i is a natural number, the minimum value is 0, and the maximum value plus 1 is the number of characters in the lyrics content.

7. The method according to claim 5, characterized in that Before splicing the sample subject words, sample lyric format attributes and lyric content annotations into a sample sequence based on the attribute tags corresponding to the subject words and the lyric format attribute information, the method further includes: Obtain sample similar keywords corresponding to the sample subject words; Based on the attribute tags corresponding to the subject words, the lyrics format attribute information and the lyrics content, the sample subject words, the sample lyrics format attributes and the lyrics content annotations are spliced ​​into a sample sequence, including: Based on the attribute tags corresponding to the subject words, similar keywords, lyrics format attribute information and lyrics content respectively, the sample subject words, sample similar keywords, sample lyrics format attributes and lyrics content annotations are spliced ​​into a sample sequence.

8. The method according to claim 7, characterized in that In the sample sequence, the sample subject words are arranged in reverse order, and the sample similar keywords are arranged in reverse order.

9. The method according to claim 8, characterized in that Determining the lyrics content corresponding to the subject word and the lyrics format attribute information according to the output sequence also includes: According to the attribute tags corresponding to the lyrics content, the lyrics content arranged in reverse order within the sentence and in normal order between sentences is obtained from the output sequence.

10. A lyrics generating device, characterized in that: include: An attribute acquisition module is configured to acquire a subject word and lyrics format attribute information corresponding to the lyrics to be generated, wherein the lyrics format attribute information includes the total number of lyrics sentences and the number of words in each sentence; An input sequence determination module is configured to determine an input sequence according to the subject words and the lyrics format attribute information, and input the input sequence into a language model, wherein the language model is trained using a sample sequence, wherein the sample sequence at least includes lyrics content annotations, wherein the lyrics content annotations are arranged in reverse order within a sentence and in normal order between sentences, and the last character of each sentence of the lyrics is placed in the front position in reverse order; An output sequence acquisition module is configured to execute acquisition of an output sequence of the language model, wherein the output sequence includes lyrics content arranged in a reverse order within a sentence and in a normal order between sentences; A lyrics content determination module is configured to determine the lyrics content corresponding to the subject word and the lyrics format attribute information according to the output sequence; The lyrics content determination module at least includes: A lyrics content conversion unit is configured to perform a reverse order processing on the lyrics content arranged in a reverse order within a sentence and a normal order between sentences, so as to obtain lyrics content corresponding to the subject word and the lyrics format attribute information; The attribute acquisition module includes: A theme word acquisition unit, configured to acquire a theme word corresponding to the lyrics to be generated input by a user; A format template display unit is configured to obtain at least one lyrics format attribute template corresponding to the subject word and display the at least one lyrics format attribute template; The format attribute acquisition unit is configured to acquire the lyrics format attribute template selected by the user from the at least one lyrics format attribute template, and determine the lyrics format attribute information corresponding to the selected lyrics format attribute template as the lyrics format attribute information corresponding to the lyrics to be generated.

11. The device according to claim 10, characterized in that The device also includes: A similar keyword acquisition module is configured to acquire similar keywords of the subject word; The input sequence determination module is configured to perform: Based on the attribute tags respectively corresponding to the subject words, similar keywords and lyrics format attribute information, the subject words, similar keywords and lyrics format attribute information are spliced ​​into an input sequence, and the input sequence is input into a language model.

12. The device according to claim 11, characterized in that The similar keyword acquisition module includes: A word vector acquisition unit, configured to acquire the word vector of the subject word; A similarity determination unit is configured to determine the similarity between the word vector of the keyword in the word vector library and the word vector of the subject word; The similar keyword determining unit is configured to determine a preset number of keywords with the highest similarity as similar keywords of the subject word.

13. The device according to any one of claims 10 to 12, characterized in that: The attribute acquisition module includes: The attribute acquisition unit is configured to acquire the subject word and the lyrics format attribute information input by the user through the lyrics attribute configuration interface, and obtain the subject word and the lyrics format attribute information corresponding to the lyrics to be generated.

14. The device according to claim 10, characterized in that The device also includes: A sample lyrics acquisition module is configured to execute acquisition of sample lyrics, wherein the sample lyrics include sample subject words, sample lyrics format attributes and lyrics content annotations; A lyrics sequence splicing module is configured to perform attribute labeling corresponding to the subject words, the lyrics format attribute information and the lyrics content, and splice the sample subject words, the sample lyrics format attributes and the lyrics content annotation into a sample sequence; The model training module is configured to input the sample sequence into the initial language model to obtain an output sequence result, and adjust the parameters of the initial language model according to the output sequence result and the sample sequence to obtain a trained language model.

15. The device according to claim 14, characterized in that When the initial language model predicts the i+1th character of the lyrics content in the sample sequence based on the sample sequence, the i+1th character is predicted based on the sample subject words, the sample lyrics format attributes and the first i characters annotated with the lyrics content, and an output sequence result including the sample subject words, the sample lyrics format attributes and the lyrics content prediction results is obtained, wherein i is a natural number, the minimum value is 0, and the maximum value plus 1 is the number of characters in the lyrics content.

16. The device according to claim 14, characterized in that The device also includes: A keyword sample acquisition module is configured to execute acquisition of sample similar keywords corresponding to the sample subject words; The lyrics sequence splicing module is configured to perform: Based on the attribute tags corresponding to the subject words, similar keywords, lyrics format attribute information and lyrics content respectively, the sample subject words, sample similar keywords, sample lyrics format attributes and lyrics content annotations are spliced ​​into a sample sequence.

17. The device according to claim 16, characterized in that In the sample sequence, the sample subject words are arranged in reverse order, and the sample similar keywords are arranged in reverse order.

18. The device according to claim 17, characterized in that The lyrics content determination module also includes: The lyrics content acquisition unit is configured to execute attribute marking corresponding to the lyrics content, and acquire the lyrics content arranged in reverse order within a sentence and in normal order between sentences from the output sequence.

19. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the lyrics generation method as described in any one of claims 1 to 9.

20. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the lyrics generation method as described in any one of claims 1 to 9.

21. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the lyrics generation method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Lyrics generating method and device

    CN106528858A

  • Text generation method, apparatus, electronic device, and computer-readable medium

    CN109086408A

  • Lyric generation method, lyric generation model training method, lyric generation model training device and electronic equipment

    CN113591472A