MCPcopy Create free account
hub / github.com/ankane/tokenizers-ruby / test_encode_add_special_tokens

Method test_encode_add_special_tokens

test/tokenizer_test.rb:69–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 end
68
69 def test_encode_add_special_tokens
70 tokenizer = Tokenizers.from_pretrained("bert-base-cased")
71
72 # encode
73 encoded = tokenizer.encode("I can feel the magic, can you?", add_special_tokens: false)
74 expected_ids = [146, 1169, 1631, 1103, 3974, 117, 1169, 1128, 136]
75 expected_tokens = ["I", "can", "feel", "the", "magic", ",", "can", "you", "?"]
76 assert_equal expected_ids, encoded.ids
77 assert_equal expected_tokens, encoded.tokens
78
79 # decode
80 assert_equal "I can feel the magic, can you?", tokenizer.decode(encoded.ids)
81 end
82
83 def test_encode_multibyte_offsets
84 tokenizer = Tokenizers.from_pretrained("gpt2")

Callers

nothing calls this directly

Calls 3

from_pretrainedMethod · 0.45
encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected