Load a tokenizer from files. Args: name: Name of the tokenizer vocab_file: Path to vocabulary file pattern: Regex pattern for text splitting special_tokens_file: Optional path to special tokens file Returns: Initialized Tokenizer instance
(
name: str,
vocab_file: str | Path,
pattern: str,
special_tokens_file: str | Path | None = None,
)
| 331 | # ==================== |
| 332 | |
| 333 | def load_tokenizer( |
| 334 | name: str, |
| 335 | vocab_file: str | Path, |
| 336 | pattern: str, |
| 337 | special_tokens_file: str | Path | None = None, |
| 338 | ) -> Tokenizer: |
| 339 | """Load a tokenizer from files. |
| 340 | |
| 341 | Args: |
| 342 | name: Name of the tokenizer |
| 343 | vocab_file: Path to vocabulary file |
| 344 | pattern: Regex pattern for text splitting |
| 345 | special_tokens_file: Optional path to special tokens file |
| 346 | |
| 347 | Returns: |
| 348 | Initialized Tokenizer instance |
| 349 | """ |
| 350 | return Tokenizer( |
| 351 | name=name, |
| 352 | pattern=pattern, |
| 353 | vocab_file=vocab_file, |
| 354 | special_tokens_file=special_tokens_file, |
| 355 | ) |
| 356 | |
| 357 | |
| 358 | def create_tokenizer( |