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.



952
953
954
955
956
957
958
959
960
961
962
# File 'lib/informers/models.rb', line 952

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.



950
951
952
# File 'lib/informers/models.rb', line 950

def dim_kv
  @dim_kv
end

#num_headsObject (readonly)

Returns the value of attribute num_heads.



950
951
952
# File 'lib/informers/models.rb', line 950

def num_heads
  @num_heads
end

#num_layersObject (readonly)

Returns the value of attribute num_layers.



950
951
952
# File 'lib/informers/models.rb', line 950

def num_layers
  @num_layers
end