MCPcopy Create free account
hub / github.com/OpenMOSS/MOSS / get_pairs

Function get_pairs

models/tokenization_moss.py:86–97  ·  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

84
85
86def get_pairs(word):
87 """
88 Return set of symbol pairs in a word.
89
90 Word is represented as tuple of symbols (symbols being variable-length strings).
91 """
92 pairs = set()
93 prev_char = word[0]
94 for char in word[1:]:
95 pairs.add((prev_char, char))
96 prev_char = char
97 return pairs
98
99
100class MossTokenizer(PreTrainedTokenizer):

Callers 1

bpeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected