CPM1
CPM1Config
- class model_center.model.CPM1Config(vocab_size=30968, dim_model=768, num_heads=12, dim_head=64, dim_ff=256, num_layers=12, dropout_p=0, emb_init_mean=0.0, emb_init_std=1, pos_bias_type='relative', position_bias_num_buckets=32, position_bias_max_distance=128, pos_init_mean=0.0, pos_init_std=1, norm_init_var=1.0, norm_bias=False, norm_eps=1e-06, att_init_mean=0.0, att_init_std=0.02, att_bias=False, att_mask_value=- inf, ffn_init_mean=0.0, ffn_init_std=0.02, ffn_bias=False, ffn_activate_fn='gated_gelu', proj_init_mean=0.0, proj_init_std=1, proj_bias=False, length_scale=False, attn_scale=False, half=True, int8=False, tied=False, cls_head=None, post_layer_norm=False)
This is a configuration class that stores the configuration of the CPM model, which inherits from the Config class. It is used to instantiate the Bert model according to the specified parameters and define the model architecture. You can set specific parameters to control the output of the model.
For example: [dim_model] is used to determine the Dimension of the encoder layers. You can choose to use the default value of 768 or customize their dimensions.
CPM1Model
- class model_center.model.CPM1(config: model_center.model.config.cpm1_config.CPM1Config)
- forward(input: torch.Tensor, length: torch.Tensor, context: torch.Tensor, span: torch.Tensor)
- This model inherits from BaseModel. This model is also a PyTorch torch.nn.Module subclass.
You can use it as a regular PyTorch Module.
- Parameters
input (
torch.Tensor
of shape(batch, seqlen)
) –length (
torch.Tensor
of shape(batch)
) –context (
torch.Tensor
of shape(batch, seqlen)
) –span (
torch.Tensor
of shape(batch, seqlen)
) –
- Returns
The CPM output. Prediction scores of the language modeling before SoftMax.
- Return type
torch.Tensor of shape (batch, seqlen, vocab_size) or (batch, seqlen, cls_head)