Class: StaticEmbeddings::CLI
- Inherits:
-
Object
- Object
- StaticEmbeddings::CLI
- Defined in:
- lib/static_embeddings/cli.rb
Constant Summary collapse
- COMMANDS =
{ "convert" => :convert, "verify" => :verify, "inspect" => :inspect_model, "tokenize" => :tokenize, "embed" => :embed, "cache-path" => :cache_path, "help" => :usage, "-h" => :usage, "--help" => :usage, nil => :usage }.freeze
- HELP =
<<~TEXT static_embeddings <command> [options] convert SOURCE_DIR Convert a HuggingFace/Model2Vec directory to .semb --out PATH Output file (default: <cache>/models/<id>.semb) --id ID Model id recorded in provenance --max-tokens N Truncation limit baked into the file (default 512) verify PATH Recompute the SHA-256 embedded in the header inspect PATH Print header fields and provenance tokenize PATH TEXT Print token ids embed PATH TEXT Print the vector, token count and UNK ratio cache-path Print the model cache directory TEXT
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run(argv) ⇒ Object
35 36 37 |
# File 'lib/static_embeddings/cli.rb', line 35 def self.run(argv) new.run(argv) end |
Instance Method Details
#run(argv) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/static_embeddings/cli.rb', line 39 def run(argv) method = COMMANDS[argv.shift] return unknown unless method send(method, argv) rescue StaticEmbeddings::Error => e warn "#{e.class.name.split('::').last}: #{e.}" 1 end |