MCPcopy
hub / github.com/InternLM/lmdeploy / indexes_containing_token

Method indexes_containing_token

lmdeploy/tokenizer.py:542–550  ·  view source on GitHub ↗

Return all the possible indexes, whose decoding output may contain the input token.

(self, token)

Source from the content-addressed store, hash-verified

540 return self.model(s)
541
542 def indexes_containing_token(self, token):
543 """Return all the possible indexes, whose decoding output may contain
544 the input token."""
545 encoded = self.encode(token, add_bos=False)
546 if len(encoded) > 1:
547 self.logger.warning(f'The token {token}, its length of indexes {encoded} is over '
548 'than 1. Currently, it can not be used as stop words')
549 return []
550 return self.model.indexes_containing_token(token)

Callers 2

_stop_wordsFunction · 0.45

Calls 1

encodeMethod · 0.95

Tested by

no test coverage detected