id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
163,493 | import copy
import math
import os
import warnings
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
from torch.utils.checkpoint import checkpoint
from transformers.activations import ACT2FN
from transformers.file_utils import (
DUMMY_INPUTS,
DUMMY_MASK,
add_start_docstrings,
add_st... | Load tf checkpoints in a pytorch model. |
163,494 | from collections import OrderedDict
import torch
from torch import nn
from transformers import AutoTokenizer
from .base import PushToHubFriendlyModel
from ..prompt.modeling_auto import AutoModelForSeq2SeqLM
The provided code snippet includes necessary dependencies for implementing the `aggregate_prompt` function. Writ... | past_prompt_dict: a dict of past_prompt from different tasks. |
163,496 | import collections
import json
import time
import os
from typing import Any, Dict, List, Optional, Tuple, Union, Callable, Iterable
from typing import NamedTuple
import datasets
from datasets import load_metric
import numpy as np
import torch
import transformers.trainer_seq2seq
from torch.utils.data import Dataset
from... | null |
163,497 | import collections
import json
import time
import os
from typing import Any, Dict, List, Optional, Tuple, Union, Callable, Iterable
from typing import NamedTuple
import datasets
from datasets import load_metric
import numpy as np
import torch
import transformers.trainer_seq2seq
from torch.utils.data import Dataset
from... | null |
163,498 | import collections
import json
import time
import os
from typing import Any, Dict, List, Optional, Tuple, Union, Callable, Iterable
from typing import NamedTuple
import datasets
from datasets import load_metric
import numpy as np
import torch
import transformers.trainer_seq2seq
from torch.utils.data import Dataset
from... | null |
163,499 | import importlib
def get_model(model):
Model = importlib.import_module('models.{}'.format(model)).Model
return Model | null |
163,500 | import importlib
def get_constructor(constructor):
Constructor = importlib.import_module('{}'.format(constructor)).Constructor
return Constructor | null |
163,501 | import importlib
def get_evaluator(evaluate_tool):
EvaluateTool = importlib.import_module('{}'.format(evaluate_tool)).EvaluateTool
return EvaluateTool | null |
163,505 | import json
import sqlite3
from nltk import word_tokenize
def tokenize(string):
string = str(string)
string = string.replace("\'", "\"") # ensures all string values wrapped by "" problem??
quote_idxs = [idx for idx, char in enumerate(string) if char == '"']
assert len(quote_idxs) % 2 == 0, "Unexpected ... | null |
163,506 | from collections import OrderedDict, Counter
from itertools import chain
import re, os
def remove_comment(text):
text = re.sub(re.compile("#.*"), "", text)
text = '\n'.join(filter(lambda x: x, text.split('\n')))
return text | null |
163,507 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def condition_has_or(conds):
return 'or' in conds[1::2] | null |
163,508 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
WHERE_OPS = ('not', 'between', '=', '>', '<', '>=', '<=', '!=', 'in', 'like', 'is', 'exists')
def condition_has_like(conds):
return WHERE_OPS.index('like')... | null |
163,509 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def condition_has_sql(conds):
for cond_unit in conds[::2]:
val1, val2 = cond_unit[3], cond_unit[4]
if val1 is not None and type(val1) is di... | null |
163,510 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
UNIT_OPS = ('none', '-', '+', "*", '/')
def val_has_op(val_unit):
return val_unit[0] != UNIT_OPS.index('none') | null |
163,511 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def accuracy(count, total):
if count == total:
return 1
return 0 | null |
163,512 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def recall(count, total):
if count == total:
return 1
return 0 | null |
163,513 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def F1(acc, rec):
if (acc + rec) == 0:
return 0
return (2. * acc * rec) / (acc + rec) | null |
163,514 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def get_scores(count, pred_total, label_total):
if pred_total != label_total:
return 0,0,0
elif count == pred_total:
return 1,1,1
r... | null |
163,515 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def eval_sel(pred, label):
pred_sel = pred['select'][1]
label_sel = label['select'][1]
label_wo_agg = [unit[1] for unit in label_sel]
pred_tota... | null |
163,516 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def eval_where(pred, label):
pred_conds = [unit for unit in pred['where'][::2]]
label_conds = [unit for unit in label['where'][::2]] # val1 is also con... | null |
163,517 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def eval_group(pred, label):
pred_cols = [unit[1] for unit in pred['groupBy']]
label_cols = [unit[1] for unit in label['groupBy']]
pred_total = len... | null |
163,518 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def eval_having(pred, label):
pred_total = label_total = cnt = 0
if len(pred['groupBy']) > 0:
pred_total = 1
if len(label['groupBy']) > 0:
... | null |
163,519 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def eval_order(pred, label):
pred_total = label_total = cnt = 0
if len(pred['orderBy']) > 0:
pred_total = 1
if len(label['orderBy']) > 0:
... | null |
163,520 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def eval_and_or(pred, label):
pred_ao = pred['where'][1::2]
label_ao = label['where'][1::2]
pred_ao = set(pred_ao)
label_ao = set(label_ao)
... | null |
163,521 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def eval_nested(pred, label):
label_total = 0
pred_total = 0
cnt = 0
if pred is not None:
pred_total += 1
if label is not None:
... | null |
163,522 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def get_keywords(sql):
res = set()
if len(sql['where']) > 0:
res.add('where')
if len(sql['groupBy']) > 0:
res.add('group')
if le... | null |
163,523 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
WHERE_OPS = ('not', 'between', '=', '>', '<', '>=', '<=', '!=', 'in', 'like', 'is', 'exists')
def count_component1(sql):
count = 0
if len(sql['where'])... | null |
163,524 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def get_nestedSQL(sql):
def count_component2(sql):
nested = get_nestedSQL(sql)
return len(nested) | null |
163,525 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def count_agg(units):
return len([unit for unit in units if has_agg(unit)])
def count_others(sql):
count = 0
# number of aggregation
agg_count ... | null |
163,526 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def isValidSQL(sql, db):
conn = sqlite3.connect(db)
cursor = conn.cursor()
try:
cursor.execute(sql)
except:
return False
re... | null |
163,527 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
class Evaluator:
"""A simple evaluator"""
def __init__(self):
self.partial_scores = None
def eval_hardness(self, sql):
count_comp1_ ... | null |
163,528 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql
def build_foreign_key_map(entry):
cols_orig = entry["column_names_original"]
tables_orig = entry["table_names_original"]
# rebuild cols correspondin... | null |
163,529 | import os, sqlite3
import numpy as np
import stanza, torch
from nltk.corpus import stopwords
from itertools import product, combinations
import torch.nn.functional as F
from utils.constants import MAX_RELATIVE_DIST
from transformers import AutoModel, AutoConfig, AutoTokenizer
import geoopt as gt
def is_number(s):
... | null |
163,530 | import os, sqlite3
import numpy as np
import stanza, torch
from nltk.corpus import stopwords
from itertools import product, combinations
import torch.nn.functional as F
from utils.constants import MAX_RELATIVE_DIST
from transformers import AutoModel, AutoConfig, AutoTokenizer
import geoopt as gt
def agg(input):
# ... | null |
163,531 | import os, sqlite3
import numpy as np
import stanza, torch
from nltk.corpus import stopwords
from itertools import product, combinations
import torch.nn.functional as F
from utils.constants import MAX_RELATIVE_DIST
from transformers import AutoModel, AutoConfig, AutoTokenizer
import geoopt as gt
The provided code snip... | Normalize all usage of quotation marks into a separate \" |
163,532 | import os, sys
import json
import sqlite3
import traceback
import argparse
from process_sql import get_sql
schemas, db_names, tables = get_schemas_from_json(table_file)
with open(sql_path) as inf:
sql_data = json.load(inf)
for data in sql_data:
try:
if data['query'] == 'SELECT T1.company_name FROM Third... | null |
163,533 | import os
import sys
import json
import sqlite3
from os import listdir, makedirs
from os.path import isfile, isdir, join, split, exists, splitext
import traceback
def convert_fk_index(data):
fk_holder = []
for fk in data["foreign_keys"]:
tn, col, ref_tn, ref_col = fk[0][0], fk[0][1], fk[1][0], fk[1][1]
... | read table and column info |
163,534 | import argparse, os, sys, pickle, json
from collections import Counter
def construct_vocab_from_dataset(*data_paths, table_path='data/tables.bin', mwf=4, reference_file=None, output_path=None, sep='\t'):
words = []
tables = pickle.load(open(table_path, 'rb'))
for fp in data_paths:
dataset = pickle.... | null |
163,535 | import os
import traceback
import re
import sys
import json
import sqlite3
import sqlparse
import random
from os import listdir, makedirs
from collections import OrderedDict
from nltk import word_tokenize, tokenize
from os.path import isfile, isdir, join, split, exists, splitext
from process_sql import get_sql
def get... | null |
163,536 | import os, sqlite3
import numpy as np
import stanza, torch
from nltk.corpus import stopwords
from itertools import product, combinations
import torch.nn.functional as F
from transformers import AutoModel, AutoConfig,AutoTokenizer
def is_number(s):
try:
float(s)
return True
except ValueError:
... | null |
163,537 | import os, sqlite3
import numpy as np
import stanza, torch
from nltk.corpus import stopwords
from itertools import product, combinations
import torch.nn.functional as F
from transformers import AutoModel, AutoConfig,AutoTokenizer
def agg(input):
# if input.size(0)==1:
# return input.squeeze()
# else :
... | null |
163,538 | import os, sqlite3
import numpy as np
import stanza, torch
from nltk.corpus import stopwords
from itertools import product, combinations
import torch.nn.functional as F
from transformers import AutoModel, AutoConfig,AutoTokenizer
The provided code snippet includes necessary dependencies for implementing the `quote_nor... | Normalize all usage of quotation marks into a separate \" |
163,539 | import sys, os, json, pickle, argparse, time, torch
from argparse import Namespace
from preprocess.process_dataset import process_tables, process_dataset
from preprocess.process_graphs import process_dataset_graph
from preprocess.common_utils import Preprocessor
from preprocess.graph_utils import GraphProcessor
from ut... | null |
163,540 | import sys, os, json, pickle, argparse, time, torch
from argparse import Namespace
from preprocess.process_dataset import process_tables, process_dataset
from preprocess.process_graphs import process_dataset_graph
from preprocess.common_utils import Preprocessor
from preprocess.graph_utils import GraphProcessor
from ut... | null |
163,541 | 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 |
163,542 | import torch
import torch.nn as nn
import torch.nn.functional as F
def cumsoftmax(x, dim=-1):
return torch.cumsum(F.softmax(x, dim=dim), dim=dim) | null |
163,543 | import dgl, math, torch
def src_dot_dst(src_field, dst_field, out_field):
def func(edges):
return {out_field: (edges.src[src_field] * edges.dst[dst_field]).sum(-1, keepdim=True)}
return func | null |
163,544 | import dgl, math, torch
def src_sum_edge_mul_dst(src_field, dst_field, e_field, out_field):
def func(edges):
return {out_field: ((edges.src[src_field] + edges.data[e_field]) * edges.dst[dst_field]).sum(-1, keepdim=True)}
return func | null |
163,545 | import dgl, math, torch
def scaled_exp(field, scale_constant):
def func(edges):
# clamp for softmax numerical stability
return {field: torch.exp((edges.data[field] / scale_constant).clamp(-10, 10))}
return func | null |
163,546 | import dgl, math, torch
def src_sum_edge_mul_edge(src_field, e_field1, e_field2, out_field):
def func(edges):
return {out_field: (edges.src[src_field] + edges.data[e_field1]) * edges.data[e_field2]}
return func | null |
163,547 | import dgl, math, torch
def div_by_z(in_field, norm_field, out_field):
def func(nodes):
return {out_field: nodes.data[in_field] / nodes.data[norm_field]}
return func | null |
163,548 | import copy, math
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn_utils
The provided code snippet includes necessary dependencies for implementing the `clones` function. Write a Python function `def clones(module, N)` to solve the following problem:
Produce N identical layers.
Here is the function... | Produce N identical layers. |
163,549 | import copy, math
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn_utils
def lens2mask(lens):
bsize = lens.numel()
max_len = lens.max()
masks = torch.arange(0, max_len).type_as(lens).to(lens.device).repeat(bsize, 1).lt(lens.unsqueeze(1))
masks.requires_grad = False
return masks | null |
163,550 | import copy, math
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn_utils
def mask2matrix(mask):
col_mask, row_mask = mask.unsqueeze(-1), mask.unsqueeze(-2)
return col_mask & row_mask | null |
163,551 | import copy, math
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn_utils
The provided code snippet includes necessary dependencies for implementing the `tile` function. Write a Python function `def tile(x, count, dim=0)` to solve the following problem:
Tiles x on dimension dim count times. E.g. [1, ... | Tiles x on dimension dim count times. E.g. [1, 2, 3], count=2 ==> [1, 1, 2, 2, 3, 3] [[1, 2], [3, 4]], count=3, dim=1 ==> [[1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4]] Different from torch.repeat |
163,552 | import copy, math
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn_utils
The provided code snippet includes necessary dependencies for implementing the `rnn_wrapper` function. Write a Python function `def rnn_wrapper(encoder, inputs, lens, cell='lstm')` to solve the following problem:
@args: encoder... | @args: encoder(nn.Module): rnn series bidirectional encoder, batch_first=True inputs(torch.FloatTensor): rnn inputs, [bsize x max_seq_len x in_dim] lens(torch.LongTensor): seq len for each sample, allow length=0, padding with 0-vector, [bsize] @return: out(torch.FloatTensor): output of encoder, bsize x max_seq_len x hi... |
163,553 | import torch
import numpy as np
from utils.example import Example, get_position_ids
from utils.constants import PAD, UNK
from model.model_utils import lens2mask, cached_property
import torch.nn.functional as F
def from_example_list_base(ex_list, device='cpu', train=True):
"""
question_lens: torch.long, bsiz... | New fields: batch.lens, batch.max_len, batch.relations, batch.relations_mask |
163,554 | import logging
import re, math
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import LambdaLR
from torch.nn.utils import clip_grad_norm_
from collections import defaultdict
schedule_dict = {
"constant": get_constant_schedule,
"linear": get_linear_schedule_with_warmup,
"ratsql":... | null |
163,555 | import logging
import re, math
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import LambdaLR
from torch.nn.utils import clip_grad_norm_
from collections import defaultdict
The provided code snippet includes necessary dependencies for implementing the `get_ratsql_schedule_with_warmup` fun... | Create a schedule with a learning rate that decreases according to the formular in RATSQL model |
163,556 | import logging
import re, math
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import LambdaLR
from torch.nn.utils import clip_grad_norm_
from collections import defaultdict
The provided code snippet includes necessary dependencies for implementing the `get_constant_schedule` function. Wri... | Create a schedule with a constant learning rate. |
163,557 | import logging
import re, math
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import LambdaLR
from torch.nn.utils import clip_grad_norm_
from collections import defaultdict
The provided code snippet includes necessary dependencies for implementing the `get_constant_schedule_with_warmup` f... | Create a schedule with a constant learning rate preceded by a warmup period during which the learning rate increases linearly between 0 and 1. |
163,558 | import logging
import re, math
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import LambdaLR
from torch.nn.utils import clip_grad_norm_
from collections import defaultdict
The provided code snippet includes necessary dependencies for implementing the `get_linear_schedule_with_warmup` fun... | Create a schedule with a learning rate that decreases linearly after linearly increasing during a warmup period. |
163,559 | import logging
import re, math
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import LambdaLR
from torch.nn.utils import clip_grad_norm_
from collections import defaultdict
The provided code snippet includes necessary dependencies for implementing the `get_cosine_schedule_with_warmup` fun... | Create a schedule with a learning rate that decreases following the values of the cosine function between 0 and `pi * cycles` after a warmup period during which it increases linearly between 0 and 1. |
163,560 | import logging
import re, math
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import LambdaLR
from torch.nn.utils import clip_grad_norm_
from collections import defaultdict
The provided code snippet includes necessary dependencies for implementing the `get_cosine_with_hard_restarts_schedu... | Create a schedule with a learning rate that decreases following the values of the cosine function with several hard restarts, after a warmup period during which it increases linearly between 0 and 1. |
163,561 | import sys, os
def hyperparam_path_text2sql(args):
task = 'task_%s__model_%s_view_%s' % (args.task, args.model, args.local_and_nonlocal)
task += '' if 'without' in args.output_model else '_gp_%s' % (args.smoothing)
# encoder params
exp_path = 'emb_%s' % (args.embed_size) if args.plm is None else 'plm_%s... | null |
163,562 | import argparse
import sys
def add_argument_base(arg_parser):
def add_argument_encoder(arg_parser):
def add_argument_decoder(arg_parser):
def init_args(params=sys.argv[1:]):
arg_parser = argparse.ArgumentParser()
arg_parser = add_argument_base(arg_parser)
arg_parser = add_argument_encoder(arg_parser)
a... | null |
163,563 | import sys, os, logging
import random, torch, dgl
import numpy as np
def set_logger(exp_path, testing=False):
logFormatter = logging.Formatter('%(asctime)s - %(message)s') #('%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger('mylogger')
logger.setLevel(logging.DEBUG)
if testing:
... | null |
163,564 | import sys, os, logging
import random, torch, dgl
import numpy as np
import random
random.seed(33)
def set_random_seed(random_seed=999):
random.seed(random_seed)
torch.manual_seed(random_seed)
if torch.cuda.is_available():
torch.cuda.manual_seed(random_seed)
np.random.seed(random_seed)
dg... | null |
163,565 | import sys, os, logging
import random, torch, dgl
import numpy as np
def set_torch_device(deviceId):
if deviceId < 0:
device = torch.device("cpu")
else:
assert torch.cuda.device_count() >= deviceId + 1
device = torch.device("cuda:%d" % (deviceId))
# os.environ['CUDA_LAUNCH_BLOCK... | null |
163,566 | import logging
import os
import time
import torch
import datasets
import transformers
from transformers import (
HfArgumentParser,
set_seed,
EarlyStoppingCallback,
)
from transformers.trainer_utils import get_last_checkpoint
from collections import OrderedDict
import utils.tool
from utils.configue import Co... | null |
163,567 | from typing import Dict, Any
from third_party.spider import evaluation as spider_evaluation
def compute_exact_match_metric(predictions, references) -> Dict[str, Any]:
foreign_key_maps = dict()
for reference in references:
if reference["db_id"] not in foreign_key_maps:
foreign_key_maps[refer... | null |
163,568 | import os
import pdb
import sys
import json
import numpy as np
import argparse
import sqlite3
import warnings
import multiprocessing as mp
from collections import OrderedDict
from func_timeout import func_timeout, FunctionTimedOut
def result_callback(result):
exec_result.append(result)
def execute_model(sql, db_pla... | null |
163,569 | import os
import pdb
import sys
import json
import numpy as np
import argparse
import sqlite3
import warnings
import multiprocessing as mp
from collections import OrderedDict
from func_timeout import func_timeout, FunctionTimedOut
def result_callback(result):
exec_result.append(result)
def execute_model(sql, db_pla... | null |
163,570 | import os
import pdb
import sys
import json
import numpy as np
import argparse
import sqlite3
import warnings
import multiprocessing as mp
from collections import OrderedDict
from func_timeout import func_timeout, FunctionTimedOut
def package_sqls(sql_path, db_name, mode='codex'):
clean_sqls = []
if mode == 'c... | null |
163,571 | import os
import pdb
import sys
import json
import numpy as np
import argparse
import sqlite3
import warnings
import multiprocessing as mp
from collections import OrderedDict
from func_timeout import func_timeout, FunctionTimedOut
def export_sqls(sql_path, db_name):
cleaned_sqls = []
sql_data = json.load(open(... | null |
163,572 | import os
import pdb
import sys
import json
import numpy as np
import argparse
import sqlite3
import warnings
import multiprocessing as mp
from collections import OrderedDict
from func_timeout import func_timeout, FunctionTimedOut
def sort_results(list_of_dicts):
return sorted(list_of_dicts, key=lambda x: x['sql_idx... | null |
163,573 | import os
import pdb
import sys
import json
import numpy as np
import argparse
import sqlite3
import warnings
import multiprocessing as mp
from collections import OrderedDict
from func_timeout import func_timeout, FunctionTimedOut
def compute_execution_accuracy(gt_results, predict_results):
num_correct = 0
num... | null |
163,575 | import os
import torch
import random
import re
from copy import deepcopy
from typing import List, Dict
from datasets.dataset_dict import DatasetDict
from torch.utils.data import Dataset
from torch.utils.data.dataset import T_co
from third_party.miscs.bridge_content_encoder import get_database_matches
from tqdm import t... | null |
163,576 | import os
import torch
import random
import re
from copy import deepcopy
from typing import List, Dict
from datasets.dataset_dict import DatasetDict
from torch.utils.data import Dataset
from torch.utils.data.dataset import T_co
from third_party.miscs.bridge_content_encoder import get_database_matches
from tqdm import t... | null |
163,577 | import os
import torch
import random
import re
from copy import deepcopy
from typing import List, Dict
from datasets.dataset_dict import DatasetDict
from torch.utils.data import Dataset
from torch.utils.data.dataset import T_co
from third_party.miscs.bridge_content_encoder import get_database_matches
from tqdm import t... | null |
163,578 | import os
import torch
import random
import re
from copy import deepcopy
from typing import List, Dict
from datasets.dataset_dict import DatasetDict
from torch.utils.data import Dataset
from torch.utils.data.dataset import T_co
from third_party.miscs.bridge_content_encoder import get_database_matches
from tqdm import t... | null |
163,579 | import os
import torch
import random
import re
from copy import deepcopy
from typing import List, Dict
from datasets.dataset_dict import DatasetDict
from torch.utils.data import Dataset
from torch.utils.data.dataset import T_co
from third_party.miscs.bridge_content_encoder import get_database_matches
from tqdm import t... | null |
163,580 | import os
import torch
import random
import re
from copy import deepcopy
from typing import List, Dict
from datasets.dataset_dict import DatasetDict
from torch.utils.data import Dataset
from torch.utils.data.dataset import T_co
from third_party.miscs.bridge_content_encoder import get_database_matches
from tqdm import t... | null |
163,581 | import os
import torch
import random
import re
from copy import deepcopy
from typing import List, Dict
from datasets.dataset_dict import DatasetDict
from torch.utils.data import Dataset
from torch.utils.data.dataset import T_co
from third_party.miscs.bridge_content_encoder import get_database_matches
from tqdm import t... | null |
163,583 | import copy
import math
import os
import warnings
import pdb
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
from torch.utils.checkpoint import checkpoint
from .rgat_tuning import RGAT_Layer
from transformers.activations import ACT2FN
from transformers.file_utils import (
DUMMY_INPUTS,
D... | Load tf checkpoints in a pytorch model. |
163,589 | import copy
import math
import os
import warnings
import pdb
import pickle
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
from torch.utils.checkpoint import checkpoint
from .rgat_tuning import RGAT_Tuning, RGAT_Layer
from transformers.activations import ACT2FN
from transformers.file_utils impor... | Load tf checkpoints in a pytorch model. |
163,590 | import copy
import math
import os
import warnings
import pdb
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
from torch.utils.checkpoint import checkpoint
from .rgat_tuning import RGAT_Tuning, RGAT_Layer
from transformers.activations import ACT2FN
from transformers.file_utils import (
DUMMY_... | Load tf checkpoints in a pytorch model. |
163,592 | import copy
import math
import os
import warnings
import pdb
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
from torch.utils.checkpoint import checkpoint
from .rgat_tuning import RGAT_Tuning
from transformers.activations import ACT2FN
from transformers.file_utils import (
DUMMY_INPUTS,
... | Load tf checkpoints in a pytorch model. |
163,596 | import pickle
import dgl
import pdb
from collections import defaultdict
graph = pickle.load(open('data/graph_pedia_total.bin', 'rb'))
def compute_relations(graph_pedia):
relation_count = defaultdict()
for idx, graph in graph_pedia.items():
relation_lst = graph['edges']
for e in relation_lst:
... | null |
163,597 | import dgl, math, torch
import pdb
def src_dot_dst(src_field, dst_field, out_field):
def func(edges):
return {out_field: (edges.src[src_field] * edges.dst[dst_field]).sum(-1, keepdim=True)}
pdb.set_trace()
return func | null |
163,598 | import dgl, math, torch
import pdb
def src_sum_edge_mul_dst(src_field, dst_field, e_field, out_field):
def func(edges):
return {out_field: ((edges.src[src_field] + edges.data[e_field]) * edges.dst[dst_field]).sum(-1, keepdim=True)}
return func | null |
163,599 | import dgl, math, torch
import pdb
def scaled_exp(field, scale_constant):
def func(edges):
# clamp for softmax numerical stability
return {field: torch.exp((edges.data[field] / scale_constant).clamp(-10, 10))}
return func | null |
163,600 | import dgl, math, torch
import pdb
def src_sum_edge_mul_edge(src_field, e_field1, e_field2, out_field):
def func(edges):
return {out_field: (edges.src[src_field] + edges.data[e_field1]) * edges.data[e_field2]}
return func | null |
163,601 | import dgl, math, torch
import pdb
def div_by_z(in_field, norm_field, out_field):
def func(nodes):
# print(nodes.data[norm_field])
return {out_field: nodes.data[in_field] / (nodes.data[norm_field] + 1e-10)}
# TODO: Jinyang
return func | null |
163,616 | import json
import argparse
import pdb
def fetch_sql(predicted_results, output_path=None):
final_sql = {}
invalid_result = []
for k, v in predicted_results.items():
idx = int(k)
print("------------------- processing {}th example -------------------".format(idx))
print(v)
try... | null |
163,617 | import argparse
import fnmatch
import json
import os
import pdb
import pickle
import re
import sqlite3
from typing import Dict, List, Tuple
import backoff
import openai
import pandas as pd
import sqlparse
from tqdm import tqdm
The provided code snippet includes necessary dependencies for implementing the `get_db_schem... | Read an sqlite file, and return the CREATE commands for each of the tables in the database. |
163,618 | import argparse
import fnmatch
import json
import os
import pdb
import pickle
import re
import sqlite3
from typing import Dict, List, Tuple
import backoff
import openai
import pandas as pd
import sqlparse
from tqdm import tqdm
def few_shot():
ini_table = "CREATE TABLE singer\n(\n singer_id TEXT not null... | null |
163,619 | import argparse
import fnmatch
import json
import os
import pdb
import pickle
import re
import sqlite3
from typing import Dict, List, Tuple
import backoff
import openai
import pandas as pd
import sqlparse
from tqdm import tqdm
def few_shot_no_kg():
ini_table = "CREATE TABLE singer\n(\n singer_id TEXT no... | null |
163,620 | import argparse
import fnmatch
import json
import os
import pdb
import pickle
import re
import sqlite3
from typing import Dict, List, Tuple
import backoff
import openai
import pandas as pd
import sqlparse
from tqdm import tqdm
openai.debug=True
def quota_giveup(e):
return isinstance(e, openai.error.RateLimitError)... | null |
163,621 | import argparse
import fnmatch
import json
import os
import pdb
import pickle
import re
import sqlite3
from typing import Dict, List, Tuple
import backoff
import openai
import pandas as pd
import sqlparse
from tqdm import tqdm
openai.debug=True
def generate_combined_prompts_one(db_path, question, knowledge=None):
s... | :param db_path: str :param question_list: [] :return: dict of responses collected from openai |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.