repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
ConSERT | ConSERT-master/transformers/generation_utils.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors, Facebook AI Research authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the L... | 51,388 | 48.035305 | 246 | py |
ConSERT | ConSERT-master/transformers/modeling_xlm_roberta.py | # coding=utf-8
# Copyright 2019 Facebook AI Research and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Licens... | 5,815 | 36.522581 | 127 | py |
ConSERT | ConSERT-master/transformers/modeling_camembert.py | # coding=utf-8
# Copyright 2019 Inria, Facebook AI Research and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the... | 5,685 | 36.163399 | 120 | py |
ConSERT | ConSERT-master/transformers/modeling_flax_roberta.py | # coding=utf-8
# Copyright 2018 The Google Flax Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | 17,979 | 38.866962 | 127 | py |
ConSERT | ConSERT-master/transformers/convert_prophetnet_original_pytorch_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 7,181 | 43.06135 | 118 | py |
ConSERT | ConSERT-master/transformers/modeling_flax_utils.py | # coding=utf-8
# Copyright 2018 The Google Flax Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | 7,330 | 36.594872 | 116 | py |
ConSERT | ConSERT-master/transformers/integrations.py | # Integrations with other Python libraries
import math
import os
# Import 3rd-party integrations first:
try:
# Comet needs to be imported before any ML frameworks
import comet_ml # noqa: F401
# XXX: there should be comet_ml.ensure_configured(), like `wandb`, for now emulate it
comet_ml.Experiment(p... | 14,363 | 40.514451 | 130 | py |
ConSERT | ConSERT-master/transformers/convert_dpr_original_checkpoint_to_pytorch.py | import argparse
import collections
from pathlib import Path
import torch
from torch.serialization import default_restore_location
from transformers import BertConfig, DPRConfig, DPRContextEncoder, DPRQuestionEncoder, DPRReader
CheckpointState = collections.namedtuple(
"CheckpointState", ["model_dict", "optimize... | 5,460 | 42.34127 | 228 | py |
ConSERT | ConSERT-master/transformers/convert_fsmt_original_pytorch_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 10,885 | 39.022059 | 131 | py |
ConSERT | ConSERT-master/transformers/tokenization_deberta.py | # coding=utf-8
# Copyright 2020 Microsoft and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required... | 24,305 | 35.605422 | 177 | py |
ConSERT | ConSERT-master/transformers/convert_xlm_original_pytorch_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 2,983 | 36.3 | 117 | py |
ConSERT | ConSERT-master/transformers/modeling_dpr.py | # coding=utf-8
# Copyright 2018 DPR Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | 28,460 | 42.65184 | 168 | py |
ConSERT | ConSERT-master/transformers/convert_dialogpt_original_pytorch_checkpoint_to_pytorch.py | import argparse
import os
import torch
from transformers.file_utils import WEIGHTS_NAME
DIALOGPT_MODELS = ["small", "medium", "large"]
OLD_KEY = "lm_head.decoder.weight"
NEW_KEY = "lm_head.weight"
def convert_dialogpt_checkpoint(checkpoint_path: str, pytorch_dump_folder_path: str):
d = torch.load(checkpoint_... | 935 | 27.363636 | 85 | py |
ConSERT | ConSERT-master/transformers/modeling_reformer.py | # coding=utf-8
# Copyright 2020 The Trax Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at... | 109,823 | 41.468677 | 251 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_xlm.py | # coding=utf-8
# Copyright 2019-present, Facebook, Inc and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 51,920 | 41.523342 | 160 | py |
ConSERT | ConSERT-master/transformers/modeling_bart.py | # coding=utf-8
# Copyright 2020 The Facebook AI Research Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | 58,368 | 40.662384 | 213 | py |
ConSERT | ConSERT-master/transformers/file_utils.py | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
import fnmatch
import json
import os
import re
import shutil
import sys
import tarfile
import tempfile
from collections import OrderedDict... | 45,174 | 33.96517 | 150 | py |
ConSERT | ConSERT-master/transformers/tokenization_dpr_fast.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 20,403 | 51.184143 | 152 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_ctrl.py | # coding=utf-8
# Copyright 2018 Salesforce and HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# h... | 28,263 | 40.748892 | 134 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_funnel.py | # coding=utf-8
# Copyright 2020-present Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | 73,584 | 43.010167 | 159 | py |
ConSERT | ConSERT-master/transformers/activations.py | import math
import torch
import torch.nn.functional as F
from .utils import logging
logger = logging.get_logger(__name__)
def swish(x):
return x * torch.sigmoid(x)
def _gelu_python(x):
"""Original Implementation of the gelu activation function in Google Bert repo when initially created.
For informat... | 1,711 | 23.811594 | 115 | py |
ConSERT | ConSERT-master/transformers/tokenization_bert_fast.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICEN... | 14,966 | 55.908745 | 188 | py |
ConSERT | ConSERT-master/transformers/__init__.py | # flake8: noqa
# There's no way to ignore "F401 '...' imported but unused" warnings in this
# module, but to preserve other warnings. So, don't check this module at all.
__version__ = "3.4.0"
# Work around to update TensorFlow's absl.logging threshold which alters the
# default Python logging output behavior when pre... | 30,900 | 35.099299 | 117 | py |
ConSERT | ConSERT-master/transformers/tokenization_bart.py | # coding=utf-8
# Copyright 2020 The Facebook AI Research Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | 7,982 | 49.847134 | 155 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_bert.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 60,374 | 40.211604 | 160 | py |
ConSERT | ConSERT-master/transformers/modeling_prophetnet.py | # coding=utf-8
# Copyright 2020 The Microsoft Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unl... | 101,399 | 48.391135 | 213 | py |
ConSERT | ConSERT-master/transformers/modeling_mobilebert.py | # MIT License
#
# Copyright (c) 2020 The Google AI Language Team Authors, The HuggingFace Inc. team and github/lonePatient
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restricti... | 68,232 | 41.067201 | 168 | py |
ConSERT | ConSERT-master/transformers/trainer_utils.py | # coding=utf-8
# Copyright 2020-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | 4,719 | 29.649351 | 116 | py |
ConSERT | ConSERT-master/transformers/tokenization_bart_fast.py | # coding=utf-8
# Copyright 2020 The Facebook AI Research Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | 8,017 | 51.75 | 155 | py |
ConSERT | ConSERT-master/transformers/modeling_retribert.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.or... | 9,240 | 42.589623 | 120 | py |
ConSERT | ConSERT-master/transformers/modeling_pegasus.py | # coding=utf-8
# Copyright 2020 Google and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | 2,696 | 47.160714 | 309 | py |
ConSERT | ConSERT-master/transformers/convert_bert_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 2,152 | 33.725806 | 117 | py |
ConSERT | ConSERT-master/transformers/convert_lxmert_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 2,128 | 33.33871 | 117 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_distilbert.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.or... | 46,463 | 41.78453 | 141 | py |
ConSERT | ConSERT-master/transformers/convert_bert_pytorch_checkpoint_to_original_tf.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 4,115 | 35.424779 | 118 | py |
ConSERT | ConSERT-master/transformers/modeling_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 46,565 | 41.217588 | 180 | py |
ConSERT | ConSERT-master/transformers/convert_xlnet_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 3,698 | 31.165217 | 117 | py |
ConSERT | ConSERT-master/transformers/modeling_albert.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... | 53,414 | 39.743707 | 168 | py |
ConSERT | ConSERT-master/transformers/modeling_blenderbot.py | #!/usr/bin/env python3
# coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | 2,374 | 40.666667 | 120 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_longformer.py | # coding=utf-8
# Copyright 2020 The Allen Institute for AI team and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2... | 78,170 | 41.927512 | 271 | py |
ConSERT | ConSERT-master/transformers/modeling_xlnet.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 89,614 | 43.363861 | 197 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_camembert.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 6,262 | 39.934641 | 224 | py |
ConSERT | ConSERT-master/transformers/modeling_xlm.py | # coding=utf-8
# Copyright 2019-present, Facebook, Inc and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 52,051 | 40.278351 | 197 | py |
ConSERT | ConSERT-master/transformers/modeling_tf_utils.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 49,337 | 45.153414 | 167 | py |
ConSERT | ConSERT-master/transformers/modeling_lxmert.py | # coding=utf-8
# Copyright 2018 Hao Tan, Mohit Bansal, and the HuggingFace team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | 64,084 | 43.534399 | 177 | py |
ConSERT | ConSERT-master/transformers/modeling_ctrl.py | # coding=utf-8
# Copyright 2018 Salesforce and HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# h... | 24,658 | 40.02995 | 124 | py |
ConSERT | ConSERT-master/transformers/trainer.py | # coding=utf-8
# Copyright 2020-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | 70,498 | 45.781022 | 188 | py |
ConSERT | ConSERT-master/transformers/tokenization_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 30,586 | 38.31491 | 136 | py |
ConSERT | ConSERT-master/transformers/modeling_transfo_xl_utilities.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 10,652 | 41.612 | 128 | py |
ConSERT | ConSERT-master/transformers/convert_reformer_trax_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 7,830 | 34.595455 | 118 | py |
ConSERT | ConSERT-master/transformers/modeling_deberta.py | # coding=utf-8
# Copyright 2020 Microsoft and the Hugging Face Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... | 41,672 | 39.341723 | 225 | py |
ConSERT | ConSERT-master/transformers/configuration_rag.py | # coding=utf-8
# Copyright 2020, The RAG Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | 8,540 | 46.187845 | 166 | py |
ConSERT | ConSERT-master/transformers/modeling_xlm_prophetnet.py | # coding=utf-8
# Copyright 2020 The Microsoft Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unl... | 6,853 | 41.8375 | 158 | py |
ConSERT | ConSERT-master/transformers/convert_pytorch_checkpoint_to_tf2.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 15,336 | 33.936219 | 126 | py |
ConSERT | ConSERT-master/transformers/modeling_roberta.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 62,680 | 41.209428 | 219 | py |
ConSERT | ConSERT-master/transformers/tokenization_utils.py | # coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 39,004 | 43.123303 | 155 | py |
ConSERT | ConSERT-master/transformers/commands/convert.py | from argparse import ArgumentParser, Namespace
from transformers.commands import BaseTransformersCLICommand
from ..utils import logging
def convert_command_factory(args: Namespace):
"""
Factory function used to convert a model TF 1.0 checkpoint in a PyTorch checkpoint.
:return: ServeCommand
"""
... | 6,582 | 40.664557 | 117 | py |
ConSERT | ConSERT-master/transformers/commands/train.py | import os
from argparse import ArgumentParser, Namespace
from transformers import SingleSentenceClassificationProcessor as Processor
from transformers import TextClassificationPipeline, is_tf_available, is_torch_available
from transformers.commands import BaseTransformersCLICommand
from ..utils import logging
if no... | 5,798 | 38.993103 | 117 | py |
ConSERT | ConSERT-master/transformers/commands/env.py | import platform
from argparse import ArgumentParser
from transformers import __version__ as version
from transformers import is_tf_available, is_torch_available
from transformers.commands import BaseTransformersCLICommand
def info_command_factory(_):
return EnvironmentCommand()
class EnvironmentCommand(BaseTra... | 2,027 | 33.372881 | 105 | py |
ConSERT | ConSERT-master/transformers/benchmark/benchmark.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | 10,617 | 38.619403 | 181 | py |
ConSERT | ConSERT-master/transformers/benchmark/benchmark_utils.py | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
import copy
import csv
import linecache
import os
import platform
import sys
from abc import ABC, abstractmethod
from collections import d... | 36,700 | 40.658343 | 204 | py |
ConSERT | ConSERT-master/transformers/benchmark/benchmark_args.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | 3,768 | 31.773913 | 127 | py |
ConSERT | ConSERT-master/transformers/utils/dummy_pt_objects.py | # This file is autogenerated by the command `make fix-copies`, do not edit.
from ..file_utils import requires_pytorch
class PyTorchBenchmark:
def __init__(self, *args, **kwargs):
requires_pytorch(self)
class PyTorchBenchmarkArguments:
def __init__(self, *args, **kwargs):
requires_pytorch(sel... | 43,177 | 20.895538 | 75 | py |
ConSERT | ConSERT-master/transformers/utils/dummy_flax_objects.py | # This file is autogenerated by the command `make fix-copies`, do not edit.
from ..file_utils import requires_flax
class FlaxBertModel:
def __init__(self, *args, **kwargs):
requires_flax(self)
@classmethod
def from_pretrained(self, *args, **kwargs):
requires_flax(self)
class FlaxRoberta... | 490 | 22.380952 | 75 | py |
ConSERT | ConSERT-master/transformers/data/data_collator.py | from dataclasses import dataclass
from typing import Any, Callable, Dict, List, NewType, Optional, Tuple, Union
import torch
from torch.nn.utils.rnn import pad_sequence
from ..tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTrainedTokenizerBase
InputDataClass = NewType("InputDataClass", Any)
"""
... | 27,108 | 50.342803 | 184 | py |
ConSERT | ConSERT-master/transformers/data/test_generation_utils.py | import random
import unittest
import timeout_decorator
from transformers import is_torch_available
from transformers.file_utils import cached_property
from transformers.testing_utils import require_torch
if is_torch_available():
import torch
from transformers import MarianConfig, MarianMTModel
@require_t... | 2,874 | 31.670455 | 94 | py |
ConSERT | ConSERT-master/transformers/data/datasets/glue.py | import os
import time
from dataclasses import dataclass, field
from enum import Enum
from typing import List, Optional, Union
import torch
from torch.utils.data.dataset import Dataset
from filelock import FileLock
from ...tokenization_utils_base import PreTrainedTokenizerBase
from ...utils import logging
from ..proc... | 5,240 | 34.412162 | 119 | py |
ConSERT | ConSERT-master/transformers/data/datasets/squad.py | import os
import time
from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List, Optional, Union
import torch
from torch.utils.data.dataset import Dataset
from filelock import FileLock
from ...modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING
from ...tokenization_utils impo... | 8,523 | 39.018779 | 129 | py |
ConSERT | ConSERT-master/transformers/data/datasets/language_modeling.py | import os
import pickle
import random
import time
from typing import Dict, List, Optional
import torch
from torch.utils.data.dataset import Dataset
from filelock import FileLock
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
logger = logging.get_logger(__name__)
class TextData... | 18,485 | 41.890951 | 119 | py |
ConSERT | ConSERT-master/transformers/data/processors/squad.py | import json
import os
from functools import partial
from multiprocessing import Pool, cpu_count
import numpy as np
from tqdm import tqdm
from ...file_utils import is_tf_available, is_torch_available
from ...tokenization_bart import BartTokenizer
from ...tokenization_bert import whitespace_tokenize
from ...tokenizatio... | 32,391 | 38.406326 | 125 | py |
ConSERT | ConSERT-master/transformers/data/processors/utils.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 14,140 | 38.946328 | 119 | py |
ConSERT | ConSERT-master/sentence_transformers/SentenceTransformer.py | import json
import logging
import os
import shutil
from collections import OrderedDict
from typing import List, Dict, Tuple, Iterable, Type, Union, Callable, Optional
from zipfile import ZipFile
import requests
import numpy as np
from numpy import ndarray
import transformers
import torch
from torch import nn, Tensor, d... | 33,194 | 44.224796 | 280 | py |
ConSERT | ConSERT-master/sentence_transformers/util.py | import requests
from torch import Tensor, device
from typing import List
from tqdm import tqdm
import sys
import importlib
import os
import torch
import numpy as np
import queue
def pytorch_cos_sim(a: Tensor, b: Tensor):
"""
Computes the cosine similarity cos_sim(a[i], b[j]) for all i and j.
This function... | 10,994 | 41.949219 | 165 | py |
ConSERT | ConSERT-master/sentence_transformers/evaluation/InformationRetrievalEvaluator.py | from . import SentenceEvaluator
import torch
import logging
from tqdm import tqdm, trange
from ..util import pytorch_cos_sim
import os
import numpy as np
from typing import List, Tuple, Dict, Set
class InformationRetrievalEvaluator(SentenceEvaluator):
"""
This class evaluates an Information Retrieval (IR) set... | 10,665 | 35.652921 | 171 | py |
ConSERT | ConSERT-master/sentence_transformers/evaluation/TranslationEvaluator.py | from . import SentenceEvaluator
import logging
from ..util import pytorch_cos_sim
import os
import csv
import numpy as np
import scipy.spatial
from typing import List
import torch
class TranslationEvaluator(SentenceEvaluator):
"""
Given two sets of sentences in different languages, e.g. (en_1, en_2, en_3...) a... | 4,278 | 39.367925 | 188 | py |
ConSERT | ConSERT-master/sentence_transformers/evaluation/MSEEvaluatorFromDataFrame.py | from sentence_transformers.evaluation import SentenceEvaluator
from sentence_transformers.util import batch_to_device
from sentence_transformers import SentenceTransformer
from typing import List, Tuple, Dict
import torch
import numpy as np
import logging
import os
import csv
class MSEEvaluatorFromDataFrame(SentenceE... | 3,814 | 42.850575 | 162 | py |
ConSERT | ConSERT-master/sentence_transformers/evaluation/LabelAccuracyEvaluator.py | from . import SentenceEvaluator
import torch
from torch.utils.data import DataLoader
import logging
from tqdm import tqdm
from ..util import batch_to_device
import os
import csv
class LabelAccuracyEvaluator(SentenceEvaluator):
"""
Evaluate a model based on its accuracy on a labeled dataset
This requires a... | 2,599 | 33.666667 | 98 | py |
ConSERT | ConSERT-master/sentence_transformers/cross_encoder/CrossEncoder.py |
from transformers import AutoModelForSequenceClassification, AutoTokenizer, AutoConfig, DistilBertConfig
import numpy as np
import logging
import os
from typing import Dict, Type, Callable, List
import transformers
import torch
from torch import nn
from torch.optim import Optimizer
from torch.utils.data import DataLoa... | 13,823 | 44.32459 | 254 | py |
ConSERT | ConSERT-master/sentence_transformers/models/Transformer.py | from torch import nn
from transformers import AutoModel, AutoTokenizer, AutoConfig
import json
from typing import List, Dict, Optional, Union
import os
class Transformer(nn.Module):
"""Huggingface AutoModel to generate token embeddings.
Loads the correct class, e.g. BERT / RoBERTa etc.
:param model_name_... | 5,724 | 45.92623 | 255 | py |
ConSERT | ConSERT-master/sentence_transformers/models/WeightedLayerPooling.py | import torch
from torch import Tensor
from torch import nn
from typing import Union, Tuple, List, Iterable, Dict
import os
import json
class WeightedLayerPooling(nn.Module):
"""
Token embeddings are weighted mean of their different hidden layer representations
"""
def __init__(self, word_embedding_dim... | 2,246 | 40.611111 | 165 | py |
ConSERT | ConSERT-master/sentence_transformers/models/CNN.py | import torch
from torch import nn, Tensor
from typing import Union, Tuple, List, Iterable, Dict
import logging
import gzip
from tqdm import tqdm
import numpy as np
import os
import json
from ..util import import_from_string, fullname, http_get
from .tokenizer import WordTokenizer, WhitespaceTokenizer
class CNN(nn.Mod... | 2,462 | 34.695652 | 119 | py |
ConSERT | ConSERT-master/sentence_transformers/models/WordEmbeddings.py | import torch
from torch import nn, Tensor
from typing import Union, Tuple, List, Iterable, Dict
import logging
import gzip
from tqdm import tqdm
import numpy as np
import os
import json
from ..util import import_from_string, fullname, http_get
from .tokenizer import WordTokenizer, WhitespaceTokenizer
class WordEmbedd... | 5,818 | 44.108527 | 171 | py |
ConSERT | ConSERT-master/sentence_transformers/models/T5.py | from torch import nn
from transformers import T5Model, T5Tokenizer
import json
from typing import List, Dict, Optional
import os
import numpy as np
import logging
class T5(nn.Module):
"""DEPRECATED: Please use models.Transformer instead.
T5 model to generate token embeddings.
Each token is mapped to an o... | 3,402 | 37.235955 | 206 | py |
ConSERT | ConSERT-master/sentence_transformers/models/WordWeights.py | import torch
from torch import Tensor
from torch import nn
from typing import Union, Tuple, List, Iterable, Dict
import os
import json
import logging
class WordWeights(nn.Module):
"""This model can weight word embeddings, for example, with idf-values."""
def __init__(self, vocab: List[str], word_weights: Dict... | 3,017 | 39.783784 | 196 | py |
ConSERT | ConSERT-master/sentence_transformers/models/WKPooling.py | import torch
from torch import Tensor
from torch import nn
from typing import Union, Tuple, List, Iterable, Dict
import os
import json
import numpy as np
class WKPooling(nn.Module):
"""
Pooling based on the paper: "SBERT-WK: A Sentence Embedding Method ByDissecting BERT-based Word Models"
https://arxiv.or... | 5,864 | 40.595745 | 130 | py |
ConSERT | ConSERT-master/sentence_transformers/models/Normalize.py | from torch import Tensor
from torch import nn
from typing import Dict
import torch.nn.functional as F
class Normalize(nn.Module):
"""
This layer normalizes embeddings to unit length
"""
def __init__(self):
super(Normalize, self).__init__()
def forward(self, features: Dict[str, Tensor]):
... | 566 | 23.652174 | 104 | py |
ConSERT | ConSERT-master/sentence_transformers/models/Dense.py | import torch
from torch import Tensor
from torch import nn
from torch import functional as F
from typing import Union, Tuple, List, Iterable, Dict
import os
import json
from ..util import fullname, import_from_string
class Dense(nn.Module):
"""Feed-forward function with activiation function.
This layer take... | 2,116 | 40.509804 | 175 | py |
ConSERT | ConSERT-master/sentence_transformers/models/BoW.py | import torch
from torch import Tensor
from torch import nn
from typing import Union, Tuple, List, Iterable, Dict
import os
import json
import logging
import numpy as np
from .tokenizer import WhitespaceTokenizer
class BoW(nn.Module):
"""Implements a Bag-of-Words (BoW) model to derive sentence embeddings.
A we... | 2,940 | 37.194805 | 150 | py |
ConSERT | ConSERT-master/sentence_transformers/models/Pooling.py | import torch
from torch import Tensor
from torch import nn
from typing import Union, Tuple, List, Iterable, Dict
import os
import json
class Pooling(nn.Module):
"""Performs pooling (max or mean) on the token embeddings.
Using pooling, it generates from a variable sized sentence a fixed sized sentence embeddi... | 8,028 | 51.477124 | 209 | py |
ConSERT | ConSERT-master/sentence_transformers/models/LSTM.py | import torch
from torch import nn
from typing import List
import os
import json
class LSTM(nn.Module):
"""
Bidirectional LSTM running over word embeddings.
"""
def __init__(self, word_embedding_dimension: int, hidden_dim: int, num_layers: int = 1, dropout: float = 0, bidirectional: bool = True):
... | 2,323 | 35.888889 | 155 | py |
ConSERT | ConSERT-master/sentence_transformers/models/MLP3.py | import torch
from torch import nn
import os
import json
from typing import Union, Tuple, List, Iterable, Dict
from torch import Tensor
class MLP3(nn.Module):
def __init__(self, hidden_dim=2048, norm=None, activation='relu'):
super().__init__()
''' page 3 baseline setting
Projection MLP. The... | 3,212 | 32.123711 | 80 | py |
ConSERT | ConSERT-master/sentence_transformers/datasets/SentenceLabelDataset.py | from torch.utils.data import Dataset
from typing import List
import bisect
import torch
import logging
import numpy as np
from tqdm import tqdm
from .. import SentenceTransformer
from ..readers.InputExample import InputExample
from multiprocessing import Pool, cpu_count
import multiprocessing
class SentenceLabelDatase... | 8,156 | 43.091892 | 161 | py |
ConSERT | ConSERT-master/sentence_transformers/datasets/SentencesDataset.py | from torch.utils.data import Dataset
from typing import List
import torch
from .. import SentenceTransformer
from ..readers.InputExample import InputExample
class SentencesDataset(Dataset):
"""
Dataset for smart batching, that is each batch is only padded to its longest sequence instead of padding all
sequ... | 1,443 | 34.219512 | 115 | py |
ConSERT | ConSERT-master/sentence_transformers/datasets/EncodeDataset.py | from torch.utils.data import Dataset
from typing import List, Union
from .. import SentenceTransformer
class EncodeDataset(Dataset):
def __init__(self,
sentences: Union[List[str], List[int]],
model: SentenceTransformer,
is_tokenized: bool = True):
"""
... | 777 | 28.923077 | 103 | py |
ConSERT | ConSERT-master/sentence_transformers/datasets/ParallelSentencesDataset.py | from torch.utils.data import Dataset
import logging
import gzip
from queue import Queue
from .. import SentenceTransformer
from typing import List
import random
class ParallelSentencesDataset(Dataset):
"""
This dataset reader can be used to read-in parallel sentences, i.e., it reads in a file with tab-seperate... | 7,073 | 43.490566 | 153 | py |
ConSERT | ConSERT-master/sentence_transformers/datasets/sampler/LabelSampler.py | """
This file contains sampler functions, that can be used to sample mini-batches with specific properties.
"""
from torch.utils.data import Sampler
import numpy as np
from ...datasets import SentenceLabelDataset
class LabelSampler(Sampler):
"""
This sampler is used for some specific Triplet Losses like BATCH... | 3,097 | 39.763158 | 121 | py |
ConSERT | ConSERT-master/sentence_transformers/losses/SimSiamLoss.py | import torch
from torch import nn, Tensor
from typing import Union, Tuple, List, Iterable, Dict
from ..SentenceTransformer import SentenceTransformer
import logging
LARGE_NUM = 1e9
class MLP1(nn.Module):
def __init__(self, hidden_dim=2048, norm=None, activation="relu"): # bottleneck structure
super().__i... | 9,366 | 47.786458 | 169 | py |
ConSERT | ConSERT-master/sentence_transformers/losses/CosineSimilarityLoss.py | import torch
from torch import nn, Tensor
from typing import Iterable, Dict
from ..SentenceTransformer import SentenceTransformer
class CosineSimilarityLoss(nn.Module):
"""
CosineSimilarityLoss expects, that the InputExamples consists of two texts and a float label.
It computes the vectors u = model(inpu... | 2,213 | 50.488372 | 177 | py |
ConSERT | ConSERT-master/sentence_transformers/losses/AdvCLSoftmaxLoss_single_stream_backup.py | import torch
from torch import nn, Tensor
from typing import Union, Tuple, List, Iterable, Dict
from ..SentenceTransformer import SentenceTransformer
import logging
LARGE_NUM = 1e9
def scheduler0(cur_step, global_step):
return 1.0, 1.0
def scheduler1(cur_step, global_step):
"""global_step=9814"""
if cur_... | 36,924 | 50.427577 | 226 | py |
ConSERT | ConSERT-master/sentence_transformers/losses/MSELoss.py | import torch
from torch import nn, Tensor
from typing import Union, Tuple, List, Iterable, Dict
class MSELoss(nn.Module):
"""
Computes the MSE loss between the computed sentence embedding and a target sentence embedding. This loss
is used when extending sentence embeddings to new languages as described in... | 888 | 39.409091 | 118 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.