Class: Candle::VLM

Inherits:
Object
  • Object
show all
Defined in:
lib/candle/vlm.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_pretrained(model_id, device: nil, **options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/candle/vlm.rb', line 6

def from_pretrained(model_id, device: nil, **options)
  device_obj = case device
               when "cpu" then Candle::Device.cpu
               when "metal" then Candle::Device.metal
               when "cuda" then Candle::Device.cuda
               when Candle::Device then device
               when nil then nil
               else Candle::Device.best
               end
  _create(model_id, device_obj)
end

Instance Method Details

#ask(image_path, question, max_length: 256) ⇒ Object



23
24
25
# File 'lib/candle/vlm.rb', line 23

def ask(image_path, question, max_length: 256)
  _ask(image_path, question, max_length)
end

#describe(image_path, max_length: 256) ⇒ Object



19
20
21
# File 'lib/candle/vlm.rb', line 19

def describe(image_path, max_length: 256)
  _describe(image_path, max_length)
end

#inspectObject



27
28
29
# File 'lib/candle/vlm.rb', line 27

def inspect
  "#<Candle::VLM model_id=#{model_id.inspect} device=#{device}>"
end