CSS-LM
76 строк · 2.5 Кб
1# coding=utf-8
2# Copyright 2018 The HuggingFace Inc. team.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15"""Tokenization classes for RetriBERT."""
16
17
18import logging
19
20from .tokenization_bert import BertTokenizer, BertTokenizerFast
21
22
23logger = logging.getLogger(__name__)
24
25VOCAB_FILES_NAMES = {"vocab_file": "vocab.txt"}
26
27PRETRAINED_VOCAB_FILES_MAP = {
28"vocab_file": {
29"yjernite/retribert-base-uncased": "https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt",
30}
31}
32
33PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {
34"yjernite/retribert-base-uncased": 512,
35}
36
37
38PRETRAINED_INIT_CONFIGURATION = {
39"yjernite/retribert-base-uncased": {"do_lower_case": True},
40}
41
42
43class RetriBertTokenizer(BertTokenizer):
44r"""
45Constructs a retribert.
46
47:class:`~transformers.retribert is identical to :class:`~transformers.BertTokenizer` and runs end-to-end
48tokenization: punctuation splitting + wordpiece.
49
50Refer to superclass :class:`~transformers.BertTokenizer` for usage examples and documentation concerning
51parameters.
52"""
53
54vocab_files_names = VOCAB_FILES_NAMES
55pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
56max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
57pretrained_init_configuration = PRETRAINED_INIT_CONFIGURATION
58model_input_names = ["attention_mask"]
59
60
61class RetriBertTokenizerFast(BertTokenizerFast):
62r"""
63Constructs a "Fast" RetriBertTokenizerFast (backed by HuggingFace's `tokenizers` library).
64
65:class:`~transformers.RetriBertTokenizerFast` is identical to :class:`~transformers.BertTokenizerFast` and runs end-to-end
66tokenization: punctuation splitting + wordpiece.
67
68Refer to superclass :class:`~transformers.BertTokenizerFast` for usage examples and documentation concerning
69parameters.
70"""
71
72vocab_files_names = VOCAB_FILES_NAMES
73pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
74max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
75pretrained_init_configuration = PRETRAINED_INIT_CONFIGURATION
76model_input_names = ["attention_mask"]
77