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
fat-albert
fat-albert-master/abmn/src/movieqa/data/data/story_loader.py
"""MovieQA - Story Understanding Benchmark. Story loaders for reading plots, subtitles, DVS, etc. http://movieqa.cs.toronto.edu/ Release: v1.0 Date: 18 Nov 2015 """ import os import re import pysrt import config PKG = config.PACKAGE_DIRECTORY dvs_rep = re.compile('^\d+-\d+') dvs_cur = re.compile('\{.+?\}') quote_...
5,064
32.322368
89
py
fat-albert
fat-albert-master/abmn/src/movieqa/data/data/config.py
"""Define file paths.""" import os PACKAGE_DIRECTORY = os.path.dirname(os.path.abspath(__file__)) MOVIES_JSON = os.path.join(PACKAGE_DIRECTORY, 'data/movies.json') QA_JSON = os.path.join(PACKAGE_DIRECTORY, 'data/qa.json') SPLIT_JSON = os.path.join(PACKAGE_DIRECTORY, 'data/splits.json')
292
23.416667
65
py
fat-albert
fat-albert-master/abmn/src/movieqa/data/data/__init__.py
"""MovieQA - Story Understanding Benchmark. http://movieqa.cs.toronto.edu/ Release: v1.0 Date: 18 Nov 2015 """ from data_loader import DataLoader
151
11.666667
43
py
fat-albert
fat-albert-master/abmn/src/movieqa/adversarial_addAny/english_words.py
"""Get common English words from Brown Corpus.""" from nltk import FreqDist from nltk.corpus import brown import string punctuation = set(string.punctuation) | set(['``', "''", "--"]) def get_common_words(outfile, num): freq_dist = FreqDist(w.lower() for w in brown.words() if w not in punctuation) vocab = [x...
533
25.7
82
py
fat-albert
fat-albert-master/abmn/src/movieqa/adversarial_addAny/create_addAny_examples.py
import sys import os sys.path.append('data') # os.chdir("..") import movieqa.data.data_loader as movie import core.util as util from random import randrange from random import shuffle import random import glob import tensorflow as tf import core.model as model import numpy as np import _pickle as pickle # implement...
12,013
38.781457
138
py
fat-albert
fat-albert-master/abmn/src/movieqa/adversarial_addAny/eval_addAny.py
import sys import os sys.path.append('data') # os.chdir("..") import movieqa.data.data_loader as movie import core.util as util from random import randrange from random import shuffle import random import glob import tensorflow as tf import core.model as model import numpy as np import _pickle as pickle # implement...
8,214
33.516807
130
py
fat-albert
fat-albert-master/abmn/src/movieqa/adversarial_addAny/add_common_words_to_vocab.py
import os import sys present_path = os.path.dirname(os.path.realpath(sys.argv[0])) sys.path.append(os.path.join(present_path, '../../')) import core.util as util import movieqa.data_conf as data_conf glove = util.loadGloveModel(data_conf.PRETRAINED_EMBEDDINGS_PATH) #vectors, vocab = util.load_embeddings(data_conf.E...
916
29.566667
82
py
fat-albert
fat-albert-master/abmn/src/movieqa/adversarial_addAny/__init__.py
0
0
0
py
fat-albert
fat-albert-master/abmn/src/ensemble_folder_test/refine.py
import numpy as np predictions = np.loadtxt('preds.txt') f = open("plot_results.txt", "a") counter = 0 for i in predictions: f.write("test:" + str(counter) + " " + str(int(i)) + "\n") counter = counter + 1
215
23
62
py
fat-albert
fat-albert-master/bert/setup.py
""" Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/master/setup.py To create the package for pypi. 1. Change the version in __init__.py, setup.py as well as docs/source/conf.py. 2. Commit these changes with the message: "Release: VERSION" 3. Add a tag in git to mark the release: "git...
2,923
39.054795
183
py
fat-albert
fat-albert-master/bert/hubconf.py
from transformers import ( AutoTokenizer, AutoConfig, AutoModel, AutoModelWithLMHead, AutoModelForSequenceClassification, AutoModelForQuestionAnswering ) from transformers.file_utils import add_start_docstrings dependencies = ['torch', 'tqdm', 'boto3', 'requests', 'regex', 'sentencepiece', 'sacremoses'] @add_star...
6,489
56.433628
189
py
fat-albert
fat-albert-master/bert/examples/run_lm_finetuning.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...
28,924
50.929982
165
py
fat-albert
fat-albert-master/bert/examples/utils_squad_evaluate.py
""" Official evaluation script for SQuAD version 2.0. Modified by XLNet authors to update `find_best_threshold` scripts for SQuAD V2.0 In addition to basic functionality, we also compute additional statistics and plot precision-recall curves if an additional na_prob.json file is provided. This file is expected to ...
12,493
36.746224
107
py
fat-albert
fat-albert-master/bert/examples/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...
31,780
54.175347
151
py
fat-albert
fat-albert-master/bert/examples/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,773
37.257827
119
py
fat-albert
fat-albert-master/bert/examples/run_glue.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...
28,343
52.278195
158
py
fat-albert
fat-albert-master/bert/examples/benchmarks.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...
23,631
48.439331
138
py
fat-albert
fat-albert-master/bert/examples/run_summarization_finetuning.py
# coding=utf-8 # Copyright 2019 The HuggingFace Inc. team. # Copyright (c) 2019 The HuggingFace Inc. 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...
15,727
30.902637
120
py
fat-albert
fat-albert-master/bert/examples/run_bertology.py
#!/usr/bin/env python3 # Copyright 2018 CMU 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 requir...
18,901
51.798883
177
py
fat-albert
fat-albert-master/bert/examples/utils_summarization_test.py
# coding=utf-8 # Copyright 2019 HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
5,178
36.80292
98
py
fat-albert
fat-albert-master/bert/examples/run_generation.py
#!/usr/bin/env python3 # 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 c...
13,112
49.241379
167
py
fat-albert
fat-albert-master/bert/examples/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...
28,788
53.013133
184
py
fat-albert
fat-albert-master/bert/examples/utils_summarization.py
from collections import deque import os import torch from torch.utils.data import Dataset # ------------ # Data loading # ------------ class CNNDailyMailDataset(Dataset): """ Abstracts the dataset used to train seq2seq models. CNN/Daily News: The CNN/Daily News raw datasets are downloaded from [1]. T...
6,022
31.556757
88
py
fat-albert
fat-albert-master/bert/examples/run_tf_glue.py
import os import tensorflow as tf import tensorflow_datasets from transformers import BertTokenizer, TFBertForSequenceClassification, BertConfig, glue_convert_examples_to_features, BertForSequenceClassification, glue_processors # script parameters BATCH_SIZE = 32 EVAL_BATCH_SIZE = BATCH_SIZE * 2 USE_XLA = False USE_AM...
3,978
41.329787
166
py
fat-albert
fat-albert-master/bert/examples/test_examples.py
# coding=utf-8 # Copyright 2018 HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
4,166
36.205357
88
py
fat-albert
fat-albert-master/bert/examples/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...
29,481
50.722807
168
py
fat-albert
fat-albert-master/bert/examples/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...
9,181
42.107981
109
py
fat-albert
fat-albert-master/bert/examples/run_xnli.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...
27,117
51.554264
151
py
fat-albert
fat-albert-master/bert/examples/utils_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 co...
42,376
40.627701
112
py
fat-albert
fat-albert-master/bert/examples/utils_multiple_choice.bak.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...
17,575
36.797849
119
py
fat-albert
fat-albert-master/bert/examples/contrib/run_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...
6,742
42.785714
111
py
fat-albert
fat-albert-master/bert/examples/contrib/run_swag.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...
31,683
45.731563
154
py
fat-albert
fat-albert-master/bert/examples/contrib/run_movieqa.bak.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...
32,036
45.701166
154
py
fat-albert
fat-albert-master/bert/examples/contrib/run_openai_gpt.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...
14,471
48.731959
132
py
fat-albert
fat-albert-master/bert/examples/contrib/run_movieqa.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...
35,214
45.274639
154
py
fat-albert
fat-albert-master/bert/examples/contrib/run_camembert.py
from pathlib import Path import tarfile import urllib.request import torch from transformers.tokenization_camembert import CamembertTokenizer from transformers.modeling_camembert import CamembertForMaskedLM def fill_mask(masked_input, model, tokenizer, topk=5): # Adapted from https://github.com/pytorch/fairseq/...
2,015
40.142857
114
py
fat-albert
fat-albert-master/bert/examples/distillation/grouped_batch_sampler.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. 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.org/licenses/LICENSE-2.0 # # Un...
4,368
40.216981
125
py
fat-albert
fat-albert-master/bert/examples/distillation/utils.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. 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.org/licenses/LICENSE-2.0 # # Un...
4,308
32.146154
104
py
fat-albert
fat-albert-master/bert/examples/distillation/lm_seqs_dataset.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. 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.org/licenses/LICENSE-2.0 # # Un...
5,453
34.881579
111
py
fat-albert
fat-albert-master/bert/examples/distillation/run_squad_w_distillation.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...
33,733
55.129784
151
py
fat-albert
fat-albert-master/bert/examples/distillation/train.py
# coding=utf-8 # Copyright 2019-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 a...
13,598
45.731959
135
py
fat-albert
fat-albert-master/bert/examples/distillation/distiller.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. 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.org/licenses/LICENSE-2.0 # # Un...
25,933
46.848708
163
py
fat-albert
fat-albert-master/bert/examples/distillation/scripts/token_counts.py
# coding=utf-8 # Copyright 2019-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 a...
2,062
38.673077
129
py
fat-albert
fat-albert-master/bert/examples/distillation/scripts/extract.py
# coding=utf-8 # Copyright 2019-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 a...
4,326
47.077778
158
py
fat-albert
fat-albert-master/bert/examples/distillation/scripts/extract_distilbert.py
# coding=utf-8 # Copyright 2019-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 a...
4,255
50.277108
158
py
fat-albert
fat-albert-master/bert/examples/distillation/scripts/binarized_data.py
# coding=utf-8 # Copyright 2019-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 a...
3,630
38.043011
140
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/modeling_xxx.py
# coding=utf-8 # Copyright 2018 XXX 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 ...
34,579
51.473445
151
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/tokenization_xxx.py
# coding=utf-8 # Copyright 2018 XXX 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...
9,578
42.739726
117
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/configuration_xxx.py
# coding=utf-8 # Copyright 2010, XXX 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...
5,273
39.259542
128
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/convert_xxx_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,565
37.878788
100
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/modeling_tf_xxx.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...
27,575
53.605941
193
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/tests/tokenization_xxx_test.py
# coding=utf-8 # Copyright 2018 XXX 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...
2,092
35.086207
90
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/tests/modeling_tf_xxx_test.py
# coding=utf-8 # Copyright 2018 XXX 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...
11,411
43.404669
160
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/tests/modeling_xxx_test.py
# coding=utf-8 # Copyright 2018 XXX 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...
11,628
44.425781
160
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_example_script/utils_xxx.py
# coding=utf-8 # Copyright 2018 XXX. 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...
41,415
40.582329
112
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_example_script/run_xxx.py
# coding=utf-8 # Copyright 2018 XXX. 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 applicable...
30,654
53.741071
151
py
fat-albert
fat-albert-master/bert/datasets/SWAG/pytorch_misc.py
""" Miscellaneous functions that might be useful for pytorch """ import h5py import numpy as np import torch from torch.autograd import Variable import os import dill as pkl from itertools import tee from torch import nn import time def optimistic_restore(network, state_dict): mismatch = False own_state = net...
15,621
29.216634
118
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/unarylstm/lstm_swag.py
from typing import Dict, List, TextIO, Optional from overrides import overrides import torch from torch.nn.modules import Linear, Dropout import torch.nn.functional as F from allennlp.common import Params from allennlp.common.checks import check_dimensions_match from allennlp.data import Vocabulary from allennlp.modu...
6,737
45.791667
97
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/unarylstm/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/unarylstm/predict.py
""" adapted from Allennlp because their version doesn't seem to work 😢😢😢 """ from typing import Dict, Any, Iterable import argparse import logging from allennlp.commands.subcommand import Subcommand from allennlp.common.util import prepare_environment, import_submodules from allennlp.common.tqdm import Tqdm from al...
4,020
35.889908
113
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/unarylstm/dataset_reader.py
# slightly different from the other dataset reader from typing import Dict, List import json import logging from overrides import overrides from allennlp.common import Params from allennlp.common.file_utils import cached_path from allennlp.data.dataset_readers.dataset_reader import DatasetReader from allennlp.data.f...
4,139
40.4
110
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/fasttext/prep_data.py
import pandas as pd from tqdm import tqdm from allennlp.common.util import get_spacy_model USE_ONLY_GOLD_EXAMPLES = False spacy_model = get_spacy_model("en_core_web_sm", pos_tags=False, parse=False, ner=False) def _tokenize(sent): return ' '.join([x.orth_.lower() for x in spacy_model(sent)]) for split in ('tra...
2,404
39.083333
146
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/fasttext/compute_performance.py
import numpy as np import argparse import os # neg probability, pos prob parser = argparse.ArgumentParser(description='compute performance') parser.add_argument('fn', metavar='fn', type=str, help='filename 2 use') fn = parser.parse_args().fn rez = [] with open(fn, 'r') as f: all_lines = f.read...
772
27.62963
67
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/fasttext/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/esim/esim_swag.py
# TODO: projection dropout with ELMO # l2 reg with ELMO # multiple ELMO layers # doc from typing import Dict, Optional import torch from torch.autograd import Variable from allennlp.common import Params from allennlp.common.checks import check_dimensions_match from allennlp.data import Vocabulary from allennlp...
13,868
45.69697
156
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/esim/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/esim/predict.py
""" adapted from Allennlp because their version doesn't seem to work 😢😢😢 """ from typing import Dict, Any, Iterable import argparse import logging from allennlp.commands.subcommand import Subcommand from allennlp.common.util import prepare_environment, import_submodules from allennlp.common.tqdm import Tqdm from al...
3,983
36.233645
113
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/esim/dataset_reader.py
# Exactly the same as the other dataset reader from typing import Dict, List import json import logging from overrides import overrides from allennlp.common import Params from allennlp.common.file_utils import cached_path from allennlp.data.dataset_readers.dataset_reader import DatasetReader from allennlp.data.field...
4,065
40.917526
110
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/decomposable_attention/decomposable_attention_swag.py
from typing import Dict, Optional import torch from allennlp.common import Params from allennlp.common.checks import check_dimensions_match from allennlp.data import Vocabulary from allennlp.models.model import Model from allennlp.modules import FeedForward, MatrixAttention from allennlp.modules import Seq2SeqEncoder...
13,628
50.430189
164
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/decomposable_attention/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/decomposable_attention/dataset_reader.py
# Exactly the same as the other dataset reader from typing import Dict, List import json import logging from overrides import overrides from allennlp.common import Params from allennlp.common.file_utils import cached_path from allennlp.data.dataset_readers.dataset_reader import DatasetReader from allennlp.data.field...
4,065
40.917526
110
py
fat-albert
fat-albert-master/bert/datasets/SWAG/raw_data/events.py
""" Dataloader for event data. this includes - rocstories - didemo - MPII - activitynet captions """ import pandas as pd import json from collections import defaultdict import numpy as np import re import os from tqdm import tqdm from allennlp.common.util import get_spacy_model from tqdm import tqdm from unidecode imp...
23,643
39.417094
148
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/questions2mturk.py
import random import pickle as pkl import numpy as np from tqdm import tqdm from nltk.tokenize.moses import MosesDetokenizer import pandas as pd import re detokenizer = MosesDetokenizer() NUM_DISTRACTORS = 5 def _detokenize(sent): s0 = detokenizer.detokenize(sent, return_str=True) s1 = re.sub(r'\b(ca|do|wo)\s...
2,111
32.52381
167
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/rebalance_dataset_mlp.py
""" The big idea will be to add in the worst scoring one. But we want to use a MULTILAYER PERCEPTRON. Also not using word features for now """ import matplotlib as mpl mpl.use('Agg') import seaborn as sns import matplotlib.pyplot as plt from allennlp.data import Vocabulary from torch.nn import functional as F from t...
10,256
39.066406
138
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/classifiers.py
""" The big idea will be to add in the worst scoring one. But we want to use a MULTILAYER PERCEPTRON. Also not using word features for now """ import torch from allennlp.common import Params from allennlp.modules.augmented_lstm import AugmentedLstm from allennlp.modules.seq2seq_encoders.pytorch_seq2seq_wrapper import...
15,626
43.019718
151
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/sample_candidates.py
import pickle as pkl from argparse import ArgumentParser from copy import deepcopy from time import time import numpy as np import pandas as pd import torch from allennlp.commands.predict import Predictor from allennlp.data import Vocabulary from allennlp.models.archival import load_archive from tqdm import tqdm from...
8,718
40.918269
119
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/rebalance_dataset_ensemble.py
""" The big idea will be to add in the worst scoring one. But we want to use a MULTILAYER PERCEPTRON. Also not using word features for now """ import pickle as pkl from argparse import ArgumentParser from copy import deepcopy import numpy as np import pandas as pd import spacy import torch from allennlp.data import ...
13,160
44.539792
122
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/pretrain_lm.py
import os import pandas as pd import torch from allennlp.data import Instance from allennlp.data import Token from allennlp.data import Vocabulary from allennlp.data.dataset import Batch from allennlp.data.fields import TextField from allennlp.data.token_indexers import SingleIdTokenIndexer from allennlp.data.token_in...
4,759
40.391304
118
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/config.py
# Set this to how many LMs you want to train on diff splits of the data NUM_FOLDS = 5 # what text to train on (right now it's toronto books) PRETRAIN_TXT = '/home/mbforbes/repos/ari-holtzman/learning_to_write/data/corpora/tbooks/train.txt'
242
33.714286
98
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/train_lm.py
import os from argparse import ArgumentParser import numpy as np import pandas as pd import torch from torch import optim from torch.optim.lr_scheduler import StepLR from tqdm import tqdm from create_swag.lm.config import NUM_FOLDS from create_swag.lm.load_data import load_lm_data, RawPassages from create_swag.lm.sim...
3,709
41.159091
104
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/simple_bilm.py
""" A wrapper around ai2s elmo LM to allow for an lm objective... """ from typing import Optional, Tuple from typing import Union, List, Dict import numpy as np import torch from allennlp.common.checks import ConfigurationError from allennlp.data import Token, Vocabulary, Instance from allennlp.data.dataset import Ba...
16,902
48.568915
117
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/load_data.py
# First make the vocabulary, etc. import os import pickle as pkl import random import simplejson as json from allennlp.common.util import get_spacy_model from allennlp.data import Instance from allennlp.data import Token from allennlp.data import Vocabulary from allennlp.data.dataset import Batch from allennlp.data.f...
6,285
40.629139
118
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/__init__.py
0
0
0
py
fat-albert
fat-albert-master/bert/datasets/MovieQA/semantic_alignment_clinical.py
import config as cfg import story_loader import data_loader import csv import numpy as np from semantic_text_similarity.models import WebBertSimilarity from semantic_text_similarity.models import ClinicalBertSimilarity web_model = WebBertSimilarity(device='cuda', batch_size=10) #defaults to GPU prediction clinical_mod...
2,519
34
100
py
fat-albert
fat-albert-master/bert/datasets/MovieQA/sem_align_eval_train.py
import config as cfg import story_loader import data_loader import csv import numpy as np from semantic_text_similarity.models import WebBertSimilarity from semantic_text_similarity.models import ClinicalBertSimilarity web_model = WebBertSimilarity(device='cuda', batch_size=100) #defaults to GPU prediction clinical_mo...
5,033
39.596774
100
py
fat-albert
fat-albert-master/bert/datasets/MovieQA/semantic_alignment.py
import config as cfg import story_loader import data_loader import csv import numpy as np from semantic_text_similarity.models import WebBertSimilarity web_model = WebBertSimilarity(device='cuda', batch_size=10) #defaults to GPU prediction num_sentences = 6 mqa = data_loader.DataLoader() def stringReplace(input): ...
5,040
42.08547
170
py
fat-albert
fat-albert-master/bert/datasets/MovieQA/sem_align_eval_val.py
import config as cfg import story_loader import data_loader import csv import numpy as np from semantic_text_similarity.models import WebBertSimilarity from semantic_text_similarity.models import ClinicalBertSimilarity web_model = WebBertSimilarity(device='cuda', batch_size=100) #defaults to GPU prediction clinical_mo...
5,009
39.403226
100
py
fat-albert
fat-albert-master/bert/datasets/MovieQA/semantic_alignment_fast.py
import config as cfg import story_loader import data_loader import csv import numpy as np from semantic_text_similarity.models import WebBertSimilarity web_model = WebBertSimilarity(device='cuda', batch_size=10) #defaults to GPU prediction num_sentences = 6 mqa = data_loader.DataLoader() def stringReplace(input): ...
2,116
37.490909
170
py
fat-albert
fat-albert-master/bert/datasets/MovieQA/plot_alignment.py
import config as cfg import story_loader import data_loader import csv mqa = data_loader.DataLoader() def stringReplace(input): output = input if not output: output = 'None' return output ## LOAD THE TRAINING DATASET movie_list = mqa.get_split_movies(split='train') story, qa = mqa.get_story_qa_da...
2,784
38.785714
170
py
fat-albert
fat-albert-master/bert/docs/source/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
5,609
28.68254
79
py
fat-albert
fat-albert-master/bert/transformers/modeling_encoder_decoder.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,827
49.893891
472
py
fat-albert
fat-albert-master/bert/transformers/tokenization_roberta.py
# coding=utf-8 # Copyright 2018 The Open AI 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,300
47.673333
120
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_albert.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors 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...
39,735
48.732165
193
py
fat-albert
fat-albert-master/bert/transformers/configuration_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...
8,112
43.576923
121
py
fat-albert
fat-albert-master/bert/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...
7,658
44.052941
134
py
fat-albert
fat-albert-master/bert/transformers/configuration_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...
6,805
38.80117
110
py
fat-albert
fat-albert-master/bert/transformers/__main__.py
# coding: utf8 def main(): import sys if (len(sys.argv) < 4 or len(sys.argv) > 6) or sys.argv[1] not in ["bert", "gpt", "transfo_xl", "gpt2", "xlnet", "xlm"]: print( "This command line utility let you convert original (author released) model checkpoint to pytorch.\n" "It should be used a...
7,085
53.507692
135
py