repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/tests/test_resolution.py | tests/test_resolution.py | import json
import os
import unittest
from aptos.primitive import Object, Primitive
from aptos.visitor import ResolveVisitor
BASE_DIR = os.path.dirname(__file__)
class ResolutionTestCase(unittest.TestCase):
def runTest(self):
with open(os.path.join(BASE_DIR, 'schema', 'product')) as fp:
sch... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/tests/test_swagger_version_3.py | tests/test_swagger_version_3.py | import json
import os
import unittest
from aptos.swagger.v3 import model
from aptos.swagger.v3.parser import OpenAPIParser
BASE_DIR = os.path.dirname(__file__)
class OpenAPIVersion3TestCase(unittest.TestCase):
def runTest(self):
with open(os.path.join(BASE_DIR, 'schema', 'petstore')) as fp:
... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/tests/test_validation.py | tests/test_validation.py | import json
import unittest
from aptos import primitive
from aptos.visitor import ValidationVisitor
class StringTestCase(unittest.TestCase):
def runTest(self):
schema = json.loads('''
{
"type": "string",
"maxLength": 3
}
''')
string... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
wuppp/shiro_rce_exp | https://github.com/wuppp/shiro_rce_exp/blob/6d067292504b47816160fdecc919438f8bfcc87a/shiro_exp.py | shiro_exp.py | # -*- coding: utf-8 -*-
from paddingoracle import BadPaddingException, PaddingOracle
from base64 import b64encode, b64decode
from urllib import quote, unquote
import requests
import socket
import time
class PadBuster(PaddingOracle):
def __init__(self, **kwargs):
super(PadBuster, self).__init__(**kwargs)
... | python | BSD-2-Clause | 6d067292504b47816160fdecc919438f8bfcc87a | 2026-01-05T07:09:54.459289Z | false |
wuppp/shiro_rce_exp | https://github.com/wuppp/shiro_rce_exp/blob/6d067292504b47816160fdecc919438f8bfcc87a/setup.py | setup.py | try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(
name='paddingoracle',
author='Marcin Wielgoszewski',
author_email='marcin.wielgoszewski@gmail.com',
version='0.2.2',
url='https://github.com/mwielgoszewski/python-paddingoracle',
py_modules=['... | python | BSD-2-Clause | 6d067292504b47816160fdecc919438f8bfcc87a | 2026-01-05T07:09:54.459289Z | false |
wuppp/shiro_rce_exp | https://github.com/wuppp/shiro_rce_exp/blob/6d067292504b47816160fdecc919438f8bfcc87a/utils.py | utils.py | # -*- coding: utf-8 -*-
from base64 import urlsafe_b64decode, urlsafe_b64encode
def dotnet_b64decode(s):
'''Decode .NET Web-Base64 encoded data.'''
s, pad_bytes = s[:-1], int(s[-1])
s += ('=' * pad_bytes)
return urlsafe_b64decode(s)
def dotnet_b64encode(s):
'''.NET Web-Base64 encode data.'''
... | python | BSD-2-Clause | 6d067292504b47816160fdecc919438f8bfcc87a | 2026-01-05T07:09:54.459289Z | false |
wuppp/shiro_rce_exp | https://github.com/wuppp/shiro_rce_exp/blob/6d067292504b47816160fdecc919438f8bfcc87a/paddingoracle.py | paddingoracle.py | # -*- coding: utf-8 -*-
'''
Padding Oracle Exploit API
~~~~~~~~~~~~~~~~~~~~~~~~~~
'''
from itertools import izip, cycle
import logging
__all__ = [
'BadPaddingException',
'PaddingOracle',
]
class BadPaddingException(Exception):
'''
Raised when a blackbox decryptor reveals a padding oracle.
Th... | python | BSD-2-Clause | 6d067292504b47816160fdecc919438f8bfcc87a | 2026-01-05T07:09:54.459289Z | false |
wuppp/shiro_rce_exp | https://github.com/wuppp/shiro_rce_exp/blob/6d067292504b47816160fdecc919438f8bfcc87a/docs/conf.py | docs/conf.py | # -*- coding: utf-8 -*-
#
# Padding Oracle Exploit API documentation build configuration file, created by
# sphinx-quickstart on Tue Jan 8 14:35:03 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogene... | python | BSD-2-Clause | 6d067292504b47816160fdecc919438f8bfcc87a | 2026-01-05T07:09:54.459289Z | false |
wuppp/shiro_rce_exp | https://github.com/wuppp/shiro_rce_exp/blob/6d067292504b47816160fdecc919438f8bfcc87a/docs/_themes/flask_theme_support.py | docs/_themes/flask_theme_support.py | # flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
class FlaskyStyle(Style):
background_color = "#f8f8f8"
default_style = "... | python | BSD-2-Clause | 6d067292504b47816160fdecc919438f8bfcc87a | 2026-01-05T07:09:54.459289Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/stability_selection.py | BraVL_fMRI/stability_selection.py | import numpy as np
from itertools import combinations
def stability_selection(data, n=None):
"""Return the indices of the n voxels with best stability
Given repeated fMRI measurements on a set of stimuli, return the indices of
the voxels that demonstrate the best stability across the repetitions. This
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/run_epochs_trimodal.py | BraVL_fMRI/run_epochs_trimodal.py | import os
import numpy as np
import math
import random
import torch
from torch.autograd import Variable
import torch.distributions as dist
from tensorboardX import SummaryWriter
from torch.utils.data import DataLoader
from divergence_measures.kl_div import calc_kl_divergence
from sklearn.svm import SVC
from sklearn.met... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | true |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/data_prepare_with_aug_DIR_Wiki.py | BraVL_fMRI/data_prepare_with_aug_DIR_Wiki.py | from __future__ import print_function
from itertools import product
import os
import pickle
import bdpy
from bdpy.dataform import Features
from bdpy.util import dump_info, makedir_ifnot
import numpy as np
from stability_selection import stability_selection
from sklearn.decomposition import PCA
from scipy import io
# S... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/main_trimodal.py | BraVL_fMRI/main_trimodal.py | import sys
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '1'
import json
import torch
from run_epochs_trimodal import run_epochs_trimodal
from utils.filehandling import create_dir_structure
from brain_image_text.flags import parser
from brain_image_text.experiment import BrainImageText
torch.set_default_tensor_type(to... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/data_prepare_with_aug_GOD_Wiki.py | BraVL_fMRI/data_prepare_with_aug_GOD_Wiki.py | from __future__ import print_function
from itertools import product
import os
import pickle
import bdpy
from bdpy.dataform import Features
from bdpy.util import dump_info, makedir_ifnot
import numpy as np
from sklearn.decomposition import PCA
from scipy import io
# Settings ############################################... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/extract_fea_with_timm.py | BraVL_fMRI/extract_fea_with_timm.py | import argparse
import os
from scipy import io
os.environ['CUDA_VISIBLE_DEVICES'] = '3'
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.transforms as transforms
import torchvision.datasets as datasets
import ... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/modalities/Modality.py | BraVL_fMRI/modalities/Modality.py |
from abc import ABC, abstractmethod
import os
import torch
import torch.distributions as dist
class Modality(ABC):
def __init__(self, name, enc, dec, class_dim, style_dim, lhood_name):
self.name = name;
self.encoder = enc;
self.decoder = dec;
self.class_dim = class_dim;
se... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/divergence_measures/mmd.py | BraVL_fMRI/divergence_measures/mmd.py | def mmd_loss(z_tilde, z, z_var):
r"""Calculate maximum mean discrepancy described in the WAE paper.
Args:
z_tilde (Tensor): samples from deterministic non-random encoder Q(Z|X).
2D Tensor(batch_size x dimension).
z (Tensor): samples from prior distributions. same shape with z_tilde.
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/divergence_measures/mm_div.py | BraVL_fMRI/divergence_measures/mm_div.py |
import torch
import torch.nn as nn
from divergence_measures.kl_div import calc_kl_divergence
from divergence_measures.kl_div import calc_kl_divergence_lb_gauss_mixture
from divergence_measures.kl_div import calc_kl_divergence_ub_gauss_mixture
from divergence_measures.kl_div import calc_entropy_gauss
from utils.utils... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/divergence_measures/kl_div.py | BraVL_fMRI/divergence_measures/kl_div.py | import math
import torch
from utils.utils import reweight_weights
def calc_kl_divergence(mu0, logvar0, mu1=None, logvar1=None, norm_value=None):
if mu1 is None or logvar1 is None:
KLD = -0.5 * torch.sum(1 - logvar0.exp() - mu0.pow(2) + logvar0)
else:
KLD = -0.5 * (torch.sum(1 - logvar0.exp()/... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/experiment.py | BraVL_fMRI/brain_image_text/experiment.py | import os
import numpy as np
import itertools
import scipy.io as sio
import torch
import torch.optim as optim
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from torch.utils.data import TensorDataset
from modalities.Modality import Modality
from brain_image_text.network... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/constants.py | BraVL_fMRI/brain_image_text/constants.py |
indices = {'img_mnist': 0, 'img_svhn': 1, 'text': 2};
modalities = ['img_mnist', 'img_svhn', 'text'];
| python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/flags.py | BraVL_fMRI/brain_image_text/flags.py | from utils.BaseFlags import parser as parser
# DATASET NAME
parser.add_argument('--dataset', type=str, default='Brain_Image_Text', help="name of the dataset")
# DATA DEPENDENT
# to be set by experiments themselves
parser.add_argument('--style_m1_dim', type=int, default=0, help="dimension of varying factor latent space... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/networks/QNET.py | BraVL_fMRI/brain_image_text/networks/QNET.py | import torch.nn as nn
import torch.nn.functional as F
import torch
class QNet(nn.Module):
def __init__(self, input_dim,latent_dim):
super(QNet, self).__init__()
self.fc1 = nn.Linear(input_dim,512)
self.fc21 = nn.Linear(512, latent_dim)
self.fc22 = nn.Linear(512, latent_dim)
def ... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/networks/MLP_Text.py | BraVL_fMRI/brain_image_text/networks/MLP_Text.py |
import torch
import torch.nn as nn
class EncoderText(nn.Module):
def __init__(self, flags):
super(EncoderText, self).__init__()
self.flags = flags;
self.hidden_dim = 512;
modules = []
modules.append(nn.Sequential(nn.Linear(flags.m3_dim, self.hidden_dim), nn.ReLU(True)))
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/networks/MLP_Image.py | BraVL_fMRI/brain_image_text/networks/MLP_Image.py |
import torch
import torch.nn as nn
class EncoderImage(nn.Module):
def __init__(self, flags):
super(EncoderImage, self).__init__()
self.flags = flags;
self.hidden_dim = 2048;
modules = []
modules.append(nn.Sequential(nn.Linear(flags.m2_dim, self.hidden_dim), nn.ReLU(True))... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/networks/VAEtrimodal.py | BraVL_fMRI/brain_image_text/networks/VAEtrimodal.py | import os
import torch
import torch.nn as nn
from utils import utils
from utils.BaseMMVae import BaseMMVae
class VAEtrimodal(BaseMMVae, nn.Module):
def __init__(self, flags, modalities, subsets):
super().__init__(flags, modalities, subsets)
class VAEbimodal(BaseMMVae, nn.Module):
def __init__(self,... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/brain_image_text/networks/MLP_Brain.py | BraVL_fMRI/brain_image_text/networks/MLP_Brain.py |
import torch
import torch.nn as nn
class EncoderBrain(nn.Module):
def __init__(self, flags):
super(EncoderBrain, self).__init__()
self.flags = flags;
self.hidden_dim = 512;
modules = []
modules.append(nn.Sequential(nn.Linear(flags.m1_dim, self.hidden_dim), nn.ReLU(True)))... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/utils/BaseFlags.py | BraVL_fMRI/utils/BaseFlags.py | import os
import argparse
import torch
import scipy.io as sio
parser = argparse.ArgumentParser()
# TRAINING
parser.add_argument('--batch_size', type=int, default=512, help="batch size for training")
parser.add_argument('--initial_learning_rate', type=float, default=0.0001, help="starting learning rate")
parser.add_arg... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/utils/BaseMMVae.py | BraVL_fMRI/utils/BaseMMVae.py | from abc import ABC, abstractmethod
import os
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.distributions as dist
from divergence_measures.mm_div import calc_alphaJSD_modalities
from divergence_measures.mm_div import calc_group_divergence_moe
from divergence_measures.mm_div impor... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/utils/BaseExperiment.py | BraVL_fMRI/utils/BaseExperiment.py | import os
from abc import ABC, abstractmethod
from itertools import chain, combinations
class BaseExperiment(ABC):
def __init__(self, flags):
self.flags = flags
self.name = flags.dataset
self.modalities = None
self.num_modalities = None
self.subsets = None
self.data... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/utils/utils.py | BraVL_fMRI/utils/utils.py | import os
import torch
# Print iterations progress
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█'):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required ... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/utils/filehandling.py | BraVL_fMRI/utils/filehandling.py |
import os
from datetime import datetime
def create_dir(dir_name):
if not os.path.exists(dir_name):
os.makedirs(dir_name)
# else:
# shutil.rmtree(dir_name, ignore_errors=True)
# os.makedirs(dir_name)
def get_str_experiments(flags):
dateTimeObj = datetime.now()
dateStr = dateTi... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_fMRI/utils/TBLogger.py | BraVL_fMRI/utils/TBLogger.py |
class TBLogger():
def __init__(self, name, writer):
self.name = name;
self.writer = writer;
self.training_prefix = 'train';
self.testing_prefix = 'test';
self.step = 0;
def write_log_probs(self, name, log_probs): self.writer.add_scalars('%s/LogProb' % name,
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/run_epochs_trimodal.py | BraVL_EEG/run_epochs_trimodal.py | import os
import numpy as np
import math
import random
import torch
from torch.autograd import Variable
import torch.distributions as dist
from tensorboardX import SummaryWriter
from torch.utils.data import DataLoader
from divergence_measures.kl_div import calc_kl_divergence
from sklearn.svm import SVC
from sklearn.met... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | true |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/main_trimodal.py | BraVL_EEG/main_trimodal.py | import sys
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '5'
import json
import torch
from run_epochs_trimodal import run_epochs_trimodal
from utils.filehandling import create_dir_structure
from brain_image_text.flags import parser
from brain_image_text.experiment import BrainImageText
torch.set_default_tensor_type(to... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/modalities/Modality.py | BraVL_EEG/modalities/Modality.py |
from abc import ABC, abstractmethod
import os
import torch
import torch.distributions as dist
class Modality(ABC):
def __init__(self, name, enc, dec, class_dim, style_dim, lhood_name):
self.name = name;
self.encoder = enc;
self.decoder = dec;
self.class_dim = class_dim;
se... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/divergence_measures/mmd.py | BraVL_EEG/divergence_measures/mmd.py | def mmd_loss(z_tilde, z, z_var):
r"""Calculate maximum mean discrepancy described in the WAE paper.
Args:
z_tilde (Tensor): samples from deterministic non-random encoder Q(Z|X).
2D Tensor(batch_size x dimension).
z (Tensor): samples from prior distributions. same shape with z_tilde.
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/divergence_measures/mm_div.py | BraVL_EEG/divergence_measures/mm_div.py |
import torch
import torch.nn as nn
from divergence_measures.kl_div import calc_kl_divergence
from divergence_measures.kl_div import calc_kl_divergence_lb_gauss_mixture
from divergence_measures.kl_div import calc_kl_divergence_ub_gauss_mixture
from divergence_measures.kl_div import calc_entropy_gauss
from utils.utils... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/divergence_measures/kl_div.py | BraVL_EEG/divergence_measures/kl_div.py | import math
import torch
from utils.utils import reweight_weights
def calc_kl_divergence(mu0, logvar0, mu1=None, logvar1=None, norm_value=None):
if mu1 is None or logvar1 is None:
KLD = -0.5 * torch.sum(1 - logvar0.exp() - mu0.pow(2) + logvar0)
else:
KLD = -0.5 * (torch.sum(1 - logvar0.exp()/... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/experiment.py | BraVL_EEG/brain_image_text/experiment.py | import os
import numpy as np
import itertools
import scipy.io as sio
import torch
import torch.optim as optim
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from torch.utils.data import TensorDataset
from modalities.Modality import Modality
from brain_image_text.network... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/constants.py | BraVL_EEG/brain_image_text/constants.py |
indices = {'img_mnist': 0, 'img_svhn': 1, 'text': 2};
modalities = ['img_mnist', 'img_svhn', 'text'];
| python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/flags.py | BraVL_EEG/brain_image_text/flags.py | from utils.BaseFlags import parser as parser
# DATASET NAME
parser.add_argument('--dataset', type=str, default='Brain_Image_Text', help="name of the dataset")
# DATA DEPENDENT
# to be set by experiments themselves
parser.add_argument('--style_m1_dim', type=int, default=0, help="dimension of varying factor latent space... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/networks/QNET.py | BraVL_EEG/brain_image_text/networks/QNET.py | import torch.nn as nn
import torch.nn.functional as F
import torch
class QNet(nn.Module):
def __init__(self, input_dim,latent_dim):
super(QNet, self).__init__()
self.fc1 = nn.Linear(input_dim,512)
self.fc21 = nn.Linear(512, latent_dim)
self.fc22 = nn.Linear(512, latent_dim)
def ... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/networks/MLP_Text.py | BraVL_EEG/brain_image_text/networks/MLP_Text.py |
import torch
import torch.nn as nn
class EncoderText(nn.Module):
def __init__(self, flags):
super(EncoderText, self).__init__()
self.flags = flags;
self.hidden_dim = 256;
modules = []
modules.append(nn.Sequential(nn.Linear(flags.m3_dim, self.hidden_dim), nn.ReLU(True)))
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/networks/MLP_Image.py | BraVL_EEG/brain_image_text/networks/MLP_Image.py |
import torch
import torch.nn as nn
class EncoderImage(nn.Module):
def __init__(self, flags):
super(EncoderImage, self).__init__()
self.flags = flags;
self.hidden_dim = 256;
modules = []
modules.append(nn.Sequential(nn.Linear(flags.m2_dim, self.hidden_dim), nn.ReLU(True)))... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/networks/VAEtrimodal.py | BraVL_EEG/brain_image_text/networks/VAEtrimodal.py | import os
import torch
import torch.nn as nn
from utils import utils
from utils.BaseMMVae import BaseMMVae
class VAEtrimodal(BaseMMVae, nn.Module):
def __init__(self, flags, modalities, subsets):
super().__init__(flags, modalities, subsets)
class VAEbimodal(BaseMMVae, nn.Module):
def __init__(self,... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/brain_image_text/networks/MLP_Brain.py | BraVL_EEG/brain_image_text/networks/MLP_Brain.py |
import torch
import torch.nn as nn
class EncoderBrain(nn.Module):
def __init__(self, flags):
super(EncoderBrain, self).__init__()
self.flags = flags;
self.hidden_dim = 256;
modules = []
modules.append(nn.Sequential(nn.Linear(flags.m1_dim, self.hidden_dim), nn.ReLU(True)))
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/utils/BaseFlags.py | BraVL_EEG/utils/BaseFlags.py | import os
import argparse
import numpy as np
import torch
import scipy.io as sio
parser = argparse.ArgumentParser()
# TRAINING
parser.add_argument('--batch_size', type=int, default=1024, help="batch size for training")
parser.add_argument('--initial_learning_rate', type=float, default=0.0001, help="starting learning ... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/utils/BaseMMVae.py | BraVL_EEG/utils/BaseMMVae.py | from abc import ABC, abstractmethod
import os
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.distributions as dist
from divergence_measures.mm_div import calc_alphaJSD_modalities
from divergence_measures.mm_div import calc_group_divergence_moe
from divergence_measures.mm_div impor... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/utils/BaseExperiment.py | BraVL_EEG/utils/BaseExperiment.py | import os
from abc import ABC, abstractmethod
from itertools import chain, combinations
class BaseExperiment(ABC):
def __init__(self, flags):
self.flags = flags
self.name = flags.dataset
self.modalities = None
self.num_modalities = None
self.subsets = None
self.data... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/utils/utils.py | BraVL_EEG/utils/utils.py | import os
import torch
# Print iterations progress
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█'):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required ... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/utils/filehandling.py | BraVL_EEG/utils/filehandling.py |
import os
from datetime import datetime
def create_dir(dir_name):
if not os.path.exists(dir_name):
os.makedirs(dir_name)
# else:
# shutil.rmtree(dir_name, ignore_errors=True)
# os.makedirs(dir_name)
def get_str_experiments(flags):
dateTimeObj = datetime.now()
dateStr = dateTi... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
ChangdeDu/BraVL | https://github.com/ChangdeDu/BraVL/blob/233b09e5c0fbb84fb75371313433c99419398acf/BraVL_EEG/utils/TBLogger.py | BraVL_EEG/utils/TBLogger.py |
class TBLogger():
def __init__(self, name, writer):
self.name = name;
self.writer = writer;
self.training_prefix = 'train';
self.testing_prefix = 'test';
self.step = 0;
def write_log_probs(self, name, log_probs): self.writer.add_scalars('%s/LogProb' % name,
... | python | MIT | 233b09e5c0fbb84fb75371313433c99419398acf | 2026-01-05T07:09:54.909762Z | false |
kagisearch/fastfeedparser | https://github.com/kagisearch/fastfeedparser/blob/315667b2a39d044e36e8510d68e278ae34cf4f5d/benchmark.py | benchmark.py | import argparse
import time
import fastfeedparser
import feedparser
import httpx
# Test feeds
feeds = [
"https://feedpress.me/FIJ",
"https://techtinkering.com/feed.xml",
"https://glineq.blogspot.com/feeds/posts/default",
"https://stml.tumblr.com/rss",
"http://feeds.feedburner.com/mishadoff",
"... | python | MIT | 315667b2a39d044e36e8510d68e278ae34cf4f5d | 2026-01-05T07:09:55.883870Z | false |
kagisearch/fastfeedparser | https://github.com/kagisearch/fastfeedparser/blob/315667b2a39d044e36e8510d68e278ae34cf4f5d/src/fastfeedparser/main.py | src/fastfeedparser/main.py | from __future__ import annotations
import datetime
from email.utils import parsedate_to_datetime
import gzip
import json
import re
import zlib
from functools import lru_cache
try:
import brotli
HAS_BROTLI = True
except ImportError:
HAS_BROTLI = False
from typing import Any, Callable, Optional, TYPE_CHECK... | python | MIT | 315667b2a39d044e36e8510d68e278ae34cf4f5d | 2026-01-05T07:09:55.883870Z | true |
kagisearch/fastfeedparser | https://github.com/kagisearch/fastfeedparser/blob/315667b2a39d044e36e8510d68e278ae34cf4f5d/src/fastfeedparser/__init__.py | src/fastfeedparser/__init__.py | from .main import parse, FastFeedParserDict
__version__ = "0.4.4"
__all__ = ["parse", "FastFeedParserDict"]
| python | MIT | 315667b2a39d044e36e8510d68e278ae34cf4f5d | 2026-01-05T07:09:55.883870Z | false |
kagisearch/fastfeedparser | https://github.com/kagisearch/fastfeedparser/blob/315667b2a39d044e36e8510d68e278ae34cf4f5d/tests/test_encoding.py | tests/test_encoding.py | from fastfeedparser import parse
def test_parse_str_with_non_utf8_xml_declaration():
xml = (
'<?xml version="1.0" encoding="iso-8859-1"?>'
'<rss version="2.0">'
"<channel>"
"<title>café</title>"
"<item><title>café</title></item>"
"</channel>"
"</rss>"
)
... | python | MIT | 315667b2a39d044e36e8510d68e278ae34cf4f5d | 2026-01-05T07:09:55.883870Z | false |
kagisearch/fastfeedparser | https://github.com/kagisearch/fastfeedparser/blob/315667b2a39d044e36e8510d68e278ae34cf4f5d/tests/test_integration.py | tests/test_integration.py | import json
from pathlib import Path
import pytest
from fastfeedparser import parse
_TESTS_DIR = Path(__file__).parent
_INTEGRATION_DIR = _TESTS_DIR.joinpath("integration")
def pytest_generate_tests(metafunc: pytest.Metafunc):
# Include both XML and JSON feed files
xml_files = list(_INTEGRATION_DIR.glob("*... | python | MIT | 315667b2a39d044e36e8510d68e278ae34cf4f5d | 2026-01-05T07:09:55.883870Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/healthcheck.py | healthcheck.py | import os
import time
import json
import fcntl
import requests
import random
from datetime import datetime, timedelta
from flask import Flask, jsonify, redirect, request, render_template
try: # Optional dependency; app runs without rate limiting if unavailable
from flask_limiter import Limiter # type: ignore
... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | true |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/gunicorn_config.py | gunicorn_config.py | import os
import logging
from healthcheck import initialize_oauth # Import the OAuth initialization function
# Configure logging with safe default (INFO) and env override
def _get_log_level_from_env(default=logging.INFO):
level_name = os.getenv("LOG_LEVEL", "INFO")
return getattr(logging, str(level_name).uppe... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_logging.py | tests/test_logging.py | import importlib
import importlib.util
import os
import logging
def _load_healthcheck():
here = os.path.dirname(__file__)
root = os.path.abspath(os.path.join(here, os.pardir))
module_path = os.path.join(root, "healthcheck.py")
spec = importlib.util.spec_from_file_location("healthcheck", module_path)
... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_http_timeout.py | tests/test_http_timeout.py | import importlib.util
import os
import types
import requests
def _load_healthcheck_with_env(env: dict) -> types.ModuleType:
# Apply env and load a fresh module instance
for k, v in env.items():
if v is None:
os.environ.pop(k, None)
else:
os.environ[k] = str(v)
here ... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_cache.py | tests/test_cache.py | import importlib.util
import os
import types
def _load_healthcheck_with_env(env: dict) -> types.ModuleType:
# Apply env and load a fresh module instance
for k, v in env.items():
if v is None:
os.environ.pop(k, None)
else:
os.environ[k] = str(v)
here = os.path.dirnam... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_ui_and_404.py | tests/test_ui_and_404.py | import os
import importlib.util
import types
from datetime import datetime, timedelta
import pytz
import pytest
def _load_healthcheck_with_env(env: dict) -> types.ModuleType:
root = os.path.dirname(os.path.dirname(__file__))
module_path = os.path.join(root, "healthcheck.py")
spec = importlib.util.spec_fr... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_retries.py | tests/test_retries.py | import importlib.util
import os
import types
from http.client import RemoteDisconnected
def _load_healthcheck_with_env(env: dict) -> types.ModuleType:
# Apply env vars and load a fresh module instance
for k, v in env.items():
if v is None:
os.environ.pop(k, None)
else:
... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_rate_limit.py | tests/test_rate_limit.py | import importlib.util
import os
import types
import pytest
try:
import flask_limiter # type: ignore
_HAVE_LIMITER = True
except Exception: # pragma: no cover
_HAVE_LIMITER = False
def _load_healthcheck() -> types.ModuleType:
here = os.path.dirname(__file__)
root = os.path.abspath(os.path.join(h... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_read_only_methods.py | tests/test_read_only_methods.py | import importlib.util
import os
import types
import pytest
def _load_healthcheck() -> types.ModuleType:
here = os.path.dirname(__file__)
root = os.path.abspath(os.path.join(here, os.pardir))
module_path = os.path.join(root, "healthcheck.py")
spec = importlib.util.spec_from_file_location("healthcheck",... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
laitco/tailscale-healthcheck | https://github.com/laitco/tailscale-healthcheck/blob/c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6/tests/test_connected_to_control.py | tests/test_connected_to_control.py | import importlib.util
import os
import types
from datetime import datetime, timedelta
from dateutil import parser as date_parser
import pytz
def _load_healthcheck_with_env(env: dict) -> types.ModuleType:
here = os.path.dirname(__file__)
root = os.path.abspath(os.path.join(here, os.pardir))
module_path = o... | python | MIT | c8ee9a977e02b7c66916b2903af0b7f92b8d1ce6 | 2026-01-05T07:09:56.533282Z | false |
keonlee9420/Soft-DTW-Loss | https://github.com/keonlee9420/Soft-DTW-Loss/blob/c89d8c2ae6b49e47f06aba08128dcdc79002ed4b/sdtw_cuda_loss.py | sdtw_cuda_loss.py | import numpy as np
import torch
import torch.cuda
from numba import jit
from torch.autograd import Function
from numba import cuda
import math
# ----------------------------------------------------------------------------------------------------------------------
@cuda.jit
def compute_softdtw_cuda(D, gamma, bandwidth,... | python | MIT | c89d8c2ae6b49e47f06aba08128dcdc79002ed4b | 2026-01-05T07:09:57.339140Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/setup.py | setup.py | from setuptools import setup
setup(
name="LegalBenchRAG",
version="0.1",
packages=["legalbenchrag"],
)
| python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/run_benchmark.py | legalbenchrag/run_benchmark.py | import asyncio
from collections.abc import Coroutine
from typing import Any
from pydantic import BaseModel, computed_field, model_validator
from typing_extensions import Self
from legalbenchrag.benchmark_types import (
Document,
QAGroundTruth,
RetrievalMethod,
RetrievedSnippet,
)
class QAResult(Base... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/benchmark_types.py | legalbenchrag/benchmark_types.py | from abc import ABC, abstractmethod
from collections.abc import Sequence
from pydantic import BaseModel, computed_field, model_validator
from typing_extensions import Self
# max_bridge_gap_len will merge spans that are within max_bridge_gap_len characters of eachother.
def sort_and_merge_spans(
spans: list[tuple... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/benchmark.py | legalbenchrag/benchmark.py | import asyncio
import datetime as dt
import os
import random
import pandas as pd
from legalbenchrag.benchmark_types import Benchmark, Document, QAGroundTruth
from legalbenchrag.methods.baseline import BaselineRetrievalMethod
from legalbenchrag.methods.retrieval_strategies import RETRIEVAL_STRATEGIES
from legalbenchra... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/maud_analysis.py | legalbenchrag/generate/maud_analysis.py | import asyncio
import os
import re
import shutil
from typing import cast
import pandas as pd
from unidecode import unidecode
from legalbenchrag.generate.generate_maud import (
download_maud,
get_contract_name_from_mae,
)
"""
This file writes out a lot of information into ./tmp/maud,
Which helps in analyzing ... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/generate_privacy_qa.py | legalbenchrag/generate/generate_privacy_qa.py | import asyncio
import os
from typing import cast
import pandas as pd
from pydantic import BaseModel
from legalbenchrag.benchmark_types import (
Benchmark,
QAGroundTruth,
Snippet,
sort_and_merge_spans,
)
from legalbenchrag.generate.utils import download_zip
save_path = "./data/raw_data/privacy_qa"
d... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/generate_cuad.py | legalbenchrag/generate/generate_cuad.py | import ast
import asyncio
import os
import shutil
from collections.abc import Coroutine
from typing import Any, cast
import pandas as pd
from legalbenchrag.benchmark_types import (
Benchmark,
QAGroundTruth,
Snippet,
sort_and_merge_spans,
)
from legalbenchrag.generate.utils import WRITE_TITLES, create_... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/__main__.py | legalbenchrag/generate/__main__.py | import asyncio
from legalbenchrag.generate import generate_all
asyncio.run(generate_all())
| python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/utils.py | legalbenchrag/generate/utils.py | import io
import os
import zipfile
import requests
from pydantic import BaseModel
from tqdm import tqdm
from legalbenchrag.utils.ai import AIMessage, AIModel, ai_call
# Used to manually verify title quality
WRITE_TITLES = False
TITLE_SYSTEM_PROMPT = (
"""
# Instructions
The User will provide to you a very long... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/__init__.py | legalbenchrag/generate/__init__.py | from legalbenchrag.generate.generate_contractnli import generate_contractnli
from legalbenchrag.generate.generate_cuad import generate_cuad
from legalbenchrag.generate.generate_maud import generate_maud
from legalbenchrag.generate.generate_privacy_qa import generate_privacy_qa
async def generate_all() -> None:
aw... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/generate_contractnli.py | legalbenchrag/generate/generate_contractnli.py | import asyncio
import os
from collections.abc import Coroutine
from typing import Any
from pydantic import BaseModel
from legalbenchrag.benchmark_types import (
Benchmark,
QAGroundTruth,
Snippet,
sort_and_merge_spans,
)
from legalbenchrag.generate.utils import WRITE_TITLES, create_title, download_zip
... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/generate/generate_maud.py | legalbenchrag/generate/generate_maud.py | import asyncio
import json
import os
import re
import shutil
import zipfile
from collections.abc import Coroutine
from typing import Any, cast
import pandas as pd
from pydantic import BaseModel
from unidecode import unidecode
from legalbenchrag.benchmark_types import (
Benchmark,
QAGroundTruth,
Snippet,
... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/methods/baseline.py | legalbenchrag/methods/baseline.py | import os
import sqlite3
import struct
from typing import Literal, cast
import sqlite_vec # type: ignore
from langchain_text_splitters import RecursiveCharacterTextSplitter
from pydantic import BaseModel
from tqdm import tqdm
from legalbenchrag.benchmark_types import (
Document,
QueryResponse,
RetrievalM... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/methods/retrieval_strategies.py | legalbenchrag/methods/retrieval_strategies.py | from typing import Literal
from legalbenchrag.methods.baseline import ChunkingStrategy, RetrievalStrategy
from legalbenchrag.utils.ai import AIEmbeddingModel, AIRerankModel
chunk_strategy_names: list[Literal["naive", "rcts"]] = ["naive", "rcts"]
rerank_models: list[AIRerankModel | None] = [
None,
AIRerankMode... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/utils/credentials.py | legalbenchrag/utils/credentials.py | import tomllib
from pydantic import BaseModel, SecretStr
class AICredentials(BaseModel):
openai_api_key: SecretStr
anthropic_api_key: SecretStr
cohere_api_key: SecretStr
voyageai_api_key: SecretStr
class Credentials(BaseModel):
ai: AICredentials
with open("./credentials/credentials.toml", "rb"... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
zeroentropy-ai/legalbenchrag | https://github.com/zeroentropy-ai/legalbenchrag/blob/431bc8f2488a81569ab7259fa633dcc50ab77f9a/legalbenchrag/utils/ai.py | legalbenchrag/utils/ai.py | import asyncio
import hashlib
import logging
import os
from collections.abc import Callable, Coroutine
from enum import Enum
from typing import Any, Literal, cast
import anthropic
import cohere
import diskcache as dc # type: ignore
import httpx
import openai
import tiktoken
import voyageai # type: ignore
import voya... | python | MIT | 431bc8f2488a81569ab7259fa633dcc50ab77f9a | 2026-01-05T07:10:08.240928Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/setup.py | setup.py | # Copyright (c) Alibaba, Inc. and its affiliates.
# !/usr/bin/env python
import os
from setuptools import find_packages, setup
from typing import List
def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return content
version_file = 'swift/version.py'
def get_version():... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/benchmark/exp.py | scripts/benchmark/exp.py | # Copyright (c) Alibaba, Inc. and its affiliates.
import argparse
import os
import os.path
from exp_utils import ExpManager, find_all_config
from swift.utils import *
logger = get_logger()
def parse_args():
parser = argparse.ArgumentParser(description='Simple args for swift experiments.')
parser.add_argume... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/benchmark/generate_report.py | scripts/benchmark/generate_report.py | # Copyright (c) Alibaba, Inc. and its affiliates.
import dataclasses
import os
from dataclasses import dataclass
from typing import Any, Dict, List
import json
import numpy as np
from swift.utils.utils import split_str_parts_by
@dataclass
class ModelOutput:
group: str = None
name: str = None
cmd: str... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/benchmark/deploy.py | scripts/benchmark/deploy.py | def test_benchmark(infer_backend: str) -> None:
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
os.environ['TIMEOUT'] = '-1'
import requests
from swift.llm import DeployArguments, get_dataset, get_model_list_client, XRequestConfig, inference_client_async
from swift.llm.deploy import llm_deplo... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/benchmark/exp_utils.py | scripts/benchmark/exp_utils.py | import os
import shutil
import subprocess
import time
from collections import deque
from copy import deepcopy
from dataclasses import asdict, dataclass, field
from typing import Any, Dict, List
import json
import torch
from swift.llm import ExportArguments
from swift.utils import get_logger
from swift.utils.torch_uti... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/benchmark/test_memory_time/run_single.py | scripts/benchmark/test_memory_time/run_single.py | import time
from dataclasses import dataclass, field
from typing import *
import numpy as np
import torch
from swift.llm import sft_main
from swift.llm.utils import *
from swift.utils import *
@dataclass
class TrainArguments(SftArguments):
run_time: int = 1
global_seed: int = 42
def __post_init__(self)... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/benchmark/test_memory_time/run_loop.py | scripts/benchmark/test_memory_time/run_loop.py | # CUDA_VISIBLE_DEVICES=0 nohup python scripts/benchmark/test_memory_time/run_loop.py &> 0.out &
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import subprocess
from typing import List
from swift.utils import read_from_jsonl, write_to_jsonl
def test_memory_time_loop(train_kwargs_jsonl: str) -> None:
while... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/tests/test_readme.py | scripts/tests/test_readme.py | import os
import re
import torch
from modelscope import snapshot_download
from swift.llm import MODEL_MAPPING
def test_readme():
for model_type in MODEL_MAPPING.keys():
model_id = MODEL_MAPPING[model_type]['model_id_or_path']
model_dir = snapshot_download(model_id, revision='master')
rea... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/tests/test_vllm.py/main.py | scripts/tests/test_vllm.py/main.py | import os
import subprocess
from swift.llm import ModelType
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
if __name__ == '__main__':
model_name_list = ModelType.get_model_name_list()
success_model_list = []
fpath = os.path.join(os.path.dirname(__file__), 'utils.py')
for model_name in model_name_list:
... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/tests/test_vllm.py/utils.py | scripts/tests/test_vllm.py/utils.py | from dataclasses import dataclass
from swift.llm import get_default_template_type, get_template, get_vllm_engine, inference_vllm
from swift.utils import get_main
@dataclass
class VLLMTestArgs:
model_type: str
def test_vllm(args: VLLMTestArgs) -> None:
model_type = args.model_type
llm_engine = get_vllm_... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/utils/plot_loss.py | scripts/utils/plot_loss.py | import os
from swift.utils import plot_images
ckpt_dir = 'output/xxx/vx-xxx'
if __name__ == '__main__':
images_dir = os.path.join(ckpt_dir, 'images')
tb_dir = os.path.join(ckpt_dir, 'runs')
plot_images(images_dir, tb_dir, ['train/loss'], 0.9)
| python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/utils/run_template.py | scripts/utils/run_template.py | from swift.llm import TemplateType
if __name__ == '__main__':
template_name_list = TemplateType.get_template_name_list()
tn_gen = ', '.join([tn for tn in template_name_list if 'generation' in tn])
tn_chat = ', '.join([tn for tn in template_name_list if 'generation' not in tn])
print(f'Text Generation: ... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/utils/run_dataset_info.py | scripts/utils/run_dataset_info.py | import os
from datasets import concatenate_datasets
from swift.llm import (DATASET_MAPPING, DatasetName, ModelType, dataset_map, get_dataset, get_default_template_type,
get_model_tokenizer, get_template)
from swift.utils import stat_array
def write_dataset_info() -> None:
fpaths = ['docs/... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/scripts/utils/run_model_info.py | scripts/utils/run_model_info.py | from typing import Any, List
from swift.llm import MODEL_MAPPING, ModelType, get_default_lora_target_modules
def get_model_info_table():
fpaths = ['docs/source/Instruction/支持的模型和数据集.md', 'docs/source_en/Instruction/Supported-models-datasets.md']
end_words = [['### 多模态大模型', '## 数据集'], ['### MLLM', '## Dataset... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
wyczzy/AIGI-Holmes | https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/multi-node/test_scr.py | multi-node/test_scr.py | import torch
import torch.distributed as dist
import os
def test_all_reduce():
dist.init_process_group(
backend="nccl",
init_method="env://",
rank=int(os.environ["RANK"]),
world_size=int(os.environ["WORLD_SIZE"]),
)
tensor = torch.ones(1).cuda()
dist.all_reduce(tensor)
... | python | Apache-2.0 | bae30b9e807230255a9f3fd18c9c64c08805b427 | 2026-01-05T07:09:55.123229Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.