id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
164,477 | import json
all_domain = [
"[taxi]","[police]","[hospital]","[hotel]","[attraction]","[train]","[restaurant]",'[profile]'
]
informable_slots = {'restaurant': ['people','day','time','name', 'adress', 'pricerange', 'food', 'post', 'bookpeople', 'phone', 'bookday', 'area', 'booktime'],
# 'profile... | Convert compacted bs span to triple list Ex: |
164,478 | import json
def ignore_none(pred_belief, target_belief):
for pred in pred_belief:
if 'catherine s' in pred:
pred.replace('catherine s', 'catherines')
clean_target_belief = []
clean_pred_belief = []
for bs in target_belief:
if 'not mentioned' in bs or 'none' in bs:
... | null |
164,479 | import json
GENERAL_TYPO = {
# type
"guesthouse":"guest house", "guesthouses":"guest house", "guest":"guest house", "mutiple sports":"multiple sports",
"sports":"multiple sports", "mutliple sports":"multiple sports","swimmingpool":"swimming pool", "concerthall":"concert hall",
"concert":... | null |
164,480 | import json, os, re, copy, zipfile
import spacy
import space.utils.ontology as ontology
import space.utils.utils as utils
from collections import OrderedDict
from tqdm import tqdm
from config import global_config as cfg
from db_ops import MultiWozDB
from clean_dataset import clean_slot_values, clean_text
def clean_sl... | null |
164,481 | import json, os, re, copy, zipfile
import spacy
import space.utils.ontology as ontology
import space.utils.utils as utils
from collections import OrderedDict
from tqdm import tqdm
from config import global_config as cfg
from db_ops import MultiWozDB
from clean_dataset import clean_slot_values, clean_text
def clean_sl... | null |
164,482 | import re
import space.utils.ontology as ontology
def my_clean_text(text):
text = re.sub(r'([a-zT]+)\.([a-z])', r'\1 . \2', text) # 'abc.xyz' -> 'abc . xyz'
text = re.sub(r'(\w+)\.\.? ', r'\1 . ', text) # if 'abc. ' -> 'abc . '
return text | null |
164,483 | import re
import space.utils.ontology as ontology
def clean_text(text):
def clean_slot_values(domain, slot, value):
value = clean_text(value)
if not value:
value = ''
elif value == 'not mentioned':
value = ''
# value = 'not mentioned' # if in DST setting
elif domain == 'profile'... | null |
164,484 | import os, json, copy, re, zipfile
from collections import OrderedDict
from space.utils.ontology import all_domains
data_path = './space/data/multiwoz2.0/'
save_path = './space/data/multiwoz2.0/'
save_path_exp = './space/data/multiwoz2.0/'
data_file = 'data.json'
domains = all_domains
def analysis():
compressed_ra... | null |
164,501 | import multiprocessing
import random
from itertools import chain
import os
import glob
import json
import numpy as np
import time
import re
from tqdm import tqdm
from space.args import str2bool
from space.data.tokenizer import Tokenizer
from space.utils import ontology
from space.utils.scores import tree_edit_score
def... | null |
164,502 | import os
import random
from collections import OrderedDict, defaultdict
from itertools import chain
import json
import sqlite3 as sql
import numpy as np
import spacy
from tqdm import tqdm
from nltk.tokenize import word_tokenize as nltk_word_tokenize
from nltk.stem import WordNetLemmatizer
from space.args import str2bo... | null |
164,507 | import json
import logging
import os
import sys
import time
from collections import OrderedDict
import torch
import numpy as np
from tqdm import tqdm
from transformers.optimization import AdamW, get_linear_schedule_with_warmup
from dst import default_cleaning, IGNORE_TURNS_TYPE2, paser_bs,ignore_none
from space.args im... | null |
164,508 | import json
import logging
import os
import sys
import time
from collections import OrderedDict
import torch
import numpy as np
from tqdm import tqdm
from transformers.optimization import AdamW, get_linear_schedule_with_warmup
from dst import default_cleaning, IGNORE_TURNS_TYPE2, paser_bs,ignore_none
from space.args im... | null |
164,521 | import re
from space.utils import ontology
def clean_text(text):
def clean_slot_values(domain, slot, value):
value = clean_text(value)
if not value:
value = ''
elif value == 'not mentioned':
value = ''
# value = 'not mentioned' # if in DST setting
elif domain == 'attraction':
... | null |
164,528 | import json
GENERAL_TYPO = {
# type
"guesthouse":"guest house", "guesthouses":"guest house", "guest":"guest house", "mutiple sports":"multiple sports",
"sports":"multiple sports", "mutliple sports":"multiple sports","swimmingpool":"swimming pool", "concerthall":"concert hall",
"concert":... | null |
164,529 | import json, os, re, copy, zipfile
import spacy
import space.utils.ontology as ontology
import space.utils.utils as utils
from collections import OrderedDict
from tqdm import tqdm
from config import global_config as cfg
from db_ops import MultiWozDB
from clean_dataset import clean_slot_values, clean_text
def clean_sl... | null |
164,557 | import json
import logging
import os
import sys
import time
from collections import OrderedDict
import torch
import numpy as np
from tqdm import tqdm
from transformers.optimization import AdamW, get_linear_schedule_with_warmup
from space.args import str2bool
from space.data.data_loader import DataLoader
from space.metr... | null |
164,574 | import re
from space.utils import ontology
def clean_text(text):
text = text.strip()
text = text.lower()
text = text.replace(u"’", "'")
text = text.replace(u"‘", "'")
text = text.replace(';', ',')
text = text.replace('"', ' ')
text = text.replace('/', ' and ')
text = text.replace("don't"... | null |
164,576 | import json
import math
from collections import Counter
import numpy as np
from nltk.util import ngrams
from sklearn.metrics import f1_score
from space.utils import ontology, utils
from space.utils.clean_dataset import clean_slot_values
def setsub(a,b):
def setsim(a,b):
a,b = set(a),set(b)
return setsub(a,b) a... | null |
164,583 | import json, os, re, copy, zipfile
import spacy
import space.utils.ontology as ontology
import space.utils.utils as utils
from collections import OrderedDict
from tqdm import tqdm
from config import global_config as cfg
from db_ops import MultiWozDB
from clean_dataset import clean_slot_values, clean_text
def clean_sl... | null |
164,591 | import os
import re
import glob
import json
import math
import torch
import pickle
import random
import logging
import argparse
import numpy as np
from model import DSTModel
from tqdm import tqdm, trange
from utils_dst import InputFeatures
from torch.nn.utils.rnn import pad_sequence
from tensorlistdataset import Tensor... | null |
164,592 | import os
import re
import glob
import json
import math
import torch
import pickle
import random
import logging
import argparse
import numpy as np
from model import DSTModel
from tqdm import tqdm, trange
from utils_dst import InputFeatures
from torch.nn.utils.rnn import pad_sequence
from tensorlistdataset import Tensor... | null |
164,593 | import os
import re
import glob
import json
import math
import torch
import pickle
import random
import logging
import argparse
import numpy as np
from model import DSTModel
from tqdm import tqdm, trange
from utils_dst import InputFeatures
from torch.nn.utils.rnn import pad_sequence
from tensorlistdataset import Tensor... | Train the model |
164,594 | import os
import re
import glob
import json
import math
import torch
import pickle
import random
import logging
import argparse
import numpy as np
from model import DSTModel
from tqdm import tqdm, trange
from utils_dst import InputFeatures
from torch.nn.utils.rnn import pad_sequence
from tensorlistdataset import Tensor... | null |
164,595 | import os
import re
import glob
import json
import math
import torch
import pickle
import random
import logging
import argparse
import numpy as np
from model import DSTModel
from tqdm import tqdm, trange
from utils_dst import InputFeatures
from torch.nn.utils.rnn import pad_sequence
from tensorlistdataset import Tensor... | null |
164,597 | import re
import os
import json
import pickle
import librosa
import argparse
import numpy as np
from tqdm import tqdm
from joblib import Parallel, delayed
from utils_dst import (DSTExample, convert_to_unicode)
def load_acts(input_file, data_indexs, slot_list):
s_dict = {}
for d in data_indexs:
# print(d... | null |
164,600 | import six
import json
import torch
import pickle
import logging
import argparse
import numpy as np
from tqdm import tqdm
from collections import defaultdict
from joblib import Parallel, delayed
from transformers import Wav2Vec2Processor, RobertaTokenizerFast, BertTokenizer
class InputFeatures(object):
"""A single ... | Loads a data file into a list of `InputBatch`s. |
164,601 | import gc
import json
import logging
import os
import textwrap
import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from tqdm import tqdm
from anchor import logger_root
from common import setup_env, mk_parser, AdvantageLogger
from models import build_model_signature, build_tokenizer... | null |
164,602 | import gc
import json
import logging
import os
import textwrap
import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from tqdm import tqdm
from anchor import logger_root
from common import setup_env, mk_parser, AdvantageLogger
from models import build_model_signature, build_tokenizer... | null |
164,603 | import argparse
import os
import random
import numpy as np
import torch
from tasks import task_mapper
from utils.logger import tabular_pretty_print, fmt_float
def setup_seed(SEED):
def setup_gpu(gpu_s):
def setup_env(gpu_s, seed):
os.environ["BITSANDBYTES_NOWELCOME"] = "1"
os.environ["TOKENIZERS_PARALLELISM"] ... | null |
164,604 | import argparse
import os
import random
import numpy as np
import torch
from tasks import task_mapper
from utils.logger import tabular_pretty_print, fmt_float
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ("yes", "true", "t", "y", "1"):
return True
elif v.lower() in ("no"... | null |
164,605 | import argparse
import os
import random
import numpy as np
import torch
from tasks import task_mapper
from utils.logger import tabular_pretty_print, fmt_float
def mk_parser_openai():
psr = argparse.ArgumentParser(add_help=False)
psr.add_argument("--prompt_version", type=str, default="v1")
psr.add_argument(... | null |
164,606 | from transformers import AutoTokenizer, PreTrainedTokenizerFast, AutoModelForCausalLM
from anchor import checkpoints_root
def build_model_signature(model_type, model_size):
if model_type == "opt":
# ["125m", "350m", "1.3b", "2.7b", "6.7b", "13b", "30b", "66b"]
return f"facebook/opt-{model_size}"
... | null |
164,607 | from transformers import AutoTokenizer, PreTrainedTokenizerFast, AutoModelForCausalLM
from anchor import checkpoints_root
def build_model_signature(model_type, model_size):
if model_type == "opt":
# ["125m", "350m", "1.3b", "2.7b", "6.7b", "13b", "30b", "66b"]
return f"facebook/opt-{model_size}"
... | null |
164,608 | import multiprocessing
from pathlib import Path
import json
def yield_chunks(data, size):
data = list(data)
for i in range(0, len(data), size):
yield data[i : i + size] | null |
164,609 | import multiprocessing
from pathlib import Path
import json
def ensure_folder(folder: Path, parents=False):
if not folder.exists():
folder.mkdir(parents=parents) | null |
164,610 | import multiprocessing
from pathlib import Path
import json
def pick_if_present(d: dict, key_in_dict, key_new=None):
if key_in_dict in d:
if not key_new:
return {key_in_dict: d[key_in_dict]}
else:
return {key_new: d[key_in_dict]}
return {} | null |
164,611 | from __future__ import absolute_import, division, unicode_literals
import logging
from pathlib import Path
import logging
import multiprocessing
import threading
def setup_logger(folder_path, log_file_name="logger.log", console_output=False, logger_name="task"):
dir_root = Path(folder_path)
full_path = dir_roo... | null |
164,612 | from __future__ import absolute_import, division, unicode_literals
import logging
from pathlib import Path
import logging
import multiprocessing
import threading
def setup_simple_logger():
root_logger = logging.getLogger()
root_logger.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s| %(me... | null |
164,613 | from __future__ import absolute_import, division, unicode_literals
import logging
from pathlib import Path
import logging
import multiprocessing
import threading
def tabular_pretty_print(grid):
lens = [max(map(len, col)) for col in zip(*grid)]
fmt = " | ".join("{{:{}}}".format(x) for x in lens)
table = [f... | null |
164,614 | from __future__ import absolute_import, division, unicode_literals
import logging
from pathlib import Path
import logging
import multiprocessing
import threading
def fmt_float(num, d=4):
fmt_string = "{{:.{}f}}".format(d)
return fmt_string.format(num) | null |
164,615 | from __future__ import absolute_import, division, unicode_literals
import logging
from pathlib import Path
import logging
import multiprocessing
import threading
class MultiProcessingHandler(logging.Handler):
def __init__(self, name, sub_handler=None):
super(MultiProcessingHandler, self).__init__()
... | Wraps the handlers in the given Logger with an MultiProcessingHandler. :param logger: whose handlers to wrap. By default, the root logger. |
164,616 | from __future__ import absolute_import, division, unicode_literals
import logging
from pathlib import Path
import logging
import multiprocessing
import threading
class MultiProcessingHandler(logging.Handler):
def __init__(self, name, sub_handler=None):
super(MultiProcessingHandler, self).__init__()
... | Unwraps the handlers in the given Logger from a MultiProcessingHandler wrapper :param logger: whose handlers to unwrap. By default, the root logger. |
164,617 | from transformers import Seq2SeqTrainer, is_torch_tpu_available, EvalPrediction
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union
import nltk
import datasets
import re
import os
import numpy as np
import torch
import random
from pathlib import Path
import nltk
from transformers.trainer... | null |
164,618 | import logging
import os
import torch
import copy,random
import sys
import json
from dataclasses import dataclass, field
from typing import Optional
from typing import List, Optional, Tuple
from sklearn.cluster import KMeans
from models.metadeca import T5ForConditionalGeneration as PromptT5
from metrics import compute_... | null |
164,619 | import logging
import os
import torch
import copy,random
import sys
import json
from dataclasses import dataclass, field
from typing import Optional
from typing import List, Optional, Tuple
from sklearn.cluster import KMeans
from models.metadecanometa import T5ForConditionalGeneration as PromptT5
from metrics import co... | null |
164,620 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_sqaud_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
conte... | null |
164,621 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_sqaud_abstractive_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_colum... | null |
164,622 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_boolq_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
question_column, context_column, answer_column ... | null |
164,623 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_boolq_batch_pretrain(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
... | null |
164,624 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_narrativeqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = [exp['summary']['text'] for ex... | null |
164,625 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_narrativeqa_batch_pretrain(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_co... | null |
164,626 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_drop_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = examples['passage']
questions = e... | null |
164,627 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_race_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = examples['article']
questions = e... | null |
164,628 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_newsqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
cont... | null |
164,629 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_ropes_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
backg... | null |
164,630 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_openbookqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples['question_stem']
... | null |
164,631 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_social_iqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = examples['article']
questio... | null |
164,632 | import sys
from typing import List, Optional, Tuple
from QAInput import StructuralQAInput as QAInput
def preprocess_dream_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = [" ".join(dialogue) for dialogue in ... | null |
164,633 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
import codecs
import nltk
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from nltk.corpus import stopwords
from collections import Counter
import json
def pr... | null |
164,634 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
import codecs
import nltk
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from nltk.corpus import stopwords
from collections import Counter
import json
def pr... | null |
164,635 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
import codecs
import nltk
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from nltk.corpus import stopwords
from collections import Counter
import json
def ad... | null |
164,636 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
import codecs
import nltk
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from nltk.corpus import stopwords
from collections import Counter
import json
def pr... | null |
164,637 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
import codecs
import nltk
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from nltk.corpus import stopwords
from collections import Counter
import json
def pr... | null |
164,641 | import argparse
import collections
import json
import os
import re
import string
import sys
import numpy as np
def normalize_answer(s):
def compute_exact(a_gold, a_pred):
def compute_f1(a_gold, a_pred):
def get_raw_scores(dataset, preds):
exact_scores = {}
f1_scores = {}
for article in dataset:
for... | null |
164,653 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
from tqdm import tqdm
import codecs
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from QAInput import StructuralQAInput, SimpleQAInput
from transformers impo... | null |
164,654 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
from tqdm import tqdm
import codecs
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from QAInput import StructuralQAInput, SimpleQAInput
from transformers impo... | null |
164,655 | import itertools
import json
import os
import csv
import errno
import random
from random import shuffle
from typing import List
from tqdm import tqdm
import codecs
import glob
import xml.etree.ElementTree as ET
from datasets import load_dataset
from QAInput import StructuralQAInput, SimpleQAInput
from transformers impo... | null |
164,656 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_sqaud_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
contexts ... | null |
164,657 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_sqaud_abstractive_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
... | null |
164,658 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_boolq_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
question_column, context_column, answer_column = 'q... | null |
164,659 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_boolq_batch_pretrain(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
... | null |
164,660 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_narrativeqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = [exp['summary']['text'] for exp in... | null |
164,661 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_narrativeqa_batch_pretrain(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column... | null |
164,662 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_drop_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = examples['passage']
questions = examp... | null |
164,663 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_race_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = examples['article']
questions = examp... | null |
164,664 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_newsqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
contexts... | null |
164,665 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_ropes_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples[question_column]
backgroun... | null |
164,666 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_openbookqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
questions = examples['question_stem']
all_... | null |
164,667 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_social_iqa_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = examples['article']
questions =... | null |
164,668 | import sys
from typing import List, Optional, Tuple
from QAInput import SimpleQAInput as QAInput
def preprocess_dream_batch(
examples,
question_column: str,
context_column: str,
answer_column: str,
) -> Tuple[List[str], List[str]]:
contexts = [" ".join(dialogue) for dialogue in exam... | null |
164,669 | import logging
import os
import torch
import copy,random
import sys
import json
from dataclasses import dataclass, field
from typing import Optional
from typing import List, Optional, Tuple
from sklearn.cluster import KMeans
from models.metadecanotask import T5ForConditionalGeneration as PromptT5
from metrics import co... | null |
164,670 | import logging
import os
import torch
import copy,random
import sys
import json
from dataclasses import dataclass, field
from typing import Optional
from typing import List, Optional, Tuple
from models.nopt5 import T5ForConditionalGeneration as PromptT5
from downstream.dataset_processors import *
from downstream.traine... | null |
164,672 | import logging
import os
import torch
import copy,random
import sys
import json
from dataclasses import dataclass, field
from typing import Optional
from typing import List, Optional, Tuple
from sklearn.cluster import KMeans
from models.metat5 import T5ForConditionalGeneration as PromptT5
from downstream.dataset_proces... | null |
164,673 | import logging
import os
import torch
import copy,random
import sys
import json
from dataclasses import dataclass, field
from typing import Optional
from typing import List, Optional, Tuple
from sklearn.cluster import KMeans
from models.metat5nometa import T5ForConditionalGeneration as PromptT5
from downstream.dataset_... | null |
164,715 | import logging
import os
import torch
import copy,random
import sys
import json
from dataclasses import dataclass, field
from typing import Optional
from typing import List, Optional, Tuple
from sklearn.cluster import KMeans
from models.metat5notask import T5ForConditionalGeneration as PromptT5
from downstream.dataset_... | null |
164,718 | import copy
import math
import os
import warnings
import numpy as np
from random import random
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
from torch.utils.checkpoint import checkpoint
from .utils import *
from transformers.activations import ACT2FN
from transformers.file_utils import (
... | Load tf checkpoints in a pytorch model. |
164,719 | import torch.nn.functional as F
from torch import nn
import torch
import copy
def euclidean_metric(a, b):
n = a.shape[0]
m = b.shape[0]
a = a.unsqueeze(1).expand(n, m, -1)
b = b.unsqueeze(0).expand(n, m, -1)
logits = -((a - b)**2).sum(dim=2)
return logits | null |
164,720 | import torch.nn.functional as F
from torch import nn
import torch
import copy
def cosine_metric(a,b):
n = a.shape[0]
m = b.shape[0]
a = a.unsqueeze(1).expand(n, m, -1)
b = b.unsqueeze(0).expand(n, m, -1)
logits = (a*b).sum(dim=2)
# logits = -logits+1
return logits | null |
164,726 | import collections
import string
import re
import numpy as np
import json
from datasets import load_metric
def computeROUGE(greedy, answer):
rouges = compute_rouge_scores(greedy, answer)
if len(rouges) > 0:
avg_rouges = {}
for key in rouges[0].keys():
avg_rouges[key] = sum(
... | null |
164,731 | from asdl.hypothesis import Hypothesis
from asdl.transition_system import ApplyRuleAction, GenTokenAction
from asdl.sql.sql_transition_system import SelectColumnAction, SelectTableAction
class ActionInfo(object):
def __init__(self, action=None):
def __repr__(self, verbose=False):
class Hypothesis(object):
... | null |
164,756 | import os, json, pickle, argparse, sys, time
from asdl.asdl import ASDLGrammar
from asdl.transition_system import TransitionSystem
from asdl.action_info import get_action_infos
from preprocess.common_utils import Preprocessor
def process_example(processor, entry, db, trans, verbose=False):
class ASDLGrammar(object):
... | null |
164,757 | import os, sqlite3
import numpy as np
import stanza, torch
import stanfordnlp
from stanfordnlp.server import CoreNLPClient
from nltk.corpus import stopwords
from itertools import product, combinations
from utils.constants import MAX_RELATIVE_DIST
def is_number(s):
try:
float(s)
return True
exce... | null |
164,758 | import os, sqlite3
import numpy as np
import stanza, torch
import stanfordnlp
from stanfordnlp.server import CoreNLPClient
from nltk.corpus import stopwords
from itertools import product, combinations
from utils.constants import MAX_RELATIVE_DIST
The provided code snippet includes necessary dependencies for implementi... | Normalize all usage of quotation marks into a separate \" |
164,766 | import sys, os, time, json, gc
from argparse import Namespace
from utils.args import init_args
from utils.hyperparams import hyperparam_path
from utils.initialization import *
from utils.example import Example
from utils.batch import Batch
from utils.optimization import set_optimizer
from model.model_utils import Regis... | null |
164,788 | import argparse
import sys
def add_argument_base(arg_parser):
#### General configuration ####
arg_parser.add_argument('--task', default='text2sql', help='task name')
arg_parser.add_argument('--seed', default=999, type=int, help='Random seed')
arg_parser.add_argument('--device', type=int, default=1, help... | null |
164,792 | import json
import os
import random
from tqdm import tqdm
from copy import deepcopy
import numpy as np
import pdb
NOISE_NUM = 4
def noise_entity_type(entity_list):
entity_type_list = []
for entity in entity_list:
entity_type_list.append(entity["type"])
entity_type_list = list(set(entity_type_list))
... | null |
164,793 | from collections import defaultdict
import os
from typing import List
def find_bracket_position(generated_text, _type_start, _type_end):
bracket_position = {_type_start: list(), _type_end: list()}
for index, char in enumerate(generated_text):
if char in bracket_position:
bracket_position[ch... | null |
164,794 | from collections import defaultdict
import os
from typing import List
def build_sentence_tree(sentence):
tree = defaultdict(set)
for prev_token, next_token in zip(sentence[:-1], sentence[1:]):
tree[prev_token].add(next_token)
return tree | null |
164,795 | from collections import defaultdict
import os
from typing import List
def generated_search_prefix_tree(generated, prefix_tree, tokenizer):
tree = prefix_tree
# Leaf is KEY_VALUE_SPLIT
for token in generated:
if token not in tree:
return [tokenizer.eos_token]
tree = tree[token]
... | null |
164,796 | from collections import defaultdict
import os
from typing import List
def match_sublist(the_list, to_match):
"""
:param the_list: [1, 2, 3, 4, 5, 6, 1, 2, 4, 5]
:param to_match:
[1, 2]
:return:
[(0, 1), (6, 7)]
"""
len_to_match = len(to_match)
matched_list = list()
for in... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.