CN114818676A - Poetry generation method, device and medium - Google Patents

Poetry generation method, device and medium Download PDF

Info

Publication number
CN114818676A
CN114818676A CN202110130845.2A CN202110130845A CN114818676A CN 114818676 A CN114818676 A CN 114818676A CN 202110130845 A CN202110130845 A CN 202110130845A CN 114818676 A CN114818676 A CN 114818676A
Authority
CN
China
Prior art keywords
poetry
information
language model
words
candidate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110130845.2A
Other languages
Chinese (zh)
Inventor
郭宝奎
康琪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sogou Technology Development Co Ltd
Original Assignee
Beijing Sogou Technology Development Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sogou Technology Development Co Ltd filed Critical Beijing Sogou Technology Development Co Ltd
Priority to CN202110130845.2A priority Critical patent/CN114818676A/en
Publication of CN114818676A publication Critical patent/CN114818676A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/274Converting codes to words; Guess-ahead of partial word inputs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Biophysics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Machine Translation (AREA)

Abstract

The embodiment of the invention provides a poetry generating method, a poetry generating device and a poetry generating medium. The method specifically comprises the following steps: receiving expression information; determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry; the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in poetry sentences to words in a word list so as to predict unknown words in the poetry sentences according to the attention information. The embodiment of the invention can realize the transmission of the expression information through the candidate poetry, can generate the candidate poetry following the poetry rule, and can improve the continuity of the generated candidate poetry.

Description

Poetry generation method, device and medium
Technical Field
The invention relates to the technical field of computers, in particular to a poetry generating method, a poetry generating device and a poetry generating medium.
Background
Poetry means poetry represented by ancient poetry, poetry close to the body and temperament. Poetry is a literary art for explaining soul, and poems and morphemes need to master mature artistic skills and express social life and the human spiritual world with a high concentration by lingering language, a thick chapter, vigorous emotion and rich image according to strict rhythm requirements.
In practical application, a user has a need for generating poems. Poems generated by the user can be sent to relatives and friends as blessing words so as to express greetings; or the generated poems can be released in the circle of friends to improve the quality of the released content.
Disclosure of Invention
The embodiment of the invention provides a poetry generating method and device and a poetry generating device, which can realize that expression information is transmitted through candidate poetry, can generate candidate poetry following the poetry rule, and can improve the continuity of the generated candidate poetry.
In order to solve the above problems, an embodiment of the present invention discloses a poetry generating method, including:
receiving expression information;
determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
On the other hand, the embodiment of the invention discloses a poetry generating device, which comprises:
the receiving module is used for receiving the expression information;
the candidate poetry determining module is used for determining at least one candidate poetry corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
In yet another aspect, an embodiment of the present invention discloses an apparatus for poetry generation, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by one or more processors include instructions for:
receiving expression information;
determining at least one candidate poetry corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
In yet another aspect, embodiments of the present invention disclose a machine-readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a poetry generation method as described in one or more of the preceding.
The embodiment of the invention has the following advantages:
in the embodiment of the invention, the expression information can carry information of poetry sentences at preset positions, such as the first character of the poetry sentences. According to the embodiment of the invention, at least one candidate poem corresponding to the expression information is generated according to an autoregressive language model. Because the information of the candidate poetry at the preset position is matched with the expression information, the expression information can be transmitted through the candidate poetry.
Firstly, a language model is obtained by training according to poetry linguistic data, and poetry rules, such as rhymes of poetry, namely five-language seven-language poetry, absolute poetry and other poetry modes, a narrow and narrow mode, a fight form and other rules can be learned in parameters of the language model; therefore, the language model can follow the poetry law in the poetry generating process, and candidate poetry following the poetry law can be generated.
Moreover, the language model of the embodiment of the invention adopts an autoregressive mechanism, and can update the input information according to a real-time prediction result, so that a text with a preset length can be iteratively generated.
In addition, the self-attention module of the language model in the embodiment of the invention can quickly capture the dependency relationship between each known word and the word in the word list, so that the word with strong dependency relationship can be used as a prediction result, and the continuity of the generated candidate poetry can be further improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic illustration of an environment in which a poetry generation method of an embodiment of the invention is applied;
FIG. 2 is a flow chart of steps of an embodiment of a poetry generation method of the present invention;
FIG. 3 is a schematic illustration of a verse generation process in accordance with an embodiment of the present invention;
FIG. 4 is a block diagram of a poetry generating apparatus according to an embodiment of the present invention;
FIG. 5 is a block diagram of an apparatus 800 for poetry generation according to an embodiment of the present invention; and
fig. 6 is a schematic structural diagram of a server in some embodiments of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a poem generating scheme, which is used for providing a Tibetan poem or Tibetan poem generating service. The Tibetan poem is a poem body in a special form in poem, and sequentially endows contents to be expressed to the first character of each poem. The first character of each sentence of the whole poem can form a complete name of a person, a place, a business name or a sentence of blessings. The Tibetan poem can be used for sequentially endowing the contents to be expressed to the last character of each poem.
The scheme specifically comprises the following steps: receiving expression information; determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry; the language model includes: a plurality of processing layers connected in sequence; the above-mentioned processing layer includes: the self-attention module is used for determining attention information from known words in poetry sentences to words in a word list so as to predict unknown words in the poetry sentences according to the attention information.
In the embodiment of the invention, the expression information can carry the information of the poetry sentences at the preset positions so as to endow the expression information to the words of the poetry sentences at the preset positions. For example, the expression information may carry beginning information, such as the first word of a poetry sentence. As another example, the enunciated information may carry end information, such as the last word of a poetry sentence. Of course, the enunciated information may carry intermediate information, such as intermediate words.
According to the embodiment of the invention, at least one candidate poem corresponding to the expression information is generated according to an autoregressive language model. Because the information of the candidate poetry at the preset position is matched with the expression information, the expression information can be transmitted through the candidate poetry.
The language model is language abstract mathematical modeling based on language objective facts. The role of the language model may include: the next word is predicted from the known information of the sentence.
The autoregressive language model employs an autoregressive mechanism. The autoregressive mechanism may be: updating the input information of the language model according to the prediction result (the predicted words); specifically, the current round of prediction result is added after the current round of input information to obtain the next round of input information, and the next round of input information is input into the language model to obtain the next round of prediction result. Because the autoregressive language model can update the input information according to a real-time prediction result, a text with a preset length can be generated iteratively, and the preset length can be in the range of poetry length.
The embodiment of the invention obtains the language model according to poetry corpus training, and can learn poetry rules, such as rhymes of poetry, namely five-language seven-language poetry, absolute poetry and other poetry, in a narrow and narrow way, in a diagonal form and other rules into parameters of the language model; therefore, the language model can follow the poetry law in the poetry generating process, and candidate poetry following the poetry law can be generated.
In terms of architecture, the language model of the embodiment of the present invention specifically includes: a plurality of processing layers connected in sequence; the treatment layer specifically includes: the self-attention module is used for determining attention information from known words in poetry sentences to words in a word list so as to predict unknown words in the poetry sentences according to the attention information. The self-attention module determines the attention of each known word to the word in the word list, namely, determines the attention information corresponding to the word in the word list at the position of each known word; thus, words that are the prediction results can be determined from the vocabulary based on the attention information. Because the self-attention module of the language model can quickly capture the dependency relationship between each known word and the word in the word list, the word with strong dependency relationship can be used as a prediction result, and the continuity of the generated candidate poetry can be further improved.
The poetry generating method provided by the embodiment of the invention can be applied to the application environment shown in fig. 1, as shown in fig. 1, the client 100 and the server 200 are located in a wired or wireless network, and the client 100 and the server 200 perform data interaction through the wired or wireless network.
Optionally, the client 100 may run on a terminal, which specifically includes but is not limited to: smart phones, tablet computers, electronic book readers, MP3 (Moving Picture Experts Group Audio Layer III) players, MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop portable computers, car-mounted computers, desktop computers, set-top boxes, smart televisions, wearable devices, and the like. The client 100 may correspond to a website, or APP (Application).
The client 100 may receive expression information input by a user, determine at least one candidate poem corresponding to the expression information according to an auto-regressive language model, and display the at least one candidate poem to the user.
Or, the client 100 may receive expression information input by the user, send the expression information to the server 200, and receive at least one candidate poem generated by the server 200 according to the expression information.
Method embodiment one
In the first embodiment of the method, the language model is trained according to poetry linguistic data so that the language model has poetry generating capability.
The embodiment of the invention obtains the language model according to poetry corpus training, and can learn poetry rules, such as rhymes of poetry, namely five-language seven-language poetry, absolute poetry and other poetry, in a narrow and narrow way, in a diagonal form and other rules into parameters of the language model; therefore, the language model can follow the poetry law in the poetry generating process, and candidate poetry following the poetry law can be generated.
The poetry corpus can include poetry of at least one format parameter. The format parameters may include: the number of sentences parameter, and the number of characters contained in the sentence parameter.
The sentence number parameter may include: eight sentences, and four sentences. The verse poetry can be divided into regular poetry, absolute sentence and the like according to the sentence quantity parameters. Wherein, the regular poems are the rhythmic poems with eight sentences each, and the absolute poems are the rhythmic poems with four sentences each.
The number of characters included in the sentence parameter may include: five words, six words, and seven words. According to the number parameters of the characters contained in the sentence, the poetry can be divided into seven-language poetry, five-language poetry and the like. Wherein, the sentence of the seven-language poetry is mainly composed of 7 characters. It is not required that each poem sentence of the seven-language poem is 7 characters, and only that a part of the sentence of the seven-language poem contains 7 characters. The five-language poetry is a poetry body with 5 characters in each sentence.
The sentence quantity parameter and the character quantity parameter may be combined. For example, the five-language poetry may include: the five-language rhythm poems and the five-language absolute sentences. The seventh-language poetry may comprise: lawyer and absolute sentences of the seven languages, etc.
The words are the idioms of a poem, the word cards are the names of the tones of the words, and the word cards can be used as the format parameters of the words. Different word cards have regulations on the total number of sentences, the number of words of each sentence and the level and the narrow pitch.
It is to be understood that the above-described fretted poems and words are merely examples of poems which are embodiments of the present invention, and are not to be construed as limitations of the poems which are embodiments of the present invention.
Actually, the poetry of the embodiment of the invention can include, besides the lattice poetry: the miscellaneous poems and the types of the miscellaneous poems can include: circling poems, skinned poems, clutch poems, pagoda poems, riddle poems, windlass poems, eight-tone song poems, Tibetan poems, deoiled poems, testimonial poems, collective sentence poems, conjunctive sentence poems, century poems, embedded sentence initial poems, anorthose body poems, intellectual body poems and the like.
In addition, besides the poetry of China, the poetry of the embodiment of the invention can also comprise poetry of other countries, such as the poetry of fourteen lines, and the format parameters of the poetry of fourteen lines can comprise: line number, vowel, syllable, tone, structure, etc. It is understood that the embodiment of the present invention does not limit the specific poetry.
The embodiment of the invention can take the poems in the preset number as poem linguistic data, and uses the poem linguistic data to perform unsupervised training on the language model, so that the trained language model has poem generating capability. Examples of the preset number may include: 64 ten thousand, etc., it can be understood that the preset number of poetry corpus is not limited in the embodiment of the present invention.
In the embodiment of the present invention, the language corresponding to the poetry corpus may include: chinese, English, German, Korean, Japanese, etc. it is understood that the language model of the present invention may be applied to any language.
According to the language model provided by the embodiment of the invention, the unknown information of poetry is predicted by taking words as units according to the known information of poetry. The known information may include: known words of poetry sentences. The known information may include: the information is expressed.
Words may represent the basic unit used to record languages. Words may include: a word or phrase. Taking the chinese language as an example, the words may include characters, that is, the chinese poetry may be generated in units of characters. Taking english as an example, words may include words, that is, english poems may be generated in units of words. Poems of other languages are generated and then are mutually referred.
In terms of architecture, the language model of the embodiment of the present invention specifically includes: a plurality of processing layers connected in sequence; the treatment layer specifically includes: the self-attention module is used for determining attention information from known words in poetry sentences to words in a word list so as to predict unknown words in the poetry sentences according to the attention information.
The number of treatment layers can be determined by one skilled in the art according to the requirements of the actual application. The number of treatment layers may range from [4, 24 ]. For example, in order to save computation amount, the number of processing layers may be 4, and it is understood that the specific number of processors is not limited by the embodiment of the present invention.
The processing of the first processing layer may include: the method comprises the steps of receiving input information, processing the input information through a self-attention module, and then transmitting a processing result to a neural network module. After the first processing layer finishes processing, the output information is transmitted to the next processing layer to continue calculation. The different processing layers are processed in the same manner, but each processing layer maintains parameters in its own self-attention module and neural network module.
After the output information is generated in the last processing layer, the language model can determine attention information corresponding to the words in the word list according to the attention information from the known words in the poetry sentences to the words in the word list, which is included in the output information; and, the words as the prediction result can be determined from the word list according to the attention information corresponding to the words in the word list. For example, if the attention information corresponding to the word in the word list is the attention score, the word serving as the prediction result may be determined from the word list in the order of the attention scores from high to low, and for example, N (N is a natural number greater than 0) words with higher attention scores may be selected as the current round of prediction results.
The vocabulary of the embodiment of the invention can be a vocabulary of a preset scale corresponding to a preset language. The predetermined language may be determined according to the language generated by the poetry, for example, the predetermined language may be chinese. The predetermined scale may characterize the number of words included in the vocabulary. Examples of the preset scale may include: 10896, it is to be understood that the embodiments of the present invention are not limited to the particular size of the vocabulary.
The general poetry corpus may include: the poetry sentences can learn the rules of poetry, such as rhymes, tone and narrow patterns, opposite-stick patterns and the like of poetry such as five-language seven-language poetry, absolute poetry and the like, into the parameters of the language model.
In an alternative embodiment of the present invention, the poetry corpus may include: the poetry sentences and the expression information positioned in front of the poetry sentences, namely, the expression information can be positioned at the head of the poetry corpus.
In practical application, preset characters can be set between the expression information of the poetry corpus and poetry sentences so as to segment the expression information of the poetry corpus and the poetry sentences. The preset characters may include: sep, etc., it is to be understood that the present invention is not limited to the specific preset characters. For example, the poetry corpus corresponding to the quiet night thought of the Tang poem may include: "bed doubt refers to low seq bed bright moonlight, doubtful frost on the ground. To look at the moon and to look low at the hometown. "
According to the embodiment of the invention, the expression information is set before the poetry sentences, so that the association between the expression information and the corresponding head positions of the poetry sentences can be learned in the parameters of the language model, and the language model can have the capability of generating the poetry sentences according to the expression information.
In a specific implementation, a forward language model can be obtained by training the poetry corpus according to the forward direction. The language model in the forward direction can generate poems according to the forward direction. Under the condition that the expression information carries the beginning information of the poetry sentences, the forward language model can determine the input information according to the beginning information of the poetry sentences and generate the poetry in the forward direction according to the input information. For example, the input expression information includes the beginning information of the following poetry sentences: "S1, S2, S3 …", the poems in the positive direction can be generated in the order of "S1, S2, S3 …".
In a specific implementation, a reverse language model can be obtained by training according to a reverse poetry corpus. The poetry can be generated according to the negative direction of the negative direction language model. Under the condition that the expression information carries tail information of poetry sentences, the negative direction language model can determine input information according to the tail information of the poetry sentences and generate negative poetry according to the input information. For example, the input expression information includes end information of a poetry sentence as follows: and W1, W2 and W3 … WP are used for generating negative poems according to the sequence of WP … W3, W2 and W1, and performing reversible operation on the negative poems to obtain the generated poems. Where P may characterize the amount of end information.
To sum up, the embodiment of the invention trains and obtains the language model according to poetry linguistic data, and can learn the rules of poetry, such as rhymes of poetry, such as five-language seven-language poetry, absolute poetry and other poetry, narrow and narrow modes, and opposite-row modes, into the parameters of the language model; therefore, the language model can follow the poetry law in the poetry generating process, and candidate poetry following the poetry law can be generated.
Method embodiment two
Referring to fig. 2, a flow chart of steps of an embodiment of a poetry generating method of the present invention is shown, which specifically includes the following steps:
step 201, receiving expression information;
step 202, determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model can be obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model may include: a plurality of processing layers connected in sequence; the treatment layer may include: the self-attention module is used for determining attention information from known words in poetry sentences to words in a word list so as to predict unknown words in the poetry sentences according to the attention information.
At least one step of the embodiment shown in fig. 2 may be performed by the server and/or the client, although the embodiment of the present invention does not limit the specific execution subject of each step.
In step 201, the expression information may be information input by a user. The user may input the expression information through input modes such as keyboard input and voice input, and it can be understood that the specific input mode of the expression information is not limited in the embodiment of the present invention.
The expression information can carry information of poetry sentences at preset positions. For example, under the condition that the expression information carries the first word of a poetry sentence, the Tibetan poetry can be generated according to the expression information. The expression information may correspond to all verses of the poetry, for example, M characters of the expression information correspond to all M verses of the poetry. Alternatively, the expression information may correspond to a part of verses of the verses, for example, M characters of the expression information correspond to the top M verses of the verses.
In step 202, the expression information may be used as input information of a language model, and the auto-regression mechanism of the language model is used to predict the words of poetry sentences in sequence, so as to generate candidate poetry.
In a specific implementation, the language model can generate and output poetry sentences by taking the poetry sentences as granularity; specifically, a poetry sentence can be generated and output. Or, the language model can generate and output complete poems by taking the poems as granularity; specifically, all poetry sentences of poetry may be generated and output.
In the embodiment of the present invention, the language model may correspond to at least one format parameter, and the language model may be used to generate at least one candidate poem that conforms to the at least one format parameter.
For example, the format parameters may include: the number of sentences parameter, and the number of characters contained in the sentence parameter.
In an alternative embodiment of the present invention, the language model may generate a plurality of candidate poetry that conforms to a plurality of format parameters. For example, a five-language rhythm in which the parameter of the number of characters is 5, a seven-language rhythm in which the parameter of the number of characters is 7, a five-language absolute sentence in which the parameter of the number of characters is 5, a seven-language absolute sentence in which the parameter of the number of characters is 7, and the like are generated.
It should be noted that the embodiment of the present invention may combine different options of parameters with different formats to obtain multiple combination results, and generate corresponding candidate poems according to the multiple combination results. For example, the combined result may include: "five words" + "regular poems", "five words" + "absolute", "seven words" + "regular poems", "seven words" + "absolute" etc.
In another alternative embodiment of the present invention, at least two format parameter options may be provided; determining at least one candidate poem corresponding to the expression information specifically includes: and determining at least one candidate poem corresponding to the expression information according to the target format parameter options selected by the user.
In a specific implementation, at least two format parameter options corresponding to one format parameter may be provided. Or at least two format parameter options corresponding to the plurality of format parameters respectively can be provided, in this case, different options selected by the user can be combined, and the corresponding candidate poetry is generated according to the obtained combination result.
For example, if the options of "regular poetry" and "absolute sentence" are provided for the sentence quantity parameter, and the options of "pentalingual" and "seven lingual" are provided for the character quantity parameter, the user selects "regular poetry" and "pentalingual", and at least one candidate poetry corresponding to "pentalingual" + "regular poetry" can be generated.
It should be noted that, for a combined result, the current round of predicted results may include, due to the poetry generation process corresponding to the combined result: n words, and therefore their corresponding poetry generation results may include: n candidate poems.
In a case that the expression information carries the initial information, the poetry forward direction generation may be performed, and accordingly, the determining at least one candidate poetry corresponding to the expression information may specifically include: acquiring the beginning information corresponding to the ith poetry sentence from the expression information; i may be a natural number greater than 0; and predicting unknown words corresponding to the ith poetry sentence according to sentences before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence.
It should be noted that the language model may determine the end of the (i-1) th poetry sentence according to the format parameters, trigger the generation of the ith poetry sentence under the condition that the (i-1) th poetry sentence is ended, determine the beginning information of the ith poetry sentence in the generation process of the ith poetry sentence, and predict unknown words corresponding to non-beginning positions corresponding to the ith poetry sentence.
For example, if the expression information is "happy birthday", the head information of the 1 st poetry sentence is "birthday", the head information of the 2 nd poetry sentence is "day", the head information of the 3 rd poetry sentence is "fast", and the head information of the 4 th poetry sentence is "happy".
Referring to fig. 3, which shows an illustration of a poetry generating process of an embodiment of the present invention, it is assumed that the expression information input by the user includes: "S1, S2, S3 …", the corresponding poetry generating process may include:
first, beginning information "S1" corresponding to the 1 st poetry sentence is obtained from the expression information, and an unknown word corresponding to the 1 st poetry sentence is predicted according to the beginning information "S1", so as to obtain a text T1 corresponding to the 1 st poetry sentence, where T1 is S1, S11, S12, S13 …, and the number of characters included in T1 may be determined according to the character number parameter.
And secondly, acquiring initial information 'S2' corresponding to the 2 nd poetry sentence from the expression information, and predicting unknown words corresponding to the 2 nd poetry sentence according to the known information 'T1' and 'S2' to obtain a text T2 corresponding to the 2 nd poetry sentence, wherein T2 is S2, S21, S22 and S23 ….
Thirdly, acquiring beginning information "S3" corresponding to the 3 rd poetry sentence from the expression information, and predicting unknown words corresponding to the 3 rd poetry sentence according to the known information "T1", "T2" and "S3" to obtain texts T3, T3 ═ S3, S31, S32 and S33 … corresponding to the 3 rd poetry sentence.
……
And analogizing in sequence until the generation of all the sentences of the poetry is finished. The text corresponding to each poetry sentence can be used as a component of candidate poetry, and the final language model can generate and output candidate poetry comprising the text corresponding to each poetry sentence. The output candidate poetry specifically comprises: t1, T2, T3 … ….
The embodiment of the invention can provide the following technical scheme for determining at least one candidate poem corresponding to the expression information:
technical solution 1
Technical solution 1 may be applicable to poetry corpus including: situation of poetry sentences. In this case, the head of the poetry sentence can be intervened in the poetry generating process.
Correspondingly, the determining at least one candidate poem corresponding to the expression information may specifically include: acquiring the beginning information corresponding to the ith poetry sentence from the expression information; i may be a natural number greater than 0; and taking the sentence before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence as input information corresponding to the generation of the ith poetry sentence, and inputting the input information into a language model so that the language model predicts unknown words corresponding to non-beginning positions corresponding to the ith poetry sentence.
It should be noted that, according to the format parameter, the end of the (i-1) th poetry sentence is determined, in the case that the (i-1) th poetry sentence is ended, the generation of the ith poetry sentence is triggered, and in the generation process of the ith poetry sentence, the head of the ith poetry sentence is intervened. Assuming that at least one candidate poetry corresponding to the expression information is determined by the control unit, and the control unit may be different from the language model, the control unit may obtain the beginning information corresponding to the ith poetry sentence from the expression information, so that prediction of the beginning position corresponding to the ith poetry sentence may be saved, and prediction of the non-beginning position corresponding to the ith poetry sentence may be triggered.
In conclusion, in the poetry generating process, the head of the poetry sentence is interfered by controlling the input information corresponding to the language model at the head of the poetry sentence, so that the poetry sentence starts from the specific words included in the expression information, and the effect of generating the Tibetan poetry can be realized.
Technical solution 2
Technical scheme 2 can be applicable to poetry corpus and include: poetry sentences, and the condition of the expression information positioned in front of the poetry sentences. In this case, the poetry corpus training can learn the association between the expression information and the head positions corresponding to the poetry sentences into the parameters of the language model, so that the language model can have the ability of generating poetry sentences according to the expression information.
Therefore, in the poetry generating process, the language model may automatically obtain the beginning information corresponding to the ith poetry sentence from the expression information, and predict the unknown words corresponding to the ith poetry sentence according to the sentences before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence.
Technical solution 1 and technical solution 2 describe in detail a process of generating a poetry sentence. In the technical scheme 1, the control unit determines the beginning information corresponding to the ith poetry sentence, and triggers the prediction of the non-beginning position corresponding to the ith poetry sentence, wherein the prediction of the non-beginning position corresponding to the ith poetry sentence is executed by the language model. In the technical means 2, the control unit inputs the expression information to the language model and triggers the generation of poetry, and the language model performs the prediction of all positions corresponding to poetry sentences, specifically, the language model performs not only the prediction of the beginning positions corresponding to the poetry sentences but also the prediction of non-beginning positions corresponding to the poetry sentences.
A process of predicting the ith poetry sentence is explained herein. The prediction of the ith poetry sentence may include: and M rounds of prediction corresponding to a plurality of positions, wherein the value of M can correspond to the character quantity parameter. For example, in the case of adopting technical scheme 1, M may be the parameter of the number of characters minus 1; in the case of adopting the technical solution 2, M may be a character number parameter.
In a link of predicting an ith poetry sentence, the determining at least one candidate poetry corresponding to the expression information may specifically include: determining current wheel input information according to the known information of poems; and inputting the current round of input information into the language model to obtain a current round of prediction results.
Assuming that the current round is the kth round of the ith poetry sentence, and k is a natural number greater than 0, the known information may include, in the case where k is 2: the (i-1) th poetry sentence and the beginning information of the ith poetry sentence. According to the embodiment of the invention, the known information can be used as the input information of the k-th round, and the input information of the k-th round is input into the language model to obtain the prediction result of the k-th round.
Further, the determining at least one candidate poem corresponding to the expression information may further include: adding the current round prediction result after the current round input information to obtain the next round input information; and inputting the input information of the next round into the language model to obtain a prediction result of the next round.
Assuming that the current round is the k-th round, the k-th round prediction result may be added after the k-th round input information to obtain the (k +1) -th round input information, and the (k +1) -th round input information may be input into the language model to obtain the (k +1) -th round prediction result.
After the prediction result of the kth round is determined, whether the prediction of the ith poem sentence is finished or not can be judged, if yes, whether the generation of the candidate poems is finished or not can be judged, and if yes, the candidate poems can be output. If the prediction of the ith poetry sentence is finished but the generation of the candidate poetry is not finished, the prediction of the (i +1) th poetry sentence can be triggered. If prediction of the ith poetry sentence is not finished, the (k +1) th prediction of the ith poetry sentence can be triggered.
Because the poetry rule can be learned into the parameters of the language model based on the training of the poetry linguistic model by the poetry corpus, the language model can confirm to finish the generation of candidate poetry after generating candidate poetry following the poetry rule.
In this embodiment of the present invention, the current round of prediction results may specifically include: the attention information meets at least one word of a preset condition, wherein different words can correspond to different current round prediction results.
For example, if the attention information corresponding to the word in the word list is the attention score, the word serving as the prediction result may be determined from the word list in the order from high to low of the attention score, for example, N words with higher attention scores may be selected as the current round of prediction results.
And under the condition that the expression information carries tail information, negative direction generation of poetry can be carried out. Correspondingly, the determining at least one candidate poem corresponding to the expression information may specifically include: acquiring tail information corresponding to the last i poetry sentence from the expression information; i may be a natural number greater than 0; and predicting unknown words corresponding to the ith poetry sentence according to sentences before the last ith poetry sentence and tail information corresponding to the ith poetry sentence.
The embodiment of the invention can display at least one candidate poem for the user to check and use. For example, the user may perform operations of copying, sharing and the like on the presented candidate poetry.
In summary, the poetry generating method of the embodiment of the invention can carry information of poetry sentences at preset positions in the expression information, such as the first characters of the poetry sentences. According to the embodiment of the invention, at least one candidate poem corresponding to the expression information is generated according to an autoregressive language model. Because the information of the candidate poetry at the preset position is matched with the expression information, the expression information can be transmitted through the candidate poetry.
Firstly, a language model is obtained by training according to poetry linguistic data, and poetry rules, such as rhymes of poetry, namely five-language seven-language poetry, absolute poetry and other poetry modes, a narrow and narrow mode, a fight form and other rules can be learned in parameters of the language model; therefore, the language model can follow the poetry law in the poetry generating process, and candidate poetry following the poetry law can be generated.
Moreover, the language model of the embodiment of the invention adopts an autoregressive mechanism, and can update the input information according to a real-time prediction result, so that a text with a preset length can be iteratively generated.
In addition, the self-attention module of the language model in the embodiment of the invention can quickly capture the dependency relationship between each known word and the word in the word list, so that the word with strong dependency relationship can be used as a prediction result, and the continuity of the generated candidate poetry can be further improved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of movement combinations, but those skilled in the art should understand that the present invention is not limited by the described movement sequence, because some steps can be performed in other sequences or simultaneously according to the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no moving act is required as an embodiment of the invention.
Device embodiment
Referring to fig. 4, a block diagram of a structure of an embodiment of a poetry generating apparatus of the present invention is shown, which may specifically include: a receiving module 401 and a candidate poetry determining module 402.
The receiving module 401 is configured to receive the expression information.
A poetry candidate determining module 402, configured to determine at least one poetry candidate corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model may include: a plurality of processing layers connected in sequence; the treatment layer may include: the self-attention module is used for determining attention information from known words in poetry sentences to words in a word list so as to predict unknown words in the poetry sentences according to the attention information.
Optionally, the candidate poetry determining module 402 may include:
the acquisition module is used for acquiring the beginning information corresponding to the ith poetry sentence from the expression information; i is a natural number greater than 0;
and the prediction module is used for predicting unknown words corresponding to the ith poetry sentence according to sentences before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence.
Optionally, the poetry corpus may include: poetry sentences and expression information positioned in front of the poetry sentences.
Optionally, the language model corresponds to at least one format parameter, and the language model is used for generating at least one candidate poetry corresponding to the at least one format parameter.
Optionally, the apparatus may further include:
a providing module for providing at least two format parameter options;
the candidate poetry determining module 402 may include:
and the first candidate poetry determining module is used for determining at least one candidate poetry corresponding to the expression information according to the target format parameter option selected by the user.
Optionally, the candidate poetry determining module 402 may include:
the first input information determining module is used for determining current wheel input information according to the known information of poems;
and the first input module is used for inputting the current round of input information into the language model so as to obtain a current round of prediction results.
Optionally, the candidate poetry determining module may further include:
the second input information determining module is used for adding the current round of prediction results after the known information to obtain the next round of input information;
and the second input module is used for inputting the next round of input information into the language model to obtain a next round of prediction result.
Optionally, the current round prediction result may include: the attention information accords with at least one word of a preset condition.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
An embodiment of the present invention provides an apparatus for poetry generation, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by one or more processors include instructions for: receiving expression information; determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry; the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
FIG. 5 is a block diagram illustrating an apparatus 800 for poetry generation according to an exemplary embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 5, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice data processing mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on radio frequency data processing (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Fig. 6 is a schematic structural diagram of a server in some embodiments of the invention. The server 1900, which may vary widely in configuration or performance, may include one or more Central Processing Units (CPUs) 1922 (e.g., one or more processors) and memory 1932, one or more storage media 1930 (e.g., one or more mass storage devices) that store applications 1942 or data 1944. Memory 1932 and storage medium 1930 can be, among other things, transient or persistent storage. The program stored in the storage medium 1930 may include one or more modules (not shown), each of which may include a sequence of instructions operating on the server. Further, a central processor 1922 may be arranged to communicate with the storage medium 1930 to execute a series of instruction operations in the storage medium 1930 on the server 1900.
The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input/output interfaces 1958, one or more keyboards 1956, and/or one or more operating systems 1941, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of an apparatus (a server or a terminal), enable the apparatus to perform a poetry generating method shown in fig. 2 or fig. 3 or fig. 4.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of an apparatus (a server or a terminal), enable the apparatus to perform a poetry generation method, the method comprising: receiving expression information; determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry; the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
The embodiment of the invention discloses A1 and a poetry generating method, wherein the method comprises the following steps:
receiving expression information;
determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
A2, according to the method of A1, the determining at least one poetry candidate corresponding to the expression information includes:
acquiring initial information corresponding to the ith poetry sentence from the expression information; i is a natural number greater than 0;
and predicting unknown words corresponding to the ith poetry sentence according to sentences before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence.
A3, according to the method in A1, the poetry corpus comprises: poetry sentences and expression information positioned in front of the poetry sentences.
A4, the method according to A1, wherein the language model corresponds to at least one format parameter, and the language model is used for generating at least one candidate poetry which conforms to the at least one format parameter.
A5, the method of A1, the method further comprising:
providing at least two format parameter options;
the determining of the at least one candidate poem corresponding to the expression information includes:
and determining at least one candidate poem corresponding to the expression information according to the target format parameter options selected by the user.
A6, according to the method of A1, the determining at least one candidate poem corresponding to the initial information includes:
determining current wheel input information according to the known information of poems;
and inputting the current round of input information into the language model to obtain a current round of prediction results.
A7, according to the method in a6, the determining at least one candidate poem corresponding to the initial information further includes:
adding the current round of prediction results after the known information to obtain the next round of input information;
and inputting the input information of the next round into the language model to obtain a prediction result of the next round.
A8, according to the method of A6, the current round prediction result comprises: the attention information accords with at least one word of a preset condition.
The embodiment of the invention discloses B9 and a poetry generating device, which comprises:
the receiving module is used for receiving the expression information;
the candidate poetry determining module is used for determining at least one candidate poetry corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
B10, the apparatus according to B9, the candidate poetry determining module comprising:
the acquisition module is used for acquiring the beginning information corresponding to the ith poetry sentence from the expression information; i is a natural number greater than 0;
and the prediction module is used for predicting unknown words corresponding to the ith poetry sentence according to sentences before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence.
B11, the apparatus according to B9, the poetry corpus comprising: poetry sentences and expression information positioned in front of the poetry sentences.
B12, the device according to B9, wherein the language model corresponds to at least one format parameter and is used for generating at least one candidate poetry which conforms to the at least one format parameter.
B13, the apparatus of B9, the apparatus further comprising:
a providing module for providing at least two format parameter options;
the candidate poetry determining module comprises:
and the first candidate poetry determining module is used for determining at least one candidate poetry corresponding to the expression information according to the target format parameter option selected by the user.
B14, the apparatus according to B9, the candidate poetry determining module comprising:
the first input information determining module is used for determining current wheel input information according to the known information of poems;
and the first input module is used for inputting the input information of the current round into the language model so as to obtain a prediction result of the current round.
B15, the candidate poetry determining module further includes, according to the apparatus of B14:
the second input information determining module is used for adding the current round of prediction results after the known information to obtain the next round of input information;
and the second input module is used for inputting the next round of input information into the language model so as to obtain a next round of prediction result.
B16, the device according to B14, the current round prediction result comprises: the attention information accords with at least one word of a preset condition.
The embodiment of the invention discloses C17, an apparatus for poetry generation, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by the one or more processors comprise instructions for:
receiving expression information;
determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
C18, according to the apparatus of C17, the determining at least one candidate poetry corresponding to the expression information includes:
acquiring initial information corresponding to the ith poetry sentence from the expression information; i is a natural number greater than 0;
and predicting unknown words corresponding to the ith poetry sentence according to sentences before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence.
C19, the apparatus according to C17, the poetry corpus includes: poetry sentences and expression information positioned in front of the poetry sentences.
C20, the apparatus according to C17, wherein the language model corresponds to at least one format parameter, and the language model is used for generating at least one candidate poetry corresponding to the at least one format parameter.
C21, the device of C17, the device also configured to execute the one or more programs by one or more processors including instructions for:
providing at least two format parameter options;
the determining of the at least one candidate poem corresponding to the expression information includes:
and determining at least one candidate poem corresponding to the expression information according to the target format parameter options selected by the user.
C22, determining at least one candidate poetry corresponding to the initial information according to the apparatus of C17, including:
determining current wheel input information according to the known information of poems;
and inputting the current round of input information into the language model to obtain a current round of prediction results.
C23, determining at least one poem candidate corresponding to the initial information according to the apparatus of C22, further comprising:
adding the current round of prediction results after the known information to obtain the next round of input information;
and inputting the input information of the next round into the language model to obtain a prediction result of the next round.
C24, the apparatus of C22, the current round of prediction results comprising: the attention information accords with at least one word of a preset condition.
Embodiments of the present invention disclose D25, a machine-readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a poetry generation method as described in one or more of a 1-a 8.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements 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 invention is limited only by the appended claims.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
The poetry generating method, the poetry generating device and the device for generating poetry provided by the invention are described in detail, specific examples are applied in the text to explain the principle and the implementation mode of the invention, and the description of the examples is only used for helping to understand the method and the core thought of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A poetry generating method, characterized in that the method comprises:
receiving expression information;
determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
2. The method of claim 1, wherein the determining at least one candidate poetry corresponding to the expression information comprises:
acquiring initial information corresponding to the ith poetry sentence from the expression information; i is a natural number greater than 0;
and predicting unknown words corresponding to the ith poetry sentence according to sentences before the ith poetry sentence and the beginning information corresponding to the ith poetry sentence.
3. The method of claim 1, wherein the poetry corpus comprises: poetry sentences and expression information positioned in front of the poetry sentences.
4. The method of claim 1 wherein said language model corresponds to at least one format parameter, and wherein said language model is used to generate at least one candidate poetry that conforms to said at least one format parameter.
5. The method of claim 1, further comprising:
providing at least two format parameter options;
the determining of the at least one candidate poem corresponding to the expression information includes:
and determining at least one candidate poem corresponding to the expression information according to the target format parameter options selected by the user.
6. The method of claim 1, wherein said determining at least one poetry candidate corresponding to the initial information comprises:
determining current wheel input information according to the known information of poems;
and inputting the current round of input information into the language model to obtain a current round of prediction results.
7. The method of claim 6, wherein said determining at least one candidate poetry corresponding to the initial information further comprises:
adding the current round of prediction results after the known information to obtain the next round of input information;
and inputting the input information of the next round into the language model to obtain a prediction result of the next round.
8. A poetry generating apparatus, comprising:
the receiving module is used for receiving the expression information;
the candidate poetry determining module is used for determining at least one candidate poetry corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in the poetry sentences to words in the word list so as to predict unknown words in the poetry sentences according to the attention information.
9. An apparatus for poetry generation comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured for execution by one or more processors the one or more programs including instructions for:
receiving expression information;
determining at least one candidate poem corresponding to the expression information according to an autoregressive language model; the language model is obtained by training according to poetry linguistic data and is used for predicting unknown information of poetry by taking words as units according to the known information of the poetry;
the language model includes: a plurality of processing layers connected in sequence; the treatment layer includes: the self-attention module is used for determining attention information from known words in poetry sentences to words in a word list so as to predict unknown words in the poetry sentences according to the attention information.
10. A machine-readable medium having stored thereon instructions, which when executed by one or more processors, cause an apparatus to perform a poetry generation method as recited in one or more of claims 1 through 7.
CN202110130845.2A 2021-01-29 2021-01-29 Poetry generation method, device and medium Pending CN114818676A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110130845.2A CN114818676A (en) 2021-01-29 2021-01-29 Poetry generation method, device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110130845.2A CN114818676A (en) 2021-01-29 2021-01-29 Poetry generation method, device and medium

Publications (1)

Publication Number Publication Date
CN114818676A true CN114818676A (en) 2022-07-29

Family

ID=82526738

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110130845.2A Pending CN114818676A (en) 2021-01-29 2021-01-29 Poetry generation method, device and medium

Country Status (1)

Country Link
CN (1) CN114818676A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114818675A (en) * 2021-01-29 2022-07-29 北京搜狗科技发展有限公司 Poetry generation method, device and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134968A (en) * 2019-05-22 2019-08-16 网易(杭州)网络有限公司 Poem generation method, device, equipment and storage medium based on deep learning
CN110852086A (en) * 2019-09-18 2020-02-28 平安科技(深圳)有限公司 Artificial intelligence based ancient poetry generating method, device, equipment and storage medium
CN111221958A (en) * 2020-01-08 2020-06-02 北京松果电子有限公司 Method for training Tibetan poem generation model, Tibetan poem generation method and device
CN114818675A (en) * 2021-01-29 2022-07-29 北京搜狗科技发展有限公司 Poetry generation method, device and medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134968A (en) * 2019-05-22 2019-08-16 网易(杭州)网络有限公司 Poem generation method, device, equipment and storage medium based on deep learning
CN110852086A (en) * 2019-09-18 2020-02-28 平安科技(深圳)有限公司 Artificial intelligence based ancient poetry generating method, device, equipment and storage medium
CN111221958A (en) * 2020-01-08 2020-06-02 北京松果电子有限公司 Method for training Tibetan poem generation model, Tibetan poem generation method and device
CN114818675A (en) * 2021-01-29 2022-07-29 北京搜狗科技发展有限公司 Poetry generation method, device and medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
YI LIAO等: ""Probabilistically Masked Language Model Capable of Autoregressive Generation in ArbitraryWord Order"", 《HTTPS://ARXIV.ORG/PDF/2004.11579》, 24 April 2020 (2020-04-24), pages 1 - 12 *
YI LIAO等: ""Probabilistically Masked Language Model Capable of Autoregressive Generation in ArbitraryWord Order"", pages 1 - 12, Retrieved from the Internet <URL:《https://arxiv.org/pdf/2004.11579》> *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114818675A (en) * 2021-01-29 2022-07-29 北京搜狗科技发展有限公司 Poetry generation method, device and medium

Similar Documents

Publication Publication Date Title
CN110209803B (en) Story generation method, apparatus, computer device and storage medium
CN109582768B (en) Text input method and device
CN111696538B (en) Voice processing method, device and medium
CN112037756A (en) Voice processing method, apparatus and medium
CN114154459A (en) Speech recognition text processing method and device, electronic equipment and storage medium
CN113689879B (en) Method, device, electronic equipment and medium for driving virtual person in real time
CN115273831A (en) Voice conversion model training method, voice conversion method and device
CN113920559A (en) Method and device for generating facial expressions and limb actions of virtual character
CN114818676A (en) Poetry generation method, device and medium
CN113689880B (en) Method, device, electronic equipment and medium for driving virtual person in real time
US20230267282A1 (en) Poetry generation
CN105913841B (en) Voice recognition method, device and terminal
CN110930977B (en) Data processing method and device and electronic equipment
CN112036195A (en) Machine translation method, device and storage medium
CN112199963A (en) Text processing method and device and text processing device
CN112151072A (en) Voice processing method, apparatus and medium
CN113345452B (en) Voice conversion method, training method, device and medium of voice conversion model
CN113409765B (en) Speech synthesis method and device for speech synthesis
CN113420553A (en) Text generation method and device, storage medium and electronic equipment
CN110908523A (en) Input method and device
CN114550691A (en) Multi-tone word disambiguation method and device, electronic equipment and readable storage medium
CN113674731A (en) Speech synthesis processing method, apparatus and medium
CN113409766A (en) Recognition method, device for recognition and voice synthesis method
CN113035189A (en) Document demonstration control method, device and equipment
CN112434521A (en) Vocabulary processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination