Download maketoken1.py from HDTenEightyP/GPT-FFDNET: direct link, hf CLI and curl.
- Browser
- Download file 405 Bytes
-
https://huggingface.co/HDTenEightyP/GPT-FFDNET/resolve/main/maketoken1.py
- Command line
-
hf download hf://HDTenEightyP/GPT-FFDNET/maketoken1.py
-
curl -L -o maketoken1.py https://huggingface.co/HDTenEightyP/GPT-FFDNET/resolve/main/maketoken1.py
405 Bytes
| from pathlib import Path | |
| import tiktoken | |
| from transformers.integrations.tiktoken import convert_tiktoken_to_fast | |
| # Load the tiktoken encoding | |
| encoding = tiktoken.get_encoding("cl100k_base") | |
| # Output directory | |
| out_dir = Path("hf_tokenizer") | |
| out_dir.mkdir(exist_ok=True) | |
| # Generate tokenizer.json | |
| convert_tiktoken_to_fast( | |
| encoding, | |
| str(out_dir), | |
| ) | |
| print(f"Saved {out_dir / 'tokenizer.json'}") | |