Module: Legion::Extensions::Apollo::Helpers::Confidence
- Defined in:
- lib/legion/extensions/apollo/helpers/confidence.rb
Constant Summary collapse
- INITIAL_CONFIDENCE =
0.5- CORROBORATION_BOOST =
0.3- RETRIEVAL_BOOST =
0.02- POWER_LAW_ALPHA =
0.5- DECAY_THRESHOLD =
0.1- CORROBORATION_SIMILARITY_THRESHOLD =
0.9- WRITE_CONFIDENCE_GATE =
0.6- WRITE_NOVELTY_GATE =
0.3- STALE_DAYS =
90- CONTENT_TYPES =
%i[fact concept procedure association observation].freeze
- STATUSES =
%w[candidate confirmed disputed decayed archived].freeze
- RELATION_TYPES =
%w[is_a has_a part_of causes similar_to contradicts supersedes depends_on].freeze
Class Method Summary collapse
- .apply_corroboration_boost(confidence:, weight: 1.0) ⇒ Object
- .apply_decay(confidence:, age_hours: nil, alpha: POWER_LAW_ALPHA) ⇒ Object
- .apply_retrieval_boost(confidence:) ⇒ Object
- .decayed?(confidence:) ⇒ Boolean
- .meets_write_gate?(confidence:, novelty:) ⇒ Boolean
Class Method Details
.apply_corroboration_boost(confidence:, weight: 1.0) ⇒ Object
36 37 38 |
# File 'lib/legion/extensions/apollo/helpers/confidence.rb', line 36 def apply_corroboration_boost(confidence:, weight: 1.0, **) [confidence + (CORROBORATION_BOOST * weight), 1.0].min end |
.apply_decay(confidence:, age_hours: nil, alpha: POWER_LAW_ALPHA) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/legion/extensions/apollo/helpers/confidence.rb', line 23 def apply_decay(confidence:, age_hours: nil, alpha: POWER_LAW_ALPHA, **) if age_hours [confidence * ((age_hours.clamp(0, Float::INFINITY) + 2.0)**(-alpha)) / ((age_hours.clamp(0, Float::INFINITY) + 1.0)**(-alpha)), 0.0].max else factor = 1.0 / (1.0 + alpha) [confidence * factor, 0.0].max end end |
.apply_retrieval_boost(confidence:) ⇒ Object
32 33 34 |
# File 'lib/legion/extensions/apollo/helpers/confidence.rb', line 32 def apply_retrieval_boost(confidence:, **) [confidence + RETRIEVAL_BOOST, 1.0].min end |
.decayed?(confidence:) ⇒ Boolean
40 41 42 |
# File 'lib/legion/extensions/apollo/helpers/confidence.rb', line 40 def decayed?(confidence:, **) confidence < DECAY_THRESHOLD end |
.meets_write_gate?(confidence:, novelty:) ⇒ Boolean
44 45 46 |
# File 'lib/legion/extensions/apollo/helpers/confidence.rb', line 44 def meets_write_gate?(confidence:, novelty:, **) confidence > WRITE_CONFIDENCE_GATE && novelty > WRITE_NOVELTY_GATE end |