Class: LLaMACpp::Model

Inherits:
Object
  • Object
show all
Defined in:
ext/llama_cpp/dummy.rb

Overview

Class for model

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_path: nil, params: nil) ⇒ Model

Create model.

Parameters:

  • model_path (String) (defaults to: nil)

    The path to the model file.

  • params (ModelParams) (defaults to: nil)

    The parameters for context.



457
# File 'ext/llama_cpp/dummy.rb', line 457

def initialize(model_path: nil, params: nil); end

Instance Attribute Details

#paramsModelParams (readonly)

Returns the model.

Returns:



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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


579
# File 'ext/llama_cpp/dummy.rb', line 579

def add_eos_token?; end

#decoder_start_tokenInteger

Returns the token id that must be provided to the decoder to start generating output sequence for encoder-decoder model.

Returns:

  • (Integer)


619
# File 'ext/llama_cpp/dummy.rb', line 619

def decoder_start_token; end

#descString

Returns the model type.

Returns:

  • (String)


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.

Parameters:

  • tokens (Array<Integer>)

    The tokens.

  • remove_special (Boolean) (defaults to: false)

    The flag whether to allow removing BOS and EOS tokens.

  • unparse_special (Boolean) (defaults to: false)

    The flag whether to render special tokens in the output.

Returns:

  • (String)


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.

Returns:

  • (Boolean)


462
# File 'ext/llama_cpp/dummy.rb', line 462

def empty?; end

#freeNilClass

Deallocates model.

Returns:

  • (NilClass)


467
# File 'ext/llama_cpp/dummy.rb', line 467

def free; end

#has_decoder?Boolean

Returns whether the model contains a decoder.

Returns:

  • (Boolean)


615
# File 'ext/llama_cpp/dummy.rb', line 615

def has_decoder?; end

#has_encoder?Boolean

Returns whether the model contains an encoder.

Returns:

  • (Boolean)


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.).

Returns:

  • (Boolean)


623
# File 'ext/llama_cpp/dummy.rb', line 623

def is_recurrent?; end

#load(model_path:, params:) ⇒ Object

Loads model.

Parameters:

  • model_path (String)

    The path to the model file.

  • params (ModelParams)

    The parameters for context.



473
# File 'ext/llama_cpp/dummy.rb', line 473

def load(model_path:, params:); end

#n_ctx_trainInteger

Returns the number of context of training.

Returns:

  • (Integer)


489
# File 'ext/llama_cpp/dummy.rb', line 489

def n_ctx_train; end

#n_embdInteger

Returns the number of embedding.

Returns:

  • (Integer)


493
# File 'ext/llama_cpp/dummy.rb', line 493

def n_embd; end

#n_layerInteger

Returns the number of layers.

Returns:

  • (Integer)


497
# File 'ext/llama_cpp/dummy.rb', line 497

def n_layer; end

#n_paramsInteger

Returns the number of parameters in the model

Returns:

  • (Integer)


529
# File 'ext/llama_cpp/dummy.rb', line 529

def n_params; end

#n_vocabInteger

Returns the number of vocabulary.

Returns:

  • (Integer)


485
# File 'ext/llama_cpp/dummy.rb', line 485

def n_vocab; end

#rope_freq_scale_trainFloat

Returns the model’s RoPE frequency scaling factor.

Returns:

  • (Float)


501
# File 'ext/llama_cpp/dummy.rb', line 501

def rope_freq_scale_train; end

#rope_typeInteger

Returns the RoPE type.

Returns:

  • (Integer)


481
# File 'ext/llama_cpp/dummy.rb', line 481

def rope_type; end

#score(token_id) ⇒ Float

Returns the score of token.

Parameters:

  • token_id (Integer)

Returns:

  • (Float)


541
# File 'ext/llama_cpp/dummy.rb', line 541

def score(token_id); end

#sizeInteger

Returns the total size of all the tensors in the model in bytes

Returns:

  • (Integer)


525
# File 'ext/llama_cpp/dummy.rb', line 525

def size; end

#text(token_id) ⇒ String

Returns the text of token.

Parameters:

  • token_id (Integer)

Returns:

  • (String)


535
# File 'ext/llama_cpp/dummy.rb', line 535

def text(token_id); end

#token_attr(token_id) ⇒ Integer

Returns the attribute of token.

Parameters:

  • token_id (Integer)

Returns:

  • (Integer)


547
# File 'ext/llama_cpp/dummy.rb', line 547

def token_attr(token_id); end

#token_bosInteger

Returns the token id the beginning of sentence token.

Returns:

  • (Integer)


551
# File 'ext/llama_cpp/dummy.rb', line 551

def token_bos; end

#token_clsInteger

Returns the token id the classification token.

Returns:

  • (Integer)


559
# File 'ext/llama_cpp/dummy.rb', line 559

def token_cls; end

#token_eosInteger

Returns the token id the end of sentence token.

Returns:

  • (Integer)


555
# File 'ext/llama_cpp/dummy.rb', line 555

def token_eos; end

#token_eotInteger

Returns the token id for end of infill middle.

Returns:

  • (Integer)


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.

Parameters:

  • token (Integer)

    The token id.

Returns:

  • (Boolean)


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.

Parameters:

  • token (Integer)

    The token id.

Returns:

  • (Boolean)


601
# File 'ext/llama_cpp/dummy.rb', line 601

def token_is_eog?(token); end

#token_middleInteger

Returns the token id for beginning of infill middle.

Returns:

  • (Integer)


587
# File 'ext/llama_cpp/dummy.rb', line 587

def token_middle; end

#token_nlInteger

Returns the token id the new line token.

Returns:

  • (Integer)


567
# File 'ext/llama_cpp/dummy.rb', line 567

def token_nl; end

#token_padInteger

Returns the token id the padding token.

Returns:

  • (Integer)


571
# File 'ext/llama_cpp/dummy.rb', line 571

def token_pad; end

#token_prefixInteger

Returns the token id for beginning of infill prefix.

Returns:

  • (Integer)


583
# File 'ext/llama_cpp/dummy.rb', line 583

def token_prefix; end

#token_sepInteger

Returns the token id the sentence separator token.

Returns:

  • (Integer)


563
# File 'ext/llama_cpp/dummy.rb', line 563

def token_sep; end

#token_suffixInteger

Returns the token id for beginning of infill suffix.

Returns:

  • (Integer)


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.

Parameters:

  • token (Integer)

    The token to be converted.

  • lstrip (Integer) (defaults to: 0)

    The number allows the user to skip up to ‘lstrip’ leading spaces before copying.

  • special (Boolean) (defaults to: false)

    The flag whether to allow rendering special tokens in the output.

Returns:

  • (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.

Parameters:

  • text (String)

    The text to be tokenized.

  • n_max_tokens (Integer)

    The maximum number of tokens.

  • add_bos (Boolean) (defaults to: false)

    The flag to add the beginning of sentence token.

  • special (Boolean) (defaults to: false)

    The flag to allow tokenizing special and/or control tokens.

Returns:

  • (Array<Integer>)


517
# File 'ext/llama_cpp/dummy.rb', line 517

def tokenize(text:, n_max_tokens:, add_bos: false, special: false); end

#vocab_typeInteger

Returns the vocabulary type.

Returns:

  • (Integer)


477
# File 'ext/llama_cpp/dummy.rb', line 477

def vocab_type; end