Class: Toy::Core::CLI::Describe
- Inherits:
-
Object
- Object
- Toy::Core::CLI::Describe
- Defined in:
- lib/toy/core/cli/describe.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Describe
constructor
A new instance of Describe.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Describe
Returns a new instance of Describe.
26 27 28 29 30 |
# File 'lib/toy/core/cli/describe.rb', line 26 def initialize(argv) @argv = argv @json = false @model = nil end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/toy/core/cli/describe.rb', line 32 def run return EXIT_BAD_INPUT unless parse_args path = File.(@model) unless File.file?(path) return fail_out("no such file: #{path}") end begin = GGUFMeta.read(path) rescue GGUFMeta::ParseError => e return fail_out("could not parse GGUF: #{e.}") end arch = ModelScan.read_arch() if arch.nil? return fail_out("#{path}: no recognizable transformer arch metadata in GGUF") end # `describe` renders the toy's llama-family Card (GQA + SwiGLU + # RoPE). Other arches (gpt2, gemma2, olmoe, ...) are genuinely # different — decline rather than render a confident wrong card. unless [:llama, :qwen2].include?(arch[:family]) return fail_out( "#{path}: #{arch[:family]} model — `toy describe` renders the " \ "llama-family Card (llama/qwen2) only; #{arch[:family]} has a " \ "different architecture. Read dims: V=#{arch[:vocab]} " \ "D=#{arch[:d_model]} L=#{arch[:n_layers]} n_q=#{arch[:n_q]} " \ "n_kv=#{arch[:n_kv]} d_ff=#{arch[:d_ff]}.") end arch[:n_params] = ModelScan.estimate_params(arch) if @json emit_json(path, arch) else emit_human(path, arch) end EXIT_OK end |