Class: Xberg::VlmFallbackPolicyOnLowQuality

Inherits:
Data
  • Object
show all
Extended by:
T::Sig
Includes:
VlmFallbackPolicy
Defined in:
lib/xberg/native.rb

Overview

Try the classical OCR backend first. If the quality score is below quality_threshold, send the page to the VLM.

quality_threshold is in the [0.0, 1.0] range, but it is not the same quantity reported on score (GH#1584). The accept decision blends text-shape quality with confidence, weighted 0.7/0.3 (extractors::pdf::ocr::pipeline_stage_score) -- when the backend's confidence is on a known scale it contributes only 30% of the compared score, so a page can clear this threshold on clean-looking text even while its own PageOcrConfidence.score reads below it. Do not calibrate this value by reading PageOcrConfidence.score off a sample page and expecting an equal quality_threshold to reproduce the same accept/reject outcome. A value of 0.5 is a reasonable starting point; calibrate with the Stage 0 benchmark harness.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#quality_thresholdObject (readonly)

Returns the value of attribute quality_threshold



5192
5193
5194
# File 'lib/xberg/native.rb', line 5192

def quality_threshold
  @quality_threshold
end

Class Method Details

.from_hash(hash) ⇒ Object



5210
5211
5212
# File 'lib/xberg/native.rb', line 5210

def self.from_hash(hash)
  new(quality_threshold: hash[:quality_threshold] || hash["quality_threshold"])
end

Instance Method Details

#always?Boolean



5206
5207
5208
# File 'lib/xberg/native.rb', line 5206

def always? = false
# @param hash [Hash] deserialized from the native extension
# @return [self]

#disabled?Boolean



5202
# File 'lib/xberg/native.rb', line 5202

def disabled? = false

#on_low_quality?Boolean



5204
# File 'lib/xberg/native.rb', line 5204

def on_low_quality? = true