public List ConvertIdsToTokens()

in Runtime/Tokenizers/Tokenizers/Tokenizers.cs [296:305]


        public List<string> ConvertIdsToTokens(List<int> ids)
        {
            /*
             Select is used instead of map to transform the list of IDs into a list of tokens.
            The conditional operator (? :) is used to check if the ID is within the valid range of the vocab array. If it is, the code retrieves the corresponding token using this.vocab[i]. If the token is null, it uses this.unk_token as the default value.
            The resulting list of tokens is returned.
            */
            List<string> tokens = ids.Select(i => Vocab.Count > i ? Vocab[i] ?? UnkToken : UnkToken).ToList();
            return tokens;
        }