Skip to content

Conversation

renmada
Copy link
Contributor

@renmada renmada commented Aug 10, 2021

PR types

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@renmada renmada changed the title Squeezebert Add squeezebert Aug 10, 2021
@renmada
Copy link
Contributor Author

renmada commented Aug 10, 2021

模型权重
链接: https://pan.baidu.com/s/1Jis7In0veo4ODae5OR_FqA 提取码: p5bk

@ZeyuChen
Copy link
Member

@renmada Thanks for your contribution, please sign CLA agreement, thanks.

Copy link
Contributor

@smallv0221 smallv0221 left a comment

Choose a reason for hiding this comment

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

The mean problem is the use of config in layers. Please also provide examples with readme. You can refer to https://github.com/PaddlePaddle/PaddleNLP/blob/develop/examples/language_model/bert/run_glue.py

Examples:
.. code-block:: python
from paddlenlp.transformers import SqueezeBertTokenizer
tokenizer = SqueezeBertTokenizer.from_pretrained('SqueezeBert-small-discriminator')
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't see SqueezeBert-small-discriminator .



class SqueezeBertEmbeddings(nn.Layer):
"""Construct the embeddings from word, position and token_type embeddings."""
Copy link
Contributor

Choose a reason for hiding this comment

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

"""
Construct the embeddings from word, position and token_type embeddings.
"""

self.position_embeddings = nn.Embedding(config.max_position_embeddings, config.embedding_size)
self.token_type_embeddings = nn.Embedding(config.type_vocab_size, config.embedding_size)

# self.LayerNorm is not snake-cased to stick with TensorFlow model variable name and be able to load
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need explanation like this.

class SqueezeBertEmbeddings(nn.Layer):
"""Construct the embeddings from word, position and token_type embeddings."""

def __init__(self, config):
Copy link
Contributor

Choose a reason for hiding this comment

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

# position_ids (1, len position emb) is contiguous in memory and exported when serialized
self.register_buffer("position_ids", paddle.arange(config.max_position_embeddings).expand((1, -1)))

def forward(self, input_ids=None, token_type_ids=None, position_ids=None, inputs_embeds=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

In PaddleNLP, only input_ids is allowed in embedding layer. Please refer to https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/transformers/bert/modeling.py



class SqueezeBertSelfAttention(nn.Layer):
def __init__(self, config, cin, q_groups=1, k_groups=1, v_groups=1):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please declare all perems here instead of using config. Please refer to https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/transformers/gpt/modeling.py



class SqueezeBertLayer(nn.Layer):
def __init__(self, config):
Copy link
Contributor

Choose a reason for hiding this comment

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

The same config problem as above.



class SqueezeBertPreTrainedModel(PretrainedModel):
base_model_prefix = "squeezebert"
Copy link
Contributor

Choose a reason for hiding this comment

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

Need more documentation here.


@register_base_model
class SqueezeBertModel(SqueezeBertPreTrainedModel):
def __init__(self, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

# Tie weights if needed
self.tie_weights()

def tie_weights(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need tie_weights? I didn't see any layer has get_output_embeddings function.

@renmada renmada mentioned this pull request Aug 30, 2021
@yingyibiao yingyibiao assigned smallv0221 and unassigned yingyibiao Sep 24, 2021
@yingyibiao yingyibiao closed this Nov 2, 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.

6 participants