encode_bpe

Encode text to token IDs

Description

Encode text to token IDs

Usage

encode_bpe(tokenizer, text, add_special_tokens = TRUE, max_length = NULL,
           padding = "none", truncation = FALSE, return_tensors = "list")

Arguments

  • tokenizer: A bpe_tokenizer object.
  • text: Character string or vector to encode.
  • add_special_tokens: Logical. Add BOS/EOS tokens.
  • max_length: Integer. Maximum sequence length (NULL for no limit).
  • padding: Character. Padding strategy: “none”, “max_length”, or “longest”.
  • truncation: Logical. Truncate to max_length.
  • return_tensors: Character. Return type: “list” or “pt” (torch tensors).

Value

List with input_ids and attention_mask.