This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from torch.distributions import Categorical | |
from transformers import GPT2Tokenizer, GPT2LMHeadModel | |
import torch | |
import torch.nn.functional as F | |
def embed_inputs(embedding, logits, device='cuda', print_entropy=False): | |
''' | |
embeds inputs in a dense representation, before passing them to the model | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import MT5Config, MT5ForConditionalGeneration, MT5Tokenizer | |
from transformers.models.t5.modeling_t5 import load_tf_weights_in_t5 | |
model_name = "persiannlp/mt5-base-parsinlu-opus-translation_fa_en" | |
tokenizer = MT5Tokenizer.from_pretrained(model_name) | |
model = MT5ForConditionalGeneration.from_pretrained(model_name) | |
def run_model(input_string, **generator_args): | |
input_ids = tokenizer.encode(input_string, return_tensors="pt") | |
res = model.generate(input_ids, **generator_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from typing import Iterable | |
from collections import Counter | |
import os | |
import logging | |
import sys | |
import json | |
import click | |
import datasets | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import argparse | |
from typing import Optional, Union, Tuple | |
import torch | |
torch.manual_seed(0) | |
from transformers import BertModel, BertTokenizer, PreTrainedModel, BertConfig | |
from transformers.modeling_outputs import MultipleChoiceModelOutput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sortMapByValue(map) { | |
var tupleArray = []; | |
for (var key in map) tupleArray.push([key, map[key]]); | |
tupleArray.sort(function (a, b) { | |
return b[1] - a[1] | |
}); | |
var sortedMap = {}; | |
tupleArray.forEach(function (el) { | |
sortedMap[el[0]] = el[1] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
all_types_to_idx = { | |
'Task': 0, | |
'Method': 1, | |
'Material': 2, | |
'Metric': 3, | |
'OtherScientificTerm': 4, | |
'Generic': 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from collections import Counter | |
from urllib.parse import urlparse | |
import json | |
import os | |
import re | |
from tqdm import tqdm | |
urls_counts = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import seaborn as sns | |
import scipy | |
import random | |
class NormalGammaPrior(): | |
"""" | |
Suppose X is distributed according to a normal distribution: X ~ N(mu, tau^{-1}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statistics as st | |
import scipy.stats | |
import numpy as np | |
def metric1(scores, row_aggregator, column_aggregator, cell_aggregator): | |
row_values = [] | |
for row_idx, row1 in enumerate(scores): | |
diagonal_x = row1[row_idx] | |
row_values.append( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
show_unpublished_scores: true | |
datasets: | |
blind_labels: danielk/genie_labels | |
evaluator: | |
image: jbragg/genie-evaluator | |
input_path: /preds/ | |
predictions_filename: predictions.json | |
label_path: /labels/ | |
output_path: /results | |
arguments: |
NewerOlder