MCPcopy Create free account
hub / github.com/SooLab/CGFormer / _tokens_match

Function _tokens_match

bert/generation_utils.py:874–886  ·  view source on GitHub ↗
(prev_tokens, tokens)

Source from the content-addressed store, hash-verified

872 banned_tokens = []
873
874 def _tokens_match(prev_tokens, tokens):
875 if len(tokens) == 0:
876 # if bad word tokens is just one token always ban it
877 return True
878 if len(tokens) > len(prev_input_ids):
879 # if bad word tokens are longer then prev input_ids they can't be equal
880 return False
881
882 if prev_tokens[-len(tokens) :] == tokens:
883 # if tokens match
884 return True
885 else:
886 return False
887
888 for prev_input_ids_slice in prev_input_ids:
889 banned_tokens_slice = []

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected