modeling

class ProphetNetModel(vocab_size, bos_token_id=102, pad_token_id=0, eos_token_id=102, hidden_size=1024, decoder_start_token_id=102, max_position_embeddings=512, activation_function='gelu', activation_dropout=0.1, dropout=0.1, relative_max_distance=128, ngram=2, num_buckets=32, encoder_ffn_dim=4096, num_encoder_attention_heads=16, num_encoder_layers=12, decoder_ffn_dim=4096, num_decoder_attention_heads=16, num_decoder_layers=12, attention_dropout=0.1, init_std=0.02, eps=0.1, add_cross_attention=True, disable_ngram_loss=False, **kwargs)[source]

Bases: paddlenlp.transformers.prophetnet.modeling.ProphetNetPretrainedModel

forward(input_ids=None, attention_mask=None, decoder_input_ids=None, decoder_attention_mask=None, encoder_output: Optional[Tuple] = None, use_cache=True, past_key_values=None)[source]

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

class ProphetNetPretrainedModel(name_scope=None, dtype='float32')[source]

Bases: paddlenlp.transformers.model_utils.PretrainedModel

An abstract class for pretrained Prophetnet models. It provides Prophetnet related model_config_file, pretrained_init_configuration, resource_files_names, pretrained_resource_files_map, base_model_prefix for downloading and loading pretrained models.

base_model_class

alias of paddlenlp.transformers.prophetnet.modeling.ProphetNetModel

class ProphetNetEncoder(word_embeddings, vocab_size, hidden_size, pad_token_id, max_position_embeddings, encoder_ffn_dim, activation_function, activation_dropout, attention_dropout, dropout, num_encoder_attention_heads, num_encoder_layers, init_std)[source]

Bases: paddlenlp.transformers.prophetnet.modeling.ProphetNetPretrainedModel

word_embeddings (torch.nn.Embeddings of shape (config.vocab_size, config.hidden_size), optional):

The word embedding parameters. This can be used to initialize ProphetNetEncoder with pre-defined word embeddings instead of randomly initialized word embeddings.

forward(input_ids=None, attention_mask=None)[source]

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

class ProphetNetDecoder(word_embeddings, vocab_size, hidden_size, pad_token_id, max_position_embeddings, relative_max_distance, ngram, num_buckets, num_decoder_attention_heads, decoder_ffn_dim, activation_function, activation_dropout, dropout, attention_dropout, add_cross_attention, num_decoder_layers, init_std)[source]

Bases: paddlenlp.transformers.prophetnet.modeling.ProphetNetPretrainedModel

forward(input_ids=None, attention_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, past_key_values=None, use_cache=True)[source]

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

class ProphetNetForConditionalGeneration(prophetnet)[source]

Bases: paddlenlp.transformers.prophetnet.modeling.ProphetNetPretrainedModel

forward(input_ids=None, attention_mask=None, decoder_input_ids=None, decoder_attention_mask=None, encoder_output=None, labels=None, use_cache=True, past_key_values=None)[source]

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments