MCPcopy Create free account
hub / github.com/Gadersd/stable-diffusion-burn / get_pairs

Function get_pairs

python/dump.py:461–470  ·  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

459 return Path(__file__).parent.parent / "weights/bpe_simple_vocab_16e6.txt.gz"
460
461def get_pairs(word):
462 """Return set of symbol pairs in a word.
463 Word is represented as tuple of symbols (symbols being variable-length strings).
464 """
465 pairs = set()
466 prev_char = word[0]
467 for char in word[1:]:
468 pairs.add((prev_char, char))
469 prev_char = char
470 return pairs
471
472def whitespace_clean(text):
473 text = re.sub(r'\s+', ' ', text)

Callers 1

bpeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected