Skip to content

Commit

Permalink
Patch recursive import (huggingface#11812)
Browse files Browse the repository at this point in the history
  • Loading branch information
LysandreJik committed May 21, 2021
1 parent bd98716 commit 1b65229
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/transformers/convert_slow_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from tokenizers.models import BPE, Unigram, WordPiece

from .file_utils import requires_backends
from .models.roformer.tokenization_utils import JiebaPreTokenizer


class SentencePieceExtractor:
Expand Down Expand Up @@ -299,6 +298,8 @@ def converted(self) -> Tokenizer:

class RoFormerConverter(Converter):
def converted(self) -> Tokenizer:
from .models.roformer.tokenization_utils import JiebaPreTokenizer

vocab = self.original_tokenizer.vocab
tokenizer = Tokenizer(WordPiece(vocab, unk_token=str(self.original_tokenizer.unk_token)))

Expand Down
7 changes: 6 additions & 1 deletion tests/test_tokenization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
isort:skip_file
"""
import os
import pickle
import tempfile
Expand All @@ -20,12 +23,14 @@

import numpy as np

# Ensure there are no circular imports when importing the parent class
from transformers import PreTrainedTokenizerFast

from transformers import (
BatchEncoding,
BertTokenizer,
BertTokenizerFast,
PreTrainedTokenizer,
PreTrainedTokenizerFast,
TensorType,
TokenSpan,
is_tokenizers_available,
Expand Down

0 comments on commit 1b65229

Please sign in to comment.