Download stackgo/stackbuild/tokenizer.py from s0duku/the-stack-go: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/datasets/s0duku/the-stack-go/resolve/main/stackgo/stackbuild/tokenizer.py
- Command line
-
hf download hf://datasets/s0duku/the-stack-go/stackgo/stackbuild/tokenizer.py
-
curl -L -o tokenizer.py https://huggingface.co/datasets/s0duku/the-stack-go/resolve/main/stackgo/stackbuild/tokenizer.py
1.27 kB
| """DeepSeek V4 Flash tokenizer defaults.""" | |
| from __future__ import annotations | |
| from functools import lru_cache | |
| import os | |
| from pathlib import Path | |
| DEFAULT_TOKENIZER_ID = "deepseek-ai/DeepSeek-V4-Flash-Base" | |
| DEFAULT_TOKENIZER_REVISION = "8855555deef230a27a21a8d6f294b7b7497759b6" | |
| def load_tokenizer(name_or_path: str = DEFAULT_TOKENIZER_ID, *, local_files_only: bool = False): | |
| from transformers import AutoTokenizer | |
| requested = name_or_path | |
| if requested == DEFAULT_TOKENIZER_ID: | |
| candidates = [ | |
| Path(os.environ["STACKBUILD_TOKENIZER_PATH"]).expanduser() | |
| if "STACKBUILD_TOKENIZER_PATH" in os.environ else None, | |
| Path(__file__).resolve().parents[2] / "tokenizers" / "deepseek-v4-flash-base", | |
| ] | |
| local = next((path for path in candidates if path is not None and path.is_dir()), None) | |
| source = str(local) if local is not None else requested | |
| else: | |
| source = str(Path(requested).expanduser()) if Path(requested).exists() else requested | |
| kwargs = {"use_fast": True, "local_files_only": local_files_only} | |
| if source == DEFAULT_TOKENIZER_ID: | |
| kwargs["revision"] = DEFAULT_TOKENIZER_REVISION | |
| return AutoTokenizer.from_pretrained(source, **kwargs) | |