Encode text into token IDs. Args: content: Input text string. Returns: List of token IDs.
(self, content: str)
| 17 | self.tokenizer = AutoTokenizer.from_pretrained(model_id) |
| 18 | |
| 19 | def encode(self, content: str) -> List[int]: |
| 20 | """Encode text into token IDs. |
| 21 | |
| 22 | Args: |
| 23 | content: Input text string. |
| 24 | |
| 25 | Returns: |
| 26 | List of token IDs. |
| 27 | """ |
| 28 | if not content.strip(): |
| 29 | return [] |
| 30 | return self.tokenizer.encode(content.strip()) |
| 31 | |
| 32 | def decode(self, token_ids: List[int]) -> str: |
| 33 | """Decode a list of token IDs back into a natural text string. |
no outgoing calls
no test coverage detected