repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
robust-transformers
robust-transformers-main/examples/pytorch/image-classification/run_image_classification_dro.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
20,092
39.756592
171
py
robust-transformers
robust-transformers-main/examples/pytorch/image-classification/run_image_classification.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
17,554
38.449438
143
py
robust-transformers
robust-transformers-main/examples/pytorch/image-classification/generate_features.py
#!/usr/bin/env python # coding=utf-8 # generating features for image classification import logging import os import sys import jsonlines import json from dataclasses import dataclass, field from typing import Optional import tqdm import pickle import datasets from datasets.dataset_dict import DatasetDict, IterableDat...
30,464
42.771552
177
py
robust-transformers
robust-transformers-main/examples/pytorch/image-classification/learn_grouper.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
22,444
41.18985
205
py
robust-transformers
robust-transformers-main/examples/pytorch/image-classification/utils.py
from dataclasses import dataclass from functools import reduce, wraps from inspect import getcallargs from typing import Collection, Mapping import meerkat as mk def unpack_args(data: mk.DataPanel, *args): if any(map(lambda x: isinstance(x, str), args)) and data is None: raise ValueError("If args are str...
2,197
32.30303
116
py
robust-transformers
robust-transformers-main/examples/pytorch/image-classification/domino_learnt_slicer.py
import math import numpy as np from turtle import forward import torch import torch.utils.checkpoint from packaging import version from torch import nn, optim, autograd import torch.distributed as dist from torch.distributed import ReduceOp from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from datacla...
20,182
48.957921
165
py
robust-transformers
robust-transformers-main/examples/pytorch/image-classification/domino_slicer.py
from __future__ import annotations import warnings from functools import wraps from typing import Union import meerkat as mk import numpy as np import sklearn.cluster as cluster from scipy import linalg from scipy.special import logsumexp from sklearn.decomposition import PCA from sklearn.exceptions import Convergenc...
30,667
39.405797
141
py
robust-transformers
robust-transformers-main/examples/pytorch/summarization/run_summarization_no_trainer.py
#!/usr/bin/env python # coding=utf-8 # Copyright The HuggingFace Team and The HuggingFace Inc. team. 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.ap...
25,382
39.874396
119
py
robust-transformers
robust-transformers-main/examples/pytorch/summarization/run_summarization.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Team. 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.apache.org/licenses/LICENSE...
30,199
42.328551
149
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/run_glue.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
25,282
43.278459
119
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/data_utils.py
""" Utilities for data handling. """ import json import logging import os import re import pandas as pd import shutil import tqdm import random from typing import Dict def convert_string_to_unique_number(string: str) -> int: """ Hack to convert SNLI ID into a unique integer ID, for tensorizing. """ id_map = {...
4,491
29.557823
99
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/group_dataset.py
""" Dataset wrapping an Arrow Table. Extended to also contain group information""" from datasets.arrow_dataset import Dataset from typing import ( TYPE_CHECKING, Any, BinaryIO, Callable, Dict, Iterable, Iterator, List, Optional, ) from datasets.formatting import format_table, get_f...
1,052
24.682927
100
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/run_glue_cartography.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
31,285
44.145743
155
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/train_dy_filtering.py
""" Filtering and dataset mapping methods based on training dynamics. By default, this module reads training dynamics from a given trained model and computes the metrics---confidence, variability, correctness, as well as baseline metrics of forgetfulness and threshold closeness for each instance in the training data. I...
18,898
40.174292
140
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/download_glue.py
''' Script for downloading all GLUE data. Note: for legal reasons, we are unable to host MRPC. You can either use the version hosted by the SentEval team, which is already tokenized, or you can download the original data from (https://download.microsoft.com/download/D/4/6/D46FF87A-F6B9-4252-AA8B-3604ED519838/MSRParap...
6,883
44.893333
190
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/run_xnli.py
#!/usr/bin/env python # 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. ...
16,340
39.750623
119
py
robust-transformers
robust-transformers-main/examples/pytorch/text-classification/run_glue_no_trainer.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LICENSE-2.0 # # Unless r...
21,165
42.020325
119
py
robust-transformers
robust-transformers-main/examples/pytorch/speech-pretraining/run_wav2vec2_pretraining_no_trainer.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
29,371
39.346154
200
py
robust-transformers
robust-transformers-main/examples/pytorch/text-generation/run_generation.py
#!/usr/bin/env python # 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 co...
10,991
36.773196
119
py
robust-transformers
robust-transformers-main/examples/pytorch/multiple-choice/run_swag.py
#!/usr/bin/env python # coding=utf-8 # Copyright The HuggingFace Team and The HuggingFace Inc. team. 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.ap...
18,885
40.416667
119
py
robust-transformers
robust-transformers-main/examples/pytorch/multiple-choice/run_swag_no_trainer.py
#!/usr/bin/env python # coding=utf-8 # Copyright The HuggingFace Team and The HuggingFace Inc. team. 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.ap...
21,483
39.921905
119
py
robust-transformers
robust-transformers-main/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Team. 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.apache.org/licenses/LICENSE...
20,824
40.40159
126
py
robust-transformers
robust-transformers-main/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
30,371
40.098782
158
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/generate_features.py
#!/usr/bin/env python # coding=utf-8 """ Code to create feature representations for instances of a text classification task, for automatic spurious-feature slice-discovery. Supported Feature types: Given a model path (pretrained or finetuned), return * CLS * Maxpool representations Given two model representat...
32,462
46.047826
197
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/assign_groups.py
import pickle import os import sys import json from tokenize import group import pandas as pd import argparse import numpy as np from collections import Counter if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--cluster_assgn_file", type=str, default=None) parser.add_argum...
2,197
36.254237
93
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/filter_groups.py
import pickle import os import sys import json from tokenize import group import pandas as pd import argparse import numpy as np from sklearn.metrics import f1_score from collections import Counter if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--cluster_assgn_file", type=st...
4,000
43.955056
212
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/custom_slicer.py
from __future__ import annotations import warnings from functools import wraps from typing import Union import meerkat as mk import numpy as np import sklearn.cluster as cluster from scipy import linalg from scipy.special import logsumexp from sklearn.decomposition import PCA from sklearn.exceptions import Convergenc...
29,931
39.231183
89
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/utils.py
from dataclasses import dataclass from functools import reduce, wraps from inspect import getcallargs from typing import Collection, Mapping import meerkat as mk def unpack_args(data: mk.DataPanel, *args): if any(map(lambda x: isinstance(x, str), args)) and data is None: raise ValueError("If args are str...
2,197
32.30303
116
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/domino_learnt_slicer.py
import math import numpy as np from turtle import forward import torch import torch.utils.checkpoint from packaging import version from torch import nn, optim, autograd import torch.distributed as dist from torch.distributed import ReduceOp from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from datacla...
19,060
48.897906
144
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/learn_groups.py
# A way to learn ideal incorporation of features for clustering in order to identify regions that have high loss # Instantiate the network randomly # Train for few epochs until convergence for the network to predict the same assignment as the ones given by the GMM model (improves convergence maybe) # Train for the fin...
25,315
42.57315
175
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/domino_slicer.py
from __future__ import annotations import warnings from functools import wraps from typing import Union import meerkat as mk import numpy as np import sklearn.cluster as cluster from scipy import linalg from scipy.special import logsumexp from sklearn.decomposition import PCA from sklearn.exceptions import Convergenc...
30,667
39.405797
141
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/filter_spurious.py
import numpy as np import pickle import sys import os import pdb domino = pickle.load(open(sys.argv[1], "rb")) mm = domino.mm means = mm.means_ cov = mm.covariances_ weights = mm.weights_ y_probs = mm.y_probs y_hat_probs = mm.y_hat_probs means_norm = means/np.expand_dims(np.linalg.norm(means, axis=1), axis=1) cov_nor...
2,548
42.20339
134
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/error_aware_slice_discovery.py
# load for each fold of training data, corresponding model, pretrained model and split out Ypred, Y # Combine all that data and create 6 folds. # For Dev set, do something similar, but now, the strategy for worst -group selection criterion is different. Recombining some of the low error groups together by class, crea...
37,779
44.905225
240
py
robust-transformers
robust-transformers-main/examples/pytorch/slice-discovery/generate_pretrained_features.py
#!/usr/bin/env python # coding=utf-8 """ Code to create feature representations for instances of a text classification task, for automatic spurious-feature slice-discovery. Supported Feature types: Given a model path (pretrained or finetuned), return * CLS * Maxpool representations Given two model representat...
28,557
44.330159
195
py
robust-transformers
robust-transformers-main/examples/pytorch/translation/run_translation_no_trainer.py
#!/usr/bin/env python # coding=utf-8 # Copyright The HuggingFace Team and The HuggingFace Inc. team. 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.ap...
24,806
40.345
119
py
robust-transformers
robust-transformers-main/examples/pytorch/translation/run_translation.py
#!/usr/bin/env python # coding=utf-8 # Copyright The HuggingFace Team and The HuggingFace Inc. team. 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.ap...
27,176
42.4832
120
py
robust-transformers
robust-transformers-main/examples/pytorch/language-modeling/run_mlm.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Team 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.apache.org/licenses/LICENSE-...
25,307
42.709845
119
py
robust-transformers
robust-transformers-main/examples/pytorch/language-modeling/run_clm_no_trainer.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
21,930
40.614801
242
py
robust-transformers
robust-transformers-main/examples/pytorch/language-modeling/run_plm.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Team 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.apache.org/licenses/LICENSE-...
22,553
41.878327
120
py
robust-transformers
robust-transformers-main/examples/pytorch/language-modeling/run_mlm_no_trainer.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
24,041
41.327465
121
py
robust-transformers
robust-transformers-main/examples/pytorch/language-modeling/run_clm.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
23,726
42.456044
152
py
robust-transformers
robust-transformers-main/examples/pytorch/audio-classification/run_audio_classification.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
16,086
40.354756
119
py
robust-transformers
robust-transformers-main/examples/pytorch/contrastive-image-text/run_clip.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2022 The HuggingFace Team 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.apache.org/licenses/LICENSE-...
21,819
41.451362
119
py
robust-transformers
robust-transformers-main/examples/tensorflow/question-answering/run_qa.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Team 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.apache.org/licenses/LICENSE-...
30,503
44.664671
124
py
robust-transformers
robust-transformers-main/examples/tensorflow/question-answering/utils_qa.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team 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.apache.org/licenses/LICENSE-2.0 # # Unless require...
22,378
50.445977
135
py
robust-transformers
robust-transformers-main/examples/tensorflow/benchmarking/plot_csv_file.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
6,407
34.798883
116
py
robust-transformers
robust-transformers-main/examples/tensorflow/benchmarking/run_benchmark_tf.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # Copyright (c) 2020, 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 a...
1,915
38.102041
92
py
robust-transformers
robust-transformers-main/examples/tensorflow/token-classification/run_ner.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
22,260
40.377323
147
py
robust-transformers
robust-transformers-main/examples/tensorflow/summarization/run_summarization.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Team. 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.apache.org/licenses/LICENSE...
27,681
40.689759
120
py
robust-transformers
robust-transformers-main/examples/tensorflow/text-classification/run_glue.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
21,938
41.028736
119
py
robust-transformers
robust-transformers-main/examples/tensorflow/text-classification/run_text_classification.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
21,233
41.983806
121
py
robust-transformers
robust-transformers-main/examples/tensorflow/multiple-choice/run_swag.py
#!/usr/bin/env python # coding=utf-8 # Copyright The HuggingFace Team and The HuggingFace Inc. team. 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.ap...
21,257
41.516
119
py
robust-transformers
robust-transformers-main/examples/tensorflow/translation/run_translation.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Team. 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.apache.org/licenses/LICENSE...
26,661
41.933977
120
py
robust-transformers
robust-transformers-main/examples/tensorflow/language-modeling/run_mlm.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
24,808
43.065719
142
py
robust-transformers
robust-transformers-main/examples/tensorflow/language-modeling/run_clm.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. 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.apache.org/licenses/LI...
22,652
42.563462
142
py
robust-transformers
robust-transformers-main/examples/legacy/run_transfo_xl.py
#!/usr/bin/env python # 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 co...
6,205
41.506849
114
py
robust-transformers
robust-transformers-main/examples/legacy/run_swag.py
#!/usr/bin/env python # 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. ...
30,163
40.836338
150
py
robust-transformers
robust-transformers-main/examples/legacy/run_language_modeling.py
#!/usr/bin/env python # 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. ...
13,704
36.547945
136
py
robust-transformers
robust-transformers-main/examples/legacy/run_chinese_ref.py
#!/usr/bin/env python import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _is_chinese_char(cp): """Checks whether CP is the codepoint of a CJK character.""" # This defines a "chinese character" as anything in the CJK Unicode block: # https:...
5,268
34.362416
115
py
robust-transformers
robust-transformers-main/examples/legacy/run_openai_gpt.py
#!/usr/bin/env python # 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 co...
14,269
43.454829
128
py
robust-transformers
robust-transformers-main/examples/legacy/run_camembert.py
#!/usr/bin/env python import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def fill_mask(masked_input, model, tokenizer, topk=5): # Adapted from https://github.com/pytorch/fairseq/blob/master/fairseq/models/roberta/hub_interface.py assert masked_input.count("<mask>") == 1 input_...
1,935
39.333333
114
py
robust-transformers
robust-transformers-main/examples/legacy/question-answering/run_squad.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...
34,739
40.805054
126
py
robust-transformers
robust-transformers-main/examples/legacy/question-answering/run_squad_trainer.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,789
35.505376
133
py
robust-transformers
robust-transformers-main/examples/legacy/pytorch-lightning/run_glue.py
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from torch.utils.data import DataLoader, TensorDataset from lightning_base import BaseTransformer, add_generic_args, generic_train from transformers import glue_compute_metrics as compute_me...
8,014
38.678218
119
py
robust-transformers
robust-transformers-main/examples/legacy/pytorch-lightning/lightning_base.py
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering, ...
15,022
37.32398
119
py
robust-transformers
robust-transformers-main/examples/legacy/pytorch-lightning/run_ner.py
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from seqeval.metrics import accuracy_score, f1_score, precision_score, recall_score from torch.nn import CrossEntropyLoss from torch.utils.data import DataLoader, Tens...
9,690
43.865741
119
py
robust-transformers
robust-transformers-main/examples/legacy/token-classification/run_ner.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...
12,219
36.950311
133
py
robust-transformers
robust-transformers-main/examples/legacy/token-classification/tasks.py
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask logger = logging.getLogger(__name__) class NER(TokenClassificationTask): def __init__(self, label_idx=-1): # in NER datasets, the last column...
5,509
32.597561
110
py
robust-transformers
robust-transformers-main/examples/legacy/token-classification/utils_ner.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...
15,649
40.957105
160
py
robust-transformers
robust-transformers-main/examples/legacy/token-classification/run_tf_ner.py
#!/usr/bin/env python # 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 ...
11,187
35.324675
133
py
robust-transformers
robust-transformers-main/examples/legacy/token-classification/scripts/preprocess.py
import sys from transformers import AutoTokenizer dataset = sys.argv[1] model_name_or_path = sys.argv[2] max_len = int(sys.argv[3]) subword_len_counter = 0 tokenizer = AutoTokenizer.from_pretrained(model_name_or_path) max_len -= tokenizer.num_special_tokens_to_add() with open(dataset, "rt") as f_p: for line i...
993
22.666667
69
py
robust-transformers
robust-transformers-main/examples/legacy/text-classification/run_tf_text_classification.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE...
10,684
33.356913
133
py
robust-transformers
robust-transformers-main/examples/legacy/multiple_choice/utils_multiple_choice.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...
20,890
35.018966
116
py
robust-transformers
robust-transformers-main/examples/legacy/multiple_choice/run_multiple_choice.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...
8,246
32.938272
133
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/run_distributed_eval.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
10,216
37.847909
119
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/old_test_datasets.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
11,060
43.600806
118
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/run_eval.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
7,285
38.814208
189
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/xla_spawn.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
2,519
28.302326
108
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/old_test_fsmt_bleu_score.py
# coding=utf-8 # Copyright 2020 Huggingface # # 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 ...
2,504
33.791667
114
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/old_test_calculate_rouge.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
5,646
58.442105
353
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/rouge_cli.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
1,180
35.90625
78
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/utils.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
25,293
37.03609
128
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/old_test_seq2seq_examples.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
4,986
36.780303
118
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/pack_dataset.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
3,385
37.044944
98
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/sentence_splitter.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
1,239
33.444444
110
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/run_eval_search.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
5,935
38.052632
182
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/old_test_tatoeba_conversion.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
1,388
34.615385
103
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/seq2seq_trainer.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
11,141
42.019305
154
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/convert_model_to_fp16.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
1,383
36.405405
117
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/minify_dataset.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
1,160
32.171429
74
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/__init__.py
import os import sys sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))
87
13.666667
63
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/download_wmt.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
2,634
37.75
187
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/save_randomly_initialized_model.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
1,539
37.5
146
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/save_len_file.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
2,111
36.052632
111
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/seq2seq_training_args.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
2,678
43.65
126
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/old_test_seq2seq_examples_multi_gpu.py
# Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
2,032
35.303571
123
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/finetune_trainer.py
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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.apache.org/licenses/LICENSE-2.0 # # Unless...
13,809
36.527174
120
py
robust-transformers
robust-transformers-main/examples/legacy/seq2seq/test_data/fsmt/build-eval-data.py
#!/usr/bin/env python import io import json import subprocess pairs = [ ["en", "ru"], ["ru", "en"], ["en", "de"], ["de", "en"], ] n_objs = 8 def get_all_data(pairs, n_objs): text = {} for src, tgt in pairs: pair = f"{src}-{tgt}" cmd = f"sacrebleu -t wmt19 -l {pair} --echo s...
877
24.823529
99
py
robust-transformers
robust-transformers-main/src/transformers/gcdro_loss_ga.py
import os import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from dataclasses import dataclass, field from collections.abc import Mapping from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union class GCDROLossComputerWithGA: def __init__(self, dro_arg...
13,707
47.098246
189
py
robust-transformers
robust-transformers-main/src/transformers/optimization.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...
27,756
40.366617
137
py