Class: Trainers::LoraConfig
- Inherits:
-
Object
- Object
- Trainers::LoraConfig
- Defined in:
- lib/trainers/lora/lora_config.rb
Constant Summary collapse
- DEFAULTS =
{ r: 8, lora_alpha: 16, lora_dropout: 0.0, target_modules: ["query", "value"], # or :all_linear bias: :none, # :none, :all, :lora_only task_type: :sequence_classification }.freeze
Instance Attribute Summary collapse
-
#bias ⇒ Object
Returns the value of attribute bias.
-
#lora_alpha ⇒ Object
Returns the value of attribute lora_alpha.
-
#lora_dropout ⇒ Object
Returns the value of attribute lora_dropout.
-
#r ⇒ Object
Returns the value of attribute r.
-
#target_modules ⇒ Object
Returns the value of attribute target_modules.
-
#task_type ⇒ Object
Returns the value of attribute task_type.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ LoraConfig
constructor
A new instance of LoraConfig.
- #scaling ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ LoraConfig
Returns a new instance of LoraConfig.
17 18 19 20 21 22 |
# File 'lib/trainers/lora/lora_config.rb', line 17 def initialize(**kwargs) DEFAULTS.each do |key, default| value = kwargs.fetch(key, default) instance_variable_set(:"@#{key}", value) end end |
Instance Attribute Details
#bias ⇒ Object
Returns the value of attribute bias.
5 6 7 |
# File 'lib/trainers/lora/lora_config.rb', line 5 def bias @bias end |
#lora_alpha ⇒ Object
Returns the value of attribute lora_alpha.
5 6 7 |
# File 'lib/trainers/lora/lora_config.rb', line 5 def lora_alpha @lora_alpha end |
#lora_dropout ⇒ Object
Returns the value of attribute lora_dropout.
5 6 7 |
# File 'lib/trainers/lora/lora_config.rb', line 5 def lora_dropout @lora_dropout end |
#r ⇒ Object
Returns the value of attribute r.
5 6 7 |
# File 'lib/trainers/lora/lora_config.rb', line 5 def r @r end |
#target_modules ⇒ Object
Returns the value of attribute target_modules.
5 6 7 |
# File 'lib/trainers/lora/lora_config.rb', line 5 def target_modules @target_modules end |
#task_type ⇒ Object
Returns the value of attribute task_type.
5 6 7 |
# File 'lib/trainers/lora/lora_config.rb', line 5 def task_type @task_type end |
Instance Method Details
#scaling ⇒ Object
24 25 26 |
# File 'lib/trainers/lora/lora_config.rb', line 24 def scaling @lora_alpha.to_f / @r end |
#to_h ⇒ Object
28 29 30 31 32 |
# File 'lib/trainers/lora/lora_config.rb', line 28 def to_h DEFAULTS.keys.each_with_object({}) do |key, hash| hash[key] = send(key) end end |