Module: Legion::Extensions::Agentic::Learning::LearningRate::Runners::LearningRate
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb
Instance Method Summary collapse
- #current_rate(domain: :general) ⇒ Object
- #fastest_domains(count: 5) ⇒ Object
- #learning_rate_stats ⇒ Object
- #record_error(magnitude:, domain: :general) ⇒ Object
- #record_prediction(correct:, domain: :general) ⇒ Object
- #record_surprise(magnitude:, domain: :general) ⇒ Object
- #slowest_domains(count: 5) ⇒ Object
- #update_learning_rate ⇒ Object
Instance Method Details
#current_rate(domain: :general) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 41 def current_rate(domain: :general, **) rate = rate_model.rate_for(domain) accuracy = rate_model.accuracy_for(domain) { success: true, domain: domain, rate: rate, accuracy: accuracy, label: rate_model.label_for(domain) } end |
#fastest_domains(count: 5) ⇒ Object
53 54 55 56 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 53 def fastest_domains(count: 5, **) domains = rate_model.fastest_domains(count) { success: true, domains: domains, count: domains.size } end |
#learning_rate_stats ⇒ Object
70 71 72 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 70 def learning_rate_stats(**) { success: true, stats: rate_model.to_h } end |
#record_error(magnitude:, domain: :general) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 34 def record_error(magnitude:, domain: :general, **) rate_model.record_error(domain: domain, magnitude: magnitude) rate = rate_model.rate_for(domain) log.debug "[learning_rate] error: domain=#{domain} magnitude=#{magnitude.round(3)} rate=#{rate.round(3)}" { success: true, domain: domain, rate: rate, label: rate_model.label_for(domain) } end |
#record_prediction(correct:, domain: :general) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 13 def record_prediction(correct:, domain: :general, **) rate_model.record_prediction(domain: domain, correct: correct) rate = rate_model.rate_for(domain) accuracy = rate_model.accuracy_for(domain) log.debug "[learning_rate] prediction: domain=#{domain} correct=#{correct} rate=#{rate.round(3)} accuracy=#{accuracy.round(3)}" { success: true, domain: domain, rate: rate, accuracy: accuracy, label: rate_model.label_for(domain) } end |
#record_surprise(magnitude:, domain: :general) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 27 def record_surprise(magnitude:, domain: :general, **) rate_model.record_surprise(domain: domain, magnitude: magnitude) rate = rate_model.rate_for(domain) log.debug "[learning_rate] surprise: domain=#{domain} magnitude=#{magnitude.round(3)} rate=#{rate.round(3)}" { success: true, domain: domain, rate: rate, label: rate_model.label_for(domain) } end |
#slowest_domains(count: 5) ⇒ Object
58 59 60 61 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 58 def slowest_domains(count: 5, **) domains = rate_model.slowest_domains(count) { success: true, domains: domains, count: domains.size } end |
#update_learning_rate ⇒ Object
63 64 65 66 67 68 |
# File 'lib/legion/extensions/agentic/learning/learning_rate/runners/learning_rate.rb', line 63 def update_learning_rate(**) rate_model.decay overall = rate_model.overall_rate log.debug "[learning_rate] tick: domains=#{rate_model.domain_count} overall=#{overall.round(3)}" { success: true, domain_count: rate_model.domain_count, overall_rate: overall } end |