文章来源于阿里语音AI,作者达摩院语音实验室
本文详细介绍PoNet模型的原理以及其在ModelScope上的体验用法,包括PoNet简介原理、PoNet在ModelScope上怎么用、PoNet在各种下游任务上的效果等。
PoNet模型全名是Pooling Network[1],在2021年由达摩院语音实验室提出,并发表在机器学习领域顶会ICLR 2022上。PoNet是一种适合对长序列进行建模的模型,对输入序列的长度N具有线性复杂度,它使用简单的pooling网络替代了传统Transformer模型中的self-attention机制。常见的长序列任务包括长文本分类,篇章话题分割,篇章摘要,长序列时间序列预测等等。
实验表明,PoNet在长文本测试Long Range Arena (LRA)榜[2]上在准确率上比Transformer高2.28个点,在GPU上运行速度是Transformer的9倍,显存占用只有1/10。此外,实验也展示了PoNet的迁移学习能力,PoNet-Base在GLUE基准上达到了BERT-Base的95.7%的准确性。
▏PoNet是如何实现的?
PoNet模型的结构图如下所示:

▏如何快速体验PoNet模型?

step 2: 选择实例类型,然后点击启动

2. 动手配置
pip install "modelscope[nlp]" -f
https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.htmlfrom modelscope.pipelines import pipeline
from modelscope.utils.constant import Taskspipeline_ins = pipeline(Tasks.fill_mask, model='damo/nlp_ponet_fill-mask_chinese-base')input = "人民文学出版社[MASK]1952[MASK],出版《[MASK][MASK]演义》、《[MASK]游记》、《水浒传》、《[MASK]楼梦》,合为“[MASK]大名著”。"
print(pipeline_ins(input))PoNet主要的用途是作为预训练模型在下游各种长文本任务上进行finetune。
首先,克隆repo。
git clone https://github.com/alibaba-damo-academy/SpokenNLP.git然后,准备ModelScope的SDK token。注册ModelScope账号,并且在个人主页获得token,然后修改alimeeting4mug/src/utils/config.py配置文件。

接下来安装ModelScope以及其他环境。
pip install "modelscope[nlp]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install -r requirements.txt最后,运行bash训练脚本,便可以预训练一个基于PoNet的文本话题分割模型。
sh run_ponet_topic_segmentation.sh更多细节参考:
https://github.com/alibaba-damo-academy/SpokenNLP/tree/main/alimeeting4mug


迁移学习
我们用大规模语料库对PoNet进行预训练,然后测试它在下游任务上的性能。下图是预训练的MLM[4]和SSO[5]两个子任务的训练曲线,可以看到,我们的模型在MLM上略微弱于BERT,在SSO上与BERT还有一定的差距,两个任务上都明显要优于FNet。

GLUE



▏联系我们
模型使用中如遇到任何问题,欢迎通过魔搭ModelScope社区与我们互动:

https://developer.aliyun.com/community/modelscope
(扫描上方二维码或输入网址即可联系我们)
ModelScope 英文PoNet页面:
抽取式篇章摘要模型页面:
https://modelscope.cn/models/damo/nlp_ponet_extractive-summarization_doc-level_chinese-base/summary
References
[1]Chao-Hong Tan, Qian Chen, Wen Wang, Qinglin Zhang, Siqi Zheng, Zhen-Hua Ling: PoNet: Pooling Network for Efficient Token Mixing in Long Sequences. ICLR 2022. URL https://openreview.net/forum?id=9jInD9JjicF.
[2] Yi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen, Dara Bahri, Philip Pham, Jinfeng Rao, Liu Yang, Sebastian Ruder, and Donald Metzler. Long Range Arena : A benchmark for efficient transformers. ICLR 2021. URL https://openreview.net/forum?id=qVyeW-grC2k.
[3] Meng-Hao Guo, Zheng-Ning Liu, Tai-Jiang Mu, and Shi-Min Hu. Beyond self-attention: External attention using two linear layers for visual tasks. CoRR, abs/2105.02358, 2021. URL https://arxiv.org/abs/2105.02358.
[4] James Lee-Thorp, Joshua Ainslie, Ilya Eckstein, and Santiago Ontanon. FNet: mixing tokens with fourier transforms. CoRR, abs/2105.03824, 2021. URL https://arxiv.org/abs/2105.03824.
[5] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. NAACL-HLT 2019. URL https://doi.org/10.18653/v1/n19-1423.
[6] Wei Wang, Bin Bi, Ming Yan, Chen Wu, Jiangnan Xia, Zuyi Bao, Liwei Peng, and Luo Si. StructBERT: incorporating language structures into pre-training for deep language understanding. ICLR 2020. URL https://openreview.net/forum?id=BJgQ4lSFPH.
