WO2019052311A1 - 风格语句的生成方法、模型训练方法、装置及计算机设备 - Google Patents

风格语句的生成方法、模型训练方法、装置及计算机设备 Download PDF

Info

Publication number
WO2019052311A1
WO2019052311A1 PCT/CN2018/101180 CN2018101180W WO2019052311A1 WO 2019052311 A1 WO2019052311 A1 WO 2019052311A1 CN 2018101180 W CN2018101180 W CN 2018101180W WO 2019052311 A1 WO2019052311 A1 WO 2019052311A1
Authority
WO
WIPO (PCT)
Prior art keywords
model
training
natural
style
statement
Prior art date
Application number
PCT/CN2018/101180
Other languages
English (en)
French (fr)
Inventor
刘晓江
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2019052311A1 publication Critical patent/WO2019052311A1/zh
Priority to US16/589,811 priority Critical patent/US11348570B2/en
Priority to US17/737,326 priority patent/US11869485B2/en

Links

Images

Classifications

    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L13/00Speech synthesis; Text to speech systems
    • G10L13/02Methods for producing synthetic speech; Speech synthesisers
    • G10L13/027Concept to speech synthesisers; Generation of natural phrases from machine-based concepts
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/06Creation of reference templates; Training of speech recognition systems, e.g. adaptation to the characteristics of the speaker's voice
    • G10L15/063Training
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/08Speech classification or search
    • G10L15/18Speech classification or search using natural language modelling
    • G10L15/183Speech classification or search using natural language modelling using context dependencies, e.g. language models
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/22Procedures used during a speech recognition process, e.g. man-machine dialogue
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L19/00Speech or audio signals analysis-synthesis techniques for redundancy reduction, e.g. in vocoders; Coding or decoding of speech or audio signals, using source filter models or psychoacoustic analysis

Definitions

  • the embodiments of the present application relate to the field of natural language processing, and in particular, to a method for generating a style statement, a model training method, a device, and a computer device.
  • the intelligent dialogue system is used to automatically generate a corresponding dialog statement according to the chat content input by the user, thereby realizing a dialogue between the person and the machine.
  • the intelligent dialogue system provides different language styles for the user to select, and the intelligent dialogue system can generate style statements with the language style according to the language style selected by the user.
  • the language style is used to indicate the specific expression of a natural statement with a certain meaning, such as: the language style is fresh and elegant, bright and clear, rhetoric, euphemistic, and spoken.
  • the intelligent dialogue system is pre-configured with a parallel corpus, which includes a plurality of sets of sentence pairs, and different sentences in each set of sentences have the same meaning and have different language styles. Statement.
  • a natural sentence having the language style is searched from the parallel corpus, and the natural sentence of the language style is encoded by the encoding function to obtain a sentence vector, which is obtained by the decoding function.
  • the statement vector is decoded to generate a style statement with the language style.
  • the intelligent dialogue system needs to generate a style statement with a multi-lingual language style, a natural statement having the language style can be found from the parallel corpus according to the sentence vector X.
  • Parallel corpus may not exhaust all language styles of a natural statement. For example, for a natural statement with "semantic x", when the parallel corpus does not have a natural statement with a subtle euphemistic language style, the intelligent dialogue system can only choose other language styles. The natural statement, or the selection of other natural statements with the language style for statement generation, resulting in the style statement generated by the intelligent dialogue system does not meet the user's expectations, the effect of style conversion is poor.
  • the embodiment of the present application provides a method for generating a style statement, a model training method, a device, and a computer device, which can solve the problem that a natural sentence having a target language style selected by a user does not exist in the parallel corpus, and the target language cannot be accurately generated.
  • the problem with style style statements is as follows:
  • a method for generating a style statement is provided, the method being performed by a computer device, the method comprising:
  • the target content vector and the target style vector are input to the first decoding model, and a style sentence corresponding to the natural sentence is generated.
  • a model training method is provided, the method being performed by a computer device, the model comprising a first coding model and a first decoding model, the method comprising:
  • the classification capability refers to the ability to classify the input natural training sentence into a corresponding content vector and style vector
  • the first decoding model is obtained by training the restoration capability of the second decoding model by the training model, and the reducing capability refers to the content vector according to the content And the ability of the style vector to restore the natural training statement;
  • the content vector is used to indicate the meaning of the natural training sentence
  • the style vector is used to indicate the language style of the natural training sentence.
  • a device for generating a style sentence comprising:
  • a first generation module configured to input the natural sentence into the first coding model to filter style information in the natural sentence, and generate a target content vector corresponding to the natural statement, where the target content vector is used to indicate the The meaning of the natural statement, the style information is used to indicate the language style of the natural statement;
  • a determining module configured to determine, according to the set target language style, a target style vector corresponding to the target language style from at least one style vector, wherein each of the at least one style vector corresponds to one Language style
  • a second generation module configured to input the target content vector and the target style vector into the first decoding model, and generate a style statement corresponding to the natural statement.
  • a model training apparatus comprising:
  • a training module configured to input at least two natural training sentences in the corpus into the training model, and the training capability of the second coding model is trained to obtain the first coding model, where each of the natural training sentences corresponds to a language style, the classification ability refers to the ability to classify the input natural training sentence into a corresponding content vector and style vector;
  • An obtaining module configured to acquire at least one style vector output by the first coding model when the first coding model is obtained by training, each of the style vectors being a first coding model according to a corresponding language style Derived from the classification of natural training statements;
  • the training module is further configured to: when the at least two natural training sentences are input into the training model, training, by using the training model, a reduction capability of the second decoding model to obtain the first decoding model, where the Capability refers to the ability to restore the natural training statement according to the content vector and the style vector;
  • the content vector is used to indicate the meaning of the natural training sentence
  • the style vector is used to indicate the language style of the natural training sentence.
  • a computer apparatus comprising a first coding model and a first decoding model
  • the first coding model is configured to filter style information of the input natural sentence to obtain a target content vector corresponding to the natural statement; the target content vector is used to indicate a meaning of the natural sentence, and the style information a language style used to indicate the natural statement;
  • the first decoding model is configured to fuse the input target style vector and the target content vector to obtain a style statement corresponding to the natural statement;
  • the target style vector is at least one style vector of the computer device a style vector corresponding to the set target language style, each of the at least one style vector corresponding to a language style.
  • a computer device comprising a processor and a memory, the memory storing at least one instruction, at least one program, a code set or a set of instructions, the at least one instruction And the at least one program, the set of codes, or the set of instructions is loaded and executed by the processor to implement a method of generating a style statement as described above, or a model training method.
  • a computer readable storage medium having stored therein at least one instruction, at least one program, a code set, or a set of instructions, the at least one instruction, the At least one program, the set of codes, or a set of instructions is loaded and executed by the processor to implement a method of generating style statements as described above, or a model training method.
  • the natural code is classified by the first coding model to obtain a content vector with as little style information as possible; and then the content vector is obtained by the first decoding model and the target style vector obtained in the training process to obtain a style statement, thereby realizing Separation of content vector and style vector. Therefore, when the natural sentence of the language style selected by the user does not exist in the parallel corpus, the computer device may not be able to generate a style statement having the target language style that meets the user's expectation; since the computer device stores the corresponding style of each language.
  • the first decoding model is capable of determining a target style vector corresponding to the target language style from the stored plurality of style vectors, and generating a style statement according to the target style vector and the content vector, thereby ensuring that each natural sentence can be Converting to a style statement with a target language style improves the intelligence of computer devices in style conversion.
  • FIG. 1 is a schematic diagram of a training model provided by an exemplary embodiment of the present application.
  • FIG. 2 is a schematic diagram of a computer device provided by an exemplary embodiment of the present application.
  • FIG. 3 is a flowchart of a model training method provided by another exemplary embodiment of the present application.
  • FIG. 4 is a schematic diagram of a model training method provided by another exemplary embodiment of the present application.
  • FIG. 5 is a flowchart of a method for generating a style statement provided by an exemplary embodiment of the present application.
  • FIG. 6 is a flowchart of a method for generating a style statement provided by another exemplary embodiment of the present application.
  • FIG. 7 is a block diagram of a device for generating a style sentence according to an exemplary embodiment of the present application.
  • FIG. 8 is a block diagram of a model training apparatus provided by an exemplary embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a computer device according to an exemplary embodiment of the present application.
  • Language style express a specific expression of a natural statement with a certain meaning, such as: language style includes fresh and elegant, bright and clear, rhetoric, euphemistic, multi-purpose spoken language. Natural statements of the same meaning can have a variety of specific expressions, each of which corresponds to a type of language style.
  • the natural style of the language style is bright and plain: the semantic x expressed by the language style 1; the natural style of the language style is the rhetoric: the semantics expressed by the language style 2 x; language style is euphemistic implicit natural statement: semantics expressed by language style 3; language style is a multi-purpose spoken natural statement: semantics expressed by language style 4 x.
  • the division of the language style can also be other ways, for example, the division of the language style into poetry, classical, literary art, etc., this embodiment does not limit the way the language style is divided.
  • Parallel corpus Includes multiple sets of sentence pairs, each set consisting of multiple sentences. Different sentences in each set of sentences have the same meaning and have different language styles.
  • the parallel corpus may also be referred to as a conversation corpus, a personalized conversation corpus, etc., and the specific name of the parallel corpus is not limited in this embodiment.
  • the intelligent dialogue system searches for a style statement with a natural sentence having the target language style in a parallel corpus according to a target language style.
  • the target language style is euphemistic
  • the intelligent dialogue system needs to generate a style statement with "semantic x". Then the language system finds a natural statement in the parallel corpus that expresses the semantic x in a euphemistically implicit style. According to the natural statement 1 Generate style statements. However, when there is no natural statement 1 in the parallel corpus that expresses the semantic x in a euphemistically implicit style, the intelligent dialogue system looks for other natural statements 2 with euphemistic implicit language styles, or the intelligent dialogue system finds the same meaning, but A natural statement 3 having other language styles, and a style statement is generated based on these natural sentences 2 and natural sentences 3. The resulting style statement may be separated from the original semantics x, or the actual language style may not match the target language style, that is, the statement with the target language style cannot be accurately generated.
  • the present application provides the following technical solution, by pre-training the style vector corresponding to each language style, filtering the style information in the natural sentence in the corpus, and performing the filtered content vector and the style vector.
  • the code gets the style statement, so that the language system no longer relies on the existing style statements in the parallel corpus to generate the style statement, and can add the target language style to all the natural sentences, which improves the intelligence of the computer equipment in the style conversion.
  • the content vector is used to indicate the meaning (or semantics) of the natural statement.
  • the content vector is represented by an i-dimensional array, and i is a positive integer.
  • the style vector is used to indicate the language style of the natural statement.
  • the style vector is represented by a j-dimensional array, and j is a positive integer.
  • Each style vector corresponds to a language style.
  • the manner in which the language style is divided is not limited, and each language and/or usage scenario may have a different language style.
  • the present application is described by taking an execution entity of each embodiment as a computer device as an example, and the computer device can be implemented as at least one of an intelligent dialogue system, a style conversion system, and a text chat robot.
  • the actual product form is not limited.
  • the computer device may be installed in the server; or it may be installed in the terminal, which is not limited in this embodiment.
  • the computer device can be a mobile phone, a tablet computer, a laptop portable computer, a desktop computer, or the like.
  • the method for converting style statements in the embodiments of the present application may be implemented as a game assistant in a mobile phone or an automatic chat function of different character models in a game program.
  • the training model (refer to FIG. 1) and the computer device in use (refer to FIG. 2) involved in the present application are respectively introduced below.
  • the training model includes a first sub-model 110 and a second sub-model 120.
  • the first sub-model 110 is created (or trained) according to the supervised model 111; the second sub-model 120 is created (or trained) according to the encoding model 121 and the decoding model 122.
  • a natural training sentence having at least two language styles in the corpus (represented by x and y in FIG. 1) is input to the coding model 121, and the coding model 121 is used for each natural training.
  • the statement is classified to obtain a content vector (represented by e(x) and e(y) in Fig. 1) and a style vector (represented by v x and v y in Fig. 1) corresponding to each natural training sentence.
  • the output result of the encoding model 121 is input as the supervising model 111, and the first sub-model 110 judges whether the input at least two content vectors having the same meaning are similar by the supervisory ability of the supervising model 111.
  • Supervising ability refers to the ability to judge the language style corresponding to the received content vector. Since at least two content vectors of the input supervised model 111 are generated according to natural training sentences having the same meaning and having different language styles. Therefore, when the supervised model 111 can determine the corresponding language style according to the input content vector, it is indicated that the content vector still has style information, and the similarity of the content vectors having different language styles is low. Therefore, the supervisory results output by the supervisory model 111 vary widely. At this time, the first sub-model 110 can determine whether at least two content vectors having the same meaning are similar according to the difference in the supervised results output by the supervised model 111.
  • the first sub-model 110 feeds back the judgment result (first result) to the coding model 121 in the second sub-model 120.
  • the encoding model 121 adjusts its own model parameters according to the judgment result, thereby improving the classification ability of the encoding model 121.
  • Classification ability refers to the ability to classify an input natural training statement into a corresponding content vector and style vector.
  • the encoding model 121 also inputs the classified content vector and style vector to the decoding model 122.
  • the decoding model 122 is used to restore a natural training sentence having a certain language style according to the content vector and the style vector. For example, in FIG. 1, the decoding model 121 restores the natural training statement d x (e(x)) according to the content vector e(x) and the style vector v x ; the decoding model 121 is based on the content vector e(y) and the genre vector v y restores the natural training statement d y (e(y)).
  • the second sub-model 120 determines the restoration ability of the decoding model 121 based on whether the output result of the decoding model 121 is the same as the natural training sentence of the input encoding model 121.
  • the decoding model 122 adjusts its own model parameters based on the output (second result) of the second sub-model 120, thereby improving the reductive power of the decoding model 122.
  • the reduction ability refers to the ability to restore the natural training statement according to the content vector and the style vector.
  • the second sub-model 120 determines the decoding model 121 according to the same probability between d x (e(x)) and the natural training sentence x, according to the same probability between d y (e(y)) and the natural training sentence y.
  • the ability to restore is the same probability between d x (e(x)) and the natural training sentence x, according to the same probability between d y (e(y)) and the natural training sentence y. The ability to restore.
  • the first sub-model 110 is represented by the following formula:
  • L critic (X, Y) refers to the output of the first sub-model, that is, the similarity of the input two content vectors;
  • X is a set of natural training statements with the first language style in the corpus,
  • is the number of natural training sentences with a first language style;
  • Y is a collection of natural training sentences with a second language style in the corpus;
  • is the number of sets of natural training statements with a second language style, wherein The first language style is different from the second language style;
  • e(x) is a content vector of the natural training sentence with the first language style output by the encoding model 121, and e(y) is the second language style output by the decoding model 122.
  • f(e(x)) is the supervised result output by the supervised model 111 when the input is e(x);
  • f(e(y)) is the supervised model 111 at the input of e(y)
  • the supervisory result of the output is the content vector of the natural training statement;
  • the second sub-model 120 is represented by the following formula:
  • L cycle (X, Y) refers to the output result of the second sub-model, that is, the probability that the two natural training sentences entered are restored;
  • d x (e(x)) is the input of the decoding model 122 is e ( x) and the decoded result of the genre vector v x ;
  • d y (e(y)) is the decoding result output when the input of the decoding model 122 is e(y) and the genre vector v y ;
  • the training model is represented by the following formula:
  • L transfer (X, Y) refers to a training result output by the training model, and the training result is used to reflect the classification ability of the coding model 121 and the restoration capability of the decoding model 122.
  • the numerical value of L transfer (X, Y) has a negative correlation with the classification ability of the coding model 121, that is, the smaller the L transfer (X, Y), the better the classification ability of the coding model 121;
  • L transfer (X, The numerical value of Y) is inversely related to the reducing power of the decoding model 122, that is, the smaller the L transfer (X, Y), the better the reducing ability of the encoding model 121.
  • the value of ⁇ is fixed; or, the value of ⁇ is adjusted according to the values of L cycle (X, Y) and/or L critic (X, Y).
  • each formula can be adaptively changed in actual implementation. For example, when the natural statements of the input encoding model 121 are three, the output corresponding to the third natural statement should be added to each formula.
  • a coding model with higher classification ability can be obtained, which is hereinafter referred to as a first coding model, and correspondingly, a coding model trained before the first coding model is obtained as a second coding model;
  • a decoding model with higher reductive power hereinafter referred to as a first decoding model, and correspondingly, a decoding model trained before the first decoding model is obtained is referred to as a second decoding model.
  • the style vector outputted by the coding model (ie, the first coding model) at the last training time is saved as a language style for adding natural language sentences during use. Style vector.
  • the computer device can be an intelligent dialog system comprising: a first encoding model 210 and a first decoding model 220.
  • the first coding model 210 is obtained by training the second coding model according to the training model shown in FIG. 1.
  • the first coding model 210 is configured to classify the input natural sentence to obtain a target content vector corresponding to the natural statement.
  • the first encoding model 210 is capable of filtering the style information in the input natural sentence, thereby obtaining a target content vector that does not include the style information as much as possible.
  • the style information is used to indicate the language style that expresses the natural statement.
  • the first encoding model 210 passes the output target content vector to the first decoding model 220.
  • the first decoding model 220 is obtained by training the second decoding model according to the training model shown in FIG. 1.
  • the first decoding model 220 determines, from the at least one style vector stored by the computer device, a target style vector corresponding to the language style to be converted, and generates a natural content according to the target style vector and the target content vector delivered by the first encoding model 210.
  • model training method is used in the training model shown in FIG. 1, and the model training method can be performed by a computer device, the method comprising:
  • Step 301 Input at least two natural training sentences in the corpus into the training model, and train the model to train the classification ability of the second coding model to obtain the first coding model.
  • each of the at least two natural training sentences corresponds to one language style.
  • the number of each natural training statement is at least one sentence. In most cases, the more natural training sentences in the same language style, the stronger the classification ability of the trained first coding model.
  • the natural training sentences of the input training model include: the natural style of the language style is euphemistic and versatile, wherein the language style is a subtle and implicit natural sentence number of five sentences, and the language style is a natural sentence with multi-spoken language. The number is also five sentences.
  • Classification ability refers to the ability to classify an input natural training statement into a corresponding content vector and style vector.
  • the content vector is used to indicate the meaning of the natural training statement
  • the style vector is used to indicate the language style of the natural training statement.
  • Step 302 Acquire at least one style vector output by the first coding model when the first coding model is obtained by training.
  • Each style vector is obtained by classifying the first coding model according to the natural training sentence of the corresponding language style.
  • the i-th style vector is obtained by classifying the first coding model according to the natural training sentence of the i-th language style.
  • Step 303 When the training model is input into the at least two natural training sentences, the first decoding model is obtained by training the restoration capability of the second decoding model by the training model.
  • Restore capability refers to the ability to restore natural training statements based on content vectors and style vectors.
  • the coding model and the decoding model are simultaneously trained by the training model, that is, this step may be performed simultaneously with step 301.
  • the training model includes a first sub-model and a second sub-model.
  • the first sub-model is established according to a preset supervised model, and the first sub-model is configured to output different content vectors according to the supervised ability of the supervised model.
  • the similarity, the supervisory ability refers to the ability to judge the language style corresponding to the received content vector;
  • the second submodel is established according to the second encoding model and the second decoding model, and the second submodel is used according to the second decoding model And the second encoding function outputs the probability that the natural statement is restored.
  • the model training method obtains the first coding model by training the classification ability of the coding model, and trains the reduction capability of the decoding model to obtain a first decoding model, so that when the computer device is in use,
  • the natural code is classified by the first coding model to obtain a content vector with as little style information as possible; and then the content vector and the target style vector obtained in the training process are encoded by the first decoding model to obtain a style statement, and the solution is solved.
  • Natural statements with the target language style can only be searched from parallel corpus, causing the computer device to be unable to generate a style statement with the target language style that meets the user's expectations; since the computer device stores the style vector corresponding to each language style,
  • the first decoding model is capable of determining a target style vector corresponding to the target language style from the stored style vector, and generating a style statement according to the target style vector and the content vector, thereby ensuring that each natural sentence can be converted into a target language.
  • Style Statements improve the intelligence of computer devices in style conversion.
  • the training process of the first coding model and the second coding model will be described in detail below.
  • the training process of the first coding model and the second coding model includes the following steps:
  • the first natural training sentence and the second natural training sentence of the m group are input into the first sub-model, and the supervising ability of the supervised model is trained.
  • each set of the first natural training statement and the second natural training statement are natural training sentences having different language styles and having the same meaning.
  • the m group natural training statement that inputs the first submodel includes the following set of natural training statements:
  • the first natural training statement and the second natural training sentence of the m group are respectively derived from the language set of the corresponding language style in the corpus, that is, the first natural training statement is derived from the language style set corresponding to the first natural training statement,
  • the second natural training statement is derived from the set of language styles corresponding to the second natural training statement.
  • the set of language styles corresponding to the first natural training statement is different from the set of language styles corresponding to the second natural training statement.
  • the natural training statement 1 "read” comes from the bright and shallow collection
  • the natural training statement 2 "has been reviewed” from the rhetoric collection
  • the natural training statement 3 "read” from the euphemistic implicit collection
  • the natural training statement 4 "has been seen” comes from a multi-purpose spoken set.
  • the natural training statement of a sub-model is at least three, and one of the two different natural training sentences is the first natural training statement and the other is the second natural training statement.
  • the natural training statement inputting the first submodel includes three different x, y, and z.
  • x when x is the first natural training statement, y is the second natural training statement; or, when y is the first natural training statement, and x is the second natural training statement.
  • y is the first natural training statement, z is the second natural training statement; or, when z is the first natural training statement, y is the second natural training statement.
  • x and z x is the first natural training statement and z is the second natural training statement; or, when z is the first natural training statement, x is the second natural training statement.
  • n is a positive integer.
  • the value of m is fixed, for example, m is 20 sentences.
  • the number of trainings is set by the developer.
  • the value of the preset number of times is not limited, for example, the number of trainings is 10, 11, 1000, 10,000, and the like.
  • the supervisory model when the supervisory model is trained, the supervisory model adjusts its own model parameters according to the training result, thereby improving its supervisory ability.
  • the supervisory model adjusts its model parameters according to the error back propagation algorithm according to the training result.
  • the m first natural training statement and the second natural training sentence input in the current training and the first natural training statement and the second natural input in the previous training are m groups. Training statements are different.
  • the supervising ability of the supervised model can be improved, thereby improving the accuracy of the first training model for judging the similarity of different content vectors, thereby improving the classification ability of the training model to judge the second coding model and The accuracy of the reduction capability of the second decoding model.
  • the first submodel in the training model is based on the post-training supervision model.
  • Each set of the third natural training sentence and the fourth natural training sentence are natural training sentences having different language styles and having the same meaning.
  • the third natural training statement is similar to the related introduction of the first natural training statement.
  • the related introduction of the fourth natural training statement is similar to the related introduction of the second natural training statement. For details, refer to step 1. This embodiment is not described herein.
  • the model training result includes: a first result of the updated first submodel output and a second result of the second submodel output.
  • the first result is used to indicate the similarity of at least two content vectors having the same meaning.
  • the value of the first result is inversely related to the classification ability of the second coding model, that is, the larger the value of the first result, the lower the similarity of the at least two content vectors having the same meaning, and the classification ability of the second coding model
  • the second result is used to indicate the same probability between the output of the second decoding model and the natural statement of the second encoding model.
  • the value of the second result is positively correlated with the reducing ability of the second decoding model, that is, the larger the value of the second result is, the higher the probability that the output result of the second decoding model is the same as the natural sentence input to the second decoding model, The more the reduction ability of the second decoding model is; the smaller the value of the second result is, the smaller the probability that the output result of the second decoding model is the same as the natural sentence input to the second coding model, and the weaker the classification ability of the second decoding model .
  • n is a positive integer.
  • the value of n is fixed, for example, n is 20 sentences.
  • the values of n and m are the same or different.
  • the step includes the following sub-steps:
  • natural training statement and the fourth natural training sentence are input into the second coding model to obtain a style vector and a content vector corresponding to each third natural training statement, and a style corresponding to each fourth natural training statement.
  • Vector and content vector are input into the second coding model to obtain a style vector and a content vector corresponding to each third natural training statement, and a style corresponding to each fourth natural training statement.
  • the content vector corresponding to the third natural training statement of the same group and the content vector corresponding to the fourth natural training statement are input into the trained supervised model to determine the similarity, and the content vector corresponding to the third natural training statement and the fourth natural training statement are obtained.
  • the similarity between the corresponding content vectors are obtained.
  • the similarity between the content vector corresponding to the third natural training statement and the content vector corresponding to the fourth natural training statement is the first result obtained by the first sub-model.
  • the similarity is represented by a difference between a supervised result of the content vector corresponding to the third natural training statement and a supervised result of the content vector corresponding to the fourth natural training statement.
  • the content vector and the genre vector corresponding to the third natural training statement of the same group, the content vector corresponding to the fourth natural training statement, and the genre vector are input into the second decoding model to be restored, and the restored third natural training statement is obtained and restored.
  • the probability that the restored third natural training statement has the same probability as the third natural training statement, and the restored fourth natural training statement and the fourth natural training statement are the second result of the second submodel output.
  • the preset training times are at least twice, and the preset training times may be 3 times, 5 times, 100 times, 1000 times, 10000 times, etc., and the value of the preset training times is not limited in this embodiment.
  • the similarity between the content vector corresponding to the third natural training statement and the content vector corresponding to the fourth natural training statement changes within a preset training time; and/or, the restored third natural training statement The same probability as the third natural training statement is changed within the preset training times; and/or, the same probability that the restored fourth natural training statement and the fourth natural training statement are present within the preset training times, according to The first result adjusts the model parameters in the second coding model to obtain the trained second coding model, and adjusts the model parameters in the second decoding model according to the second result to obtain the trained second decoding model.
  • At least one style vector outputted by the first coding model in the last training process is stored, and the at least one style vector is used in the language used.
  • the language of the input natural language is converted.
  • step 1 is performed again, that is, the supervising ability of the m group first natural training sentence and the second natural training sentence input into the first submodel to supervise the model is performed again.
  • the steps of training are performed again, that is, the supervising ability of the m group first natural training sentence and the second natural training sentence input into the first submodel to supervise the model is performed again.
  • the supervising ability of the supervised model can be improved, thereby improving the accuracy of the first training model for judging the similarity of different content vectors, thereby improving the training model to determine the second encoding.
  • the classification ability of the model and the accuracy of the reduction ability of the second decoding model are improved.
  • the language processing system may not perform the training on the supervised model, that is, the steps 1-3 are not performed, which is not limited in this embodiment.
  • the computer device further pre-trains the supervisory model, the second coding model, and the second decoding model.
  • Pre-training the supervised model includes: inputting at least two content vectors whose similarity is greater than a preset threshold into the first sub-model; when the first result output by the first sub-model is different from the first result of the pre-p pre-training, The model parameters in the supervised model are adjusted; when the first result output by the first sub-model is the same as the first result of the pre-p pre-training, the pre-trained supervised model is obtained.
  • the language processing system executes the above steps 1-6 according to the pre-trained supervision model.
  • Pre-training the second coding model and the second decoding model includes: inputting at least one pre-training statement into the second sub-model; and when the second result output by the second sub-model is different from the second result of the previous q pre-training And adjusting a model parameter in the second coding model and/or the second decoding model; when the second result output by the second submodel is the same as the second result of the previous q pre-training, obtaining the second coding model after the pre-training And a second decoding model after pre-training.
  • the language processing system performs the above steps 1-6 according to the pre-trained second coding model and the pre-trained second decoding model.
  • the embodiment by pre-training the supervised model, the second coding model, and the second decoding model, rough model parameters in the supervised model, the second coding model, and the second decoding model can be obtained, thereby avoiding
  • the second coding model and the second decoding model are directly trained according to the training model, and the number of trainings is too large, resulting in the problem of consuming too many resources, and improving the efficiency of training the second coding model and the second decoding model.
  • FIG. 5 is a flowchart of a method for generating a style sentence provided by an exemplary embodiment of the present application.
  • the method for generating the style statement is used in the computer device shown in FIG. 2, and the method includes:
  • Step 501 Obtain a natural statement to be converted.
  • the natural statement to be converted is selected by the language processing system from the corpus; or the natural statement to be converted is input by the user.
  • Step 502 The natural sentence is input into the first coding model to filter the style information in the natural sentence, and the target content vector corresponding to the natural statement is generated.
  • the first coding model is obtained by training the second coding model through the training model, and the training model is used to train the classification ability of the second coding model to obtain the first coding model;
  • the classification capability refers to classifying the input natural sentences into corresponding The ability of content vectors and style vectors.
  • the target content vector is used to indicate the meaning of the natural statement
  • the style information is used to indicate the language style of the natural statement.
  • Step 503 Determine a target style vector corresponding to the target language style from the at least one style vector according to the set target language style.
  • the computer device is provided with at least one language style, and the computer device sets the target language style according to the received setting operation.
  • the setting operation is performed by the user.
  • each style vector in at least one style vector corresponds to a language style.
  • the corresponding style vector exists in at least one language style provided by the computer device.
  • At least one style vector is obtained by classifying the input language-style natural training sentences by the first coding model when training the first coding model, and each language-style natural training statement corresponds to at least one style vector A style vector in the middle.
  • Step 504 Input the target content vector and the target style vector into the first decoding model to generate a style statement corresponding to the natural sentence.
  • the first decoding model is obtained by training the second decoding model through the training model; the training model is also used to train the second decoding model to obtain the first decoding model; the reducing capability refers to restoring according to the content vector and the genre vector. The ability to produce natural statements.
  • the style statement generation method classifies the natural sentence by using the first coding model to obtain a content vector with as little style information as possible; and then the content vector and the training through the first decoding model.
  • the target style vector obtained in the process is encoded to obtain a style statement, which solves the problem that the natural language with the target language style can only be searched from the parallel corpus, and the computer device may not be able to generate the style statement with the target language style that meets the user's expectation; Since the style vector corresponding to each language style is stored in the computer device, the first decoding model can determine the target style vector corresponding to the target language style from the stored style vector, and generate a style statement according to the target style vector and the content vector. Therefore, it is guaranteed that each natural statement can be converted into a style statement with a target language style, which improves the intelligence of the computer device.
  • the computer device is further provided with a combination of language styles composed of at least one language style, such as a combination of fresh and elegant language styles, and if the target language style set in the computer device is a combination of language styles.
  • the computer device is also capable of generating a language style with a fusion of language styles.
  • step 503 is replaced by the following steps:
  • Step 5031 when the set target language style is a combination of at least two language styles, selecting a style vector corresponding to each language style from at least one style vector, and obtaining at least two style vectors.
  • the language processing system determines a fresh and elegant corresponding style vector and a lightly corresponding style vector from at least one style vector.
  • step 5032 at least two style vectors are merged to obtain a target style vector.
  • the computer device fuses the at least two style vectors to obtain the target style vector, including: determining an average of the at least two style vectors, and determining the average as the target style vector.
  • the computer device calculates a fresh and elegant corresponding style vector and an average value of the style vector corresponding to the bright and shallow light, and determines the average value as the target style vector.
  • the target style vector is obtained by fusing different style vectors, and the language style provided by the language processing system is expanded.
  • the natural statement, the natural training statement, and the pre-training statement are statements in a corpus of the language processing system.
  • these statements are called natural statements; in the training process of the language processing system, these statements are called natural training sentences; in the pre-training process of the language processing system, these statements are called pre-training statements. .
  • the coding model is created based on a Long Short Term Memory (LSTM) neural network; or the coding model is created based on a Gate Recycling Unit (GRU) neural network;
  • the embodiment does not limit the type of coding model.
  • the coding model includes a first coding model and a second coding model.
  • the decoding model is created based on a Long Short Term Memory (LSTM) neural network; or the decoding model is created based on a Gate Recycling Unit (GRU) neural network;
  • the embodiment does not limit the type of decoding model.
  • the decoding model includes a first decoding model and a second decoding model.
  • the supervised model is created based on a Long Short Term Memory (LSTM) neural network; or the supervised model is created based on a gated loop unit Gated Reactor Unit (GRU) neural network;
  • LSTM Long Short Term Memory
  • GRU Gated Reactor Unit
  • the embodiment does not limit the type of supervisory model.
  • FIG. 7 is a block diagram of a device for generating a style sentence provided by an exemplary embodiment of the present application.
  • the device can be implemented as all or part of a computer device by software, hardware or a combination of both.
  • the apparatus includes an acquisition module 710, a first generation module 720, a determination module 730, and a second generation module 740.
  • the obtaining module 710 is configured to obtain a natural statement to be converted.
  • a first generation module 720 configured to input the natural sentence into the first coding model to filter style information in the natural sentence, and generate a target content vector corresponding to the natural statement, where the target content vector is used to indicate Describe the meaning of the natural statement, the style information is used to indicate the language style of the natural statement;
  • a determining module 730 configured to determine, according to the set target language style, a target style vector corresponding to the target language style from at least one style vector, wherein each style vector in the at least one style vector corresponds to a language style;
  • the second generation module 740 is configured to input the target content vector and the target style vector into the first decoding model to generate a style statement corresponding to the natural statement.
  • the at least one style vector is obtained by classifying the input language-style natural training sentences by the first coding model when the first coding model is obtained, each having a language style a natural training statement corresponding to one of the at least one style vector;
  • the determining module includes: a selecting unit and a merging unit.
  • a selecting unit configured to: when the set target language style is a combination of at least two language styles, select a style vector corresponding to each language style from the at least one style vector to obtain at least two style vectors;
  • a merging unit configured to fuse the at least two style vectors to obtain the target genre vector.
  • the merging unit is further configured to:
  • An average of the at least two style vectors is determined, the average being determined as the target style vector.
  • the first coding model is obtained by training a second coding model by using a training model; and the training model is used to train a classification capability of the second coding model to obtain the first coding model;
  • the first decoding model is obtained by training the second decoding model by the training model; the training model is further configured to train the reducing capability of the second decoding model to obtain the first decoding model;
  • the classification capability refers to the ability to classify the input natural sentence into a corresponding content vector and style vector
  • the reduction capability refers to the ability to restore the natural sentence according to the content vector and the style vector.
  • FIG. 8 is a block diagram of a model training device provided by an exemplary embodiment of the present application.
  • the device can be implemented as all or part of a computer device by software, hardware or a combination of both.
  • the model includes a first coding model and a first decoding model
  • the apparatus includes a training module 810 and an acquisition module 820.
  • the training module 810 is configured to input at least two natural training sentences in the corpus into the training model, and the classification function of the second coding model is trained by the training model to obtain the first coding model, and each of the natural training sentences Corresponding to a language style, the classification ability refers to the ability to classify the input natural training sentence into a corresponding content vector and style vector;
  • the obtaining module 820 is configured to acquire at least one style vector output by the first coding model when the first coding model is obtained by training, each of the style vectors being the first coding model according to a corresponding language style.
  • the natural training statement is classified;
  • the training module 810 is further configured to: when the at least two natural training sentences are input into the training model, training, by using the training model, a reduction capability of the second decoding model to obtain the first decoding model, where
  • the reducing ability refers to the ability to restore the natural training statement according to the content vector and the style vector;
  • the content vector is used to indicate the meaning of the natural training sentence
  • the style vector is used to indicate the language style of the natural training sentence.
  • the training model includes a first sub-model and a second sub-model, the first sub-model is established according to a preset supervision model, and the first sub-model is used for supervising according to the supervised model
  • the ability to output a similarity between different content vectors, the supervisory capability refers to the ability to determine a language style corresponding to the received content vector;
  • the second sub-model is based on the second encoding model and the second Established by the decoding model, the second sub-model is configured to output a probability that the natural sentence is restored according to the second decoding model and the second encoding function.
  • the training module 810 includes: a supervised training unit, a first generating unit, a model updating unit, a model training unit, and a second generating unit.
  • a supervisory training unit configured to input the m group first natural training sentence and the second natural training sentence into the first submodel to train the supervised ability of the supervised model; each set of the first natural training statement and The second natural training statement is a natural training statement having different language styles and having the same meaning, and the m is a positive integer;
  • a first generating unit configured to stop training when the number of training reaches a preset number of times, and obtain a supervised model after training
  • a model updating unit configured to update the first sub-model in the training model by using the trained supervised model
  • model training unit configured to input n sets of third natural training sentences and fourth natural training sentences into the training model to train the second coding model and the second decoding model to obtain model training results, each group of The third natural training statement and the fourth natural training sentence are natural training sentences having different language styles and having the same meaning;
  • the model training result includes a first result of the updated first submodel output and the a second result of the second submodel output, the n being a positive integer;
  • a second generating unit configured to stop training when determining that the function model converges according to the model training result, to obtain the first coding model and the first decoding model, where the function model includes a second coding model after training And the second decoding model after training.
  • model training unit is further configured to:
  • a similarity between the content vector corresponding to the third natural training statement and the content vector corresponding to the fourth natural training statement, and the restored third natural training statement is the same as the third natural training statement Determining, the probability that the restored fourth natural training statement and the fourth natural training statement remain the same within the preset training number, determining that the function model converges to stop training, and obtains the first coding model And the first decoding model.
  • the supervised training unit is further configured to:
  • the embodiment of the present application further provides a computer readable storage medium, where the computer readable storage medium stores at least one instruction, at least one program, a code set, or an instruction. And the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement a method for generating a style statement described in each of the foregoing method embodiments, or The model training method described in the method embodiment.
  • FIG. 9 is a schematic structural diagram of a computer device according to an exemplary embodiment of the present application.
  • the computer device is equipped with the training model shown in FIG. 1 and/or the first encoding model and the first decoding model shown in FIG. 2.
  • the computer device includes a processor 911, a memory 914, and a bus 919.
  • the processor 911 includes one or more processing cores, and the memory 914 is coupled to the processor 911 via a bus 919 for storing program instructions.
  • the processor 911 executes the program instructions in the memory 914 to implement the styles provided by the various method embodiments described above. The method of generating the statement, or the model training method.
  • memory 914 may be implemented by any type of volatile or non-volatile storage device, or a combination thereof, 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, Disk or Optical Disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read only memory
  • EPROM Erasable Programmable Read Only Memory
  • PROM Programmable Read Only Memory
  • ROM Read Only Memory
  • Magnetic Memory Flash Memory
  • Disk Disk or Optical Disk.
  • a computer device may include more or less components, such as a computer device may not include a transmitter, or the computer device may include other components such as a sensor, a display screen, a power source, and the like. This embodiment will not be described again.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Human Computer Interaction (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Multimedia (AREA)
  • Acoustics & Sound (AREA)
  • Artificial Intelligence (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Signal Processing (AREA)
  • General Health & Medical Sciences (AREA)
  • Machine Translation (AREA)

Abstract

本申请公开了一种风格语句的生成方法、模型训练方法、装置及计算机设备,属于自然语言处理领域。所述方法包括:获取待转换的自然语句;将所述自然语句输入第一编码模型对所述自然语句中的风格信息进行过滤,生成所述自然语句对应的目标内容向量;根据设置的目标语言风格,从至少一种风格向量中确定与所述目标语言风格相对应的目标风格向量,将所述目标内容向量和所述目标风格向量输入第一解码模型,生成与所述自然语句对应的风格语句;保证了每种自然语句都能较为准确的转换成具有目标语言风格的风格语句,提高了计算机设备在风格转化时的智能化程度。

Description

风格语句的生成方法、模型训练方法、装置及计算机设备
本申请要求于2017年09月12日提交中国国家知识产权局、申请号为201710817322.9、发明名称为“风格语句的生成方法、模型的训练方法、装置及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及自然语言处理领域,特别涉及一种风格语句的生成方法、模型训练方法、装置及计算机设备。
背景技术
智能对话系统用于根据用户输入的聊天内容自动生成对应的对话语句,从而实现人与机器之间的对话。目前,智能对话系统提供有不同的语言风格供用户选择,智能对话系统根据用户选择的语言风格,可以生成具有该语言风格的风格语句。其中,语言风格用于指示表达具有某一含义的自然语句的特定表达方式,比如:语言风格为清新淡雅、明快浅显、辞藻华丽、委婉含蓄、多用口语等。
在一种生成对话语句的方法中,智能对话系统预设有平行语料库,该平行预料库中包括多组句子对,每组句子对中的不同句子是具有相同含义、且具有不同语言风格的自然语句。
当智能对话系统需要生成具有某一语言风格的风格语句时,从平行语料库中查找具有该语言风格的自然语句,通过编码函数对该语言风格的自然语句进行编码得到语句向量,通过解码函数对该语句向量进行解码,生成具有该语言风格的风格语句。比如:当输入语句是“采用语言风格1表达的语义x”,将“采用语言风格1表达的语义X”通过编码函数进行编码得到语句向量X,语句向量X是与“语义x”对应的向量;若智能对话系统需要生成具有多用口语的语言风格的风格语句,则在从平行语料库中根据语句向量X查找出具有该语言风格的自然语句即可。
平行语料库可能不能穷尽某一自然语句的所有语言风格,比如:对于具有“语义x”的自然语句,当平行语料库不存在具有含蓄委婉的语言风格的自然语 句,智能对话系统只能选择其它语言风格的自然语句,或者,选择具有该语言风格的其它自然语句进行语句生成,从而导致智能对话系统生成的风格语句不符合用户期望,风格转化的效果较差的问题。
发明内容
本申请实施例提供了一种风格语句的生成方法、模型训练方法、装置及计算机设备,可以解决平行语料库中不存在具有用户选择的目标语言风格的自然语句时,导致无法准确生成具有该目标语言风格的风格语句的问题。所述技术方案如下:
根据本申请的一个方面,提供了一种风格语句的生成方法,所述方法由计算机设备执行,所述方法包括:
获取待转换的自然语句;
将所述自然语句输入第一编码模型对所述自然语句中的风格信息进行过滤,生成所述自然语句对应的目标内容向量,所述目标内容向量用于指示所述自然语句的含义,所述风格信息用于指示所述自然语句的语言风格;
根据设置的目标语言风格,从至少一种风格向量中确定与所述目标语言风格相对应的目标风格向量,其中,所述至少一种风格向量中的每种风格向量对应一种语言风格;
将所述目标内容向量和所述目标风格向量输入第一解码模型,生成与所述自然语句对应的风格语句。
根据本申请的另一方面,提供了一种模型训练方法,所述方法由计算机设备执行,所述模型包括第一编码模型和第一解码模型,所述方法包括:
将语料库中的至少两种自然训练语句输入训练模型,通过所述训练模型对第二编码模型的分类能力进行训练得到所述第一编码模型,每种所述自然训练语句对应一种语言风格,所述分类能力是指将输入的所述自然训练语句分类为对应的内容向量和风格向量的能力;
在训练得到所述第一编码模型时,获取所述第一编码模型输出的至少一种风格向量,每种所述风格向量是所述第一编码模型根据对应语言风格的所述自然训练语句进行分类得到的;
在所述至少两种自然训练语句输入所述训练模型时,通过所述训练模型对第二解码模型的还原能力进行训练得到所述第一解码模型,所述还原能力是指 根据所述内容向量和所述风格向量还原出所述自然训练语句的能力;
其中,所述内容向量用于指示所述自然训练语句的含义,所述风格向量用于指示所述自然训练语句的语言风格。
根据本申请的另一方面,提供了一种风格语句的生成装置,所述装置包括:
获取模块,用于获取待转换的自然语句;
第一生成模块,用于将所述自然语句输入第一编码模型对所述自然语句中的风格信息进行过滤,生成所述自然语句对应的目标内容向量,所述目标内容向量用于指示所述自然语句的含义,所述风格信息用于指示所述自然语句的语言风格;
确定模块,用于根据设置的目标语言风格,从至少一种风格向量中确定与所述目标语言风格相对应的目标风格向量,其中,所述至少一种风格向量中的每种风格向量对应一种语言风格;
第二生成模块,用于将所述目标内容向量和所述目标风格向量输入第一解码模型,生成与所述自然语句对应的风格语句。
根据本申请的另一方面,提供了一种模型训练装置,所述模型包括第一编码模型和第一解码模型,所述装置包括:
训练模块,用于将语料库中的至少两种自然训练语句输入训练模型,通过所述训练模型对第二编码模型的分类能力进行训练得到所述第一编码模型,每种所述自然训练语句对应一种语言风格,所述分类能力是指将输入的所述自然训练语句分类为对应的内容向量和风格向量的能力;
获取模块,用于在训练得到所述第一编码模型时,获取所述第一编码模型输出的至少一种风格向量,每种所述风格向量是所述第一编码模型根据对应语言风格的所述自然训练语句进行分类得到的;
所述训练模块,还用于在所述至少两种自然训练语句输入所述训练模型时,通过所述训练模型对第二解码模型的还原能力进行训练得到所述第一解码模型,所述还原能力是指根据所述内容向量和所述风格向量还原出所述自然训练语句的能力;
其中,所述内容向量用于指示所述自然训练语句的含义,所述风格向量用于指示所述自然训练语句的语言风格。
根据本申请的另一方面,提供了一种计算机设备,所述计算机设备包括第一编码模型和第一解码模型;
所述第一编码模型,用于对输入的自然语句的风格信息进行过滤,得到所述自然语句对应的目标内容向量;所述目标内容向量用于指示所述自然语句的含义,所述风格信息用于指示所述自然语句的语言风格;
所述第一解码模型,用于对输入的目标风格向量和所述目标内容向量进行融合,得到所述自然语句对应的风格语句;所述目标风格向量是所述计算机设备的至少一种风格向量中,与设置的目标语言风格对应的风格向量,所述至少一种风格向量中的每种风格向量对应一种语言风格。
根据本申请的另一方面,提供了一种计算机设备,所述计算机设备包括处理器和存储器,所述存储器中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现如上所述的风格语句的生成方法,或者,模型训练方法。
根据本申请的另一方面,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现如上所述的风格语句的生成方法,或者,模型训练方法。
本发明实施例提供的技术方案带来的有益效果至少包括:
通过第一编码模型对自然语句进行分类,得到具有尽可能少的风格信息的内容向量;再通过第一解码模型将该内容向量与训练过程中得到的目标风格向量进行编码得到风格语句,实现了内容向量和风格向量的分离。从而解决了当平行语料库中不存在用户选择的语言风格的自然语句时,计算机设备可能无法生成符合用户期望的具有目标语言风格的风格语句的问题;由于计算机设备中存储有每种语言风格对应的风格向量,第一解码模型能够从存储的多个风格向量中确定出目标语言风格对应的目标风格向量,并根据该目标风格向量与内容向量生成风格语句,因此,保证了每种自然语句都能转换成具有目标语言风格的风格语句,提高了计算机设备在风格转化时的智能化程度。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下, 还可以根据这些附图获得其他的附图。
图1是本申请一个示例性实施例提供的训练模型的示意图;
图2是本申请一个示例性实施例提供的计算机设备的示意图;
图3是本申请另一个示例性实施例提供的模型训练方法的流程图;
图4是本申请另一个示例性实施例提供的模型训练方法的示意图;
图5是本申请一个示例性实施例提供的风格语句的生成方法的流程图;
图6是本申请另一个示例性实施例提供的风格语句的生成方法的流程图;
图7是本申请一个示例性实施例提供的风格语句的生成装置的框图;
图8是本申请一个示例性实施例提供的模型训练装置的框图;
图9是本申请一个示例性实施例提供的计算机设备的结构示意图。
具体实施方式
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。
首先,对本申请涉及的若干个名词进行介绍。
语言风格:表达具有某一含义的自然语句的特定表达方式,比如:语言风格包括清新淡雅、明快浅显、辞藻华丽、委婉含蓄、多用口语等。同一含义的自然语句可以有多种特定表达方式,每种特定表达方式对应一种类型的语言风格。
比如:对于表达含义为“语义x”的自然语句,语言风格为明快浅显的自然语句为:采用语言风格1表达的语义x;语言风格为辞藻华丽的自然语句为:采用语言风格2表达的语义x;语言风格为委婉含蓄的自然语句为:采用语言风格3表达的语义x;语言风格为多用口语的自然语句为:采用语言风格4表达的语义x。
当然,语言风格的划分方式还可以为其它方式,比如:语言风格的划分为诗意、古典、文艺等,本实施例不对语言风格的划分方式作限定。
平行语料库:包括多组句子对,每组句子对中包括多个句子。每组句子对中的不同句子具有相同的含义,且具有不同的语言风格。
可选地,平行语料库也可称为对话语料库、个性化对话语料库等,本实施例不对平行语料库的具体名称作限定。
相关技术中,智能对话系统根据目标语言风格,在平行语料库中查找具有该目标语言风格的自然语句来生成风格语句。
比如:目标语言风格为委婉含蓄,智能对话系统需要生成具有“语义x”的风格语句,则语言系统在平行语料库中查找到采用委婉含蓄风格对语义x进行表达的自然语句1,根据自然语句1生成风格语句。但在平行语料库中不存在采用委婉含蓄风格对语义x进行表达的自然语句1时,则智能对话系统查找具有委婉含蓄的语言风格的其它自然语句2,或者,智能对话系统查找具有相同含义、但具有其它语言风格的自然语句3,根据这些自然语句2和自然语句3来生成风格语句。最终生成的风格语句可能脱离了原本的语义x,也可能实际语言风格与目标语言风格不符,也即无法准确生成具有目标语言风格的语句。
基于上述技术问题,本申请提供了如下技术方案,通过预先训练出每种语言风格对应的风格向量,再将语料库中的自然语句中的风格信息过滤,将过滤后得到的内容向量与风格向量进行编码得到风格语句,使得语言系统不再依赖于平行语料库中的已有风格语句来生成风格语句,并能够为所有自然语句添加目标语言风格,提高了计算机设备在风格转化时的智能化程度。
内容向量用于指示自然语句的含义(或者说语义)。可选地,内容向量通过i维数组表示,i为正整数。
风格向量用于指示自然语句的语言风格。可选地,风格向量通过j维数组表示,j为正整数。每个风格向量对应一种语言风格。本实施例对语言风格的划分方式不加以限定,每个语种和/或使用场景可以具有不同的语言风格。
可选地,本申请以各个实施例的执行主体为计算机设备为例进行说明,该计算机设备可以实现成为智能对话系统、风格转化系统、文字聊天机器人中的至少一种,本申请对该计算机设备的实际产品形式不加以限定。该计算机设备可以安装在服务器中;或者,也可以安装在终端中,本实施例对此不作限定。其中,计算机设备可以为手机、平板电脑、膝上型便携计算机和台式计算机等。在一些实施例中,本申请实施例中的风格语句的转换方法可以实现成为手机中的游戏助手,或者,游戏程序中的不同角色模型的自动聊天功能。
下面对本申请所涉及的训练模型(参考图1)和使用过程中的计算机设备(参考图2)分别进行介绍。
图1是本申请一个示例性实施例提供的训练模型的示意图。该训练模型包括:第一子模型110和第二子模型120。
第一子模型110根据监督模型111创建(或训练)得到;第二子模型120根据编码模型121和解码模型122创建(或训练)得到。
在对编码模型121和解码模型122进行训练时,将语料库中具有至少两种语言风格的自然训练语句(图1中通过x和y来表示)输入编码模型121,编码模型121对每种自然训练语句进行分类得到每种自然训练语句对应的内容向量(图1中通过e(x)和e(y)来表示)和风格向量(图1中通过v x和v y来表示)。
编码模型121的输出结果作为监督模型111的输入,第一子模型110通过监督模型111的监督能力判断输入的具有相同含义的至少两个内容向量是否相似。
监督能力是指判断接收到的内容向量对应的语言风格的能力。由于输入监督模型111的至少两个内容向量是根据具有相同含义、且具有不同的语言风格的自然训练语句生成的。因此,当监督模型111能够根据输入的内容向量判断出对应的语言风格时,说明该内容向量中仍然具有风格信息,而具有不同语言风格的内容向量的相似度较低。因此,监督模型111输出的监督结果差异较大。此时,第一子模型110根据监督模型111输出的监督结果的差异,能够确定出具有相同含义的至少两个内容向量是否相似。
第一子模型110将判断结果(第一结果)反馈给第二子模型120中的编码模型121。编码模型121根据判断结果调节自身的模型参数,从而提高该编码模型121的分类能力。分类能力是指将输入的自然训练语句分类为对应的内容向量和风格向量的能力。
编码模型121还将分类得到的内容向量和风格向量输入至解码模型122。解码模型122用于根据内容向量和风格向量还原出具有某种语言风格的自然训练语句。比如:在图1中,解码模型121根据内容向量e(x)和风格向量v x还原得到自然训练语句d x(e(x));解码模型121根据内容向量e(y)和风格向量v y还原得到自然训练语句d y(e(y))。
第二子模型120根据解码模型121的输出结果与输入编码模型121的自然训练语句是否相同的概率来判断解码模型121的还原能力。解码模型122根据第二子模型120的输出结果(第二结果)调节自身的模型参数,从而提高该解 码模型122的还原能力。其中,还原能力是指根据内容向量和风格向量还原出自然训练语句的能力。
比如:第二子模型120根据d x(e(x))与自然训练语句x之间相同的概率、根据d y(e(y))与自然训练语句y之间相同的概率确定解码模型121的还原能力。
示意性地,第一子模型110通过下述公式表示:
Figure PCTCN2018101180-appb-000001
其中,L critic(X,Y)是指第一子模型的输出结果,即,输入的两个内容向量的相似度;X为语料库中具有第一语言风格的自然训练语句构成的集合,|X|为具有第一语言风格的自然训练语句的数量;Y为语料库中具有第二语言风格的自然训练语句构成的集合;|Y|为具有第二语言风格的自然训练语句构成的集合数量,其中,第一语言风格与第二语言风格不同;e(x)为编码模型121输出的具有第一语言风格的自然训练语句的内容向量,e(y)为解码模型122输出的具有第二语言风格的自然训练语句的内容向量;f(e(x))为监督模型111在输入为e(x)时输出的监督结果;f(e(y))为监督模型111在输入为e(y)时输出的监督结果。
示意性地,第二子模型120通过下述公式表示:
Figure PCTCN2018101180-appb-000002
其中,L cycle(X,Y)是指第二子模型的输出结果,即,输入的两个自然训练语句被还原的概率;d x(e(x))是解码模型122的输入为e(x)和风格向量v x时输出的解码结果;d y(e(y))是解码模型122的输入为e(y)和风格向量v y时输出的解码结果;p(d x(e(x))=x)为d x(e(x))与自然训练语句x相同的概率;p(d y(e(y))=y)为d y(e(y))与自然训练语句y相同的概率。
示意性地,训练模型通过下述公式表示:
L transfer(X,Y)=L cycle(X,Y)-λL critic(X,Y)
其中,L transfer(X,Y)是指训练模型输出的训练结果,该训练结果用于反映编码模型121的分类能力和解码模型122的还原能力。其中,L transfer(X,Y) 的数值大小与编码模型121的分类能力呈负相关关系,即,L transfer(X,Y)越小,编码模型121的分类能力越好;L transfer(X,Y)的数值大小与解码模型122的还原能力呈负相关关系,即,L transfer(X,Y)越小,编码模型121的还原能力越好。λ为平衡因子,λ为小于1的正数,比如:λ=0.9。可选地,λ的取值固定不变;或者,λ的取值根据L cycle(X,Y)和/或L critic(X,Y)的取值进行调整。
需要补充说明的是,上述公式仅是示意性的,各个公式在实际实现时可进行适应性变化。比如:当输入编码模型121的自然语句为3种时,各个公式中应当添加第三种自然语句对应的输出结果。
经过上述训练模型的训练后,能够得到分类能力较高的编码模型,下文中称为第一编码模型,相应地,将得到第一编码模型之前训练的编码模型称为第二编码模型;以及,还原能力较高的解码模型,下文中称为第一解码模型,相应地,将得到第一解码模型之前训练的解码模型称为第二解码模型。
本实施例中,在训练得到第一编码模型的过程中,将最后一次训练时编码模型(即第一编码模型)输出的风格向量保存,作为在使用过程中用于为自然语句添加语言风格的风格向量。
图2是本申请一个示例性实施例提供的计算机设备的示意图。该计算机设备可以是智能对话系统,该计算机设备包括:第一编码模型210和第一解码模型220。
第一编码模型210是根据图1所示的训练模型对第二编码模型进行训练得到的。第一编码模型210用于对输入的自然语句进行分类,得到该自然语句对应的目标内容向量。第一编码模型210能够将输入的自然语句中的风格信息过滤,从而得到尽可能不包括风格信息的目标内容向量。其中,风格信息用于指示表达自然语句的语言风格。
第一编码模型210将输出的目标内容向量传递给第一解码模型220。
第一解码模型220是根据图1所示的训练模型对第二解码模型进行训练得到的。第一解码模型220从计算机设备存储的至少一种风格向量中,确定待转化的语言风格对应的目标风格向量,根据该目标风格向量和第一编码模型210传递的目标内容向量,生成与该自然语句对应的风格语句。
图3是本申请一个示例性实施例提供的模型训练方法的流程图。该模型训练方法用于图1所示的训练模型中,该模型训练方法可以由计算机设备来执行,该方法包括:
步骤301,将语料库中的至少两种自然训练语句输入训练模型,通过训练模型对第二编码模型的分类能力进行训练得到第一编码模型。
其中,至少两种自然训练语句中的每种自然训练语句对应一种语言风格。每种自然训练语句的数量为至少一句。在大部分情况下,同一种语言风格下的自然训练语句越多,则训练出的第一编码模型的分类能力越强。
示意性的,输入训练模型的自然训练语句包括:语言风格为委婉含蓄和多用口语的自然语句,其中,语言风格为委婉含蓄的自然语句的数量为5句,语言风格为多用口语的自然语句的数量也为5句。
分类能力是指将输入的自然训练语句分类为对应的内容向量和风格向量的能力。内容向量用于指示自然训练语句的含义,风格向量用于指示自然训练语句的语言风格。当第一编码模型的分类能力较强时,内容向量所携带的风格信息会尽可能地少。
步骤302,在训练得到第一编码模型时,获取第一编码模型输出的至少一种风格向量。
每种风格向量是第一编码模型根据对应语言风格的自然训练语句进行分类得到的。或者说,第i种风格向量是第一编码模型根据第i种语言风格的自然训练语句进行分类得到的。
步骤303,在至少两种自然训练语句输入训练模型时,通过训练模型对第二解码模型的还原能力进行训练得到第一解码模型。
还原能力是指根据内容向量和风格向量还原出自然训练语句的能力。
可选地,本实施例中,通过训练模型同时训练编码模型和解码模型,即,本步骤可以与步骤301同时执行。
可选地,训练模型包括第一子模型和第二子模型,第一子模型是根据预设的监督模型建立的,第一子模型用于根据监督模型的监督能力输出不同的内容向量之间的相似度,监督能力是指判断接收到的内容向量对应的语言风格的能力;第二子模型是根据第二编码模型和第二解码模型建立的,第二子模型用于根据第二解码模型和第二编码函数输出自然语句被还原的概率。
综上所述,本申请提供的模型训练方法,通过对编码模型的分类能力进行 训练得到第一编码模型、对解码模型的还原能力进行训练得到第一解码模型,使得计算机设备在使用时,能够通过第一编码模型对自然语句进行分类,得到具有尽可能少的风格信息的内容向量;再通过第一解码模型将该内容向量与训练过程中得到的目标风格向量进行编码得到风格语句,解决了只能从平行语料中查找具有目标语言风格的自然语句,导致计算机设备可能无法生成符合用户期望的具有目标语言风格的风格语句的问题;由于计算机设备中存储有每种语言风格对应的风格向量,第一解码模型能够从存储的风格向量中确定出目标语言风格对应的目标风格向量,并根据该目标风格向量与内容向量生成风格语句,因此,保证了每种自然语句都能转换成具有目标语言风格的风格语句,提高了计算机设备在风格转化时的智能化程度。
下面对第一编码模型和第二编码模型的训练过程进行详细介绍。
在一些实施例中,第一编码模型和第二编码模型的训练过程包括如下几个步骤:
1、将m组第一自然训练语句和第二自然训练语句输入第一子模型,对监督模型的监督能力进行训练。
其中,每组第一自然训练语句和第二自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句。
比如:输入第一子模型的m组自然训练语句包括如下一组自然训练语句:
自然训练语句1“已读”、自然训练语句2“已审核过”、自然训练语句3“已阅”和自然训练语句4“已经看过了”。
显然,该组自然训练语句的含义相同,但语言风格不同。
可选地,m组第一自然训练语句和第二自然训练语句分别来源于语料库中对应语言风格的语言集合,即,第一自然训练语句来源于第一自然训练语句对应的语言风格集合,第二自然训练语句来源于第二自然训练语句对应的语言风格集合。第一自然训练语句对应的语言风格集合与第二自然训练语句对应的语言风格集合不同。
比如:在上例中,自然训练语句1“已读”来源于明快浅显集合、自然训练语句2“已审核过”来源于辞藻华丽集合、自然训练语句3“已阅”来源于委婉含蓄集合、自然训练语句4“已经看过了”来源于多用口语集合。
需要补充说明的是,输入第一子模型的自然训练语句为至少两种,本实施 例中仅以第一自然训练语句和第二自然训练语句为例进行说明,在实际实现时,若输入第一子模型的自然训练语句为至少三种,则不同的两种自然训练语句中,其中一种为第一自然训练语句,另一种为第二自然训练语句。
比如:输入第一子模型的自然训练语句包括三种不同的x、y、z,则对于x和y来说,当x为第一自然训练语句,y为第二自然训练语句;或者,当y为第一自然训练语句,x为第二自然训练语句。对于y和z来说,y为第一自然训练语句,z为第二自然训练语句;或者,当z为第一自然训练语句,y为第二自然训练语句。对于x和z来说,x为第一自然训练语句,z为第二自然训练语句;或者,当z为第一自然训练语句,x为第二自然训练语句。
其中,m为正整数。可选地,m的取值固定,比如:m为20句。
2、在训练次数达到预设次数时停止训练,得到训练后的监督模型。
可选地,训练次数由开发者设置,本实施例不对预设次数的数值作限定,比如:训练次数为10次、11次、1000次、10000次等。
可选地,在对监督模型进行训练时,监督模型会根据本次训练结果调整自身的模型参数,从而提高自身的监督能力。可选地,监督模型会根据本次训练结果按照误差反向传播算法调整自身的模型参数。
可选地,在对监督模型进行训练时,本次训练时输入的m组第一自然训练语句和第二自然训练语句与前几次训练时输入的m组第一自然训练语句和第二自然训练语句均不同。
本实施例通过对监督模型进行训练,可以提高监督模型的监督能力,从而提高第一训练模型判断不同的内容向量的相似度的准确性,从而提高了训练模型判断第二编码模型的分类能力和第二解码模型的还原能力的准确性。
3、通过训练后的监督模型更新训练模型中的第一子模型。
训练模型中的第一子模型是根据训练后的监督模型得到的。
4、将n组第三自然训练语句和第四自然训练语句输入训练模型,对第二编码模型和第二解码模型进行训练,得到模型训练结果。
每组第三自然训练语句和第四自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句。
第三自然训练语句与第一自然训练语句的相关介绍类似,第四自然训练语句的相关介绍与第二自然训练语句的相关介绍类似,详见步骤1,本实施例在此不作赘述。
模型训练结果包括:更新后的第一子模型输出的第一结果和第二子模型输出的第二结果。
第一结果用于指示具有相同含义的至少两个内容向量的相似度。第一结果的数值与第二编码模型的分类能力呈负相关关系,即,第一结果的数值越大,具有相同含义的至少两个内容向量的相似度越低,第二编码模型的分类能力越弱;第一结果的数值越小,具有相同含义的至少两个内容向量的相似度越高,第二编码模型的分类能力越强。
第二结果用于指示第二解码模型的输出结果与输入第二编码模型的自然语句之间相同的概率。第二结果的数值与第二解码模型的还原能力呈正相关关系,即,第二结果的数值越大,第二解码模型的输出结果与输入第二解码模型的自然语句相同的概率越高,第二解码模型的还原能力越强;第二结果的数值越小,第二解码模型的输出结果与输入第二编码模型的自然语句之间相同的概率越小,第二解码模型的分类能力越弱。
其中,n为正整数。可选地,n的取值固定,比如:n为20句。可选地,n与m的值相同或者不同。
可选地,参考图4,本步骤包括如下几个子步骤:
41、将n组第三自然训练语句和第四自然训练语句输入第二编码模型进行分类,得到每组第三自然训练语句对应的风格向量和内容向量,每组第四自然训练语句对应的风格向量和内容向量。
第二编码模型的分类能力越强,则分类得到的内容向量中包含的风格信息越少。
42、将同组第三自然训练语句对应的内容向量和第四自然训练语句对应的内容向量输入训练后的监督模型判断相似度,得到第三自然训练语句对应的内容向量和第四自然训练语句对应的内容向量之间的相似度。
其中,第三自然训练语句对应的内容向量和第四自然训练语句对应的内容向量之间的相似度,即为第一子模型得到的第一结果。
可选地,本实施例中,以第三自然训练语句对应的内容向量的监督结果与第四自然训练语句对应的内容向量的监督结果之间的差值来表示相似度。
43、将同组第三自然训练语句对应的内容向量和风格向量、第四自然训练语句对应的内容向量和风格向量输入第二解码模型进行还原,得到还原后的第三自然训练语句和还原后的第四自然训练语句。
44、当第三自然训练语句对应的内容向量和第四自然训练语句对应的内容向量之间的相似度、还原后的第三自然训练语句与第三自然训练语句相同的概率、还原后的第四自然训练语句与第四自然训练语句相同的概率在预设训练次数内保持不变(或变化范围小于预设条件)时,确定函数收敛,停止训练,得到第一编码模型和第一解码模型。
其中,还原后的第三自然训练语句与第三自然训练语句相同的概率、还原后的第四自然训练语句与第四自然训练语句相同的概率即为第二子模型输出的第二结果。
预设训练次数为至少两次,预设训练次数可以为3次、5次、100次、1000次、10000次等,本实施例不对预设训练次数的数值作限定。
可选地,当第三自然训练语句对应的内容向量和第四自然训练语句对应的内容向量之间的相似度在预设训练次数内存在变化;和/或,还原后的第三自然训练语句与第三自然训练语句相同的概率在预设训练次数内存在变化;和/或,还原后的第四自然训练语句与第四自然训练语句相同的概率在预设训练次数内存在变化时,根据第一结果调整第二编码模型中的模型参数,得到训练后的第二编码模型,根据第二结果调整第二解码模型中的模型参数,得到训练后的第二解码模型。
可选地,在最后一次训练得到第一编码模型和第一解码模型时,将最后一次训练过程中第一编码模型输出的至少一种风格向量存储,该至少一种风格向量用于在使用语言处理系统生成风格时,对输入的自然语句进行语言风格的转换。
5、在根据模型训练结果确定出函数模型收敛时停止训练,得到第一编码模型和第一解码模型。
6、在根据模型训练结果确定出函数模型不收敛时,再次执行步骤1,即,再次执行将m组第一自然训练语句和第二自然训练语句输入第一子模型对监督模型的监督能力进行训练的步骤。
综上所述,本实施例通过对监督模型进行训练,可以提高监督模型的监督能力,从而提高第一训练模型判断不同的内容向量的相似度的准确性,从而提高了训练模型判断第二编码模型的分类能力和第二解码模型的还原能力的准确性。
可选地,语言处理系统也可以不对监督模型进行训练,即,不执行步骤1-3, 本实施例对此不作限定。
可选地,在步骤1之前,计算机设备还对监督模型、第二编码模型和第二解码模型进行预训练。
对监督模型进行预训练包括:将相似度大于预设阈值的至少两个内容向量输入第一子模型;当第一子模型输出的第一结果与前p次预训练的第一结果不同时,调节监督模型中的模型参数;当第一子模型输出的第一结果与前p次预训练的第一结果相同时,得到预训练后的监督模型。此时,语言处理系统根据该预训练后的监督模型执行上述步骤1-6。
对第二编码模型和第二解码模型进行预训练包括:将至少一种预训练语句输入第二子模型;当第二子模型输出的第二结果与前q次预训练的第二结果不同时,调节第二编码模型和/或第二解码模型中的模型参数;当第二子模型输出的第二结果与前q次预训练的第二结果相同时,得到预训练后的第二编码模型和预训练后的第二解码模型。此时,语言处理系统根据该预训练后的第二编码模型和预训练后的第二解码模型执行上述步骤1-6。
综上所述,本实施例中,通过对监督模型、第二编码模型和第二解码模型进行预训练,能够得到监督模型、第二编码模型和第二解码模型中粗略的模型参数,避免了直接根据训练模型对第二编码模型和第二解码模型进行训练,训练次数过多,导致消耗过多资源的问题,提高了训练第二编码模型和第二解码模型的效率。
图5是本申请一个示例性实施例提供的风格语句的生成方法的流程图。该风格语句的生成方法用于图2所示的计算机设备中,该方法包括:
步骤501,获取待转换的自然语句。
可选地,待转换的自然语句为语言处理系统从语料库中选择的;或者,待转换的自然语句为用户输入的。
步骤502,将自然语句输入第一编码模型对自然语句中的风格信息进行过滤,生成自然语句对应的目标内容向量。
其中,第一编码模型是通过训练模型对第二编码模型进行训练得到的,训练模型用于训练第二编码模型的分类能力得到第一编码模型;分类能力是指将输入的自然语句分类为对应的内容向量和风格向量的能力。
目标内容向量用于指示自然语句的含义,风格信息用于指示自然语句的语言风格。
步骤503,根据设置的目标语言风格,从至少一种风格向量中确定与目标语言风格相对应的目标风格向量。
可选地,计算机设备提供有至少一种语言风格,计算机设备根据接收到的设置操作设置目标语言风格。可选地,设置操作是用户执行的。
其中,至少一种风格向量中的每种风格向量对应一种语言风格。此时,计算机设备提供的至少一种语言风格都存在对应的风格向量。
至少一种风格向量是在训练得到第一编码模型时,由第一编码模型对输入的具有语言风格的自然训练语句进行分类得到的,每种具有语言风格的自然训练语句对应至少一种风格向量中的一种风格向量。
步骤504,将目标内容向量和目标风格向量输入第一解码模型,生成与自然语句对应的风格语句。
其中,第一解码模型是通过训练模型对第二解码模型进行训练得到的;训练模型还用于训练第二解码模型的还原能力得到第一解码模型;还原能力是指根据内容向量和风格向量还原出自然语句的能力。
综上所述,本实施例提供的风格语句生成方法,通过第一编码模型对自然语句进行分类,得到具有尽可能少的风格信息的内容向量;再通过第一解码模型将该内容向量与训练过程中得到的目标风格向量进行编码得到风格语句,解决了只能从平行语料中查找具有目标语言风格的自然语句,导致计算机设备可能无法生成符合用户期望的具有目标语言风格的风格语句的问题;由于计算机设备中存储有每种语言风格对应的风格向量,第一解码模型能够从存储的风格向量中确定出目标语言风格对应的目标风格向量,并根据该目标风格向量与内容向量生成风格语句,因此,保证了每种自然语句都能转换成具有目标语言风格的风格语句,提高了计算机设备的智能化程度。
可选地,计算机设备还提供有由至少一种语言风格构成的语言风格的组合,比如:清新淡雅和明快浅显的语言风格的组合,若计算机设备中设置的目标语言风格为语言风格的组合时,计算机设备还能够生成语言风格融合后的风格语言。
参考图5,此时,参考图6,步骤503替换为如下几个步骤:
步骤5031,当设置的目标语言风格是至少两种语言风格的组合时,从至少一种风格向量中选择每种语言风格对应的风格向量,得到至少两种风格向量。
比如:目标语言风格为清新淡雅和明快浅显的语言风格的组合,则语言处理系统从至少一种风格向量中确定清新淡雅对应的风格向量和明快浅显对应的风格向量。
步骤5032,将至少两种风格向量进行融合得到目标风格向量。
计算机设备将至少两种风格向量进行融合得到目标风格向量,包括:确定至少两种风格向量的平均值,将平均值确定为目标风格向量。
比如:计算机设备计算清新淡雅对应的风格向量和明快浅显对应的风格向量的平均值,将该平均值确定为目标风格向量。
本实施例中,通过将不同的风格向量进行融合得到目标风格向量,扩展了语言处理系统提供的语言风格。
可选地,在上述实施例中,自然语句、自然训练语句和预训练语句均为语言处理系统的语料库中的语句。在语言处理系统的使用过程中,这些语句称为自然语句;在语言处理系统的训练过程中,这些语句称为自然训练语句;在语言处理系统的预训练过程中,这些语句称为预训练语句。
可选地,在上述实施例中,编码模型是基于时间递归(Long Short Term Memory,LSTM)神经网络创建的;或者,编码模型是基于门循环单元Gated Recurrent Unit,GRU)神经网络创建的;本实施例不对编码模型的类型作限定。其中,编码模型包括第一编码模型和第二编码模型。
可选地,在上述实施例中,解码模型是基于时间递归(Long Short Term Memory,LSTM)神经网络创建的;或者,解码模型是基于门循环单元Gated Recurrent Unit,GRU)神经网络创建的;本实施例不对解码模型的类型作限定。其中,解码模型包括第一解码模型和第二解码模型。
可选地,在上述实施例中,监督模型是基于时间递归(Long Short Term Memory,LSTM)神经网络创建的;或者,监督模型是基于门循环单元Gated Recurrent Unit,GRU)神经网络创建的;本实施例不对监督模型的类型作限定。
图7是本申请一个示例性实施例提供的风格语句的生成装置的框图。该装置可以通过软件、硬件或两者的结合实现成为计算机设备的全部或一部分。所述装置包括:获取模块710、第一生成模块720、确定模块730和第二生成模 块740。
获取模块710,用于获取待转换的自然语句;
第一生成模块720,用于将所述自然语句输入第一编码模型对所述自然语句中的风格信息进行过滤,生成所述自然语句对应的目标内容向量,所述目标内容向量用于指示所述自然语句的含义,所述风格信息用于指示所述自然语句的语言风格;
确定模块730,用于根据设置的目标语言风格,从至少一种风格向量中确定与所述目标语言风格相对应的目标风格向量,其中,所述至少一种风格向量中的每种风格向量对应一种语言风格;
第二生成模块740,用于将所述目标内容向量和所述目标风格向量输入第一解码模型,生成与所述自然语句对应的风格语句。
可选地,所述至少一种风格向量是在训练得到所述第一编码模型时,由所述第一编码模型对输入的具有语言风格的自然训练语句进行分类得到的,每种具有语言风格的自然训练语句对应所述至少一种风格向量中的一种风格向量;
所述确定模块,包括:选择单元和融合单元。
选择单元,用于当设置的所述目标语言风格是至少两种语言风格的组合时,从所述至少一种风格向量中选择每种语言风格对应的风格向量,得到至少两种风格向量;
融合单元,用于将所述至少两种风格向量进行融合得到所述目标风格向量。
可选地,所述融合单元,还用于:
确定所述至少两种风格向量的平均值,将所述平均值确定为所述目标风格向量。
可选地,所述第一编码模型是通过训练模型对第二编码模型进行训练得到的;所述训练模型用于训练所述第二编码模型的分类能力得到所述第一编码模型;
所述第一解码模型是通过所述训练模型对第二解码模型进行训练得到的;所述训练模型还用于训练所述第二解码模型的还原能力得到所述第一解码模型;
其中,所述分类能力是指将输入的自然语句分类为对应的内容向量和风格向量的能力;所述还原能力是指根据所述内容向量和所述风格向量还原出所述 自然语句的能力。
图8是本申请一个示例性实施例提供的模型训练装置的框图。该装置可以通过软件、硬件或两者的结合实现成为计算机设备的全部或一部分。所述模型包括第一编码模型和第一解码模型,所述装置包括:训练模块810和获取模块820。
训练模块810,用于将语料库中的至少两种自然训练语句输入训练模型,通过所述训练模型对第二编码模型的分类能力进行训练得到所述第一编码模型,每种所述自然训练语句对应一种语言风格,所述分类能力是指将输入的所述自然训练语句分类为对应的内容向量和风格向量的能力;
获取模块820,用于在训练得到所述第一编码模型时,获取所述第一编码模型输出的至少一种风格向量,每种所述风格向量是所述第一编码模型根据对应语言风格的所述自然训练语句进行分类得到的;
所述训练模块810,还用于在所述至少两种自然训练语句输入所述训练模型时,通过所述训练模型对第二解码模型的还原能力进行训练得到所述第一解码模型,所述还原能力是指根据所述内容向量和所述风格向量还原出所述自然训练语句的能力;
其中,所述内容向量用于指示所述自然训练语句的含义,所述风格向量用于指示所述自然训练语句的语言风格。
可选地,所述训练模型包括第一子模型和第二子模型,所述第一子模型是根据预设的监督模型建立的,所述第一子模型用于根据所述监督模型的监督能力输出不同的内容向量之间的相似度,所述监督能力是指判断接收到的内容向量对应的语言风格的能力;所述第二子模型是根据所述第二编码模型和所述第二解码模型建立的,所述第二子模型用于根据所述第二解码模型和所述第二编码函数输出所述自然语句被还原的概率。
可选地,所述训练模块810,包括:监督训练单元、第一生成单元、模型更新单元、模型训练单元和第二生成单元。
监督训练单元,用于将m组第一自然训练语句和第二自然训练语句输入所述第一子模型对所述监督模型的所述监督能力进行训练;每组所述第一自然训练语句和所述第二自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句,所述m为正整数;
第一生成单元,用于在训练次数达到预设次数时停止训练,得到训练后的监督模型;
模型更新单元,用于通过所述训练后的监督模型更新所述训练模型中的所述第一子模型;
模型训练单元,用于将n组第三自然训练语句和第四自然训练语句输入所述训练模型对所述第二编码模型和所述第二解码模型进行训练,得到模型训练结果,每组所述第三自然训练语句和所述第四自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句;所述模型训练结果包括更新后的第一子模型输出的第一结果和所述第二子模型输出的第二结果,所述n为正整数;
第二生成单元,用于在根据所述模型训练结果确定出函数模型收敛时停止训练,得到所述第一编码模型和所述第一解码模型,所述函数模型包括训练后的第二编码模型和训练后的第二解码模型。
可选地,所述模型训练单元,还用于:
将所述n组第三自然训练语句和第四自然训练语句输入所述第二编码模型进行分类,得到每组所述第三自然训练语句对应的风格向量和内容向量,每组所述第四自然训练语句对应的风格向量和内容向量;
将同组所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量输入所述训练后的监督模型判断相似度,得到所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量之间的相似度;
将同组所述第三自然训练语句对应的内容向量和风格向量、所述第四自然训练语句对应的内容向量和风格向量输入所述第二解码模型进行还原,得到还原后的第三自然训练语句和还原后的第四自然训练语句;
当所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量之间的相似度、所述还原后的第三自然训练语句与所述第三自然训练语句相同的概率、所述还原后的第四自然训练语句与所述第四自然训练语句相同的概率在预设训练次数内保持不变时,确定所述函数模型收敛停止训练,得到所述第一编码模型和所述第一解码模型。
可选地,所述监督训练单元,还用于:
在根据所述模型训练结果确定出所述函数模型不收敛时,继续执行所述将m组第一自然训练语句和第二自然训练语句输入所述第一子模型对所述监督 模型的所述监督能力进行训练的步骤。
可选地,本申请实施例还提供了一种计算机可读存储介质,该存储介质中一种计算机可读存储介质,所述存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现上述各个方法实施例所述的风格语句的生成方法,或者,实现上述各个方法实施例所述的模型训练方法。
图9示出了本申请一个示例性实施例所涉及的计算机设备的结构示意图。该计算机设备安装有图1所示的训练模型和/或图2所示的第一编码模型和第一解码模型,该计算机设备包括:处理器911、存储器914和总线919。
处理器911包括一个或者一个以上处理核心,存储器914通过总线919与处理器911相连,存储器914用于存储程序指令,处理器911执行存储器914中的程序指令时实现上述各个方法实施例提供的风格语句的生成方法,或者,模型训练方法。
可选地,存储器914可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随时存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
上述结构示意仅为对计算机设备的示意性说明,计算机设备可以包括更多或更少的部件,比如计算机设备可以不包括发送器,或者,计算机设备还包括传感器、显示屏、电源等其它部件,本实施例不再赘述。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述仅为本申请的较佳实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (21)

  1. 一种风格语句的生成方法,所述方法由计算机设备执行,其特征在于,所述方法包括:
    获取待转换的自然语句;
    将所述自然语句输入第一编码模型对所述自然语句中的风格信息进行过滤,生成所述自然语句对应的目标内容向量,所述目标内容向量用于指示所述自然语句的含义,所述风格信息用于指示所述自然语句的语言风格;
    根据设置的目标语言风格,从至少一种风格向量中确定与所述目标语言风格相对应的目标风格向量,其中,所述至少一种风格向量中的每种风格向量对应一种语言风格;
    将所述目标内容向量和所述目标风格向量输入第一解码模型,生成与所述自然语句对应的风格语句。
  2. 根据权利要求1所述的方法,其特征在于,所述至少一种风格向量是在训练得到所述第一编码模型时,由所述第一编码模型对输入的具有语言风格的自然训练语句进行分类得到的,每种具有语言风格的自然训练语句对应所述至少一种风格向量中的一种风格向量;
    所述根据设置的目标语言风格,从至少一种风格向量中确定与所述目标语言风格相对应的目标风格向量,包括:
    当设置的所述目标语言风格是至少两种语言风格的组合时,从所述至少一种风格向量中选择每种语言风格对应的风格向量,得到至少两种风格向量;
    将所述至少两种风格向量进行融合得到所述目标风格向量。
  3. 根据权利要求2所述的方法,其特征在于,所述将所述至少两种风格向量进行融合得到所述目标风格向量,包括:
    确定所述至少两种风格向量的平均值,将所述平均值确定为所述目标风格向量。
  4. 根据权利要求1至3任一所述的方法,其特征在于,
    所述第一编码模型是通过训练模型对第二编码模型进行训练得到的;所述 训练模型用于训练所述第二编码模型的分类能力得到所述第一编码模型;
    所述第一解码模型是通过所述训练模型对第二解码模型进行训练得到的;所述训练模型还用于训练所述第二解码模型的还原能力得到所述第一解码模型;
    其中,所述分类能力是指将输入的自然语句分类为对应的内容向量和风格向量的能力;所述还原能力是指根据所述内容向量和所述风格向量还原出所述自然语句的能力。
  5. 一种模型训练方法,所述方法由计算机设备执行,其特征在于,所述模型包括第一编码模型和第一解码模型,所述方法包括:
    将语料库中的至少两种自然训练语句输入训练模型,通过所述训练模型对第二编码模型的分类能力进行训练得到所述第一编码模型,每种所述自然训练语句对应一种语言风格,所述分类能力是指将输入的所述自然训练语句分类为对应的内容向量和风格向量的能力;
    在训练得到所述第一编码模型时,获取所述第一编码模型输出的至少一种风格向量,每种所述风格向量是所述第一编码模型根据对应语言风格的所述自然训练语句进行分类得到的;
    在所述至少两种自然训练语句输入所述训练模型时,通过所述训练模型对第二解码模型的还原能力进行训练得到所述第一解码模型,所述还原能力是指根据所述内容向量和所述风格向量还原出所述自然训练语句的能力;
    其中,所述内容向量用于指示所述自然训练语句的含义,所述风格向量用于指示所述自然训练语句的语言风格。
  6. 根据权利要求5所述的方法,其特征在于,所述训练模型包括第一子模型和第二子模型,所述第一子模型是根据预设的监督模型建立的,所述第一子模型用于根据所述监督模型的监督能力输出不同的内容向量之间的相似度,所述监督能力是指判断接收到的内容向量对应的语言风格的能力;所述第二子模型是根据所述第二编码模型和所述第二解码模型建立的,所述第二子模型用于根据所述第二解码模型和所述第二编码函数输出所述自然语句被还原的概率。
  7. 根据权利要求6所述的方法,其特征在于,所述通过训练模型对第二编 码模型进行训练得到所述第一编码模型;通过所述训练模型对第二解码模型进行训练得到所述第一解码模型,包括:
    将m组第一自然训练语句和第二自然训练语句输入所述第一子模型对所述监督模型的所述监督能力进行训练;每组所述第一自然训练语句和所述第二自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句,所述m为正整数;
    在训练次数达到预设次数时停止训练,得到训练后的监督模型;
    通过所述训练后的监督模型更新所述训练模型中的所述第一子模型;
    将n组第三自然训练语句和第四自然训练语句输入所述训练模型对所述第二编码模型和所述第二解码模型进行训练,得到模型训练结果,每组所述第三自然训练语句和所述第四自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句;所述模型训练结果包括更新后的第一子模型输出的第一结果和所述第二子模型输出的第二结果,所述n为正整数;
    在根据所述模型训练结果确定出函数模型收敛时停止训练,得到所述第一编码模型和所述第一解码模型,所述函数模型包括训练后的第二编码模型和训练后的第二解码模型。
  8. 根据权利要求7所述的方法,其特征在于,所述将n组第三自然训练语句和第四自然训练语句输入所述训练模型对所述第二编码模型和所述第二解码模型进行训练,包括:
    将所述n组第三自然训练语句和第四自然训练语句输入所述第二编码模型进行分类,得到每组所述第三自然训练语句对应的风格向量和内容向量,每组所述第四自然训练语句对应的风格向量和内容向量;
    将同组所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量输入所述训练后的监督模型判断相似度,得到所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量之间的相似度;
    将同组所述第三自然训练语句对应的内容向量和风格向量、所述第四自然训练语句对应的内容向量和风格向量输入所述第二解码模型进行还原,得到还原后的第三自然训练语句和还原后的第四自然训练语句;
    当所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量之间的相似度、所述还原后的第三自然训练语句与所述第三自然训练 语句相同的概率、所述还原后的第四自然训练语句与所述第四自然训练语句相同的概率在预设训练次数内保持不变时,确定所述函数模型收敛停止训练,得到所述第一编码模型和所述第一解码模型。
  9. 根据权利要求7所述的方法,其特征在于,所述将n组第三自然训练语句和第四自然训练语句输入所述训练模型对所述第二编码模型和所述第二解码模型进行训练之后,还包括:
    在根据所述模型训练结果确定出所述函数模型不收敛时,继续执行所述将m组第一自然训练语句和第二自然训练语句输入所述第一子模型对所述监督模型的所述监督能力进行训练的步骤。
  10. 一种风格语句的生成装置,其特征在于,所述装置包括:
    获取模块,用于获取待转换的自然语句;
    第一生成模块,用于将所述自然语句输入第一编码模型对所述自然语句中的风格信息进行过滤,生成所述自然语句对应的目标内容向量,所述目标内容向量用于指示所述自然语句的含义,所述风格信息用于指示所述自然语句的语言风格;
    确定模块,用于根据设置的目标语言风格,从至少一种风格向量中确定与所述目标语言风格相对应的目标风格向量,其中,所述至少一种风格向量中的每种风格向量对应一种语言风格;
    第二生成模块,用于将所述目标内容向量和所述目标风格向量输入第一解码模型,生成与所述自然语句对应的风格语句。
  11. 根据权利要求10所述的装置,其特征在于,所述至少一种风格向量是在训练得到所述第一编码模型时,由所述第一编码模型对输入的具有语言风格的自然训练语句进行分类得到的,每种具有语言风格的自然训练语句对应所述至少一种风格向量中的一种风格向量;
    所述确定模块,包括:选择单元和融合单元;
    所述选择单元,用于当设置的所述目标语言风格是至少两种语言风格的组合时,从所述至少一种风格向量中选择每种语言风格对应的风格向量,得到至少两种风格向量;
    所述融合单元,用于将所述至少两种风格向量进行融合得到所述目标风格向量。
  12. 根据权利要求10所述的装置,其特征在于,
    所述融合单元,还用于确定所述至少两种风格向量的平均值,将所述平均值确定为所述目标风格向量。
  13. 根据权利要求10所述的装置,其特征在于,所述第一编码模型是通过训练模型对第二编码模型进行训练得到的;所述训练模型用于训练所述第二编码模型的分类能力得到所述第一编码模型;
    所述第一解码模型是通过所述训练模型对第二解码模型进行训练得到的;所述训练模型还用于训练所述第二解码模型的还原能力得到所述第一解码模型;
    其中,所述分类能力是指将输入的自然语句分类为对应的内容向量和风格向量的能力;所述还原能力是指根据所述内容向量和所述风格向量还原出所述自然语句的能力。
  14. 一种模型训练装置,其特征在于,所述模型包括第一编码模型和第一解码模型,所述装置包括:
    训练模块,用于将语料库中的至少两种自然训练语句输入训练模型,通过所述训练模型对第二编码模型的分类能力进行训练得到所述第一编码模型,每种所述自然训练语句对应一种语言风格,所述分类能力是指将输入的所述自然训练语句分类为对应的内容向量和风格向量的能力;
    获取模块,用于在训练得到所述第一编码模型时,获取所述第一编码模型输出的至少一种风格向量,每种所述风格向量是所述第一编码模型根据对应语言风格的所述自然训练语句进行分类得到的;
    所述训练模块,还用于在所述至少两种自然训练语句输入所述训练模型时,通过所述训练模型对第二解码模型的还原能力进行训练得到所述第一解码模型,所述还原能力是指根据所述内容向量和所述风格向量还原出所述自然训练语句的能力;
    其中,所述内容向量用于指示所述自然训练语句的含义,所述风格向量用 于指示所述自然训练语句的语言风格。
  15. 根据权利要求14所述的装置,其特征在于,所述训练模型包括第一子模型和第二子模型;
    所述第一子模型是根据预设的监督模型建立的,所述第一子模型用于根据所述监督模型的监督能力输出不同的内容向量之间的相似度,所述监督能力是指判断接收到的内容向量对应的语言风格的能力;
    所述第二子模型是根据所述第二编码模型和所述第二解码模型建立的,所述第二子模型用于根据所述第二解码模型和所述第二编码函数输出所述自然语句被还原的概率。
  16. 根据权利要求14所述的装置,其特征在于,所述训练模块,包括:监督训练单元、第一生成单元、模型更新单元、模型训练单元和第二生成单元;
    所述监督训练单元,用于将m组第一自然训练语句和第二自然训练语句输入所述第一子模型对所述监督模型的所述监督能力进行训练;每组所述第一自然训练语句和所述第二自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句,所述m为正整数;
    所述第一生成单元,用于在训练次数达到预设次数时停止训练,得到训练后的监督模型;
    所述模型更新单元,用于通过所述训练后的监督模型更新所述训练模型中的所述第一子模型;
    所述模型训练单元,用于将n组第三自然训练语句和第四自然训练语句输入所述训练模型对所述第二编码模型和所述第二解码模型进行训练,得到模型训练结果,每组所述第三自然训练语句和所述第四自然训练语句是具有不同语言风格、且具有相同含义的自然训练语句;所述模型训练结果包括更新后的第一子模型输出的第一结果和所述第二子模型输出的第二结果,所述n为正整数;
    所述第二生成单元,用于在根据所述模型训练结果确定出函数模型收敛时停止训练,得到所述第一编码模型和所述第一解码模型,所述函数模型包括训练后的第二编码模型和训练后的第二解码模型。
  17. 根据权利要求16所述的装置,其特征在于,所述模型训练单元,还用 于:
    将所述n组第三自然训练语句和第四自然训练语句输入所述第二编码模型进行分类,得到每组所述第三自然训练语句对应的风格向量和内容向量,每组所述第四自然训练语句对应的风格向量和内容向量;
    将同组所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量输入所述训练后的监督模型判断相似度,得到所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量之间的相似度;
    将同组所述第三自然训练语句对应的内容向量和风格向量、所述第四自然训练语句对应的内容向量和风格向量输入所述第二解码模型进行还原,得到还原后的第三自然训练语句和还原后的第四自然训练语句;
    当所述第三自然训练语句对应的内容向量和所述第四自然训练语句对应的内容向量之间的相似度、所述还原后的第三自然训练语句与所述第三自然训练语句相同的概率、所述还原后的第四自然训练语句与所述第四自然训练语句相同的概率在预设训练次数内保持不变时,确定所述函数模型收敛停止训练,得到所述第一编码模型和所述第一解码模型。
  18. 根据权利要求16所述的装置,其特征在于,所述监督训练单元,还用于:
    在根据所述模型训练结果确定出所述函数模型不收敛时,继续执行所述将m组第一自然训练语句和第二自然训练语句输入所述第一子模型对所述监督模型的所述监督能力进行训练的步骤。
  19. 一种计算机设备,其特征在于,所述计算机设备包括第一编码模型和第一解码模型;
    所述第一编码模型,用于对输入的自然语句的风格信息进行过滤,得到所述自然语句对应的目标内容向量;所述目标内容向量用于指示所述自然语句的含义,所述风格信息用于指示所述自然语句的语言风格;
    所述第一解码模型,用于对输入的目标风格向量和所述目标内容向量进行融合,得到所述自然语句对应的风格语句;所述目标风格向量是所述计算机设备的至少一种风格向量中,与设置的目标语言风格对应的风格向量,所述至少一种风格向量中的每种风格向量对应一种语言风格。
  20. 一种计算机设备,其特征在于,所述计算机设备包括处理器和存储器,所述存储器中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现如如权利要求1至4任一所述的风格语句的生成方法,或者,权利要求5至9任一所述的模型训练方法。
  21. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现如权利要求1至4任一所述的风格语句的生成方法,或者,权利要求5至9任一所述的模型训练方法。
PCT/CN2018/101180 2017-09-12 2018-08-17 风格语句的生成方法、模型训练方法、装置及计算机设备 WO2019052311A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US16/589,811 US11348570B2 (en) 2017-09-12 2019-10-01 Method for generating style statement, method and apparatus for training model, and computer device
US17/737,326 US11869485B2 (en) 2017-09-12 2022-05-05 Method for generating style statement, method and apparatus for training model, and computer device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710817322.9 2017-09-12
CN201710817322.9A CN108304436B (zh) 2017-09-12 2017-09-12 风格语句的生成方法、模型的训练方法、装置及设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/589,811 Continuation US11348570B2 (en) 2017-09-12 2019-10-01 Method for generating style statement, method and apparatus for training model, and computer device

Publications (1)

Publication Number Publication Date
WO2019052311A1 true WO2019052311A1 (zh) 2019-03-21

Family

ID=62869636

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/101180 WO2019052311A1 (zh) 2017-09-12 2018-08-17 风格语句的生成方法、模型训练方法、装置及计算机设备

Country Status (3)

Country Link
US (2) US11348570B2 (zh)
CN (1) CN108304436B (zh)
WO (1) WO2019052311A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110457661A (zh) * 2019-08-16 2019-11-15 腾讯科技(深圳)有限公司 自然语言生成方法、装置、设备及存储介质
CN111126047A (zh) * 2019-12-23 2020-05-08 中国银联股份有限公司 一种同义文本生成的方法及装置
CN111767744A (zh) * 2020-07-06 2020-10-13 北京猿力未来科技有限公司 文本风格迁移系统的训练方法及装置
EP3739499A1 (en) * 2019-05-15 2020-11-18 NVIDIA Corporation Grammar transfer using one or more neural networks
CN112016300A (zh) * 2020-09-09 2020-12-01 平安科技(深圳)有限公司 预训练模型处理、下游任务处理方法、装置及存储介质
CN114579608A (zh) * 2022-04-26 2022-06-03 阿里巴巴达摩院(杭州)科技有限公司 基于表格数据的人机交互方法、装置及设备

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108304436B (zh) 2017-09-12 2019-11-05 深圳市腾讯计算机系统有限公司 风格语句的生成方法、模型的训练方法、装置及设备
GB2568233A (en) * 2017-10-27 2019-05-15 Babylon Partners Ltd A computer implemented determination method and system
US10963273B2 (en) 2018-04-20 2021-03-30 Facebook, Inc. Generating personalized content summaries for users
US11307880B2 (en) * 2018-04-20 2022-04-19 Meta Platforms, Inc. Assisting users with personalized and contextual communication content
US11886473B2 (en) 2018-04-20 2024-01-30 Meta Platforms, Inc. Intent identification for agent matching by assistant systems
CN109447706B (zh) * 2018-10-25 2022-06-21 深圳前海微众银行股份有限公司 广告文案生成方法、装置、设备以及可读存储介质
CN109635253B (zh) * 2018-11-13 2024-05-28 平安科技(深圳)有限公司 文本风格转换方法、装置及存储介质、计算机设备
CN109614111B (zh) * 2018-12-28 2022-02-01 北京百度网讯科技有限公司 用于生成代码的方法和装置
US10977439B2 (en) * 2019-04-01 2021-04-13 International Business Machines Corporation Controllable style-based text transformation
KR20200121611A (ko) * 2019-04-16 2020-10-26 삼성전자주식회사 서버 및 그 제어 방법
CN110148424B (zh) * 2019-05-08 2021-05-25 北京达佳互联信息技术有限公司 语音处理方法、装置、电子设备及存储介质
CN110334334B (zh) * 2019-06-19 2024-05-14 腾讯科技(深圳)有限公司 一种摘要生成方法、装置及计算机设备
CN110688834B (zh) * 2019-08-22 2023-10-31 创新先进技术有限公司 基于深度学习模型进行智能文稿风格改写的方法和设备
CN111757173B (zh) * 2019-12-23 2022-11-08 北京沃东天骏信息技术有限公司 一种解说词生成方法、装置、智能音箱及存储介质
CN111414733B (zh) * 2020-03-18 2022-08-19 联想(北京)有限公司 一种数据处理方法、装置及电子设备
CN112035628A (zh) * 2020-08-03 2020-12-04 北京小米松果电子有限公司 对话数据清洗方法、装置及存储介质
CN114519339A (zh) * 2020-11-20 2022-05-20 北京搜狗科技发展有限公司 一种输入方法、装置和用于输入的装置
CN113343648B (zh) * 2021-05-21 2023-05-26 湖北大学 基于潜在空间编辑的文本风格转换方法
CN115879469B (zh) * 2022-12-30 2023-10-03 北京百度网讯科技有限公司 文本数据处理方法、模型训练方法、装置及介质
CN116151249B (zh) * 2023-03-14 2023-08-08 天津大学 一种基于困难样本筛选的即兴委婉语检测方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104750705A (zh) * 2013-12-27 2015-07-01 华为技术有限公司 信息回复方法及装置
US20160203819A1 (en) * 2015-01-13 2016-07-14 Huawei Technologies Co., Ltd. Text Conversion Method and Device
CN106469212A (zh) * 2016-09-05 2017-03-01 北京百度网讯科技有限公司 基于人工智能的人机交互方法和装置
CN106528858A (zh) * 2016-11-29 2017-03-22 北京百度网讯科技有限公司 歌词生成方法及装置
CN106598921A (zh) * 2016-12-12 2017-04-26 清华大学 基于lstm模型的现代文到古诗的转换方法及装置
CN108304436A (zh) * 2017-09-12 2018-07-20 深圳市腾讯计算机系统有限公司 风格语句的生成方法、模型的训练方法、装置及设备

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005115628A (ja) * 2003-10-07 2005-04-28 Hewlett-Packard Development Co Lp 定型表現を用いた文書分類装置・方法・プログラム
JP2012198277A (ja) * 2011-03-18 2012-10-18 Toshiba Corp 文書読み上げ支援装置、文書読み上げ支援方法および文書読み上げ支援プログラム
US8681176B1 (en) * 2011-09-20 2014-03-25 Google Inc. Rendering a map using style identifiers
WO2015092936A1 (ja) * 2013-12-20 2015-06-25 株式会社東芝 音声合成装置、音声合成方法およびプログラム
US11093711B2 (en) * 2016-09-28 2021-08-17 Microsoft Technology Licensing, Llc Entity-specific conversational artificial intelligence
US10650094B2 (en) * 2017-11-14 2020-05-12 Adobe Inc. Predicting style breaches within textual content

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104750705A (zh) * 2013-12-27 2015-07-01 华为技术有限公司 信息回复方法及装置
US20160203819A1 (en) * 2015-01-13 2016-07-14 Huawei Technologies Co., Ltd. Text Conversion Method and Device
CN106469212A (zh) * 2016-09-05 2017-03-01 北京百度网讯科技有限公司 基于人工智能的人机交互方法和装置
CN106528858A (zh) * 2016-11-29 2017-03-22 北京百度网讯科技有限公司 歌词生成方法及装置
CN106598921A (zh) * 2016-12-12 2017-04-26 清华大学 基于lstm模型的现代文到古诗的转换方法及装置
CN108304436A (zh) * 2017-09-12 2018-07-20 深圳市腾讯计算机系统有限公司 风格语句的生成方法、模型的训练方法、装置及设备

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3739499A1 (en) * 2019-05-15 2020-11-18 NVIDIA Corporation Grammar transfer using one or more neural networks
CN110457661A (zh) * 2019-08-16 2019-11-15 腾讯科技(深圳)有限公司 自然语言生成方法、装置、设备及存储介质
CN110457661B (zh) * 2019-08-16 2023-06-20 腾讯科技(深圳)有限公司 自然语言生成方法、装置、设备及存储介质
CN111126047A (zh) * 2019-12-23 2020-05-08 中国银联股份有限公司 一种同义文本生成的方法及装置
CN111126047B (zh) * 2019-12-23 2024-02-13 中国银联股份有限公司 一种同义文本生成的方法及装置
CN111767744A (zh) * 2020-07-06 2020-10-13 北京猿力未来科技有限公司 文本风格迁移系统的训练方法及装置
CN111767744B (zh) * 2020-07-06 2024-02-09 北京猿力未来科技有限公司 文本风格迁移系统的训练方法及装置
CN112016300A (zh) * 2020-09-09 2020-12-01 平安科技(深圳)有限公司 预训练模型处理、下游任务处理方法、装置及存储介质
CN112016300B (zh) * 2020-09-09 2022-10-14 平安科技(深圳)有限公司 预训练模型处理、下游任务处理方法、装置及存储介质
CN114579608A (zh) * 2022-04-26 2022-06-03 阿里巴巴达摩院(杭州)科技有限公司 基于表格数据的人机交互方法、装置及设备

Also Published As

Publication number Publication date
US11869485B2 (en) 2024-01-09
CN108304436B (zh) 2019-11-05
CN108304436A (zh) 2018-07-20
US11348570B2 (en) 2022-05-31
US20200035220A1 (en) 2020-01-30
US20220262346A1 (en) 2022-08-18

Similar Documents

Publication Publication Date Title
WO2019052311A1 (zh) 风格语句的生成方法、模型训练方法、装置及计算机设备
CN111310438B (zh) 基于多粒度融合模型的中文句子语义智能匹配方法及装置
CN108615073B (zh) 图像处理方法及装置、计算机可读存储介质、电子设备
WO2021051516A1 (zh) 基于人工智能的古诗词生成方法、装置、设备及存储介质
WO2021037113A1 (zh) 一种图像描述的方法及装置、计算设备和存储介质
CN111078838A (zh) 关键词提取方法、关键词提取装置及电子设备
CN108628868B (zh) 文本分类方法和装置
CN109271516B (zh) 一种知识图谱中实体类型分类方法及系统
US20230259707A1 (en) Systems and methods for natural language processing (nlp) model robustness determination
CN111027292B (zh) 一种限定采样文本序列生成方法及其系统
CN112328797A (zh) 一种基于神经网络和注意力机制的情感分类方法及系统
WO2023050708A1 (zh) 一种情感识别方法、装置、设备及可读存储介质
CN109117474A (zh) 语句相似度的计算方法、装置及存储介质
US11322151B2 (en) Method, apparatus, and medium for processing speech signal
CN114444476A (zh) 信息处理方法、装置和计算机可读存储介质
CN113705207A (zh) 语法错误识别方法及装置
CN117076608A (zh) 一种基于文本动态跨度的整合外部事件知识的脚本事件预测方法及装置
JP6899973B2 (ja) 意味関係学習装置、意味関係学習方法、及び意味関係学習プログラム
CN115146589B (zh) 文本处理方法、装置、介质以及电子设备
CN114358019A (zh) 意图预测模型的训练方法及系统
CN112200268A (zh) 一种基于编码器-解码器框架的图像描述方法
CN115248846B (zh) 文本识别方法、设备、介质
CN113392221B (zh) 一种对薄实体的处理方法及相关装置
US20240045895A1 (en) Information processing device, information processing method, and program
CN117521674B (zh) 对抗信息的生成方法、装置、计算机设备和存储介质

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18856774

Country of ref document: EP

Kind code of ref document: A1