MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / get_pairs

Function get_pairs

codegeex/megatron/tokenizer/gpt2_tokenization.py:81–91  ·  view source on GitHub ↗

Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).

(word)

Source from the content-addressed store, hash-verified

79
80
81def get_pairs(word):
82 """Return set of symbol pairs in a word.
83
84 Word is represented as tuple of symbols (symbols being variable-length strings).
85 """
86 pairs = set()
87 prev_char = word[0]
88 for char in word[1:]:
89 pairs.add((prev_char, char))
90 prev_char = char
91 return pairs
92
93
94class GPT2Tokenizer(object):

Callers 1

bpeMethod · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected