Class: Informers::PretrainedConfig
- Inherits:
-
Object
- Object
- Informers::PretrainedConfig
- Defined in:
- lib/informers/configs.rb
Instance Attribute Summary collapse
-
#id2label ⇒ Object
readonly
Returns the value of attribute id2label.
-
#model_type ⇒ Object
readonly
Returns the value of attribute model_type.
-
#problem_type ⇒ Object
readonly
Returns the value of attribute problem_type.
Class Method Summary collapse
- .from_pretrained(pretrained_model_name_or_path, progress_callback: nil, config: nil, cache_dir: nil, local_files_only: false, revision: "main", **kwargs) ⇒ Object
- .load_config(pretrained_model_name_or_path, **options) ⇒ Object
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(config_json) ⇒ PretrainedConfig
constructor
A new instance of PretrainedConfig.
Constructor Details
#initialize(config_json) ⇒ PretrainedConfig
Returns a new instance of PretrainedConfig.
5 6 7 8 9 10 11 |
# File 'lib/informers/configs.rb', line 5 def initialize(config_json) @is_encoder_decoder = false @model_type = config_json["model_type"] @problem_type = config_json["problem_type"] @id2label = config_json["id2label"] end |
Instance Attribute Details
#id2label ⇒ Object (readonly)
Returns the value of attribute id2label.
3 4 5 |
# File 'lib/informers/configs.rb', line 3 def id2label @id2label end |
#model_type ⇒ Object (readonly)
Returns the value of attribute model_type.
3 4 5 |
# File 'lib/informers/configs.rb', line 3 def model_type @model_type end |
#problem_type ⇒ Object (readonly)
Returns the value of attribute problem_type.
3 4 5 |
# File 'lib/informers/configs.rb', line 3 def problem_type @problem_type end |
Class Method Details
.from_pretrained(pretrained_model_name_or_path, progress_callback: nil, config: nil, cache_dir: nil, local_files_only: false, revision: "main", **kwargs) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/informers/configs.rb', line 17 def self.from_pretrained( pretrained_model_name_or_path, progress_callback: nil, config: nil, cache_dir: nil, local_files_only: false, revision: "main", **kwargs ) data = config || load_config( pretrained_model_name_or_path, progress_callback:, config:, cache_dir:, local_files_only:, revision: ) new(data) end |
.load_config(pretrained_model_name_or_path, **options) ⇒ Object
37 38 39 40 |
# File 'lib/informers/configs.rb', line 37 def self.load_config(pretrained_model_name_or_path, **) info = Utils::Hub.get_model_json(pretrained_model_name_or_path, "config.json", true, **) info end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/informers/configs.rb', line 13 def [](key) instance_variable_get("@#{key}") end |