Class: ModelEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/toy/io/model_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path, family, n_params, size_b, source) ⇒ ModelEntry

Returns a new instance of ModelEntry.



35
36
37
38
39
40
41
42
# File 'lib/toy/io/model_index.rb', line 35

def initialize(name, path, family, n_params, size_b, source)
  @name = name
  @path = path
  @family = family
  @n_params = n_params
  @size_b = size_b
  @source = source
end

Instance Attribute Details

#familyObject (readonly)

:qwen2 / :llama / etc. (from Arch.from_gguf)



30
31
32
# File 'lib/toy/io/model_index.rb', line 30

def family
  @family
end

#n_paramsObject (readonly)

approx parameter count



31
32
33
# File 'lib/toy/io/model_index.rb', line 31

def n_params
  @n_params
end

#nameObject (readonly)

friendly name shown to the user



28
29
30
# File 'lib/toy/io/model_index.rb', line 28

def name
  @name
end

#pathObject (readonly)

absolute path to the GGUF



29
30
31
# File 'lib/toy/io/model_index.rb', line 29

def path
  @path
end

#size_bObject (readonly)

file size in bytes



32
33
34
# File 'lib/toy/io/model_index.rb', line 32

def size_b
  @size_b
end

#sourceObject (readonly)

“hf”, “ollama”, “lmstudio”, “local”



33
34
35
# File 'lib/toy/io/model_index.rb', line 33

def source
  @source
end

Instance Method Details

#params_summaryObject



44
45
46
47
48
49
50
51
52
# File 'lib/toy/io/model_index.rb', line 44

def params_summary
  if @n_params >= 1_000_000_000
    ((@n_params.to_f / 1_000_000_000.0 * 10.0).round.to_f / 10.0).to_s + "B"
  elsif @n_params >= 1_000_000
    (@n_params / 1_000_000).to_s + "M"
  else
    @n_params.to_s
  end
end

#size_summaryObject



54
55
56
57
58
59
60
# File 'lib/toy/io/model_index.rb', line 54

def size_summary
  if @size_b >= 1_000_000_000
    ((@size_b.to_f / 1_000_000_000.0 * 10.0).round.to_f / 10.0).to_s + " GB"
  else
    (@size_b / 1_000_000).to_s + " MB"
  end
end