repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
SimXNS | SimXNS-main/SimANS/Doc_training/star_tokenizer.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
#
# ... | 136,291 | 44.460974 | 372 | py |
SimXNS | SimXNS-main/SimANS/Doc_training/co_training_doc_generate.py | import sys
sys.path += ['../']
import argparse
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
import torch.distributed as dist
from torch import nn
from model.models import Reranker, RobertaDot
from co_training_generate_new_train impo... | 12,125 | 36.310769 | 123 | py |
SimXNS | SimXNS-main/SimANS/Doc_training/co_training_generate_new_train.py | import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from tqdm import tqdm
import torch.distributed as dist
from utils.util import ... | 19,490 | 42.506696 | 148 | py |
SimXNS | SimXNS-main/SimANS/wiki/co_training_generate_new_train_wiki.py | import faiss
from tqdm import tqdm
import pickle
from torch.utils.data import DataLoader
import logging
logger = logging.getLogger("__main__")
import torch
from utils.util import (
is_first_worker,
)
import os
import numpy as np
import torch.distributed as dist
import csv
import json
from utils.dpr_utils import Si... | 20,721 | 43.563441 | 135 | py |
SimXNS | SimXNS-main/SimANS/wiki/co_training_wiki_generate.py | import sys
sys.path += ['../']
import argparse
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
import torch.distributed as dist
from torch import nn
from model.models import BiBertEncoder, HFBertEncoder
from co_training_generate_new_tra... | 12,110 | 34.937685 | 123 | py |
SimXNS | SimXNS-main/SimANS/wiki/co_training_wiki_train.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler
from torch.utils.data.distributed import DistributedSampler
from tqdm im... | 27,964 | 39.295389 | 129 | py |
SimXNS | SimXNS-main/SimANS/co_training/co_training_marco_generate.py | import sys
sys.path += ['../']
import argparse
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
import torch.distributed as dist
from torch import nn
from model.models import BiBertEncoder
from co_training_generate import RenewTools
impo... | 14,660 | 35.470149 | 123 | py |
SimXNS | SimXNS-main/SimANS/co_training/co_training_marco_train.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler
from tqdm import tqdm
import torch.distributed as dist
from torch impo... | 26,862 | 38.915305 | 123 | py |
SimXNS | SimXNS-main/SimANS/co_training/co_training_generate.py | import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from tqdm import tqdm
import torch.distributed as dist
from utils.util import ... | 19,377 | 42.742664 | 129 | py |
SimXNS | SimXNS-main/SimANS/utils/MARCO_until_new.py | from collections import namedtuple
import os
from tqdm import tqdm
import torch
import random
import math
def csv_reader(fd, delimiter='\t', trainer_id=0, trainer_num=1):
def gen():
for i, line in tqdm(enumerate(fd)):
if i % trainer_num == trainer_id:
slots = line.rstrip('\n').s... | 23,187 | 43.421456 | 128 | py |
SimXNS | SimXNS-main/SimANS/utils/dpr_utils.py | import collections
import sys
sys.path += ['../']
import glob
import logging
import os
from typing import List, Tuple
import faiss
import pickle
import numpy as np
import unicodedata
import torch
import torch.distributed as dist
from torch import nn
from torch.serialization import default_restore_location
import regex
... | 15,351 | 35.639618 | 136 | py |
SimXNS | SimXNS-main/SimANS/utils/MARCO_until_Doc.py | from collections import namedtuple
import os
from tqdm import tqdm
import torch
import random
import math
def csv_reader(fd, delimiter='\t', trainer_id=0, trainer_num=1):
def gen():
for i, line in tqdm(enumerate(fd)):
if i % trainer_num == trainer_id:
slots = line.rstrip('\n').s... | 8,510 | 40.315534 | 116 | py |
SimXNS | SimXNS-main/SimANS/utils/util.py | import sys
sys.path += ['../']
import gzip
import copy
import torch.distributed as dist
from tqdm import tqdm
import os
import json
import logging
import random
import pickle
import numpy as np
import torch
from transformers import AutoTokenizer
import math
from multiprocessing import Process
from torch.utils.data imp... | 30,182 | 36.034356 | 156 | py |
SimXNS | SimXNS-main/SimANS/utils/util_wiki.py | import sys
sys.path += ['../']
import pandas as pd
from sklearn.metrics import roc_curve, auc
import gzip
import copy
import torch
from torch import nn
import torch.distributed as dist
from tqdm import tqdm, trange
import os
from os import listdir
from os.path import isfile, join
import json
import logging
import rand... | 28,480 | 35.097592 | 140 | py |
SimXNS | SimXNS-main/SimANS/model/models.py | import transformers
from transformers import (
RobertaConfig,
RobertaModel, RobertaPreTrainedModel,
RobertaTokenizer,
BertModel,
BertTokenizer,
BertConfig,
)
import torch
from torch import nn
import torch.nn.functional as F
from torch import Tensor as T
from torch.nn import CrossEntropyLoss
cl... | 32,483 | 43.805517 | 126 | py |
SimXNS | SimXNS-main/LEAD/modeling_distilbert.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language 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.or... | 51,306 | 43.537326 | 119 | py |
SimXNS | SimXNS-main/LEAD/inference_de.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
from os.path import isfile, join
import csv
import numpy as np
import torch
import pytrec_eval
import json
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.ge... | 26,351 | 40.696203 | 176 | py |
SimXNS | SimXNS-main/LEAD/modeling_bert.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... | 84,492 | 43.563819 | 198 | py |
SimXNS | SimXNS-main/LEAD/dataset.py | from torch.utils.data import Dataset, DataLoader, RandomSampler
import os
import random
import torch
import json
import logging
import collections
import csv
import sys
from tqdm import tqdm
import unicodedata
csv.field_size_limit(sys.maxsize)
logger = logging.getLogger(__name__)
BiEncoderPassage = collections.namedt... | 14,071 | 42.566563 | 154 | py |
SimXNS | SimXNS-main/LEAD/util.py | import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import logging
import os
import torch
from torch.nn import functional as F
from torch.nn import MSELoss
os.environ["TOKENIZERS_PARALLELISM"] = "false"
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
sys.pat... | 61,285 | 53.719643 | 215 | py |
SimXNS | SimXNS-main/LEAD/run_single_model.py | import sys
sys.path += ['../']
sys.path += ['../../']
import logging
import os
import torch
os.environ["TOKENIZERS_PARALLELISM"] = "false"
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(os.getcwd()))))
from torc... | 9,562 | 43.47907 | 190 | py |
SimXNS | SimXNS-main/LEAD/run_LEAD.py | import sys
sys.path += ['../']
sys.path += ['../../']
import logging
import os
import torch
os.environ["TOKENIZERS_PARALLELISM"] = "false"
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(os.getcwd()))))
from torc... | 16,727 | 47.912281 | 186 | py |
SimXNS | SimXNS-main/LEAD/models.py | from transformers import (
BertConfig,
DistilBertConfig,
BertTokenizerFast,
__version__
)
from modeling_bert import BertModel
from modeling_distilbert import DistilBertModel
import torch
from torch import nn
import torch.nn.functional as F
from torch import Tensor as T
import string
from transformers.ac... | 13,067 | 46.007194 | 153 | py |
SimXNS | SimXNS-main/LEAD/retrieve_hard_negative.py | import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
import csv
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
from tqdm import tqdm, trange
import torch.distributed as dist
import... | 19,746 | 39.631687 | 141 | py |
SimXNS | SimXNS-main/PROD/ProD_base/rerank_eval_marco.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 22,455 | 35.395462 | 127 | py |
SimXNS | SimXNS-main/PROD/ProD_base/train_CE_model_marcodoc.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 22,120 | 36.303541 | 125 | py |
SimXNS | SimXNS-main/PROD/ProD_base/rerank_eval_marcodoc.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 23,160 | 35.82194 | 127 | py |
SimXNS | SimXNS-main/PROD/ProD_base/train_DE_model_nq.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import Da... | 33,751 | 37.840046 | 151 | py |
SimXNS | SimXNS-main/PROD/ProD_base/train_CE_model_nq.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 21,767 | 36.466437 | 143 | py |
SimXNS | SimXNS-main/PROD/ProD_base/rerank_eval_nq.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 16,156 | 35.064732 | 127 | py |
SimXNS | SimXNS-main/PROD/ProD_base/inference_DE_marco.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
from os.path import isfile, join
import random
import time
import csv
import numpy as np
import torch
from pathlib import Path
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(o... | 30,919 | 39.418301 | 261 | py |
SimXNS | SimXNS-main/PROD/ProD_base/rerank_train_eval_marcodoc.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 25,414 | 36.048105 | 127 | py |
SimXNS | SimXNS-main/PROD/ProD_base/inference_DE_nq.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
from os.path import isfile, join
import csv
import numpy as np
import torch
from pathlib import Path
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd(... | 32,821 | 37.478312 | 127 | py |
SimXNS | SimXNS-main/PROD/ProD_base/rerank_train_eval_marco.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 23,694 | 35.622875 | 127 | py |
SimXNS | SimXNS-main/PROD/ProD_base/inference_DE_trec.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
from os.path import isfile, join
import random
import time
import csv
import numpy as np
import torch
from pathlib import Path
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(o... | 28,160 | 37.055405 | 139 | py |
SimXNS | SimXNS-main/PROD/ProD_base/train_DE_model_marcodoc.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import Da... | 34,189 | 37.764172 | 151 | py |
SimXNS | SimXNS-main/PROD/ProD_base/train_CE_model_marco.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 22,126 | 36.313659 | 125 | py |
SimXNS | SimXNS-main/PROD/ProD_base/train_DE_model_marco.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import Da... | 34,195 | 37.770975 | 151 | py |
SimXNS | SimXNS-main/PROD/ProD_base/inference_DE_marcodoc.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
import transformers
transformers.logging.set_verbosity_error()
sys.path += ['../']
import json
import logging
import os
from os.path import isfile, join
import random
import time
import csv
import numpy as np
import torch
from pathlib import Path
... | 32,399 | 40.168996 | 261 | py |
SimXNS | SimXNS-main/PROD/ProD_base/rerank_train_eval_nq.py | from os.path import join
import sys
sys.path += ['../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler,... | 19,248 | 36.017308 | 127 | py |
SimXNS | SimXNS-main/PROD/ProD_base/utils/marco_until.py | from collections import namedtuple
import sys
import os
from tqdm import tqdm, trange
import torch
import gzip
import copy
import json
import random
import torch.distributed as dist
import logging
logger = logging.getLogger(__name__)
def csv_reader(fd, delimiter='\t', trainer_id=0, trainer_num=1):
def gen():
... | 13,960 | 43.603834 | 158 | py |
SimXNS | SimXNS-main/PROD/ProD_base/utils/dpr_utils.py | import collections
import sys
sys.path += ['../']
import glob
import logging
import os
from typing import List, Tuple, Dict
import faiss
import pickle
import numpy as np
import unicodedata
import torch
import torch.distributed as dist
from torch import nn
from torch.serialization import default_restore_location
import ... | 15,523 | 35.874109 | 136 | py |
SimXNS | SimXNS-main/PROD/ProD_base/utils/util.py | import sys
sys.path += ['../']
import pandas as pd
from sklearn.metrics import roc_curve, auc
import gzip
import copy
import torch
from torch import nn
import torch.distributed as dist
from tqdm import tqdm, trange
import os
from os import listdir
from os.path import isfile, join
import json
import logging
import rand... | 27,648 | 35.865333 | 156 | py |
SimXNS | SimXNS-main/PROD/ProD_base/utils/lamb.py | """Lamb optimizer."""
import collections
import math
import torch
from tensorboardX import SummaryWriter
from torch.optim import Optimizer
def log_lamb_rs(optimizer: Optimizer, event_writer: SummaryWriter, token_count: int):
"""Log a histogram of trust ratio scalars in across layers."""
results = collection... | 4,887 | 38.419355 | 109 | py |
SimXNS | SimXNS-main/PROD/ProD_base/model/models.py | import transformers
from transformers import (
BertModel,
BertConfig,
)
import torch
from torch import nn
import torch.nn.functional as F
from torch import Tensor as T
from torch.nn import CrossEntropyLoss
from transformers import DistilBertTokenizer, DistilBertModel, DistilBertConfig
class HFBertEncoder(Bert... | 18,636 | 40.323725 | 143 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/run_progressive_distill_marco.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
import copy
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.da... | 50,784 | 40.389568 | 158 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/run_progressive_distill_nq.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
import copy
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.da... | 53,495 | 41.222573 | 163 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/run_progressive_distill_marcodoc.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import random
import numpy as np
import torch
import copy
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.da... | 50,943 | 40.317113 | 163 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/utils/marco_until.py | from collections import namedtuple
import sys
import os
from tqdm import tqdm, trange
import torch
import gzip
import copy
import json
import random
import torch.distributed as dist
import logging
logger = logging.getLogger(__name__)
def csv_reader(fd, delimiter='\t', trainer_id=0, trainer_num=1):
def gen():
... | 13,960 | 43.603834 | 158 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/utils/dpr_utils.py | import collections
import sys
sys.path += ['../']
import glob
import logging
import os
from typing import List, Tuple, Dict
import faiss
import pickle
import numpy as np
import unicodedata
import torch
import torch.distributed as dist
from torch import nn
from torch.serialization import default_restore_location
import ... | 15,502 | 35.824228 | 136 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/utils/util.py | import sys
sys.path += ['../']
import pandas as pd
from sklearn.metrics import roc_curve, auc
import gzip
import copy
import torch
from torch import nn
import torch.distributed as dist
from tqdm import tqdm, trange
import os
from os import listdir
from os.path import isfile, join
import json
import logging
import rand... | 27,528 | 36.151147 | 156 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/utils/lamb.py | """Lamb optimizer."""
import collections
import math
import torch
from tensorboardX import SummaryWriter
from torch.optim import Optimizer
def log_lamb_rs(optimizer: Optimizer, event_writer: SummaryWriter, token_count: int):
"""Log a histogram of trust ratio scalars in across layers."""
results = collection... | 4,887 | 38.419355 | 109 | py |
SimXNS | SimXNS-main/PROD/ProD_KD/model/models.py | import transformers
from transformers import (
BertModel,
BertConfig,
)
import torch
from torch import nn
import torch.nn.functional as F
from torch import Tensor as T
from torch.nn import CrossEntropyLoss
from transformers import DistilBertTokenizer, DistilBertModel, DistilBertConfig
class HFBertEncoder(BertM... | 53,374 | 40.089299 | 142 | py |
SimXNS | SimXNS-main/MASTER/pretrain/modeling.py | import os
import warnings
import torch
from torch import nn, Tensor
import torch.distributed as dist
import torch.nn.functional as F
from transformers import BertModel, BertConfig, AutoModel, AutoModelForMaskedLM, AutoConfig, PretrainedConfig, \
RobertaModel, ElectraForMaskedLM, ElectraModel, ElectraForMaskedLM
fr... | 19,694 | 41.173448 | 165 | py |
SimXNS | SimXNS-main/MASTER/pretrain/data.py | import random
from dataclasses import dataclass
from typing import List, Dict
import copy
import torch
from torch.utils.data import Dataset
from transformers import DataCollatorForWholeWordMask
@dataclass
class CondenserCollator(DataCollatorForWholeWordMask):
max_seq_length: int = 512
decoder_mlm_probability:... | 18,571 | 39.907489 | 166 | py |
SimXNS | SimXNS-main/MASTER/pretrain/trainer.py | import os
from contextlib import nullcontext
from typing import Dict, List, Tuple, Optional, Any, Union
from transformers import ElectraForMaskedLM
import torch
import torch.distributed as dist
from torch import nn, Tensor
from torch.cuda.amp import autocast
from transformers.trainer import Trainer
from transformers.t... | 11,966 | 42.835165 | 155 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/co_training_model.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedS... | 27,648 | 37.454798 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/inference_de.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
import csv
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
from tqdm import tqdm
import torch.distributed as dis... | 43,916 | 38.106857 | 141 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/run_ce_model_ele.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedS... | 20,762 | 36.819672 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/co_training_model_ele_continue.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedS... | 27,719 | 37.446602 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/co_training_model_ele.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedS... | 27,965 | 37.573793 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/run_de_model.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialS... | 23,667 | 37.422078 | 147 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/run_ce_model.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedS... | 20,734 | 36.76867 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/MS/inference_de_prob.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
import csv
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
from tqdm import tqdm
import torch.distributed as dis... | 44,314 | 38.25155 | 141 | py |
SimXNS | SimXNS-main/MASTER/finetune/wiki/co_training_model.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedS... | 24,723 | 37.095532 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/wiki/inference_de.py | import argparse
import sys
from torch.utils.data.dataset import Dataset
sys.path += ['../']
import json
import logging
import os
import csv
import numpy as np
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
from tqdm import tqdm
import torch.distributed as dis... | 36,102 | 37.82043 | 125 | py |
SimXNS | SimXNS-main/MASTER/finetune/wiki/run_de_model.py | from os.path import join
import sys
sys.path += ['../']
sys.path += ['../../']
import argparse
import glob
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialS... | 22,423 | 36.498328 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/wiki/run_ce_model.py | import sys
sys.path += ['../']
import argparse
import json
import logging
import os
import torch
sys.path.append(os.getcwd())
sys.path.append(os.path.abspath(os.path.dirname(os.getcwd())))
#
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedS... | 20,232 | 36.330258 | 123 | py |
SimXNS | SimXNS-main/MASTER/finetune/utils/dpr_utils.py | import collections
import sys
sys.path += ['../']
import glob
import logging
import os
from typing import List, Tuple, Dict
import faiss
import pickle
import numpy as np
import unicodedata
import torch
import torch.distributed as dist
from torch import nn
from torch.serialization import default_restore_location
import ... | 15,523 | 35.874109 | 136 | py |
SimXNS | SimXNS-main/MASTER/finetune/utils/MARCO_until.py | from collections import namedtuple
import sys
import os
from tqdm import tqdm
import torch
import random
def csv_reader(fd, delimiter='\t', trainer_id=0, trainer_num=1):
outputs = []
for i, line in tqdm(enumerate(fd)):
if i % trainer_num == trainer_id:
slots = line.rstrip('\n').split(delimit... | 20,912 | 44.861842 | 156 | py |
SimXNS | SimXNS-main/MASTER/finetune/utils/util.py | import sys
sys.path += ['../']
import gzip
import copy
import torch.distributed as dist
from tqdm import tqdm, trange
import os
import json
import logging
import random
import pickle
import numpy as np
import torch
from transformers import AutoTokenizer, AutoModel
import transformers
transformers.logging.set_verbosit... | 26,929 | 34.668874 | 129 | py |
SimXNS | SimXNS-main/MASTER/finetune/utils/lamb.py | """Lamb optimizer."""
import collections
import math
import torch
from tensorboardX import SummaryWriter
from torch.optim import Optimizer
def log_lamb_rs(optimizer: Optimizer, event_writer: SummaryWriter, token_count: int):
"""Log a histogram of trust ratio scalars in across layers."""
results = collection... | 4,887 | 38.419355 | 109 | py |
SimXNS | SimXNS-main/MASTER/finetune/model/models.py | import transformers
from transformers import (
BertModel,
BertConfig,
)
import torch
from torch import nn
import torch.nn.functional as F
from torch import Tensor as T
from torch.nn import CrossEntropyLoss
class HFBertEncoder(BertModel):
def __init__(self, config):
BertModel.__init__(self, config)... | 10,569 | 41.793522 | 114 | py |
SimXNS | SimXNS-main/MASTER/finetune/model/models_ele.py | import transformers
from transformers import (
BertModel, ElectraModel,
BertConfig, ElectraConfig
)
import torch
from torch import nn
import torch.nn.functional as F
from torch import Tensor as T
from torch.nn import CrossEntropyLoss
class HFBertEncoder(BertModel):
def __init__(self, config):
Bert... | 12,095 | 41.893617 | 114 | py |
fastCover | fastCover-master/graph_util.py | import igraph
import torch
import dgl
import numpy as np
# ==================== GRAPH LOADERS ====================
def get_rev_graph(graph, train_graph_is_directed):
g = igraph.Graph(directed=True)
g.add_vertices(graph.vcount())
src, dst = zip(*graph.get_edgelist())
g.add_edges(list(zip(dst, src)))
... | 3,561 | 28.683333 | 94 | py |
fastCover | fastCover-master/pytorchtools.py | import numpy as np
import torch
class EarlyStopping:
"""Early stops the training if validation loss doesn't improve after a given patience."""
def __init__(self, patience=7, verbose=False, delta=0, path='checkpoint.pt', trace_func=print):
"""
Args:
patience (int): How long to wait a... | 2,108 | 40.352941 | 121 | py |
fastCover | fastCover-master/train.py | import time
import sys
from util import get_model, get_memory
from load_graph import load_train
from algo import greedy
import torch
from copy import deepcopy
from tqdm import tqdm
import logging
from pytorchtools import EarlyStopping
import numpy as np
# ==================== PARAMETERS ====================
PATH_TO_PA... | 10,859 | 30.29683 | 172 | py |
fastCover | fastCover-master/baselines/heuristics.py | import logging
import time
import igraph
import heapq
from collections import deque
import numpy as np
import torch
class Node:
def __init__(self, id, value):
self.id = id
self.value = value
def __lt__(self, other):
return self.value < other.value
def __str__(self):
# we ... | 9,760 | 29.4081 | 107 | py |
fastCover | fastCover-master/experiments/evaluate_models.py | import sys
sys.path.append("/home/featurize/work/newMCP/") # Change the path.
import time
from pathlib import Path
import logging
from util import get_filename, get_model, get_memory
from glob import glob
from furl import furl
import torch
import pandas as pd
from experiments.igraph_loader import next_graph, next_dgl... | 5,109 | 32.181818 | 127 | py |
fastCover | fastCover-master/experiments/train_models.py | import sys
sys.path.append("/home/featurize/work/newMCP/") # Change the path
import torch
from graph_util import get_adj_mat
from model.functional.MaxCoverLoss import KSetMaxCoverAdjLoss
from load_graph import load_train
from util import get_model
from train import train
import time
import logging
import pickle
impo... | 3,733 | 31.189655 | 123 | py |
fastCover | fastCover-master/model/GCN.py | from model.layer.GCNLayer import GCNLayer
from model.layer.DegreeGCNLayer import DegreeGCNLayer
import torch.nn as nn
import torch
import torch.nn.functional as F
# GCN models
# List of models:
class DGCN2_(nn.Module):
def __init__(self, in_feats, hidden_feats1, out_feats, *args):
super(DGCN2_, self).__i... | 2,688 | 31.011905 | 96 | py |
fastCover | fastCover-master/model/APPNP.py | import torch
import torch.nn as nn
from dgl.nn.pytorch.conv import APPNPConv
class APPNP(nn.Module):
def __init__(self, in_feats, hidden_feats, activations, feat_drop=0.01, edge_drop=0.01, alpha=0.1, k=10):
"""
APP Convolution Net
:param in_feats: input dimension
:param hidden_feat... | 1,932 | 34.796296 | 109 | py |
fastCover | fastCover-master/model/GAT.py | from model.layer.GATLayer import GATLayer
import torch.nn as nn
import torch
# GAT models
# List of models: GAT2, GAT3
class GAT2(nn.Module):
def __init__(self, in_feats, hidden_feats1, out_feats, *args):
super(GAT2, self).__init__()
self.gat1 = GATLayer(in_feats, hidden_feats1)
self.gat2 =... | 1,292 | 29.785714 | 81 | py |
fastCover | fastCover-master/model/GRAT.py | from model.layer.GRATLayer import GRATLayer
from model.layer.GRATVarLayer import GRATVLayer
import torch.nn as nn
import torch
# GRAT models
# List of models: GRAT2, GRAT3, GRAT4
class GRAT2_(nn.Module): # GRAT2 before sigmoid
def __init__(self, in_feats, hidden_feats1, out_feats, *args):
super(GRAT2_, ... | 5,268 | 32.993548 | 96 | py |
fastCover | fastCover-master/model/layer/GCNLayer.py | import dgl.function as fn
import torch.nn as nn
# https://docs.dgl.ai/tutorials/models/1_gnn/1_gcn.html
message_func = fn.copy_src(src='h', out='m')
reduce_func = fn.sum(msg='m', out='h')
class GCNLayer(nn.Module):
def __init__(self, in_feats, out_feats, activation):
super(GCNLayer, self).__init__()
... | 813 | 34.391304 | 71 | py |
fastCover | fastCover-master/model/layer/DegreeGCNLayer.py | import torch
import torch.nn as nn
# GCN layer
def message_func(edges):
tmp = edges.src['degree'].repeat(edges.src['h'].size(1), 1)
tmp = torch.transpose(tmp, 1, 0)
return {'m': torch.div(edges.src['h'], torch.sqrt(tmp))}
def reduce_func(nodes):
return {'h': torch.sum(nodes.mailbox['m'], dim=1)}
c... | 1,600 | 28.648148 | 70 | py |
fastCover | fastCover-master/model/layer/GRATLayer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from dgl.nn.pytorch.softmax import edge_softmax
# Guanhao's GRAT
class GRATLayer(nn.Module):
def __init__(self, in_feats, out_feats):
# TODO: why not another linear layer before entering the net
super(GRATLayer, self).__init__()
... | 1,835 | 33.641509 | 100 | py |
fastCover | fastCover-master/model/layer/GATLayer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
# https://docs.dgl.ai/en/0.4.x/tutorials/models/1_gnn/9_gat.htmlé
class GATLayer(nn.Module):
def __init__(self, in_feats, out_feats):
super(GATLayer, self).__init__()
# self.g = g
# equation (1)
self.fc = nn.Linear(... | 1,820 | 31.517857 | 65 | py |
fastCover | fastCover-master/model/layer/DegreeGCNPlusLayer.py | import dgl.function as fn
import torch
import torch.nn as nn
# GCN layer
message_func = fn.sum(src='h', out='m')
reduce_func = fn.sum(msg='m', out='h')
class DegreeGCNPlusNodeApplyModule(nn.Module):
def __init__(self, in_feats, out_feats):
"""
:param in_feats: input dimension
:param out_fe... | 1,497 | 29.571429 | 74 | py |
fastCover | fastCover-master/model/layer/GRATVarLayer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from dgl.nn.pytorch.softmax import edge_softmax
# GRAT more similar to GAT
class GRATVLayer(nn.Module):
def __init__(self, in_feats, out_feats):
super(GRATVLayer, self).__init__()
# linear layer
self.fc = nn.Linear(in_feat... | 1,757 | 35.625 | 102 | py |
fastCover | fastCover-master/model/functional/MaxCoverLoss.py | import torch
import torch.nn as nn
import numpy as np
class KSetMaxCoverLoss(nn.Module):
def __init__(self, C):
super().__init__()
self.C = C
def forward(self, v, graph, *args):
adj_mat = np.array(graph.get_adjacency().data, dtype=np.int32)
adj_mat = torch.from_numpy(np.array(... | 2,177 | 30.114286 | 121 | py |
ugle | ugle-main/ugle/utils.py | from omegaconf import OmegaConf, open_dict, DictConfig
from optuna import Study
from typing import Tuple
import random
import torch
import numpy as np
import optuna
import os
import pickle
from ugle.logger import log
neural_algorithms = ['daegc', 'dgi', 'dmon', 'grace', 'mvgrl', 'selfgnn', 'sublime', 'bgrl', 'vgaer', ... | 13,135 | 34.502703 | 116 | py |
ugle | ugle-main/ugle/datasets.py | import os
from omegaconf import OmegaConf, DictConfig
import numpy as np
from karateclub.dataset import GraphReader
import networkx as nx
import zipfile
import gdown
from pathlib import Path
import shutil
import torch
import copy
import random
import scipy.sparse as sp
import plotly.graph_objects as go
from typing impo... | 14,772 | 34.856796 | 114 | py |
ugle | ugle-main/ugle/gnn_architecture.py | import torch
from torch import nn
import torch.nn.functional as F
class mvgrl_Discriminator(nn.Module):
def __init__(self, n_h):
super(mvgrl_Discriminator, self).__init__()
self.f_k = nn.Bilinear(n_h, n_h, 1)
for m in self.modules():
self.weights_init(m)
def weights_init(s... | 6,247 | 30.084577 | 80 | py |
ugle | ugle-main/ugle/process.py | import numpy as np
import scipy.sparse as sp
import torch
from scipy.linalg import fractional_matrix_power, inv
from sklearn.metrics import f1_score, normalized_mutual_info_score
from scipy.optimize import linear_sum_assignment
import math
import warnings
SMOOTH_K_TOLERANCE = 1e-5
MIN_K_DIST_SCALE = 1e-3
NPY_INFINITY ... | 6,289 | 31.590674 | 116 | py |
ugle | ugle-main/ugle/models/mvgrl.py | # https://github.com/kavehhassani/mvgrl
import torch
import torch.nn as nn
import ugle
import scipy.sparse as sp
import numpy as np
from sklearn.cluster import KMeans
from sklearn.preprocessing import MinMaxScaler
from ugle.trainer import ugleTrainer
from ugle.gnn_architecture import GCN, AvgReadout, mvgrl_Discriminato... | 5,368 | 36.284722 | 116 | py |
ugle | ugle-main/ugle/models/bgrl.py | # https://github.com/Namkyeong/BGRL_Pytorch
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from sklearn.cluster import KMeans
import scipy.sparse as sp
from torch_geometric.nn import GCNConv
import copy
from torch_geometric.utils import dropout_adj
import ugle
from ugle.trainer im... | 6,452 | 35.874286 | 136 | py |
ugle | ugle-main/ugle/models/sublime.py | # https://github.com/GRAND-Lab/SUBLIME
import torch
import torch.nn as nn
from torch.nn import Sequential, Linear, ReLU
import torch.nn.functional as F
import numpy as np
import copy
from sklearn.cluster import KMeans
from ugle.trainer import ugleTrainer
EOS = 1e-10
class GCNConv_dense(nn.Module):
def __init__(sel... | 12,696 | 35.173789 | 132 | py |
ugle | ugle-main/ugle/models/dmon.py | # https://github.com/google-research/google-research/blob/master/graph_embedding/dmon/dmon.py
import ugle
import scipy.sparse as sp
from ugle.trainer import ugleTrainer
import torch.nn as nn
import torch
from ugle.gnn_architecture import GCN
import math
from collections import OrderedDict
class DMoN(nn.Module):
d... | 4,771 | 36.574803 | 125 | py |
ugle | ugle-main/ugle/models/daegc.py | # code insipred from https://github.com/Tiger101010/DAEGC
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
from torch.optim import Adam
from sklearn.cluster import KMeans
import scipy.sparse as sp
import ugle
from ugle.logger import log
from ... | 4,869 | 35.343284 | 109 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.