Method: Informers::ZeroShotClassificationPipeline#initialize

Defined in:
lib/informers/pipelines.rb

#initialize(**options) ⇒ ZeroShotClassificationPipeline

Returns a new instance of ZeroShotClassificationPipeline.



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/informers/pipelines.rb', line 407

def initialize(**options)
  super(**options)

  @label2id = @model.config[:label2id].transform_keys(&:downcase)

  @entailment_id = @label2id["entailment"]
  if @entailment_id.nil?
    warn "Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."
    @entailment_id = 2
  end

  @contradiction_id = @label2id["contradiction"] || @label2id["not_entailment"]
  if @contradiction_id.nil?
    warn "Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."
    @contradiction_id = 0
  end
end