[go: up one dir, main page]

CN111126078B - Translation method and device - Google Patents

Translation method and device Download PDF

Info

Publication number
CN111126078B
CN111126078B CN201911316920.3A CN201911316920A CN111126078B CN 111126078 B CN111126078 B CN 111126078B CN 201911316920 A CN201911316920 A CN 201911316920A CN 111126078 B CN111126078 B CN 111126078B
Authority
CN
China
Prior art keywords
text
translation
word segmentation
decoder
input
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.)
Active
Application number
CN201911316920.3A
Other languages
Chinese (zh)
Other versions
CN111126078A (en
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201911316920.3A priority Critical patent/CN111126078B/en
Publication of CN111126078A publication Critical patent/CN111126078A/en
Application granted granted Critical
Publication of CN111126078B publication Critical patent/CN111126078B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Machine Translation (AREA)

Abstract

本公开实施例公开了翻译的方法和装置。方法采用翻译模型,翻译模型包括编码器、分类器和解码器,方法包括:将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示;将中间表示输入分类器,得到分类器输出的分类标签;响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到解码器输出的第二文本。该方法使得翻译质量得到保证的情况下降低系统耗时,并且,在现有的翻译模型的基础上容易进行改进,使用简单且引入有监督的学习来实现了翻译单元的控制。

Figure 201911316920

The embodiment of the present disclosure discloses a translation method and device. The method adopts a translation model, and the translation model includes an encoder, a classifier and a decoder. The method includes: inputting the vector matrix determined based on the word segmentation sequence of the first text into the encoder to obtain an intermediate representation output by the encoder; inputting the intermediate representation into the classifier , to obtain the classification label output by the classifier; in response to the classification label indicating that the word segmentation at the end of the word segmentation sequence of the first text is an independent translation unit, the intermediate representation is input into the decoder, and the second text output by the decoder is obtained. This method reduces the time consumption of the system while the translation quality is guaranteed, and is easy to improve on the basis of the existing translation model, and realizes the control of the translation unit by using simple and introducing supervised learning.

Figure 201911316920

Description

翻译的方法和装置Method and device for translation

技术领域technical field

本公开涉及计算机技术领域,具体涉及翻译技术领域,尤其涉及翻译的方法和装置。The present disclosure relates to the field of computer technology, in particular to the field of translation technology, and in particular to a translation method and device.

背景技术Background technique

同传翻译在过去的两年里发展迅速,各大互联网公司也相继推出了各自的同传产品。Simultaneous interpretation has developed rapidly in the past two years, and major Internet companies have launched their own simultaneous interpretation products one after another.

现在的同传系统大都基于管道(pipeline)的方式进行的,先通过语音识别(ASR)生成文本,然后调用断句模块对文本进行断句,再调用翻译模型来翻译断句后的文本,最后展示翻译结果。具体地,同传系统增加断句的频率,减小断句的粒度。或者,同传系统采用wait-k words模型,当识别结果大于K个词时开始翻译,每多识别出来一个词,便多翻译出来一个词。当断句模型判断可以断句时,将尾部部分一次性翻译出来。Most of the current simultaneous interpretation systems are based on the pipeline (pipeline). First, the text is generated through speech recognition (ASR), and then the sentence segmentation module is called to segment the text, and then the translation model is called to translate the text after the sentence segmentation, and finally the translation result is displayed. . Specifically, the simultaneous interpretation system increases the frequency of sentence segmentation and reduces the granularity of sentence segmentation. Alternatively, the simultaneous interpretation system adopts the wait-k words model. When the recognition result exceeds K words, the translation starts. Every time an additional word is recognized, an additional word is translated. When the sentence segmentation model judges that the sentence can be segmented, the tail part is translated at one time.

然而,若同传系统通过频繁添加标点来增大调用翻译的频率,则增加了错误断句的几率,影响翻译质量,而且如果子句之间存在语义依赖,则会进一步增加翻译错误;另外子句翻译的时延仍然较大。若同传系统采用wait-k words模型,对降低同传系统的延时问题提供了极大帮助,但是仍然需要依赖额外的断句模块,否则会出现翻译结果比识别结果延时越来越大的情况,如中英翻译,相同表义下,英文平均句长约是中文的1.25倍(Huangand Zhao,When to finish?Optimal beam search for neural text generation),如果没有断句时刻的“追赶”,英文将永远落后于中文。另外,wait-k模型要求在每个时刻必须解码出来一个词,在识别结果信息不充分的情况下,这个解码出来的词很可能错误,对翻译效果造成影响。However, if the simultaneous interpretation system increases the frequency of calling translation by frequently adding punctuation, it will increase the probability of wrong sentence segmentation, which will affect the quality of translation, and if there is semantic dependence between clauses, it will further increase translation errors; The translation delay is still relatively large. If the simultaneous interpretation system adopts the wait-k words model, it will greatly help reduce the delay of the simultaneous interpretation system, but it still needs to rely on an additional sentence segmentation module, otherwise the translation result will be delayed more than the recognition result. In the case of Chinese-English translation, under the same meaning, the average English sentence length is about 1.25 times that of Chinese (Huang and Zhao, When to finish? Optimal beam search for neural text generation), if there is no "catch-up" at the moment of sentence breaking, English will Always behind Chinese. In addition, the wait-k model requires that a word must be decoded at each moment. If the recognition result information is insufficient, the decoded word may be wrong, which will affect the translation effect.

发明内容Contents of the invention

本公开实施例提供了翻译的方法和装置。Embodiments of the present disclosure provide translation methods and devices.

第一方面,本公开实施例提供了一种翻译的方法,包括:一种翻译的方法,采用翻译模型,翻译模型包括编码器、分类器和解码器,方法包括:将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示;将中间表示输入分类器,得到分类器输出的分类标签;响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到解码器输出的第二文本。In the first aspect, an embodiment of the present disclosure provides a translation method, including: a translation method, using a translation model, the translation model includes an encoder, a classifier, and a decoder, and the method includes: converting word segmentation based on the first text The vector matrix determined by the sequence is input to the encoder to obtain the intermediate representation output by the encoder; the intermediate representation is input to the classifier to obtain the classification label output by the classifier; in response to the classification label, it indicates that the word segmentation at the end of the word segmentation sequence of the first text is independent The translation unit of , inputs the intermediate representation into the decoder, and obtains the second text output by the decoder.

在一些实施例中,响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到解码器输出的第二文本包括:响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,且历史翻译结果中存在对应第一文本的分词序列中位于尾部之前的分词的翻译结果,将中间表示输入解码器,以及将历史翻译结果中对应第一文本的分词序列中位于尾部之前的分词的翻译结果作为约束,将约束输入解码器,得到解码器输出的第二文本。In some embodiments, in response to the classification label indicating that the word segmentation at the end of the word segmentation sequence of the first text is an independent translation unit, the intermediate representation is input into the decoder, and the second text output by the decoder includes: in response to the classification label indication The word segmentation at the end of the word segmentation sequence of the first text is an independent translation unit, and there are translation results corresponding to the word segmentation before the end of the word segmentation sequence of the first text in the historical translation results, the intermediate representation is input into the decoder, and the history In the translation result, the translation result corresponding to the word segment before the tail in the word segment sequence of the first text is used as a constraint, and the constraint is input into the decoder to obtain the second text output by the decoder.

在一些实施例中,翻译模型的训练数据样本基于以下步骤确定:采用词对齐工具对齐翻译模型的训练数据,得到训练数据的对齐信息;将训练数据的对齐信息,作为翻译模型的训练数据样本。In some embodiments, the training data samples of the translation model are determined based on the following steps: using a word alignment tool to align the training data of the translation model to obtain alignment information of the training data; using the alignment information of the training data as the training data samples of the translation model.

在一些实施例中,第一文本的分词序列经由以下步骤得到:识别输入的第一语音,得到第一文本;对第一文本进行分词,得到第一文本的分词序列。In some embodiments, the word segmentation sequence of the first text is obtained through the following steps: recognizing the input first voice to obtain the first text; performing word segmentation on the first text to obtain the word segmentation sequence of the first text.

在一些实施例中,方法还包括:基于翻译后的第二文本,生成第二语音;播放第二语音。In some embodiments, the method further includes: generating a second voice based on the translated second text; and playing the second voice.

第二方面,本公开实施例提供了一种翻译的装置,采用翻译模型,翻译模型包括编码器、分类器和解码器,装置包括:编码器输入单元,被配置成将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示;分类器输入单元,被配置成将中间表示输入分类器,得到分类器输出的分类标签;解码器输入单元,被配置成响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到解码器输出的第二文本。In a second aspect, an embodiment of the present disclosure provides a device for translation, using a translation model, the translation model includes an encoder, a classifier, and a decoder, and the device includes: an encoder input unit configured to convert word segmentation based on the first text The sequence-determined vector matrix is input to the encoder to obtain an intermediate representation output by the encoder; the classifier input unit is configured to input the intermediate representation to the classifier to obtain the classification label output by the classifier; the decoder input unit is configured to respond to The classification label indicates that the word segmentation at the end of the word segmentation sequence of the first text is an independent translation unit, and the intermediate representation is input into the decoder to obtain the second text output by the decoder.

在一些实施例中,解码器输入单元进一步被配置成:响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,且历史翻译结果中存在对应第一文本的分词序列中位于尾部之前的分词的翻译结果,将中间表示输入解码器,以及将历史翻译结果中对应第一文本的分词序列中位于尾部之前的分词的翻译结果作为约束,将约束输入解码器,得到解码器输出的第二文本。In some embodiments, the decoder input unit is further configured to: respond to the classification label indicating that the word segment located at the end of the word segment sequence of the first text is an independent translation unit, and there is a word segment sequence corresponding to the first text in the historical translation results The translation result of the participle before the end in the middle representation is input into the decoder, and the translation result of the participle before the end in the participle sequence corresponding to the first text in the historical translation result is used as a constraint, and the constraint is input into the decoder to obtain the decoding The second text output by the compiler.

在一些实施例中,装置中所使用的翻译模型的训练数据样本基于以下单元确定:训练数据对齐单元,被配置成采用词对齐工具对齐翻译模型的训练数据,得到训练数据的对齐信息;训练数据确定单元,被配置成将训练数据的对齐信息,作为翻译模型的训练数据样本。In some embodiments, the training data samples of the translation model used in the device are determined based on the following units: a training data alignment unit configured to use a word alignment tool to align the training data of the translation model to obtain alignment information of the training data; The determining unit is configured to use the alignment information of the training data as a training data sample of the translation model.

在一些实施例中,装置还包括:第一语音识别单元,被配置成识别输入的第一语音,得到第一文本;第一文本分词单元,被配置成对第一文本进行分词,得到第一文本的分词序列。In some embodiments, the device further includes: a first speech recognition unit configured to recognize the input first speech to obtain the first text; a first text word segmentation unit configured to perform word segmentation on the first text to obtain the first text The token sequence of the text.

在一些实施例中,装置还包括:第二语音生成单元,被配置成基于翻译后的第二文本,生成第二语音;第二语音播放单元,被配置成播放第二语音。In some embodiments, the device further includes: a second speech generation unit configured to generate a second speech based on the translated second text; a second speech playback unit configured to play the second speech.

第三方面,本公开实施例提供了一种电子设备/终端/服务器,包括:一个或多个处理器;存储装置,用于存储一个或多个程序;当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现如上任一所述的翻译的方法。In a third aspect, an embodiment of the present disclosure provides an electronic device/terminal/server, including: one or more processors; a storage device for storing one or more programs; when one or more programs are used by one or more executed by one or more processors, so that one or more processors implement the method of translation as described above.

第四方面,本公开实施例提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现如上任一所述的翻译的方法。In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned translation method is implemented.

本公开实施例提供的翻译的方法和装置,翻译的方法采用翻译模型,翻译模型包括编码器、分类器和解码器,方法包括:首先,将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示;之后,将中间表示输入分类器,得到分类标签,分类标签指示第一文本的分词序列中位于尾部的分词是否为独立的翻译单元;之后,响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,并将解码器输出的文本作为翻译后的第二文本。在这一过程中,去掉了传统系统pipeline流程中的断句模块,由翻译模型来控制翻译单元,使得翻译质量得到保证的情况下降低系统耗时,并且,在现有的翻译模型的基础上容易进行改进,使用简单且引入有监督的学习来实现了翻译单元的控制,并且,在部分实施例中,翻译过程中每一次尾部分词的翻译均考虑了第一文本的分词序列中在先的分词的历史翻译结果,可以有效地解决实体指代的消歧和领域的翻译问题。The translation method and device provided by the embodiments of the present disclosure, the translation method adopts a translation model, and the translation model includes an encoder, a classifier, and a decoder. The method includes: first, inputting the vector matrix determined based on the word segmentation sequence of the first text into the encoding device to obtain the intermediate representation output by the encoder; after that, input the intermediate representation into the classifier to obtain the classification label, which indicates whether the word at the end of the word segmentation sequence of the first text is an independent translation unit; after that, in response to the classification label Indicates that the word segment at the end of the word segment sequence of the first text is an independent translation unit, the intermediate representation is input into the decoder, and the text output by the decoder is used as the translated second text. In this process, the sentence segmentation module in the traditional system pipeline process is removed, and the translation unit is controlled by the translation model, so that the time consumption of the system is reduced while the translation quality is guaranteed, and, on the basis of the existing translation model, it is easy to Improvement, the control of the translation unit is realized by using simple and supervised learning, and, in some embodiments, each translation of the tail participle in the translation process takes into account the previous part of the participle sequence of the first text The historical translation results of word segmentation can effectively solve the problem of entity reference disambiguation and domain translation.

附图说明Description of drawings

通过阅读参照以下附图所作的对非限制性实施例详细描述,本公开的其它特征、目的和优点将会变得更明显:Other features, objects and advantages of the present disclosure will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

图1是本公开可以应用于其中的示例性系统架构图;FIG. 1 is an exemplary system architecture diagram in which the present disclosure can be applied;

图2a是根据本公开实施例的翻译的方法的一个实施例的流程示意图;Fig. 2a is a schematic flowchart of an embodiment of a translation method according to an embodiment of the present disclosure;

图2b示出了图2a中的翻译模型的示例性结构图;Figure 2b shows an exemplary structural diagram of the translation model in Figure 2a;

图3是根据本公开实施例的翻译的方法的一个示例性应用场景;FIG. 3 is an exemplary application scenario of a translation method according to an embodiment of the present disclosure;

图4是根据本公开实施例的翻译的方法的另一个实施例的流程示意图;Fig. 4 is a schematic flowchart of another embodiment of a translation method according to an embodiment of the present disclosure;

图5是本公开的翻译的装置的一个实施例的示例性结构图;Fig. 5 is an exemplary structural diagram of an embodiment of the translation device of the present disclosure;

图6是适于用来实现本公开实施例的服务器的计算机系统的结构示意图。FIG. 6 is a schematic structural diagram of a computer system suitable for implementing a server according to an embodiment of the present disclosure.

具体实施方式Detailed ways

下面结合附图和实施例对本公开作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。The present disclosure will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain related inventions, rather than to limit the invention. It should also be noted that, for the convenience of description, only the parts related to the related invention are shown in the drawings.

需要说明的是,在不冲突的情况下,本公开中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本公开。It should be noted that, in the case of no conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and embodiments.

图1示出了可以应用本公开的翻译的方法或翻译的装置的实施例的示例性系统架构100。FIG. 1 shows an exemplary system architecture 100 of an embodiment of the translating method or translating apparatus to which the present disclosure can be applied.

如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 1 , a system architecture 100 may include terminal devices 101 , 102 , 103 , a network 104 and a server 105 . The network 104 is used as a medium for providing communication links between the terminal devices 101 , 102 , 103 and the server 105 . Network 104 may include various connection types, such as wires, wireless communication links, or fiber optic cables, among others.

用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如翻译类应用、浏览器应用、购物类应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等。Users can use terminal devices 101 , 102 , 103 to interact with server 105 via network 104 to receive or send messages and the like. Various communication client applications can be installed on the terminal devices 101, 102, 103, such as translation applications, browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

终端设备101、102、103可以是硬件,也可以是软件。当终端设备101、102、103为硬件时,可以是支持浏览器应用的各种电子设备,包括但不限于平板电脑、膝上型便携计算机和台式计算机等等。当终端设备101、102、103为软件时,可以安装在上述所列举的电子设备中。其可以实现成例如用来提供分布式服务的多个软件或软件模块,也可以实现成单个软件或软件模块。在此不做具体限定。The terminal devices 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, and 103 are hardware, they may be various electronic devices supporting browser applications, including but not limited to tablet computers, laptop computers, and desktop computers. When the terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented, for example, as a plurality of software or software modules for providing distributed services, or as a single software or software module. No specific limitation is made here.

服务器105可以是提供各种服务的服务器,例如对终端设备101、102、103上进行的浏览器应用提供支持的后台服务器。后台服务器可以对接收到的请求等数据进行分析等处理,并将处理结果反馈给终端设备。The server 105 may be a server that provides various services, such as a background server that provides support for browser applications running on the terminal devices 101 , 102 , and 103 . The background server can analyze and process the data received, such as requests, and feed back the processing results to the terminal device.

需要说明的是,服务器可以是硬件,也可以是软件。当服务器为硬件时,可以实现成多个服务器组成的分布式服务器集群,也可以实现成单个服务器。当服务器为软件时,可以实现成例如用来提供分布式服务的多个软件或软件模块,也可以实现成单个软件或软件模块。在此不做具体限定。It should be noted that the server may be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server. When the server is software, it may be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. No specific limitation is made here.

在实践中,本公开实施例所提供的翻译的方法可以由终端设备101、102、103和/或服务器105、106执行,翻译的装置也可以设置于终端设备101、102、103和/或服务器105、106中。In practice, the translation method provided by the embodiments of the present disclosure can be executed by the terminal equipment 101, 102, 103 and/or the server 105, 106, and the translation device can also be set on the terminal equipment 101, 102, 103 and/or the server 105, 106 in.

应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in Fig. 1 are only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.

继续参考图2a,图2a示出了根据本公开的翻译的方法的一个实施例的流程200。该翻译的方法包括以下步骤:Continuing to refer to FIG. 2a, FIG. 2a shows a process 200 of an embodiment of the translation method according to the present disclosure. The translation method includes the following steps:

步骤201,将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示。Step 201, input the vector matrix determined based on the word segmentation sequence of the first text into the encoder to obtain the intermediate representation output by the encoder.

在本实施例中,翻译的方法的执行主体(例如图1所示的终端或服务器)可以采用带有分类器的翻译模型在翻译时控制翻译的单元。这里的翻译模型,可以为多任务的神经翻译模型,具体地,可以包括:编码器、分类器和解码器。In this embodiment, the executing subject of the translation method (for example, the terminal or the server shown in FIG. 1 ) may use a translation model with a classifier to control the translation unit during translation. The translation model here may be a multi-task neural translation model, specifically, may include: an encoder, a classifier, and a decoder.

其中,编码器接受第一文本的分词序列作为输入,并将分词序列中的信息编码为中间表示。分类器接受中间表示作为输入,并判定第一文本的分词序列中位于尾部的分词是否为独立的翻译单元,若是,将中间表示输入解码器。解码器解码中间表示为目标语言。Among them, the encoder accepts the word segmentation sequence of the first text as input, and encodes the information in the word segmentation sequence into an intermediate representation. The classifier accepts the intermediate representation as input, and determines whether the word segment at the end of the word segment sequence of the first text is an independent translation unit, and if so, inputs the intermediate representation into the decoder. The decoder decodes the intermediate representation into the target language.

具体地,上述执行主体可以在检测到输入的第一文本中包括K(K为大于1的整数)个数量的分词时,开始将基于第一文本的分词序列确定的向量矩阵输入编码器,以得到编码器输出的中间表示。Specifically, when the above execution subject detects that the input first text includes K (K is an integer greater than 1) number of word segments, it starts to input the vector matrix determined based on the word segment sequence of the first text into the encoder to Get an intermediate representation of the encoder output.

上述的翻译模型,可以参考图2b所示的结构,上述的翻译模型上部分就是一个常规的翻译模型(可以为现有技术或未来发展的技术中的翻译模型,本申请对此不作限定。例如,基于Vaswani and Shazeer的Transformer(Attention is all you need)或RNN等),上述的翻译模型的下部分在编码器之后接入了一个分类模型。可以通过有监督的学习来优化更新,分类器和解码器共同更新编码器端的参数。具体地,首先可以构造大规模的源语言-目标语言的翻译句对,然后利用端到端翻译模型在此句对上训练来优化模型参数。在测试时一般是给定源语言文本来直接生成目标语言文本。The above-mentioned translation model can refer to the structure shown in Figure 2b. The upper part of the above-mentioned translation model is a conventional translation model (it can be a translation model in the prior art or a technology developed in the future, and the present application is not limited to this. For example , based on Vaswani and Shazeer's Transformer (Attention is all you need) or RNN, etc.), the lower part of the above translation model is connected to a classification model after the encoder. The update can be optimized by supervised learning, where the classifier and decoder jointly update the parameters at the encoder. Specifically, a large-scale source language-target language translation sentence pair can be constructed first, and then an end-to-end translation model can be used to train on this sentence pair to optimize model parameters. When testing, the source language text is generally given to directly generate the target language text.

在本实施例的一些可选实现方式中,翻译模型的训练数据样本基于以下步骤确定:采用词对齐工具对齐翻译模型的训练数据,得到训练数据的对齐信息;将训练数据的对齐信息,作为翻译模型的训练数据样本。In some optional implementations of this embodiment, the training data samples of the translation model are determined based on the following steps: use a word alignment tool to align the training data of the translation model to obtain the alignment information of the training data; use the alignment information of the training data as the translation A sample of training data for the model.

在本实现方式中,通过采用现有技术或未来发展的技术中的词对齐工具(例如TER-based,GIZA++,METEOR),可以将翻译模型的训练数据进行对齐,得到训练数据的对齐信息。一个具体的示例如下:In this implementation, by using word alignment tools (such as TER-based, GIZA++, METEOR) in existing technologies or technologies developed in the future, the training data of the translation model can be aligned to obtain the alignment information of the training data. A concrete example is as follows:

源文本:我|想要|一个|极好|的钱夹。Source text: I |want|a |excellent| wallet.

目标文本:I|want|a|magnificent|wallet.Target text: I|want|a|magnificent|wallet.

根据以上的对齐信息,可以生成新的翻译模型的多条训练数据,如下表1中所示,训练目标有两个,分别是分类的标签(二分类,即是否可以作为一个独立的翻译单元)和翻译目标。其中需要注意的是,在输入中最后一个“|”为当时需要分类的位置,在此之后共有W个词(W为窗口大小,这里取3)。According to the above alignment information, multiple pieces of training data for the new translation model can be generated, as shown in Table 1 below, there are two training targets, which are classification labels (binary classification, that is, whether it can be used as an independent translation unit) and translation targets. It should be noted that the last "|" in the input is the position that needs to be classified at that time, and there are W words after that (W is the window size, 3 is taken here).

表1:Table 1:

输入enter 训练目标training target 我|想要一I | want one 分类标签:1翻译:IClassification Label: 1 Translation: I 我|想|要一个I | want | want one 分类标签:-1翻译:IClassification label: -1 Translation: I 我|想要|一个极I | want | a pole 分类标签:1翻译:I wantTags: 1Translation: I want 我|想要|一|个极好I|want|a|excellent 分类标签:-1翻译:I wantCategory label: -1 Translation: I want 我|想要|一个|极好的i | want | a | excellent 分类标签:1翻译:I want aCategory Tags: 1 Translation: I want a 我|想要|一个|极好|的钱夹I |want|a |excellent| wallet 分类标签:1翻译:I want a magnificentTags: 1Translation: I want a magnificent

步骤202,将中间表示输入分类器,得到分类器输出的分类标签。Step 202, input the intermediate representation into the classifier, and obtain the classification label output by the classifier.

在本实施例中,上述执行主体将中间表示输入分类器,得到分类器输出的分类标签,分类标签用于指示第一文本的分词序列中位于尾部的分词是否为独立的翻译单元。In this embodiment, the execution subject inputs the intermediate representation into the classifier, and obtains a classification label output by the classifier. The classification label is used to indicate whether the word segment at the end of the word segment sequence of the first text is an independent translation unit.

其中,分类器可以为现有技术或未来发展的技术中对输入进行二分类的机器学习网络模型,本申请对此不作限定。例如,采用支持向量机、决策树、Logistic回归模型、Logistic回归模型等实现的二分类网络。Wherein, the classifier may be a machine learning network model that performs binary classification on the input in the existing technology or a technology developed in the future, which is not limited in this application. For example, a binary classification network implemented using support vector machines, decision trees, Logistic regression models, and Logistic regression models.

步骤203,响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到所述解码器输出的的第二文本。Step 203: In response to the classification label indicating that the word segment at the end of the word segment sequence of the first text is an independent translation unit, the intermediate representation is input into the decoder to obtain the second text output by the decoder.

本实施例中,若分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,表明可以基于第一文本的分词序列得到准确的翻译,此时将中间表示输入解码器,可以提高解码器输出的第二文本的完整性和准确性。In this embodiment, if the classification label indicates that the word segment at the end of the word segment sequence of the first text is an independent translation unit, it indicates that an accurate translation can be obtained based on the word segment sequence of the first text. At this time, the intermediate representation can be input into the decoder. The integrity and accuracy of the second text output by the decoder is improved.

在本实施例的一些可选实现方式中,响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器包括:响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,且历史翻译结果中存在对应第一文本的分词序列中位于尾部之前的分词的翻译结果,将中间表示输入解码器,以及将历史翻译结果中对应第一文本的分词序列中位于尾部之前的分词的翻译结果作为约束,将约束输入解码器,得到解码器输出的第二文本。In some optional implementations of this embodiment, in response to the classification label indicating that the word segmentation at the end of the word segmentation sequence of the first text is an independent translation unit, inputting the intermediate representation into the decoder includes: in response to the classification label indicating the first text The word segment at the end of the word segment sequence is an independent translation unit, and there is a translation result corresponding to the word segment before the tail in the word segment sequence of the first text in the historical translation result, the intermediate representation is input into the decoder, and the historical translation result is The translation result of the word segment before the tail in the word segment sequence corresponding to the first text is used as a constraint, and the constraint is input into the decoder to obtain the second text output by the decoder.

在本实现方式中,可以采用第一文本分词序列中的位于尾部之前的分词所对应的历史翻译结果,约束对于第一文本的分词序列的翻译结果,提高了翻译的准确性和时效性。In this implementation, the historical translation results corresponding to the word segments before the tail in the word segment sequence of the first text can be used to constrain the translation results of the word segment sequence of the first text, which improves the accuracy and timeliness of translation.

在一个具体的示例中,解码器输出的第二文本如下表二所示。In a specific example, the second text output by the decoder is shown in Table 2 below.

表二:Table II:

Figure BDA0002326079250000081
Figure BDA0002326079250000081

本公开上述实施例的翻译的方法,可以采用分类器确定第一文本的分词序列中位于尾部的分词是否为独立的翻译单元,当确定为独立的翻译单元时进行第一文本的翻译,从而提高了翻译得到的第二文本的完整性和准确性。与现有技术相比,由于去掉了传统系统pipeline流程中的断句模块,降低了系统耗时。在部分实施例中,由于确定尾部的分词为独立的翻译单元时,对第一文本的分词序列的翻译考虑了尾部之前的分词的历史翻译结果,从而可以有效地解决实体指代的消歧和领域的翻译问题。In the translation method of the above-mentioned embodiments of the present disclosure, a classifier may be used to determine whether the word segment located at the end of the word segment sequence of the first text is an independent translation unit, and when it is determined to be an independent translation unit, the translation of the first text is performed, thereby improving ensure the completeness and accuracy of the translated second text. Compared with the prior art, the time consumption of the system is reduced due to the removal of the sentence segmentation module in the traditional system pipeline process. In some embodiments, when the word segmentation at the tail is determined to be an independent translation unit, the translation of the word segmentation sequence of the first text takes into account the historical translation results of the word segmentation before the tail, so that the disambiguation and disambiguation of entity reference can be effectively solved. Domain translation problems.

以下结合图3,描述本公开的翻译的方法的示例性应用场景。An exemplary application scenario of the translation method of the present disclosure is described below with reference to FIG. 3 .

如图3所示,图3示出了根据本公开的翻译的方法的一个示例性应用场景。As shown in FIG. 3 , FIG. 3 shows an exemplary application scenario of the translation method according to the present disclosure.

如图3所示,翻译的方法300运行于电子设备320中,采用翻译模型进行翻译,翻译模型包括编码器、分类器和解码器,方法300包括:As shown in FIG. 3 , the translation method 300 is run in an electronic device 320, and a translation model is used for translation. The translation model includes an encoder, a classifier and a decoder. The method 300 includes:

将基于第一文本的分词序列301确定的向量矩阵302输入编码器303,得到编码器303输出的中间表示304;The vector matrix 302 determined based on the word segmentation sequence 301 of the first text is input into the encoder 303 to obtain the intermediate representation 304 output by the encoder 303;

将中间表示304输入分类器305,得到分类器305输出的分类标签306;Input the intermediate representation 304 into the classifier 305 to obtain the classification label 306 output by the classifier 305;

响应于分类标签306指示第一文本的分词序列301中位于尾部的分词307为独立的翻译单元308,将中间表示304输入解码器309,得到解码器309输出的第二文本310。In response to the classification label 306 indicating that the last word segment 307 in the word segment sequence 301 of the first text is an independent translation unit 308 , the intermediate representation 304 is input to the decoder 309 to obtain a second text 310 output by the decoder 309 .

应当理解,上述图3中所示出的翻译的方法的应用场景,仅为对于翻译的方法的示例性描述,并不代表对该方法的限定。例如,上述图3中示出的各个步骤,可以进一步采用更为细节的实现方法。也可以在上述图3的基础上,进一步增加其它翻译的步骤。It should be understood that the application scenario of the translation method shown in FIG. 3 is only an exemplary description of the translation method, and does not represent a limitation to the method. For example, each step shown in FIG. 3 above may further adopt a more detailed implementation method. It is also possible to further add other translation steps on the basis of the above-mentioned FIG. 3 .

进一步参考图4,图4示出了根据本公开的翻译的方法的另一个实施例的示意性流程图。Further referring to FIG. 4 , FIG. 4 shows a schematic flowchart of another embodiment of the translation method according to the present disclosure.

如图4所示,本实施例的翻译的方法400,可以包括以下步骤:As shown in FIG. 4, the translation method 400 of this embodiment may include the following steps:

步骤401,识别输入的第一语音,得到第一文本。Step 401, recognize the inputted first voice to obtain the first text.

在本实施例中,翻译的方法的执行主体(例如图1所示的终端或服务器)可以采用现有技术或未来发展的技术中的语音识别技术,实时识别输入的第一语音,并得到第一文本。In this embodiment, the execution subject of the translation method (for example, the terminal or server shown in FIG. 1 ) can use the speech recognition technology in the existing technology or the technology developed in the future to recognize the first speech input in real time, and obtain the second speech a text.

步骤402,对第一文本进行分词,得到第一文本的分词序列。Step 402, perform word segmentation on the first text to obtain a word segmentation sequence of the first text.

在本实施例中,上述执行主体可以按照预设的规则或采用现有技术中或未来发展的技术中的分词工具,对第一文本进行分词,从而得到第一文本的分词序列。In this embodiment, the execution subject may perform word segmentation on the first text according to a preset rule or by using a word segmentation tool in the existing technology or a technology developed in the future, so as to obtain a word segmentation sequence of the first text.

步骤403,将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示。Step 403: Input the vector matrix determined based on the word segmentation sequence of the first text into the encoder to obtain an intermediate representation output by the encoder.

在本实施例中,翻译的方法的执行主体(例如图1所示的终端或服务器)可以采用带有分类器的翻译模型在翻译时控制翻译的单元。这里的翻译模型,可以为多任务的神经翻译模型,具体地,可以包括:编码器、分类器和解码器。In this embodiment, the executing subject of the translation method (for example, the terminal or the server shown in FIG. 1 ) may use a translation model with a classifier to control the translation unit during translation. The translation model here may be a multi-task neural translation model, specifically, may include: an encoder, a classifier, and a decoder.

其中,编码器接受第一文本的分词序列作为输入,并将分词序列中的信息编码为中间表示。分类器接受中间表示作为输入,并判定第一文本的分词序列中位于尾部的分词是否为独立的翻译单元,若是,将中间表示输入解码器。解码器解码中间表示为目标语言。Among them, the encoder accepts the word segmentation sequence of the first text as input, and encodes the information in the word segmentation sequence into an intermediate representation. The classifier accepts the intermediate representation as input, and determines whether the word segment at the end of the word segment sequence of the first text is an independent translation unit, and if so, inputs the intermediate representation into the decoder. The decoder decodes the intermediate representation into the target language.

步骤404,将中间表示输入分类器,得到所述分类器输出的分类标签。Step 404, input the intermediate representation into the classifier, and obtain the classification label output by the classifier.

在本实施例中,上述执行主体将中间表示输入分类器,得到分类器输出的分类标签,分类标签用于指示第一文本的分词序列中位于尾部的分词是否为独立的翻译单元。In this embodiment, the execution subject inputs the intermediate representation into the classifier, and obtains a classification label output by the classifier. The classification label is used to indicate whether the word segment at the end of the word segment sequence of the first text is an independent translation unit.

其中,分类器可以为现有技术或未来发展的技术中对输入进行二分类的机器学习网络模型,本申请对此不作限定。例如,采用支持向量机、决策树、Logistic回归模型、Logistic回归模型等实现的二分类网络。Wherein, the classifier may be a machine learning network model that performs binary classification on the input in the existing technology or a technology developed in the future, which is not limited in this application. For example, a binary classification network implemented using support vector machines, decision trees, Logistic regression models, and Logistic regression models.

步骤405,响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到解码器输出的第二文本。Step 405: In response to the classification label indicating that the word segment at the end of the word segment sequence of the first text is an independent translation unit, the intermediate representation is input into the decoder to obtain the second text output by the decoder.

本实施例中,若分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,表明可以基于第一文本的分词序列得到准确的翻译,此时上述执行主体可以将中间表示输入解码器,从而提高解码器输出的第二文本的完整性和准确性。In this embodiment, if the classification label indicates that the word segment at the end of the word segment sequence of the first text is an independent translation unit, it indicates that an accurate translation can be obtained based on the word segment sequence of the first text. At this time, the above-mentioned executive body can input the intermediate representation a decoder, thereby improving the integrity and accuracy of the second text output by the decoder.

步骤406,基于翻译后的第二文本,生成第二语音。Step 406: Generate a second voice based on the translated second text.

在本实施例中,上述执行主体可以根据翻译后的第二文本,可以采用文字转换语音工具或AI语音智能合成工具等,将翻译后的第二文本转换为语音。In this embodiment, the above-mentioned executor can convert the translated second text into speech by using a text-to-speech tool or an AI speech intelligent synthesis tool based on the translated second text.

步骤407,播放第二语音。Step 407, playing the second voice.

在本实施例中,上述执行主体可以播放步骤406中生成的第二语音,从而完成同声传译。In this embodiment, the execution subject may play the second speech generated in step 406, so as to complete the simultaneous interpretation.

本公开图4中的实施例中的翻译的方法,在图2中所示的翻译的方法的基础上,细化了基于输入的第一语音得到播放的第二语音的过程,并且播放第二语音,提高了同声传译的准确率和效率。The translation method in the embodiment in FIG. 4 of the present disclosure, on the basis of the translation method shown in FIG. 2, refines the process of obtaining the played second voice based on the input first voice, and plays the second voice Voice, which improves the accuracy and efficiency of simultaneous interpretation.

进一步参考图5,作为对上述各图所示方法的实现,本公开实施例提供了一种翻译的装置的一个实施例,该装置实施例与图2-图4中所示的方法实施例相对应,该装置具体可以应用于上述终端设备或服务器中。Further referring to FIG. 5 , as an implementation of the methods shown in the above figures, an embodiment of the present disclosure provides an embodiment of a translation device, which is similar to the method embodiments shown in FIGS. 2-4 Correspondingly, the apparatus can be specifically applied to the above-mentioned terminal device or server.

如图5所示,本实施例的翻译的装置500可以包括:采用翻译模型,翻译模型包括编码器、分类器和解码器,装置包括:编码器输入单元510,被配置成将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示;分类器输入单元520,被配置成将中间表示输入分类器,得到分类器输出的分类标签;解码器输入单元530,被配置成响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到解码器输出的第二文本。As shown in FIG. 5 , the translation device 500 of this embodiment may include: using a translation model, the translation model includes an encoder, a classifier, and a decoder, and the device includes: an encoder input unit 510 configured to convert the first text based on The vector matrix determined by the word segmentation sequence is input into the encoder to obtain the intermediate representation output by the encoder; the classifier input unit 520 is configured to input the intermediate representation into the classifier to obtain the classification label output by the classifier; the decoder input unit 530 is obtained by It is configured to input the intermediate representation into the decoder to obtain the second text output by the decoder in response to the classification label indicating that the word segment located at the end of the word segment sequence of the first text is an independent translation unit.

在一些实施例中,解码器输入单元进一步被配置成:响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,且历史翻译结果中存在对应第一文本的分词序列中位于尾部之前的分词的翻译结果,将中间表示输入解码器,以及将历史翻译结果中对应第一文本的分词序列中位于尾部之前的分词的翻译结果作为约束,将约束输入解码器,得到解码器输出的第二文本。In some embodiments, the decoder input unit is further configured to: respond to the classification label indicating that the word segment located at the end of the word segment sequence of the first text is an independent translation unit, and there is a word segment sequence corresponding to the first text in the historical translation results The translation result of the participle before the end in the middle representation is input into the decoder, and the translation result of the participle before the end in the participle sequence corresponding to the first text in the historical translation result is used as a constraint, and the constraint is input into the decoder to obtain the decoding The second text output by the compiler.

在一些实施例中,装置中所使用的翻译模型的训练数据样本基于以下单元(图中未示出)确定:训练数据对齐单元,被配置成采用词对齐工具对齐翻译模型的训练数据,得到训练数据的对齐信息;训练数据确定单元,被配置成将训练数据的对齐信息,作为翻译模型的训练数据样本。In some embodiments, the training data samples of the translation model used in the device are determined based on the following units (not shown in the figure): the training data alignment unit is configured to align the training data of the translation model with a word alignment tool to obtain the training Alignment information of the data; the training data determining unit is configured to use the alignment information of the training data as a training data sample of the translation model.

在一些实施例中,装置还包括(图中未示出):第一语音识别单元,被配置成识别输入的第一语音,得到第一文本;第一文本分词单元,被配置成对第一文本进行分词,得到第一文本的分词序列。In some embodiments, the device further includes (not shown in the figure): a first speech recognition unit configured to recognize the inputted first speech to obtain the first text; a first text word segmentation unit configured to Word segmentation is performed on the text to obtain a word segmentation sequence of the first text.

在一些实施例中,装置还包括(图中未示出):第二语音生成单元,被配置成基于翻译后的第二文本,生成第二语音;第二语音播放单元,被配置成播放第二语音。In some embodiments, the device further includes (not shown in the figure): a second speech generation unit configured to generate a second speech based on the translated second text; a second speech playback unit configured to play the second speech Second voice.

应当理解,装置500中记载的各个单元与参考图2-图4描述的方法中记载的各个步骤相对应。由此,上文针对方法描述的操作和特征同样适用于装置500及其中包含的各个单元,在此不再赘述。It should be understood that each unit recorded in the apparatus 500 corresponds to each step recorded in the method described with reference to FIGS. 2-4 . Therefore, the operations and features described above for the method are also applicable to the device 500 and each unit contained therein, and will not be repeated here.

下面参考图6,其示出了适于用来实现本公开的实施例的电子设备(例如图1中的服务器或终端设备)600的结构示意图。本公开的实施例中的终端设备可以包括但不限于诸如笔记本电脑、台式计算机等。图6示出的终端设备/服务器仅仅是一个示例,不应对本公开的实施例的功能和使用范围带来任何限制。Referring now to FIG. 6 , it shows a schematic structural diagram of an electronic device (such as the server or terminal device in FIG. 1 ) 600 suitable for implementing the embodiments of the present disclosure. Terminal devices in the embodiments of the present disclosure may include, but are not limited to, devices such as notebook computers and desktop computers. The terminal device/server shown in FIG. 6 is only an example, and should not limit the functions and scope of use of the embodiments of the present disclosure.

如图6所示,电子设备600可以包括处理装置(例如中央处理器、图形处理器等)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储装置608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有电子设备600操作所需的各种程序和数据。处理装置601、ROM 602以及RAM603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 6, an electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may be randomly accessed according to a program stored in a read-only memory (ROM) 602 or loaded from a storage device 608. Various appropriate actions and processes are executed by programs in the memory (RAM) 603 . In the RAM 603, various programs and data necessary for the operation of the electronic device 600 are also stored. The processing device 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to the bus 604 .

通常,以下装置可以连接至I/O接口605:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置606;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置607;包括例如磁带、硬盘等的存储装置608;以及通信装置609。通信装置609可以允许电子设备600与其他设备进行无线或有线通信以交换数据。虽然图6示出了具有各种装置的电子设备600,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。图6中示出的每个方框可以代表一个装置,也可以根据需要代表多个装置。Typically, the following devices can be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speaker, vibration an output device 607 such as a computer; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While FIG. 6 shows electronic device 600 having various means, it should be understood that implementing or having all of the means shown is not a requirement. More or fewer means may alternatively be implemented or provided. Each block shown in FIG. 6 may represent one device, or may represent multiple devices as required.

特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置609从网络上被下载和安装,或者从存储装置608被安装,或者从ROM 602被安装。在该计算机程序被处理装置601执行时,执行本公开的实施例的方法中限定的上述功能。需要说明的是,本公开的实施例所述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开的实施例中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开的实施例中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, where the computer program includes program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are executed. It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of the present disclosure, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable signal medium may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device . Program code embodied on a computer readable medium may be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示;将中间表示输入分类器,得到分类器输出的分类标签;响应于分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,将中间表示输入解码器,得到解码器输出的第二文本。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device, or may exist independently without being incorporated into the electronic device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device: inputs the vector matrix determined based on the word segmentation sequence of the first text into the encoder to obtain the encoded The intermediate representation of the device output; the intermediate representation is input into the classifier, and the classification label output by the classifier is obtained; in response to the classification label indicating that the word segmentation at the tail in the word segmentation sequence of the first text is an independent translation unit, the intermediate representation is input into the decoder, Get the second text output by the decoder.

可以以一种或多种程序设计语言或其组合来编写用于执行本公开的实施例的操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)——连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for carrying out operations of embodiments of the present disclosure may be written in one or more programming languages, or combinations thereof, including object-oriented programming languages—such as Java, Smalltalk, C++, Also included are conventional procedural programming languages - such as the "C" 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 cases involving a remote computer, the remote computer may be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, using an Internet service provider to connected via the Internet).

附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。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 a flowchart or block diagram may represent a module, program segment, or portion of code that contains one or more logical functions for implementing specified executable instructions. 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 they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified functions or operations , or may be implemented by a combination of dedicated hardware and computer instructions.

描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元也可以设置在处理器中,例如,可以描述为:一种处理器包括编码器输入单元、分类器输入单元和解码器输入单元。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定,例如,编码器输入单元还可以被描述为“将基于第一文本的分词序列确定的向量矩阵输入编码器,得到编码器输出的中间表示的单元”。The units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The described units may also be set in a processor, for example, it may be described as: a processor includes an encoder input unit, a classifier input unit, and a decoder input unit. Among them, the names of these units do not constitute a limitation of the unit itself in some cases. For example, the encoder input unit can also be described as "input the vector matrix determined based on the word segmentation sequence of the first text into the encoder, and obtain The unit of the intermediate representation of the encoder output".

以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present disclosure and an illustration of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in this disclosure is not limited to the technical solution formed by the specific combination of the above-mentioned technical features, but should also cover the technical solutions formed by the above-mentioned technical features or without departing from the above-mentioned inventive concept. Other technical solutions formed by any combination of equivalent features. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

Claims (10)

1.一种翻译的方法,采用翻译模型,所述翻译模型包括编码器、分类器和解码器,所述方法包括:1. A method of translation, using a translation model, said translation model comprising encoder, classifier and decoder, said method comprising: 将基于第一文本的分词序列确定的向量矩阵输入所述编码器,得到所述编码器输出的中间表示;Inputting the vector matrix determined based on the word segmentation sequence of the first text into the encoder to obtain an intermediate representation output by the encoder; 将所述中间表示输入所述分类器,得到所述分类器输出的分类标签;Inputting the intermediate representation into the classifier to obtain a classification label output by the classifier; 响应于所述分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,且历史翻译结果中存在对应第一文本的分词序列中位于尾部之前的分词的翻译结果,将所述中间表示输入所述解码器,以及将历史翻译结果中对应第一文本的分词序列中位于尾部之前的分词的翻译结果作为约束,将所述约束输入所述解码器,得到所述解码器输出的第二文本。In response to the classification label indicating that the word segmentation at the tail in the word segmentation sequence of the first text is an independent translation unit, and there is a translation result corresponding to the word segmentation before the tail in the word segmentation sequence of the first text in the historical translation results, the The intermediate representation is input into the decoder, and the translation result of the word segmentation before the tail in the word segmentation sequence corresponding to the first text in the historical translation result is used as a constraint, and the constraint is input into the decoder to obtain the output of the decoder second text. 2.根据权利要求1所述的方法,其中,所述翻译模型的训练数据样本基于以下步骤确定:2. The method according to claim 1, wherein the training data samples of the translation model are determined based on the following steps: 采用词对齐工具对齐翻译模型的训练数据,得到训练数据的对齐信息;Use the word alignment tool to align the training data of the translation model to obtain the alignment information of the training data; 将所述训练数据的对齐信息,作为所述翻译模型的训练数据样本。The alignment information of the training data is used as a training data sample of the translation model. 3.根据权利要求1所述的方法,其中,所述第一文本的分词序列经由以下步骤得到:3. The method according to claim 1, wherein the word segmentation sequence of the first text is obtained through the following steps: 识别输入的第一语音,得到第一文本;Recognizing the input first voice to obtain the first text; 对所述第一文本进行分词,得到第一文本的分词序列。Word segmentation is performed on the first text to obtain a word segmentation sequence of the first text. 4.根据权利要求1-3任意一项所述的方法,其中,所述方法还包括:4. The method according to any one of claims 1-3, wherein the method further comprises: 基于所述翻译后的第二文本,生成第二语音;generating a second voice based on the translated second text; 播放所述第二语音。Play the second voice. 5.一种翻译的装置,采用翻译模型,所述翻译模型包括编码器、分类器和解码器,所述装置包括:5. A device for translation, using a translation model, the translation model includes an encoder, a classifier and a decoder, and the device includes: 编码器输入单元,被配置成将基于第一文本的分词序列确定的向量矩阵输入所述编码器,得到所述编码器输出的中间表示;An encoder input unit configured to input the vector matrix determined based on the word segmentation sequence of the first text into the encoder to obtain an intermediate representation output by the encoder; 分类器输入单元,被配置成将所述中间表示输入所述分类器,得到所述分类器输出的分类标签;a classifier input unit configured to input the intermediate representation into the classifier to obtain a classification label output by the classifier; 解码器输入单元,被配置成响应于所述分类标签指示第一文本的分词序列中位于尾部的分词为独立的翻译单元,且历史翻译结果中存在对应第一文本的分词序列中位于尾部之前的分词的翻译结果,将所述中间表示输入所述解码器,以及将历史翻译结果中对应第一文本的分词序列中位于尾部之前的分词的翻译结果作为约束,将所述约束输入所述解码器,得到所述解码器输出的第二文本。The decoder input unit is configured to indicate in response to the classification label that the word segment located at the tail in the word segment sequence of the first text is an independent translation unit, and there is a corresponding word segment located before the tail in the word segment sequence of the first text in the historical translation result The translation result of the word segmentation, the intermediate representation is input into the decoder, and the translation result of the word segmentation before the tail in the word segmentation sequence corresponding to the first text in the historical translation result is used as a constraint, and the constraint is input into the decoder , to obtain the second text output by the decoder. 6.根据权利要求5所述的装置,其中,所述装置中所使用的翻译模型的训练数据样本基于以下单元确定:6. The device according to claim 5, wherein the training data samples of the translation model used in the device are determined based on the following units: 训练数据对齐单元,被配置成采用词对齐工具对齐翻译模型的训练数据,得到训练数据的对齐信息;The training data alignment unit is configured to use a word alignment tool to align the training data of the translation model to obtain alignment information of the training data; 训练数据确定单元,被配置成将所述训练数据的对齐信息,作为所述翻译模型的训练数据样本。The training data determination unit is configured to use the alignment information of the training data as a training data sample of the translation model. 7.根据权利要求5所述的装置,其中,所述装置还包括:7. The apparatus of claim 5, wherein the apparatus further comprises: 第一语音识别单元,被配置成识别输入的第一语音,得到第一文本;The first speech recognition unit is configured to recognize the input first speech to obtain the first text; 第一文本分词单元,被配置成对所述第一文本进行分词,得到第一文本的分词序列。The first text word segmentation unit is configured to perform word segmentation on the first text to obtain a word segmentation sequence of the first text. 8.根据权利要求5-7任意一项所述的装置,其中,所述装置还包括:8. The device according to any one of claims 5-7, wherein the device further comprises: 第二语音生成单元,被配置成基于所述翻译后的第二文本,生成第二语音;a second speech generation unit configured to generate a second speech based on the translated second text; 第二语音播放单元,被配置成播放所述第二语音。The second voice playing unit is configured to play the second voice. 9.一种电子设备,包括:9. An electronic device comprising: 一个或多个处理器;one or more processors; 存储装置,用于存储一个或多个程序;storage means for storing one or more programs; 当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-4中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors are made to implement the method according to any one of claims 1-4. 10.一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现如权利要求1-4中任一所述的方法。10. A computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the method according to any one of claims 1-4 is realized.
CN201911316920.3A 2019-12-19 2019-12-19 Translation method and device Active CN111126078B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911316920.3A CN111126078B (en) 2019-12-19 2019-12-19 Translation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911316920.3A CN111126078B (en) 2019-12-19 2019-12-19 Translation method and device

Publications (2)

Publication Number Publication Date
CN111126078A CN111126078A (en) 2020-05-08
CN111126078B true CN111126078B (en) 2023-04-07

Family

ID=70500794

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911316920.3A Active CN111126078B (en) 2019-12-19 2019-12-19 Translation method and device

Country Status (1)

Country Link
CN (1) CN111126078B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112052693B (en) * 2020-09-15 2024-07-05 科大讯飞股份有限公司 Machine translation effect evaluation method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102015217538A1 (en) * 2015-09-14 2017-03-16 Continental Automotive Gmbh Computer program and method for determining a desired ratio of a motor vehicle
CN109543200A (en) * 2018-11-30 2019-03-29 腾讯科技(深圳)有限公司 Text translation method and device
CN109582982A (en) * 2018-12-17 2019-04-05 北京百度网讯科技有限公司 Method and apparatus for translated speech

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9892115B2 (en) * 2013-06-11 2018-02-13 Facebook, Inc. Translation training with cross-lingual multi-media support
US9928236B2 (en) * 2015-09-18 2018-03-27 Mcafee, Llc Systems and methods for multi-path language translation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102015217538A1 (en) * 2015-09-14 2017-03-16 Continental Automotive Gmbh Computer program and method for determining a desired ratio of a motor vehicle
CN109543200A (en) * 2018-11-30 2019-03-29 腾讯科技(深圳)有限公司 Text translation method and device
CN109582982A (en) * 2018-12-17 2019-04-05 北京百度网讯科技有限公司 Method and apparatus for translated speech

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
熊德意 ; 李军辉 ; 王星 ; 张飚 ; .基于约束的神经机器翻译.中国科学:信息科学.2018,(第05期),全文. *

Also Published As

Publication number Publication date
CN111126078A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
CN112633947B (en) Text generation model generation method, text generation method, device and equipment
CN108022586B (en) Method and apparatus for controlling pages
US20240021202A1 (en) Method and apparatus for recognizing voice, electronic device and medium
CN108985358B (en) Emotion recognition method, device, device and storage medium
JP7520246B2 (en) Method and apparatus for generating text - Patents.com
CN111986655B (en) Audio content identification method, device, equipment and computer readable medium
US11036996B2 (en) Method and apparatus for determining (raw) video materials for news
CN113782007B (en) Voice recognition method, device, voice recognition equipment and storage medium
WO2023024975A1 (en) Text processing method and apparatus, and electronic device
CN112364653A (en) Text analysis method, apparatus, server and medium for speech synthesis
CN113051895A (en) Method, apparatus, electronic device, medium, and program product for speech recognition
WO2020182123A1 (en) Method and device for pushing statement
WO2023082931A1 (en) Method for punctuation recovery in speech recognition, and device and storage medium
CN112509562A (en) Method, apparatus, electronic device and medium for text post-processing
CN111104796B (en) Method and device for translation
CN110992938A (en) Voice data processing method, apparatus, electronic device and computer readable medium
CN110245334B (en) Method and device for outputting information
WO2024077906A1 (en) Speech text generation method and apparatus, and training method and apparatus for speech text generation model
CN111783395A (en) Method and apparatus for outputting text
CN111126078B (en) Translation method and device
US20250246191A1 (en) Interactive method based on large model, training method, intelligent agent, device, and medium
CN112530416B (en) Speech recognition method, apparatus, device and computer readable medium
CN114880520B (en) Video title generation method, device, electronic equipment and medium
CN113241061B (en) Method and device for processing voice recognition result, electronic equipment and storage medium
CN113806485B (en) A method, device and readable medium for intent recognition based on small-sample cold start

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
GR01 Patent grant
GR01 Patent grant