Skip to content

Commit 9b75ef1

Browse files
author
Mark Lee
authored
Avoid a top-level import of tokenizers. (apple#935)
1 parent 9996f34 commit 9b75ef1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

axlearn/experiments/text/gpt/c4_trainer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
```
4141
"""
4242

43-
4443
from axlearn.common.config import InstantiableConfig, config_for_class, config_for_function
4544
from axlearn.common.input_lm import lm_text_preprocessor
4645
from axlearn.common.utils import get_data_dir

axlearn/experiments/text/gpt/vocabulary_fuji_v3.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import jax
1010
import numpy as np
1111
import tensorflow.compat.v2 as tf
12-
from tokenizers import Tokenizer
1312

1413
import axlearn.common.file_system as fs
1514
from axlearn.common.utils import get_data_dir
@@ -93,6 +92,10 @@ class FujiV3Vocabulary:
9392
"""
9493

9594
def __init__(self, filename: str):
95+
# Only require tokenizers if instantiating.
96+
# pylint: disable-next=import-outside-toplevel
97+
from tokenizers import Tokenizer
98+
9699
data_dir = get_data_dir()
97100
data_dir = (
98101
os.path.join(os.path.dirname(__file__), "..", "..", "..", "data")

0 commit comments

Comments
 (0)