论文阅读:Dual Learning for Machine Translation

本文介绍了一种名为对偶学习的方法,旨在解决机器翻译中因缺乏大量双语对照数据而导致的问题。通过模拟两个只会各自语言的代理人之间的交互,这种方法能够在没有双语对照数据的情况下改善翻译质量。

论文阅读:Dual Learning for Machine Translation

问题提出:

目前在机器翻译的领域,神经机器翻译(NMT)快速发展,取得了很好的效果,但是为了得到一个好的NMT的模型,需要大量的人工标记的训练
集即双语的语句对。人工标记大量的数据费时费力,本文的目的就是提出一种方案(dual learning)来解决这个问题,并且可以得到相比于NMT模
型更好的效果。

思考:

作者观察到在机器学习的任务中,有许多任务是对偶存在的,比如:英汉互译。现实中我们往往分别考虑两个过程,即对于汉语翻译成英语进行一个模型的训练,
对于英语翻译成汉语进行另一个模型的训练。那这两个模型之间是否存在着什么关系呢?是否可以同时训练这两个过程,同时两者之间可以相互的促进?假如前面
两个问题是true的话,回到本文的初衷,新的模型又是如何解决大量标记数据的问题的呢?

思想:

Dual learning的整个过程可以看作两个代理人的交流游戏:
1. 第一个Agent 只懂得语言A,可以将语言A的信息通过一个有噪声的信道发送给第二个Agent,这个有噪声的信道可以使用一个翻译模型将语言A翻译成
第二个Agent懂得的语言B。
2. 第二个Agent只懂得语言B,她接收到第一个Agent发来的信息(已经被翻译成语言B),然后她会对该信息进行判断(比如语法是否正确,语句是否完整等),
注意她并不能准确的判断该信息的正确性,因为原始的信息对她来说是不可见的。之后她将此时的信息通过另一个有噪声的信道再发送回第一个Agent,该信道使用另一个翻译模型将语言B的信息转换为语言A。
3. 第一个Agent接收到B传回来的信息后,就与原始的信息进行比对,看两者的一致性。通过这个反馈(feedback),两个Agent都可以知道两个信道(两个翻译模型)是否执行的比较好(perform well)以及是否可以相互促进。
4. 当然也可以从第二个Agent开始。这两个Agent通过这个闭环的过程,根据反馈可以不断的提升两个翻译模型。
从上述描述中可以看出,尽管这两个Agent都没有与之标记的双语的标签,但是她们依然可以得到关于这两个翻译模型的反馈,并依据此反馈来提高模型的翻译能力。由此也可以看出,我们并不需要大量的双语对的训练集(为了加快模型的训练速度,也可以先使用少量的双语对训练集进行模型的训练——需要实验的论证)。

算法过程:

有两个单语言的集合DA和DB,分别是语言A的集合和语言B的集合,这里注意DA和DB并不需要相互匹配,甚至不需要含有部分的匹配。现在假定我们已经有了两个比较弱的翻译模型,可以将语言A翻译成语言B,也可以将语言B翻译成语言A,我们的目标是使用单语言的集合来提高我们模型的翻译准确率(这里看出其实是不需要进行标记,是一个无监督学习过程)。
假设DA包含NA个句子,DB包含NB个句子。定义 表示两个神经翻译模型,分别是这两个模型的参数。
假设我们已经有了两个训练好的语言模型,每个语言模型接受一个句子作为输入,然后输出一个真值(real value)来表示该语句是否是一个自然的语句(natural sentence),注意它只是判断一个句子是否正常,如是否符合语法,是否通顺等,并不是进行翻译。



第1行:算法的输入,数据集DA和DB,初始化后的翻译模型参数 (弱翻译器),语言模型
超参数,beam search算法的大小参数(size),学习率
第2行到第17行:循环过程直至算法收敛
第3行:t 表示算法的迭代次数,每经过一次迭代,t的值加上1
第4行:例句SA和SB分别来自于DA和DB
第5行:令s为SA(假定模型更新从A开始)
第6行:使用beam search算法,根据翻译模型生成K个句子
第7行到第11行:for循环,1—K
第8行:令语言模型对第K个例句的回报为
第9行:令第k个例句的交流回报为
第10行:令第K个例句的整个回报为
第12行:使用随机梯度下降策略计算的下降梯度
第13行:使用随机梯度下降策略计算的下降梯度
第14行:更新参数
第15行:令s为SB
第16行:返回第6行继续执行 (这里返回后,第8行的回报计算式子使用来计算,第9行的也要相应的更换)


实验验证:

实验的评测方法使用BLUE,baseline使用NMT和pseudo-NMT。

其中Large表示使用所有的数据集,Small表示使用整个数据集的10%,从表中可以看出,相比于baseline,有了很大的提高,尤其是
对于数据量相对较小时更加明显。

进一步的,本文使用一些手段对原有的三个模型从语句向量的构造,硬件条件等方面进行改进(如:利用主流的框架实现NMT,但保证GPU为单一变量),
得到下表:

结论依然不变。


拓展(extension):

本文述了对于两个对偶的任务,可以使用对偶学习(dual learning),但并不局限于两个任务,因为我们关心的是其中的反馈,
如果3个甚至更多个任务可以构成一个闭环,从理论上我们依然可以利用本文的思想(dual learning),使用无标签的数据进行每个模型的
训练。比如我们有一个英语语句X ,可以将其翻译成汉语Y,然后再翻译成法语语句Z,最后翻译成英语 W ,通过比较X和W我们就可以
指出这三个翻译模型翻译的准确率,问题解决的关键点是这个闭环过程中的反馈(feedback)。

### Dual-Softmax in Machine Learning In the context of machine learning, particularly within advanced models such as those discussed in cluster-based k-nearest neighbor machine translation methods[^1], dual-softmax refers to a technique that enhances model performance by applying softmax operations twice across different dimensions or contexts. #### Definition The traditional softmax function transforms a vector of values into probabilities proportional to the exponentials of these input elements. In contrast, dual-softmax extends this concept: - **First Softmax**: Applied over one dimension (e.g., vocabulary size), converting raw scores into probability distributions. - **Second Softmax**: Operated on another axis (such as clusters or neighbors), further refining predictions based on contextual information from multiple sources. This approach allows for more nuanced modeling of relationships between entities like words and their translations while maintaining computational efficiency through clustering mechanisms. #### Usage Implementing dual-softmax can be beneficial when dealing with tasks requiring fine-grained understanding of semantic structures, including but not limited to neural machine translation systems. By leveraging both local and global perspectives provided via two separate applications of the softmax operation, models achieve better generalization capabilities without significantly increasing complexity. Below is an illustrative Python code snippet demonstrating how dual-softmax might look implemented within a hypothetical scenario involving sentence embeddings: ```python import torch import torch.nn.functional as F def dual_softmax(scores, dim1=0, dim2=-1): """ Applies softmax along specified axes sequentially Args: scores (Tensor): Input tensor containing logits before activation dim1 (int): Dimension index for first application of softmax dim2 (int): Dimension index for second application of softmax Returns: Tensor: Output after applying dual-softmax activations """ # Apply first layer of normalization normalized_scores = F.softmax(scores, dim=dim1) # Apply second layer of normalization final_output = F.softmax(normalized_scores, dim=dim2) return final_output # Example usage logits = torch.randn((5, 7)) # Simulated batched data points output = dual_softmax(logits) print(output.shape) # Should match original shape ``` --related questions-- 1. How does dual-softmax compare against single-layer softmax implementations? 2. What are some practical examples where dual-softmax has been successfully applied beyond NLP domains? 3. Can you explain why introducing additional layers of softmax helps improve certain types of predictive models' accuracy? 4. Are there any drawbacks associated with implementing dual-softmax compared to simpler alternatives? : Efficient Cluster-Based k-Nearest-Neighbor Machine Translation [^2]: CLUES: A Benchmark for Learning Classifiers using Natural Language Explanations (Note: Although mentioned initially, content directly related specifically to was not utilized here due to relevance constraints.)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值