Class: LLaMACpp::Model
- Inherits:
-
Object
- Object
- LLaMACpp::Model
- Defined in:
- ext/llama_cpp/dummy.rb
Overview
Class for model
Instance Attribute Summary collapse
-
#params ⇒ ModelParams
readonly
Returns the model.
Instance Method Summary collapse
-
#add_bos_token? ⇒ Boolean
Returns the flag to add the beginning of sentence token.
-
#add_eos_token? ⇒ Boolean
Returns the flag to add the end of sentence token.
-
#decoder_start_token ⇒ Integer
Returns the token id that must be provided to the decoder to start generating output sequence for encoder-decoder model.
-
#desc ⇒ String
Returns the model type.
-
#detokenize(tokens, remove_special: false, unparse_special: false) ⇒ String
Returns the text that is converted from the given tokens.
-
#empty? ⇒ Boolean
Returns whether the model is not loaded.
-
#free ⇒ NilClass
Deallocates model.
-
#has_decoder? ⇒ Boolean
Returns whether the model contains a decoder.
-
#has_encoder? ⇒ Boolean
Returns whether the model contains an encoder.
-
#initialize(model_path: nil, params: nil) ⇒ Model
constructor
Create model.
-
#is_recurrent? ⇒ Boolean
Returns whether the model is recurrent (like Mamba, RWKV, etc.).
-
#load(model_path:, params:) ⇒ Object
Loads model.
-
#n_ctx_train ⇒ Integer
Returns the number of context of training.
-
#n_embd ⇒ Integer
Returns the number of embedding.
-
#n_layer ⇒ Integer
Returns the number of layers.
-
#n_params ⇒ Integer
Returns the number of parameters in the model.
-
#n_vocab ⇒ Integer
Returns the number of vocabulary.
-
#rope_freq_scale_train ⇒ Float
Returns the model’s RoPE frequency scaling factor.
-
#rope_type ⇒ Integer
Returns the RoPE type.
-
#score(token_id) ⇒ Float
Returns the score of token.
-
#size ⇒ Integer
Returns the total size of all the tensors in the model in bytes.
-
#text(token_id) ⇒ String
Returns the text of token.
-
#token_attr(token_id) ⇒ Integer
Returns the attribute of token.
-
#token_bos ⇒ Integer
Returns the token id the beginning of sentence token.
-
#token_cls ⇒ Integer
Returns the token id the classification token.
-
#token_eos ⇒ Integer
Returns the token id the end of sentence token.
-
#token_eot ⇒ Integer
Returns the token id for end of infill middle.
-
#token_is_control?(token) ⇒ Boolean
Returns whether the token is control or render-able token.
-
#token_is_eog?(token) ⇒ Boolean
Returns whether the token is end-of-generation.
-
#token_middle ⇒ Integer
Returns the token id for beginning of infill middle.
-
#token_nl ⇒ Integer
Returns the token id the new line token.
-
#token_pad ⇒ Integer
Returns the token id the padding token.
-
#token_prefix ⇒ Integer
Returns the token id for beginning of infill prefix.
-
#token_sep ⇒ Integer
Returns the token id the sentence separator token.
-
#token_suffix ⇒ Integer
Returns the token id for beginning of infill suffix.
-
#token_to_piece(token, lstrip: 0, special: false) ⇒ String
Converts token to Ruby String.
-
#tokenize(text:, n_max_tokens:, add_bos: false, special: false) ⇒ Array<Integer>
Returns the logits.
-
#vocab_type ⇒ Integer
Returns the vocabulary type.
Constructor Details
#initialize(model_path: nil, params: nil) ⇒ Model
Create model.
457 |
# File 'ext/llama_cpp/dummy.rb', line 457 def initialize(model_path: nil, params: nil); end |
Instance Attribute Details
#params ⇒ ModelParams (readonly)
Returns the model.
451 452 453 |
# File 'ext/llama_cpp/dummy.rb', line 451 def params @params end |
Instance Method Details
#add_bos_token? ⇒ Boolean
Returns the flag to add the beginning of sentence token.
575 |
# File 'ext/llama_cpp/dummy.rb', line 575 def add_bos_token?; end |
#add_eos_token? ⇒ Boolean
Returns the flag to add the end of sentence token.
579 |
# File 'ext/llama_cpp/dummy.rb', line 579 def add_eos_token?; end |
#decoder_start_token ⇒ Integer
Returns the token id that must be provided to the decoder to start generating output sequence for encoder-decoder model.
619 |
# File 'ext/llama_cpp/dummy.rb', line 619 def decoder_start_token; end |
#desc ⇒ String
Returns the model type.
521 |
# File 'ext/llama_cpp/dummy.rb', line 521 def desc; end |
#detokenize(tokens, remove_special: false, unparse_special: false) ⇒ String
Returns the text that is converted from the given tokens.
631 |
# File 'ext/llama_cpp/dummy.rb', line 631 def detokenize(tokens, remove_special: false, unparse_special: false); end |
#empty? ⇒ Boolean
Returns whether the model is not loaded.
462 |
# File 'ext/llama_cpp/dummy.rb', line 462 def empty?; end |
#free ⇒ NilClass
Deallocates model.
467 |
# File 'ext/llama_cpp/dummy.rb', line 467 def free; end |
#has_decoder? ⇒ Boolean
Returns whether the model contains a decoder.
615 |
# File 'ext/llama_cpp/dummy.rb', line 615 def has_decoder?; end |
#has_encoder? ⇒ Boolean
Returns whether the model contains an encoder.
611 |
# File 'ext/llama_cpp/dummy.rb', line 611 def has_encoder?; end |
#is_recurrent? ⇒ Boolean
Returns whether the model is recurrent (like Mamba, RWKV, etc.).
623 |
# File 'ext/llama_cpp/dummy.rb', line 623 def is_recurrent?; end |
#load(model_path:, params:) ⇒ Object
Loads model.
473 |
# File 'ext/llama_cpp/dummy.rb', line 473 def load(model_path:, params:); end |
#n_ctx_train ⇒ Integer
Returns the number of context of training.
489 |
# File 'ext/llama_cpp/dummy.rb', line 489 def n_ctx_train; end |
#n_embd ⇒ Integer
Returns the number of embedding.
493 |
# File 'ext/llama_cpp/dummy.rb', line 493 def n_embd; end |
#n_layer ⇒ Integer
Returns the number of layers.
497 |
# File 'ext/llama_cpp/dummy.rb', line 497 def n_layer; end |
#n_params ⇒ Integer
Returns the number of parameters in the model
529 |
# File 'ext/llama_cpp/dummy.rb', line 529 def n_params; end |
#n_vocab ⇒ Integer
Returns the number of vocabulary.
485 |
# File 'ext/llama_cpp/dummy.rb', line 485 def n_vocab; end |
#rope_freq_scale_train ⇒ Float
Returns the model’s RoPE frequency scaling factor.
501 |
# File 'ext/llama_cpp/dummy.rb', line 501 def rope_freq_scale_train; end |
#rope_type ⇒ Integer
Returns the RoPE type.
481 |
# File 'ext/llama_cpp/dummy.rb', line 481 def rope_type; end |
#score(token_id) ⇒ Float
Returns the score of token.
541 |
# File 'ext/llama_cpp/dummy.rb', line 541 def score(token_id); end |
#size ⇒ Integer
Returns the total size of all the tensors in the model in bytes
525 |
# File 'ext/llama_cpp/dummy.rb', line 525 def size; end |
#text(token_id) ⇒ String
Returns the text of token.
535 |
# File 'ext/llama_cpp/dummy.rb', line 535 def text(token_id); end |
#token_attr(token_id) ⇒ Integer
Returns the attribute of token.
547 |
# File 'ext/llama_cpp/dummy.rb', line 547 def token_attr(token_id); end |
#token_bos ⇒ Integer
Returns the token id the beginning of sentence token.
551 |
# File 'ext/llama_cpp/dummy.rb', line 551 def token_bos; end |
#token_cls ⇒ Integer
Returns the token id the classification token.
559 |
# File 'ext/llama_cpp/dummy.rb', line 559 def token_cls; end |
#token_eos ⇒ Integer
Returns the token id the end of sentence token.
555 |
# File 'ext/llama_cpp/dummy.rb', line 555 def token_eos; end |
#token_eot ⇒ Integer
Returns the token id for end of infill middle.
595 |
# File 'ext/llama_cpp/dummy.rb', line 595 def token_eot; end |
#token_is_control?(token) ⇒ Boolean
Returns whether the token is control or render-able token.
607 |
# File 'ext/llama_cpp/dummy.rb', line 607 def token_is_control?(token); end |
#token_is_eog?(token) ⇒ Boolean
Returns whether the token is end-of-generation.
601 |
# File 'ext/llama_cpp/dummy.rb', line 601 def token_is_eog?(token); end |
#token_middle ⇒ Integer
Returns the token id for beginning of infill middle.
587 |
# File 'ext/llama_cpp/dummy.rb', line 587 def token_middle; end |
#token_nl ⇒ Integer
Returns the token id the new line token.
567 |
# File 'ext/llama_cpp/dummy.rb', line 567 def token_nl; end |
#token_pad ⇒ Integer
Returns the token id the padding token.
571 |
# File 'ext/llama_cpp/dummy.rb', line 571 def token_pad; end |
#token_prefix ⇒ Integer
Returns the token id for beginning of infill prefix.
583 |
# File 'ext/llama_cpp/dummy.rb', line 583 def token_prefix; end |
#token_sep ⇒ Integer
Returns the token id the sentence separator token.
563 |
# File 'ext/llama_cpp/dummy.rb', line 563 def token_sep; end |
#token_suffix ⇒ Integer
Returns the token id for beginning of infill suffix.
591 |
# File 'ext/llama_cpp/dummy.rb', line 591 def token_suffix; end |
#token_to_piece(token, lstrip: 0, special: false) ⇒ String
Converts token to Ruby String.
508 |
# File 'ext/llama_cpp/dummy.rb', line 508 def token_to_piece(token, lstrip: 0, special: false); end |
#tokenize(text:, n_max_tokens:, add_bos: false, special: false) ⇒ Array<Integer>
Returns the logits.
517 |
# File 'ext/llama_cpp/dummy.rb', line 517 def tokenize(text:, n_max_tokens:, add_bos: false, special: false); end |
#vocab_type ⇒ Integer
Returns the vocabulary type.
477 |
# File 'ext/llama_cpp/dummy.rb', line 477 def vocab_type; end |