| 12 | |
| 13 | |
| 14 | class BaseLlamaTokenizer(abc.ABC): |
| 15 | @abc.abstractmethod |
| 16 | def tokenize( |
| 17 | self, text: bytes, add_bos: bool = True, special: bool = True |
| 18 | ) -> List[int]: |
| 19 | """Tokenize the text into tokens. |
| 20 | |
| 21 | Args: |
| 22 | text: The utf-8 encoded string to tokenize. |
| 23 | add_bos: Whether to add a beginning of sequence token. |
| 24 | special: Whether to tokenize special tokens. |
| 25 | """ |
| 26 | raise NotImplementedError |
| 27 | |
| 28 | @abc.abstractmethod |
| 29 | def detokenize( |
| 30 | self, |
| 31 | tokens: List[int], |
| 32 | prev_tokens: Optional[List[int]] = None, |
| 33 | special: bool = False, |
| 34 | ) -> bytes: |
| 35 | """Detokenize the tokens into text. |
| 36 | |
| 37 | Args: |
| 38 | tokens: The list of tokens to detokenize. |
| 39 | prev_tokens: The list of previous tokens. Offset mapping will be performed if provided. |
| 40 | special: Whether to detokenize special tokens. |
| 41 | """ |
| 42 | raise NotImplementedError |
| 43 | |
| 44 | |
| 45 | class LlamaTokenizer(BaseLlamaTokenizer): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…