CN115688808A - Translation method, translation device, readable medium and electronic equipment - Google Patents

Translation method, translation device, readable medium and electronic equipment Download PDF

Info

Publication number
CN115688808A
CN115688808A CN202211430812.0A CN202211430812A CN115688808A CN 115688808 A CN115688808 A CN 115688808A CN 202211430812 A CN202211430812 A CN 202211430812A CN 115688808 A CN115688808 A CN 115688808A
Authority
CN
China
Prior art keywords
text
style
target
translation
vector
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211430812.0A
Other languages
Chinese (zh)
Inventor
孙泽维
王移帆
程善伯
王明轩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Youzhuju Network Technology Co Ltd
Lemon Inc Cayman Island
Original Assignee
Beijing Youzhuju Network Technology Co Ltd
Lemon Inc Cayman Island
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Youzhuju Network Technology Co Ltd, Lemon Inc Cayman Island filed Critical Beijing Youzhuju Network Technology Co Ltd
Priority to CN202211430812.0A priority Critical patent/CN115688808A/en
Publication of CN115688808A publication Critical patent/CN115688808A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Machine Translation (AREA)

Abstract

The embodiment of the disclosure relates to a translation method, a translation device, a readable medium and electronic equipment. The method comprises the following steps: determining a source text to be translated and a target language style; determining a text with an undetermined style from a plurality of styles corresponding to the target language style according to the source text; and inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is a target language style. Therefore, the translation process of the text translation model can be assisted through the text with the undetermined style, so that the text translation model can realize accurate stylized translation without training a large amount of stylized bilingual texts, the training complexity of the text translation model is reduced, and the accuracy of the stylized translation of the text translation model is improved.

Description

Translation method, translation device, readable medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a translation method, an apparatus, a readable medium, and an electronic device.
Background
With the advancement of computer technology, machine translation has become an important research topic in natural language text processing. Machine translation refers to the process of translating, by a computer or other electronic device, text in a source language to semantically equivalent text in a target language. Natural language text can be written in various styles with different vocabularies and syntax, while the semantics of the different styles remain the same. The language style plays an important role in communication in many languages, for example, american english style and english style in english, and pars style and non-pars style in korean, and so on.
However, in the related art, the machine translation cannot achieve the language style after the translation in a targeted manner, and the language needs to be manually adjusted after the translation is completed, which affects the translation effect and the translation efficiency of the machine translation.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
According to a first aspect of embodiments of the present disclosure, there is provided a translation method, the method including:
determining a source text to be translated and a target language style;
determining a text with a pending style from a plurality of styles of texts corresponding to the target language style according to the source text;
inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is the target language style.
According to a second aspect of embodiments of the present disclosure, there is provided a translation apparatus, the apparatus comprising:
the first determining module is used for determining a source text to be translated and a target language style;
the second determining module is used for determining texts with undetermined styles from a plurality of style texts corresponding to the target language style according to the source texts;
and the translation module is used for inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is the target language style.
According to a third aspect of embodiments of the present disclosure, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processing apparatus, performs the steps of the method of the first aspect of the present disclosure.
According to a fourth aspect of embodiments of the present disclosure, there is provided an electronic apparatus including:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to implement the steps of the method of the first aspect of the present disclosure.
By adopting the technical scheme, the source text to be translated and the target language style are determined; determining a text with an undetermined style from a plurality of styles corresponding to the target language style according to the source text; and inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is a target language style. Therefore, the translation process of the text translation model can be assisted through the text with the undetermined style, so that the text translation model can realize accurate stylized translation without training a large amount of stylized bilingual texts, the training complexity of the text translation model is reduced, and the accuracy of the stylized translation of the text translation model is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
FIG. 1 is a flow diagram illustrating a translation method in accordance with an exemplary embodiment.
Fig. 2 is a flowchart illustrating a step S102 according to the embodiment shown in fig. 1.
FIG. 3 is a diagram illustrating a translation method according to an exemplary embodiment.
FIG. 4 is a flow diagram illustrating a method of generating a target style text set in accordance with an exemplary embodiment.
Fig. 5 is a block diagram illustrating a translation apparatus according to an example embodiment.
FIG. 6 is a block diagram illustrating another translation apparatus according to an example embodiment.
FIG. 7 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise. In the description of the present disclosure, unless otherwise indicated, "plurality" means two or more, and other terms are similar; "at least one item", "one or more item", or similar expressions, refers to any combination of these item(s), including any combination of single item(s) or plural item(s). For example, at least one item(s) a, may represent any number a; as another example, one or more of a, b, and c may represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c can be single or multiple; "and/or" is an association describing an associated object, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural.
Although operations or steps may be described in a particular order in the drawings in the embodiments of the disclosure, they should not be construed as requiring that such operations or steps be performed in the particular order shown or in serial order, or that all illustrated operations or steps be performed, to achieve desirable results. In embodiments of the present disclosure, these operations or steps may be performed in series; these operations or steps may also be performed in parallel; some of these operations or steps may also be performed.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
It is understood that before the technical solutions disclosed in the embodiments of the present disclosure are used, the type, the use range, the use scene, etc. of the personal information related to the present disclosure should be informed to the user and obtain the authorization of the user through a proper manner according to the relevant laws and regulations.
For example, in response to receiving an active request from a user, a prompt message is sent to the user to explicitly prompt the user that the requested operation to be performed would require the acquisition and use of personal information to the user. Thus, the user can autonomously select whether to provide personal information to software or hardware such as an electronic device, an application program, a server, or a storage medium that performs the operations of the technical solution of the present disclosure, according to the prompt information.
As an optional but non-limiting implementation manner, in response to receiving an active request from the user, the manner of sending the prompt information to the user may be, for example, a pop-up window, and the prompt information may be presented in a text manner in the pop-up window. In addition, a selection control for providing personal information to the electronic device by the user's selection of "agreeing" or "disagreeing" can be carried in the pop-up window.
It is understood that the above notification and user authorization process is only illustrative and not limiting, and other ways of satisfying relevant laws and regulations may be applied to the implementation of the present disclosure.
Meanwhile, it is understood that the data involved in the present technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of the corresponding laws and regulations and the related regulations.
The disclosure is described below with reference to specific examples.
First, an application scenario of the present disclosure will be explained. The present disclosure may be applied to a language translation scenario, particularly a stylized language translation scenario, for example, in a scenario in which chinese is translated into american english, or in a scenario in which english is translated into the tongue style of korean.
In order to enable the machine translation model to realize stylized translation, a large number of stylized bilingual texts (for example, a text pair of a chinese text and a american english text, and a text pair of an english text and a korean tongue style text) can be collected, and the machine translation model is trained to obtain the stylized translation model. However, with this method, a large amount of stylized bilingual text needs to be collected, and the trained model translation accuracy is not high due to limited corpus of the stylized bilingual text.
FIG. 1 is a flow diagram illustrating a translation method in accordance with an exemplary embodiment. The method can be applied to electronic devices, which may include terminal devices, such as smart phones, smart wearable devices, smart speakers, smart tablets, PDAs (Personal Digital assistants), CPEs (Customer Premise Equipment), personal computers, vehicle terminals, and the like; the electronic device may also include a server, such as a local server or a cloud server. As shown in fig. 1, the method may include:
s101, determining a source text to be translated and a target language style.
Wherein the target language style may be an expected language style after translating the source text; the source text may be a word, sentence, paragraph, or article, as this disclosure does not limit.
The language corresponding to the source text may be referred to as a source language, the language expected after translation may be referred to as a target language, and the language style expected after translation may be referred to as a target language style. For example, if the source text input by the user is Chinese text, the source language is Chinese, the target language expected after translation may be English, and the target language style expected after translation may be American English.
The translated target language and the target language style can be specified by a user or can be automatically detected and determined by the electronic equipment.
In some embodiments, the text to be translated input by the user may be used as the source text, and the language style input by the user may be used as the target language style.
For example, a speech style selection box may be provided to the user, and the user may select a corresponding speech style as the target speech style through the speech style selection box.
In other embodiments, the text to be translated input by the user may be used as a source text, and the target language style may be automatically determined according to the state parameters of the electronic device used by the user to input the source text.
The status parameters may include a current time zone parameter, a country and a language parameter of the electronic device, and the like.
And S102, determining the text with the undetermined style from the plurality of style texts corresponding to the target language style according to the source text.
The plurality of style texts corresponding to the target language style may be pre-generated monolingual style texts. For example, if the target language style is american english style, the plurality of style texts are all american english style texts; if the target language style is a korean idiom style, the plurality of style texts are all korean idiom style texts.
In some embodiments, the text closest to the source text in the plurality of style texts may be considered as the pending style text. For example, the style text and the source text may be respectively encoded through a pre-generated text encoding model, the similarity between the source text and each style text is calculated, and the style text with the highest similarity is used as the pending style text.
In other embodiments, a style text may be randomly selected from a plurality of style texts as the pending style text.
S103, inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model.
The language style of the target translation text may be a target language style.
In some embodiments, the source text and the text of the undetermined style can be spliced to obtain a target spliced text, and the target spliced text is input into the text translation model to obtain a target translation text.
For example, the source text and the text of the undetermined style may be spliced according to preset keywords, and may be spliced as the text of the undetermined style + the preset keywords + the source text, or may be spliced as the text of the source text + the preset keywords + the text of the undetermined style.
For example, the preset keyword may be < token >, and if the source text is "I don't know, he will not tell me", the pending style text is "I tell the, kate, ' twas burn and led away", and the target spliced text obtained after splicing may be "I tell the, kate, ' twas burn and led away < token > I do not know, he will not tell me", or "I don't know, he will not tell me < token > I, ' tee, kate twas burn and led away".
In other embodiments, the source text and the text of the undetermined style may be input into the text translation model, respectively, to obtain a target translation text.
In some embodiments, the text with the undetermined style may be used as a prompt monolingual corresponding to the source text, and is used to prompt the text translation model, so that the style text or a target language style corresponding to the style text is reserved in the translated target translation text, that is, the language style of the output target translation text is the target language style.
In other embodiments, the text translation model may determine a target language style from the pending style text such that a speech style of the translated target translated text is the same or similar to the target language style.
It should be noted that the text translation model may adopt a machine translation model in the related art, for example, a Transformer model or a BERT model, and the disclosure is not limited thereto.
Determining a source text to be translated and a target language style by adopting the method; determining a text with an undetermined style from a plurality of styles corresponding to the target language style according to the source text; and inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is a target language style. Therefore, the translation process of the text translation model can be assisted through the text with the undetermined style, so that the text translation model can realize accurate stylized translation without training a large amount of stylized bilingual texts, the complexity of the training of the text translation model is reduced, and the accuracy of the stylized translation of the text translation model is improved.
Fig. 2 is a flowchart illustrating a step S102 according to the embodiment shown in fig. 1. As shown in fig. 2, the step S102 may include the following sub-steps:
and S1021, determining a target style text set corresponding to the target language style.
The target style text set may be a pre-generated text set, the target style text set may include a plurality of style texts, and a first vector corresponding to each style text, different language styles may correspond to different style text sets, and language styles corresponding to style texts in the same style text set may be the same.
For example, where the target language style is American English, the target style text set may be an American English style text set.
And S1022, inputting the source text into a pre-generated multi-language coding model to obtain a second vector output by the multi-language coding model.
It should be noted that the multi-language coding model may be developed based on XLM-Roberta, but the embodiment is not limited to the model network structure of XLM-Roberta, and may be other neural network structures. The XLM-Roberta is a typical multilingual pre-training model, which is a converter-based language model, and can process 100 texts in different languages by using a mask language model as a target.
In some embodiments, the second vector may be a 512-dimensional or 768-dimensional vector.
In some embodiments, the first vector may also be a vector obtained by encoding the style text through the same multi-language coding model.
And S1023, determining the text of the undetermined style from the target style text set according to the second vector and the first vector.
In some embodiments, a third vector having the smallest vector distance (i.e., the highest similarity) to the second vector may be determined from the first vector of the target style text set; and taking the style text corresponding to the third vector as the undetermined style text.
In other embodiments, a third vector having a minimum vector distance from the second vector may be determined from the first vector of the target style text set; and taking the style text corresponding to the third vector as the text of the undetermined style under the condition that the vector distance between the third vector and the second vector is less than or equal to a preset distance threshold. The preset distance threshold may be a preset threshold.
In this way, the pending style text can be determined from the plurality of style texts corresponding to the target language style according to the source text.
Therefore, cross-language retrieval can be performed through the multi-language coding model to obtain the undetermined style text corresponding to the source text, and the retrieved undetermined style text is spliced with the source text, so that the language style of the target translation text output by the text translation model can be interfered.
FIG. 3 is a diagram illustrating a translation method according to an exemplary embodiment. The data flow illustration of the translation method is given in fig. 3 by way of example for three source texts.
First, a source text to be translated is determined.
Taking fig. 3 as an example, the three source texts may include: the source text Case1 is "i don't know, nor does he tell me. "source text Case2 is" a woman more beautiful than i love? ", the source text Case3 is" i tell you now so you do not have to ask. ".
And secondly, inputting the three source texts into a pre-generated multi-language coding model to obtain a second vector output by the multi-language coding model aiming at each source text.
Exemplarily, the second vector corresponding to the source text Case1 is [0.01,0.02, -0.03, …,0.05,0.37]; the second vector corresponding to the source text Case2 is [0.09,0.04, -0.01, …,0.17,0.07]; the second vector corresponding to the source text Case3 is [ -0.01,0.07,0.05, …,0.23,0.02].
And thirdly, determining the undetermined style text corresponding to the source text from the target style text set according to the second vector for each source text.
And the vector distance between the first vector and the second vector corresponding to the text with the undetermined style is minimum (namely, the similarity is highest).
Exemplarily, the vector distance of the source text Case1 to the top1 neighbor vector is 20; the pending style text 1 corresponding to the source text Case1 is ' I tell they, kate, ' twas burn and draied away. '; the vector distance between the source text Case2 and the top1 adjacent vector is 40; the text 2 with undetermined style corresponding to the source text Case2 is "And I the king call love the."; the vector distance between the source text Case3 and the top1 adjacent vector is 30; the pending style text 3 corresponding to the source text Case3 is "Now let me se if I can register it.".
And then, splicing the text with the undetermined style with the source text to obtain a target spliced text.
Exemplarily, the target concatenation text 1 corresponding to the source text Case1 is: "I tell the, kate,' twas burn and driven way. < token > I do not know, nor does he tell I. "; the target splicing text 2 corresponding to the source text Case2 is as follows: "an I the king shell love the. < token > a woman more beautiful than I loved? "; the target concatenation text 3 corresponding to the source text Case3 is: "Now let me see if I can register it < token > Now tell you so you don't ask. "
And finally, inputting the target spliced text into a text translation model to obtain a target translation text output by the text translation model.
Therefore, the language style of the target translation text output by the text translation model can be interfered by splicing the text with the undetermined style and the source text, and accurate stylized translation is realized.
In some embodiments of the present disclosure, the target style text set may be a pre-generated text set. FIG. 4 is a flow diagram illustrating a method of generating a target style text set in accordance with an exemplary embodiment. As shown in fig. 4, the target style text set may be pre-generated by:
s301, a plurality of style texts corresponding to the target language style are obtained.
In this step, a plurality of styles of texts in the target language style may be manually collected, or a plurality of styles of texts corresponding to the target language style may be obtained by searching on the network.
S302, aiming at each style text, inputting the style text into a multi-language coding model to obtain a first vector output by the multi-language coding model.
Similarly, the multi-language coding model may be a model developed based on XLM-Roberta, and the first vector may be a 512-dimensional or 768-dimensional vector.
In some embodiments, the dimension of the first vector and the dimension of the second vector may be the same, e.g., 768 dimensions each.
And S303, generating a target style text set according to the style text and the first vector.
In some embodiments, a target set of style text may be generated based on a pre-set search algorithm from the style text and the first vector. The preset search algorithm may implement search of a text vector, for example, the preset search algorithm may be an ANN (Approximate Nearest Neighbor) algorithm, and may also be a text vector search engine in the related art, which is not limited in this disclosure.
For example, a search pair (pair) may be generated according to each style text and the first vector corresponding to the style text, for example, the search pair may be (style text, first vector), or the search pair may also be (first vector, style text). The search may be trained on an input text vector search engine through an ANN (Approximate Nearest Neighbor) algorithm to generate a target style text set. The target style text set may be a search base, and the style text may be used as the data (Value) and the first vector may be used as the search Key (Key) of the search base.
Thus, the target style text set can be generated in advance in this way.
In some embodiments of the present disclosure, the target style text set described above may be used for training of a text translation model, which is illustratively pre-generated by:
first, a translation training sample is obtained.
The translation training sample comprises a plurality of source sample texts and a target sample text corresponding to each source sample text.
Secondly, according to the source sample text, determining a style sample text corresponding to the source sample text from the target style text set.
In some embodiments, the source sample text may be input into the multi-language coding model to obtain a third vector output by the multi-language coding model; and determining style sample text from the target style text set according to the third vector and the first vector in the target style text set.
And finally, training a preset translation model according to the style sample text, the source sample text and the target sample text to obtain a text translation model.
For example, the style sample text and the source sample text may be spliced to obtain a spliced source sample text, the spliced source sample text and the target sample text are used as new translation training samples, and a preset translation model is trained to obtain a target translation model.
Therefore, the text translation model can be trained according to the target style text set, and the accuracy of the text translation model is further improved.
The translation method provided in some embodiments of the present disclosure may be divided into an offline stage and an online stage, for example, the target style text set and the text translation model may be generated offline first; and then, performing online translation according to the target style text set and the text translation model, so that the delay of an online translation stage can be reduced, and the translation efficiency is improved.
Further, by adopting the mode in the embodiment of the disclosure, when a new language style is generated, the style text set corresponding to the language style can be generated off-line, so that the translation style of the text translation model can be interfered, and the text translation model can be trained without collecting a large number of samples again, thereby realizing the zero-sample learning ability.
Fig. 4 is a block diagram illustrating a translation apparatus 400 according to an example embodiment, and as shown in fig. 4, the apparatus 400 may include:
a first determining module 401, configured to determine a source text and a target language style to be translated;
a second determining module 402, configured to determine, according to the source text, a text of an undetermined style from among multiple styles of texts corresponding to the target language style;
the translation module 403 is configured to input the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, where a language style of the target translation text is the target language style.
According to one or more embodiments of the present disclosure, the second determining module 402 is configured to determine a target style text set corresponding to the target language style; the target style text set is a pre-generated text set, and the target style text set comprises a plurality of style texts and a first vector corresponding to each style text; different language styles correspond to different style text sets, and the language styles corresponding to the style texts in the same style text set are the same; inputting the source text into a pre-generated multi-language coding model to obtain a second vector output by the multi-language coding model; and determining the text with undetermined style from the target style text set according to the second vector and the first vector.
According to one or more embodiments of the present disclosure, the second determining module 402 is configured to determine, from the first vector of the target style text set, a third vector having a minimum vector distance from the second vector; and taking the style text corresponding to the third vector as the undetermined style text.
Fig. 5 is a block diagram illustrating another translation apparatus according to an example embodiment, and as shown in fig. 5, the apparatus 400 may include:
a generating module 404, configured to obtain a plurality of style texts corresponding to the target language style; inputting the style text into the multi-language coding model aiming at each style text to obtain a first vector output by the multi-language coding model; and generating the target style text set according to the style text and the first vector.
According to one or more embodiments of the present disclosure, the generating module 404 is configured to generate the target style text set based on a preset retrieval algorithm according to the style text and the first vector.
According to one or more embodiments of the present disclosure, the generating module 404 is further configured to obtain a translation training sample; the translation training sample comprises a plurality of source sample texts and a target sample text corresponding to each source sample text; determining style sample texts corresponding to the source sample texts from the target style text set according to the source sample texts; and training a preset translation model according to the style sample text, the source sample text and the target sample text to obtain the text translation model.
According to one or more embodiments of the present disclosure, the translation module 403 is configured to splice the source text and the text with the undetermined style to obtain a target spliced text; and inputting the target spliced text into the text translation model to obtain the target translation text.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Referring now to fig. 6, shown is a schematic diagram of an electronic device 2000 (e.g., a terminal device or a server) suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The server in the embodiments of the present disclosure may include, but is not limited to, devices such as a local server, a cloud server, a single server, a distributed server, and the like. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, the electronic device 2000 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 2001, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 2002 or a program loaded from a storage means 2008 into a Random Access Memory (RAM) 2003. In the RAM2003, various programs and data necessary for the operation of the electronic apparatus 2000 are also stored. The processing device 2001, the ROM2002, and the RAM2003 are connected to each other by a bus 2004. An input/output (I/O) interface 2005 is also connected to bus 2004.
Generally, the following devices may be connected to the input/output interface 2005: input devices 2006 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 2007 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 2008 including, for example, magnetic tapes, hard disks, and the like; and a communication device 2009. The communication means 2009 may allow the electronic device 2000 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 2000 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication device 2009, or installed from the storage device 2008, or installed from the ROM 2002. The computer program, when executed by the processing device 2001, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: determining a source text to be translated and a target language style; determining a text with an undetermined style from a plurality of style texts corresponding to the target language style according to the source text; inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is the target language style.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a module does not in some cases constitute a definition of the module itself, for example, the first determining module may also be described as a "module that determines the source text and target language style to be translated".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems on a chip (SOCs), complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a translation method including:
determining a source text to be translated and a target language style;
determining a text with an undetermined style from a plurality of style texts corresponding to the target language style according to the source text;
inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is the target language style.
According to one or more embodiments of the present disclosure, the determining, according to the source text, a pending style text from a plurality of style texts corresponding to the target language style includes:
determining a target style text set corresponding to the target language style; the target style text set is a pre-generated text set, and the target style text set comprises a plurality of style texts and a first vector corresponding to each style text; different language styles correspond to different style text sets, and the language styles corresponding to the style texts in the same style text set are the same;
inputting the source text into a pre-generated multi-language coding model to obtain a second vector output by the multi-language coding model;
and determining the text with undetermined style from the target style text set according to the second vector and the first vector.
According to one or more embodiments of the present disclosure, the determining a pending style text from the target style text set according to the second vector and the first vector comprises:
determining a third vector having a minimum vector distance from the second vector from the first vector of the target style text set;
and taking the style text corresponding to the third vector as the undetermined style text.
According to one or more embodiments of the present disclosure, the target style text set is pre-generated by:
acquiring a plurality of style texts corresponding to the target language style;
inputting the style text into the multi-language coding model aiming at each style text to obtain a first vector output by the multi-language coding model;
and generating the target style text set according to the style text and the first vector.
According to one or more embodiments of the present disclosure, the generating the target style text set from the style text and the first vector comprises:
and generating the target style text set based on a preset retrieval algorithm according to the style text and the first vector.
According to one or more embodiments of the present disclosure, the text translation model is pre-generated by:
acquiring a translation training sample; the translation training sample comprises a plurality of source sample texts and a target sample text corresponding to each source sample text;
determining style sample texts corresponding to the source sample texts from the target style text set according to the source sample texts;
and training a preset translation model according to the style sample text, the source sample text and the target sample text to obtain the text translation model.
According to one or more embodiments of the present disclosure, the inputting the source text and the text of the pending style into a pre-generated text translation model, and obtaining a target translation text output by the text translation model includes:
splicing the source text and the text with the undetermined style to obtain a target spliced text;
and inputting the target spliced text into the text translation model to obtain the target translation text.
According to one or more embodiments of the present disclosure, there is provided a translation apparatus including:
the first determining module is used for determining a source text to be translated and a target language style;
the second determining module is used for determining texts with undetermined styles from a plurality of style texts corresponding to the target language style according to the source texts;
and the translation module is used for inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is the target language style.
According to one or more embodiments of the present disclosure, the second determining module is configured to determine a target style text set corresponding to the target language style; the target style text set is a pre-generated text set, and the target style text set comprises a plurality of style texts and a first vector corresponding to each style text; different language styles correspond to different style text sets, and the language styles corresponding to the style texts in the same style text set are the same; inputting the source text into a pre-generated multi-language coding model to obtain a second vector output by the multi-language coding model; and determining the text with undetermined style from the target style text set according to the second vector and the first vector.
According to one or more embodiments of the present disclosure, the second determining module is configured to determine, from the first vector of the target style text set, a third vector having a minimum vector distance from the second vector; and taking the style text corresponding to the third vector as the undetermined style text.
According to one or more embodiments of the present disclosure, the apparatus further comprises:
the generating module is used for acquiring a plurality of style texts corresponding to the target language style; inputting the style text into the multi-language coding model aiming at each style text to obtain a first vector output by the multi-language coding model; and generating the target style text set according to the style text and the first vector.
According to one or more embodiments of the present disclosure, the generating module is configured to generate the target style text set based on a preset retrieval algorithm according to the style text and the first vector.
According to one or more embodiments of the present disclosure, the generation module is further configured to obtain a translation training sample; the translation training sample comprises a plurality of source sample texts and a target sample text corresponding to each source sample text; determining style sample texts corresponding to the source sample texts from the target style text set according to the source sample texts; and training a preset translation model according to the style sample text, the source sample text and the target sample text to obtain the text translation model.
According to one or more embodiments of the present disclosure, the translation module is configured to splice the source text and the text with the undetermined style to obtain a target spliced text; and inputting the target spliced text into the text translation model to obtain the target translation text.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other combinations of features described above or equivalents thereof without departing from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims (10)

1. A method of translation, the method comprising:
determining a source text to be translated and a target language style;
determining a text with an undetermined style from a plurality of style texts corresponding to the target language style according to the source text;
inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is the target language style.
2. The method of claim 1, wherein determining, from the source text, a pending style text from a plurality of style texts corresponding to the target language style comprises:
determining a target style text set corresponding to the target language style; the target style text set is a pre-generated text set, and the target style text set comprises a plurality of style texts and a first vector corresponding to each style text; different language styles correspond to different style text sets, and the language styles corresponding to the style texts in the same style text set are the same;
inputting the source text into a pre-generated multi-language coding model to obtain a second vector output by the multi-language coding model;
and determining the text with undetermined style from the target style text set according to the second vector and the first vector.
3. The method of claim 2, wherein said determining a pending style text from the target style text set based on the second vector and the first vector comprises:
determining a third vector having a minimum vector distance from the second vector from the first vector of the target style text set;
and taking the style text corresponding to the third vector as the undetermined style text.
4. The method of claim 2, wherein the target style text set is pre-generated by:
acquiring a plurality of style texts corresponding to the target language style;
inputting the style text into the multi-language coding model aiming at each style text to obtain a first vector output by the multi-language coding model;
and generating the target style text set according to the style text and the first vector.
5. The method of claim 4, wherein generating the target style text set from the style text and the first vector comprises:
and generating the target style text set based on a preset retrieval algorithm according to the style texts and the first vector.
6. The method of claim 2, wherein the text translation model is pre-generated by:
acquiring a translation training sample; the translation training sample comprises a plurality of source sample texts and a target sample text corresponding to each source sample text;
determining style sample texts corresponding to the source sample texts from the target style text set according to the source sample texts;
and training a preset translation model according to the style sample text, the source sample text and the target sample text to obtain the text translation model.
7. The method according to any one of claims 1 to 6, wherein the inputting the source text and the text of the pending style into a pre-generated text translation model, and obtaining a target translation text output by the text translation model comprises:
splicing the source text and the text with the undetermined style to obtain a target spliced text;
and inputting the target spliced text into the text translation model to obtain the target translation text.
8. A translation apparatus, the apparatus comprising:
the first determining module is used for determining a source text to be translated and a target language style;
the second determining module is used for determining the text of the undetermined style from the texts of the plurality of styles corresponding to the target language style according to the source text;
and the translation module is used for inputting the source text and the text with the undetermined style into a pre-generated text translation model to obtain a target translation text output by the text translation model, wherein the language style of the target translation text is the target language style.
9. A computer-readable medium, on which a computer program is stored, which, when being executed by a processing means, carries out the steps of the method according to any one of claims 1 to 7.
10. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method according to any one of claims 1 to 7.
CN202211430812.0A 2022-11-15 2022-11-15 Translation method, translation device, readable medium and electronic equipment Pending CN115688808A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211430812.0A CN115688808A (en) 2022-11-15 2022-11-15 Translation method, translation device, readable medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211430812.0A CN115688808A (en) 2022-11-15 2022-11-15 Translation method, translation device, readable medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115688808A true CN115688808A (en) 2023-02-03

Family

ID=85051025

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211430812.0A Pending CN115688808A (en) 2022-11-15 2022-11-15 Translation method, translation device, readable medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115688808A (en)

Similar Documents

Publication Publication Date Title
CN109086303A (en) The Intelligent dialogue method, apparatus understood, terminal are read based on machine
JP7046134B2 (en) Methods and devices for outputting information
CN109858045B (en) Machine translation method and device
CN111046677B (en) Method, device, equipment and storage medium for obtaining translation model
CN114861889B (en) Deep learning model training method, target object detection method and device
CN112509562B (en) Method, apparatus, electronic device and medium for text post-processing
JP7050857B2 (en) Summary generation method and equipment
CN115640815A (en) Translation method, translation device, readable medium and electronic equipment
CN112380876B (en) Translation method, device, equipment and medium based on multilingual machine translation model
US20210004406A1 (en) Method and apparatus for storing media files and for retrieving media files
CN113407767A (en) Method and device for determining text relevance, readable medium and electronic equipment
CN114501064A (en) Video generation method, device, equipment, medium and product
CN111104796B (en) Method and device for translation
CN115908640A (en) Method and device for generating image, readable medium and electronic equipment
CN114765025A (en) Method for generating and recognizing speech recognition model, device, medium and equipment
CN112309384A (en) Voice recognition method, device, electronic equipment and medium
CN113591490A (en) Information processing method and device and electronic equipment
CN111026849B (en) Data processing method and device
CN114881008B (en) Text generation method and device, electronic equipment and medium
CN115688808A (en) Translation method, translation device, readable medium and electronic equipment
CN114429629A (en) Image processing method and device, readable storage medium and electronic equipment
CN112632241A (en) Method, device, equipment and computer readable medium for intelligent conversation
CN111859902A (en) Text processing method, device, equipment and medium
US20240233350A1 (en) Processing method, electronic device, and non-transitory computer-readable storage medium for multimodal data
CN113343668B (en) Method and device for solving selected questions, electronic equipment and readable storage medium

Legal Events

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