Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

funnel transformer #1419

Merged
merged 14 commits into from
Dec 23, 2021
Merged

funnel transformer #1419

merged 14 commits into from
Dec 23, 2021

Conversation

zzz2010
Copy link
Contributor

@zzz2010 zzz2010 commented Dec 9, 2021

PR types

new transformer model

PR changes

主要是添加了funnel 模型在paddlenlp的transformer 下面, 和修改了run_squad.py 在examples 下,可以测试funnel 模型

Description

复现论文比赛第四期, funnel 的复现,团队:小木桌

请在google drive 下载所有pretrain 模型 放到 https://bj.bcebos.com/paddlenlp/models:
https://drive.google.com/drive/folders/1eo2Jq0xDd7qO_9-N5lf42WsqQSi7i9aS?usp=sharing

different token than `bos`, the id of that token.
- **sep_token_id** (:obj:`int`, `optional`)) -- The id of the `separation` token.

PyTorch specific parameters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不需要提供PyTorch和TF的特定的参数,可以去掉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,已经去掉

return x

def constant_(x, val):
temp_value=paddle.zeros_like(x)+val
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以使用paddle.full替代

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的, 已经改为 paddle.full_like(x,fill_value=val)

return x * paddle.sigmoid(x)


if version.parse(paddle.__version__) < version.parse("1.7"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问这里检验版本的作用是?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有作用, 之前torch的版本检验,已经remove。 保留 silu = nn.functional.silu




def expand(self, *sizes):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

与上面重复了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经remove

return x


def repeat_interleave(x, repeats, dim=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

与上面重复了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经remove

return paddle.reshape(x, orig_shape)


def gather(x, dim, index):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

与上面重复,下同

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经remove


def is_tensor(x):
"""
Tests if ``x`` is a :obj:`paddle.Tensor`, :obj:`tf.Tensor`, obj:`jaxlib.xla_extension.DeviceArray` or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该不需要判断tf的Tensor吧?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的, 已经删除无关注释

return_dict=None,
):
r"""
labels (:obj:`paddle.LongTensor` of shape :obj:`(batch_size,)`, `optional`):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里以及下面几个任务类都可以稍微整理一下注释,可以参考BertForSequenceClassification。还有就是paddle只有Tensor没有LongTensor类型,注意修改~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

谢谢,已经修改

return_dict=None,
):
r"""
labels (``paddle.LongTensor`` of shape ``(batch_size, sequence_length)``, `optional`):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同下,注意修改

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经修改

return self.linear_out(hidden)

from collections import OrderedDict
class FunnelForPreTrainingOutput(OrderedDict):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释里涉及到FloatTenor,LongTensor类型的统一修改为Tensor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经修改

@@ -86,3 +86,5 @@
from .reformer.tokenizer import *
from .mobilebert.modeling import *
from .mobilebert.tokenizer import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方冲突了,注意解决冲突~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经修改

return ACT2FN[activation_string]
else:
raise KeyError(f"function {activation_string} not found in ACT2FN mapping {list(ACT2FN.keys())}")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里空行较多,是否没有安装代码检查工具呢?建议安装git hook,并重新提交代码

 pre-commit install

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不太会用,我尝试过window, 和ubuntu安装, commit的时候都出现先配置错误。 可否帮忙看看现在的版本是否还有空行问题?


PyTorch specific parameters

- **torchscript** (:obj:`bool`, `optional`, defaults to :obj:`False`) -- Whether or not the model should be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

貌似很多注释都出现torch、TensorFlow的字眼,目前PaddleNLP暂时不用支持torch和tensorflow的输入,可以把相关的信息删除掉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经删除

Copy link
Contributor

@joey12300 joey12300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joey12300 joey12300 merged commit 74f9fae into PaddlePaddle:develop Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants