Class: Informers::GPT2PreTrainedModel

Inherits:
PreTrainedModel show all
Defined in:
lib/informers/models.rb

Direct Known Subclasses

GPT2LMHeadModel, GPT2Model

Constant Summary

Constants inherited from PreTrainedModel

PreTrainedModel::MAIN_INPUT_NAME

Instance Attribute Summary collapse

Attributes inherited from PreTrainedModel

#config

Instance Method Summary collapse

Methods inherited from PreTrainedModel

#call, construct_session, from_pretrained, #generate

Constructor Details

#initialize(config, session, generation_config) ⇒ GPT2PreTrainedModel

Returns a new instance of GPT2PreTrainedModel.



1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
# File 'lib/informers/models.rb', line 1050

def initialize(config, session, generation_config)
  super(config, session)
  @generation_config = generation_config

  # config doesn't contain pad_token_id, so we assume it is the eos_token_id
  @config["pad_token_id"] = @config["eos_token_id"]

  @num_heads = @config["n_head"]
  @num_layers = @config["n_layer"]
  @dim_kv = @config["n_embd"] / @num_heads.to_f
end

Instance Attribute Details

#dim_kvObject (readonly)

Returns the value of attribute dim_kv.



1048
1049
1050
# File 'lib/informers/models.rb', line 1048

def dim_kv
  @dim_kv
end

#num_headsObject (readonly)

Returns the value of attribute num_heads.



1048
1049
1050
# File 'lib/informers/models.rb', line 1048

def num_heads
  @num_heads
end

#num_layersObject (readonly)

Returns the value of attribute num_layers.



1048
1049
1050
# File 'lib/informers/models.rb', line 1048

def num_layers
  @num_layers
end