increment_list_index: Convert from Python Standard to torch

View source: R/tokenize.R

increment_list_indexR Documentation

Convert from Python Standard to torch

Description

The torch R package uses the R standard of starting counts at 1. Many tokenizers use the Python standard of starting counts at 0. This function converts a list of token ids provided by such a tokenizer to torch-friendly values (by adding 1 to each id).

Usage

increment_list_index(list_of_integers)

Value

The list of integers, with 1 added to each integer.

Examples

increment_list_index(
  list(
    1:5,
    2:6,
    3:7
  )
)

macmillancontentscience/torchtransformers documentation built on Aug. 6, 2023, 5:35 a.m.