Skip to content

Refactor Tokenizer -> BaseTokenizer #1333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/docker/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pytest==7.3.2
pytest-cov
pre-commit
tomli-w >= 1.1.0
transformers
2 changes: 0 additions & 2 deletions .ci/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ torchdata >= 0.8.0
datasets >= 3.6.0
tomli >= 1.1.0 ; python_version < "3.11"
tensorboard
tiktoken
blobfile
tabulate
wandb
fsspec
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ We actively welcome your pull requests.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints (`pre-commit run --all-files`).
5. Make sure your code lints (`pre-commit run --files $(git diff --name-only HEAD~1)`).
6. If you haven't already, complete the Contributor License Agreement ("CLA").

### Contributor License Agreement ("CLA")
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ dependencies = [
"datasets>=2.21.0",

# Tokenization
"blobfile",
"tiktoken",
"tokenizers",

# Miscellaneous
"tomli>=1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/download_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def is_tokenizer_file(filename: str) -> bool:
print(f"Successfully downloaded {filename} to {file_path}")
downloaded_files.append(filename)
except HTTPError as e:
if e.response.status_code == 404:
if e.response and e.response.status_code == 404:
print(f"File {filename} not found, skipping...")
continue
else:
Expand All @@ -122,7 +122,7 @@ def is_tokenizer_file(filename: str) -> bool:
print(f"Warning: No tokenizer files could be downloaded from {repo_id}")

except HTTPError as e:
if e.response.status_code == 401:
if e.response and e.response.status_code == 401:
print(
"You need to pass a valid `--hf_token=...` to download private checkpoints."
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_generate(
input_ids = (
(
torch.tensor(
tokenizer.encode(prompt, bos=True, eos=False), dtype=torch.long
tokenizer.encode(prompt, add_bos=True, add_eos=False), dtype=torch.long
)
.view(1, -1)
.repeat(batch_size, 1)
Expand Down
Loading
Loading