CSS-LM

Форк
0
/
tokenization_retribert.py 
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

18
import logging
19

20
from .tokenization_bert import BertTokenizer, BertTokenizerFast
21

22

23
logger = logging.getLogger(__name__)
24

25
VOCAB_FILES_NAMES = {"vocab_file": "vocab.txt"}
26

27
PRETRAINED_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

33
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {
34
    "yjernite/retribert-base-uncased": 512,
35
}
36

37

38
PRETRAINED_INIT_CONFIGURATION = {
39
    "yjernite/retribert-base-uncased": {"do_lower_case": True},
40
}
41

42

43
class RetriBertTokenizer(BertTokenizer):
44
    r"""
45
    Constructs a  retribert.
46

47
    :class:`~transformers.retribert is identical to :class:`~transformers.BertTokenizer` and runs end-to-end
48
    tokenization: punctuation splitting + wordpiece.
49

50
    Refer to superclass :class:`~transformers.BertTokenizer` for usage examples and documentation concerning
51
    parameters.
52
    """
53

54
    vocab_files_names = VOCAB_FILES_NAMES
55
    pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
56
    max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
57
    pretrained_init_configuration = PRETRAINED_INIT_CONFIGURATION
58
    model_input_names = ["attention_mask"]
59

60

61
class RetriBertTokenizerFast(BertTokenizerFast):
62
    r"""
63
    Constructs 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
66
    tokenization: punctuation splitting + wordpiece.
67

68
    Refer to superclass :class:`~transformers.BertTokenizerFast` for usage examples and documentation concerning
69
    parameters.
70
    """
71

72
    vocab_files_names = VOCAB_FILES_NAMES
73
    pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
74
    max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
75
    pretrained_init_configuration = PRETRAINED_INIT_CONFIGURATION
76
    model_input_names = ["attention_mask"]
77

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.