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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/sentence_transformers/SentenceTransformer.py
import copy 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 n...
34,422
45.454791
280
py
SLT-FAI
SLT-FAI-main/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...
11,267
42.674419
165
py
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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,725
46.322314
255
py
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/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
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/TripletLoss.py
import torch from torch import nn, Tensor from typing import Union, Tuple, List, Iterable, Dict import torch.nn.functional as F from enum import Enum from ..SentenceTransformer import SentenceTransformer class TripletDistanceMetric(Enum): """ The metric for the triplet loss """ COSINE = lambda x, y: 1 ...
2,728
45.254237
164
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/BatchHardSoftMarginTripletLoss.py
import torch from torch import nn, Tensor from typing import Union, Tuple, List, Iterable, Dict from .BatchHardTripletLoss import BatchHardTripletLoss, BatchHardTripletLossDistanceFunction from sentence_transformers.SentenceTransformer import SentenceTransformer class BatchHardSoftMarginTripletLoss(BatchHardTripletLos...
4,942
54.539326
162
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/AdvCLSoftmaxLoss.py
import json import os import copy import numpy as np import torch from torch import nn, Tensor from torch.autograd import Function from typing import Union, Tuple, List, Iterable, Dict, Set, Any, Optional from ..SentenceTransformer import SentenceTransformer import logging LARGE_NUM = 1e9 def scheduler0(cur_step, gl...
50,752
50.947799
226
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/MegaBatchMarginLoss.py
from .. import util import torch from torch import nn, Tensor from typing import Iterable, Dict import torch.nn.functional as F class MegaBatchMarginLoss(nn.Module): """ Loss function inspired from ParaNMT paper: https://www.aclweb.org/anthology/P18-1042/ Given a large batch (like 500 or more examples...
5,229
51.828283
209
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/BatchHardTripletLoss.py
import torch from torch import nn, Tensor from typing import Union, Tuple, List, Iterable, Dict from sentence_transformers import util from sentence_transformers.SentenceTransformer import SentenceTransformer class BatchHardTripletLossDistanceFunction: """ This class defines distance functions, that can be us...
9,398
45.300493
162
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/MultipleNegativesRankingLoss.py
import torch from torch import nn, Tensor from typing import Iterable, Dict from ..SentenceTransformer import SentenceTransformer from .. import util class MultipleNegativesRankingLoss(nn.Module): """ This loss expects as input a batch consisting of sentence pairs (a_1, p_1), (a_2, p_2)..., (a_n, p_n) ...
3,613
47.837838
157
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/SimCLRLoss.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...
10,167
48.120773
155
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/BatchAllTripletLoss.py
import torch from torch import nn, Tensor from typing import Union, Tuple, List, Iterable, Dict from .BatchHardTripletLoss import BatchHardTripletLoss, BatchHardTripletLossDistanceFunction from sentence_transformers.SentenceTransformer import SentenceTransformer class BatchAllTripletLoss(nn.Module): """ Batch...
4,700
50.659341
162
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/BatchSemiHardTripletLoss.py
import torch from torch import nn, Tensor from typing import Union, Tuple, List, Iterable, Dict from .BatchHardTripletLoss import BatchHardTripletLoss, BatchHardTripletLossDistanceFunction from sentence_transformers.SentenceTransformer import SentenceTransformer class BatchSemiHardTripletLoss(nn.Module): """ ...
5,586
48.442478
162
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/AdvCLSoftmaxLoss_refactoring.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 MLP(torch.nn.Module): def __init__(self, input_dim: int, hidden_dim: int, ...
21,694
51.026379
179
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/OnlineContrastiveLoss.py
from typing import Iterable, Dict import torch.nn.functional as F from torch import nn, Tensor from .ContrastiveLoss import SiameseDistanceMetric from sentence_transformers.SentenceTransformer import SentenceTransformer class OnlineContrastiveLoss(nn.Module): """ Online Contrastive loss. Similar to Constrativ...
2,732
51.557692
162
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/ContrastiveLoss.py
from enum import Enum from typing import Iterable, Dict import torch.nn.functional as F from torch import nn, Tensor from sentence_transformers.SentenceTransformer import SentenceTransformer class SiameseDistanceMetric(Enum): """ The metric for the contrastive loss """ EUCLIDEAN = lambda x, y: F.pai...
2,794
44.080645
162
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/SoftmaxLoss.py
import torch from torch import nn, Tensor from typing import Union, Tuple, List, Iterable, Dict from ..SentenceTransformer import SentenceTransformer import logging class SoftmaxLoss(nn.Module): """ This loss was used in our SBERT publication (https://arxiv.org/abs/1908.10084) to train the SentenceTransformer ...
3,637
45.050633
152
py
SLT-FAI
SLT-FAI-main/sentence_transformers/losses/AdvSimSiamLoss.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 MLP(torch.nn.Module): def __init__(self, input_dim: int, hidden_dim: int, ...
25,701
49.794466
179
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/inference.py
import argparse import os import numpy as np from tqdm import tqdm from PIL import Image import matplotlib.pyplot as plt from torchvision import transforms from torch.autograd import Variable from mypath import Path from dataloaders import make_data_loader from dataloaders.custom_transforms import denormalizeimage fro...
5,786
37.58
111
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/DenseCRFLoss.py
import torch import torch.nn as nn from torch.autograd import Function from torch.autograd import Variable import torch.nn.functional as F import numpy as np import sys sys.path.append("../wrapper/bilateralfilter/build/lib.linux-x86_64-3.6") from bilateralfilter import bilateralfilter, bilateralfilter_batch from datalo...
2,810
39.157143
117
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/GridCRFLoss.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np import sys import math from dataloaders.custom_transforms import denormalizeimage from itertools import repeat class BilinearPottsRelaxation(object): @staticmethod def comute(a, b): return a * (1 - b) class TVPotts...
3,859
34.740741
117
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/train_with_dcr.py
import os, sys import argparse import math import time from tqdm import tqdm import numpy as np import torchvision import torch import torch.nn.functional as F from mypath import Path from dataloaders import make_data_loader from dataloaders.utils import decode_seg_map_sequence, normalize_image_to_range from dataloa...
26,384
46.455036
147
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/train_withdensecrfloss.py
import argparse import os, time import numbers import json import numpy as np from tqdm import tqdm from mypath import Path from dataloaders import make_data_loader from dataloaders.custom_transforms import denormalizeimage from modeling.sync_batchnorm.replicate import patch_replication_callback from modeling.deeplab ...
16,448
44.31405
155
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/train.py
import numbers import json from tqdm import tqdm import torch, torchvision import torch.nn.functional as F from modeling.deeplab import * from dataloaders.utils import decode_seg_map_sequence, normalize_image_to_range from dataloaders import make_data_loader from utils.lr_scheduler import LR_Scheduler from utils.save...
7,395
41.751445
124
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/AlphaExpansion.py
import torch import alphaexpansion import torch.nn as nn from torch.autograd import Function from torch.autograd import Variable import torch.nn.functional as F import numpy as np import sys, warnings from datetime import datetime class AlphaExpansion(nn.Module): def __init__(self, max_iter, potts_weight, ce_weig...
4,248
41.49
123
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/custom_transforms.py
import torch import torch.nn.functional as F import random import numpy as np from PIL import Image, ImageOps, ImageFilter class Normalize(object): """Normalize a tensor image with mean and standard deviation. Args: mean (tuple): means for each channel. std (tuple): standard deviations for eac...
10,938
31.363905
124
py