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 |
|---|---|---|---|---|---|---|
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/dataset.py | from __future__ import annotations
import torch
import torch.nn.functional as F
from glob import glob
from typing import Literal, List
from pedalboard.io import ReadableAudioFile
from torch.utils.data import Dataset
from tfcrnn.utils import mkpath
from tfcrnn.config import Config
CLASSES = ['backward', 'bed', 'bird'... | 3,763 | 30.630252 | 120 | py |
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/models/blocks/tf_blocks.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
from .plain_blocks import BasicBlock
class TFBasicBlock(nn.Module):
def __init__(self, in_channels, out_channels, hidden_size, amp_rate):
super().__init__()
self.base_block = BasicBlock(in_channels, out_ch... | 3,213 | 36.372093 | 87 | py |
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/models/blocks/plain_blocks.py | import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
class BasicBlock(nn.Sequential):
def __init__(self, in_channels, out_channels):
super().__init__()
self.add_module('conv', nn.Conv1d(in_channels, out_channels, 3, 1, 1))
self.add_module('norm', nn.BatchNorm1d(out_c... | 2,546 | 35.385714 | 85 | py |
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/models/skeletons/crnn.py | from __future__ import annotations
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
from tfcrnn.config import Config
from ..blocks import BasicBlock, SEBlock, ResSEBlock
class CRNN(nn.Module):
def __init__(self, config: Config):
super(CRNN, sel... | 3,438 | 35.2 | 106 | py |
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/models/skeletons/cnn.py | from __future__ import annotations
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
from tfcrnn.config import Config
from ..blocks import BasicBlock, SEBlock, ResSEBlock
class CNN(nn.Module):
def __init__(self, config: Config):
super(CNN, self)... | 3,175 | 36.364706 | 115 | py |
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/models/skeletons/tf_crnn.py | from __future__ import annotations
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
from tfcrnn.config import Config
from ..blocks import TFBasicBlock, TFSEBlock, TFResSEBlock
class TFCRNN(nn.Module):
def __init__(self, config: Config):
super(T... | 3,636 | 35.009901 | 119 | py |
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/runners/speech_commands_runner.py | from __future__ import annotations
import os
import wandb
import torch
import torch.nn.functional as F
from collections import OrderedDict
from tqdm import tqdm
from torch.utils.data import DataLoader
from tfcrnn.config import Config
from tfcrnn.dataset import SpeechCommandsDataset
from .base_runner import BaseRunner... | 3,649 | 28.918033 | 72 | py |
temporal-feedback-crnn | temporal-feedback-crnn-main/tfcrnn/runners/base_runner.py | from __future__ import annotations
import numpy as np
import os
import abc
import wandb
import torch
import torch.optim as optim
import torch.nn.functional as F
from torch.optim.lr_scheduler import ReduceLROnPlateau
from tfcrnn.models import CNN, CRNN, TFCRNN
from tfcrnn.config import Config
from tfcrnn.utils import ... | 5,233 | 32.33758 | 118 | py |
switchprompt | switchprompt-main/training/trainer_exp.py | """ Utility classes and functions related to SwitchPrompt (EACL 2023).
Copyright (c) 2022 Robert Bosch GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
... | 25,340 | 48.015474 | 130 | py |
switchprompt | switchprompt-main/model/sequence_classification.py | """ Utility classes and functions related to SwitchPrompt (EACL 2023).
Copyright (c) 2022 Robert Bosch GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
... | 15,176 | 38.626632 | 140 | py |
switchprompt | switchprompt-main/model/prefix_encoder.py | """ Utility classes and functions related to SwitchPrompt (EACL 2023).
Copyright (c) 2022 Robert Bosch GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
... | 5,075 | 51.329897 | 132 | py |
switchprompt | switchprompt-main/tasks/clinic/dataset.py | """ Utility classes and functions related to SwitchPrompt (EACL 2023).
Copyright (c) 2022 Robert Bosch GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
... | 5,412 | 42.304 | 139 | py |
reinforced-genetic-algorithm | reinforced-genetic-algorithm-main/RGA.py | '''
- import and config
- policy network
- for i in 1,...,generation
- crossover
- RGA use policy network to select ligand ***
- crossover
- docking
- RGA update policy network ***
- mutation
- RGA use policy network to select ligand ***
- mutation
- docking
- RGA update policy network ***
-... | 53,684 | 42.329298 | 204 | py |
reinforced-genetic-algorithm | reinforced-genetic-algorithm-main/demo_docking.py | import argparse
PARSER = argparse.ArgumentParser()
# Allows the run commands to be submitted via a .json file.
PARSER.add_argument(
"--json",
"-j",
metavar="param.json",
help="Name of a json file containing all parameters. \
Overrides other arguments.",
)
# Allows the run in debug mode. Doesn't d... | 37,208 | 35.055233 | 131 | py |
reinforced-genetic-algorithm | reinforced-genetic-algorithm-main/model.py | import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from rdkit import Chem, DataStructs
from rdkit.Chem import AllChem, Descriptors
def smiles2fp(smiles_string):
mol = Chem.MolFromSmiles(smiles_string)
Chem.SanitizeMol(mol)
fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2,... | 12,570 | 33.535714 | 133 | py |
reinforced-genetic-algorithm | reinforced-genetic-algorithm-main/run.py | import argparse
PARSER = argparse.ArgumentParser()
# Allows the run commands to be submitted via a .json file.
PARSER.add_argument(
"--json",
"-j",
metavar="param.json",
help="Name of a json file containing all parameters. \
Overrides other arguments.",
)
# Allows the run in debug mode. Doesn't d... | 32,721 | 33.553326 | 131 | py |
reinforced-genetic-algorithm | reinforced-genetic-algorithm-main/autogrow/model.py | import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from rdkit import Chem, DataStructs
from rdkit.Chem import AllChem, Descriptors
def smiles2fp(smiles_string):
mol = Chem.MolFromSmiles(smiles_string)
Chem.SanitizeMol(mol)
fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2, nB... | 2,365 | 24.170213 | 72 | py |
reinforced-genetic-algorithm | reinforced-genetic-algorithm-main/autogrow/autogrow_main_execute.py | """
Top level for running AutoGrow.
Runs all population generation (operations) and docking.
Runs plotting at end.
"""
import __future__
import os
import glob
import sys
import shutil
import autogrow.docking.execute_docking as DockingClass
import autogrow.operators.operations as operations
import autogrow.docking.con... | 15,174 | 40.236413 | 250 | py |
transformers | transformers-main/conftest.py | # Copyright 2020 The HuggingFace Team. 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 3,232 | 36.16092 | 113 | py |
transformers | transformers-main/setup.py | # Copyright 2021 The HuggingFace Team. 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 15,948 | 33.447084 | 157 | py |
transformers | transformers-main/hubconf.py | # Copyright 2020 The HuggingFace Team. 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 8,496 | 51.450617 | 189 | py |
transformers | transformers-main/examples/run_on_remote.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. 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 copy of the License at
#
# http://www.apache.org/licenses/LI... | 3,649 | 49.694444 | 125 | py |
transformers | transformers-main/examples/research_projects/longform-qa/eli5_app.py | import datasets
import faiss
import numpy as np
import streamlit as st
import torch
from elasticsearch import Elasticsearch
from eli5_utils import (
embed_questions_for_retrieval,
make_qa_s2s_model,
qa_s2s_generate,
query_es_index,
query_qa_dense_index,
)
import transformers
from transformers impor... | 13,474 | 37.28125 | 159 | py |
transformers | transformers-main/examples/research_projects/longform-qa/eli5_utils.py | import functools
import math
import os # noqa: F401
from random import choice, randint
from time import time
import datasets # noqa: F401
import faiss # noqa: F401
import numpy as np
import pandas as pd
import torch
import torch.utils.checkpoint as checkpoint
from elasticsearch import Elasticsearch # noqa: F401
fr... | 28,240 | 39.988389 | 119 | py |
transformers | transformers-main/examples/research_projects/codeparrot/scripts/codeparrot_training.py | import logging
import os
import time
from argparse import Namespace
from pathlib import Path
import datasets
import torch
from accelerate import Accelerator, DistributedType
from accelerate.utils import ProjectConfiguration
from arguments import TrainingArguments
from datasets import load_dataset
from huggingface_hub ... | 12,979 | 38.452888 | 116 | py |
transformers | transformers-main/examples/research_projects/codeparrot/scripts/validation_loss.py | import logging
import torch
from accelerate import Accelerator
from arguments import EvaluationArguments
from datasets import load_dataset
from torch.utils.data import IterableDataset
from torch.utils.data.dataloader import DataLoader
from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, set... | 3,496 | 33.97 | 114 | py |
transformers | transformers-main/examples/research_projects/codeparrot/scripts/human_eval.py | import json
import multiprocessing
import os
import re
from collections import defaultdict
import torch
from accelerate import Accelerator
from accelerate.utils import set_seed
from arguments import HumanEvalArguments
from datasets import load_dataset, load_metric
from torch.utils.data import IterableDataset
from torc... | 9,004 | 38.323144 | 118 | py |
transformers | transformers-main/examples/research_projects/self-training-text-classification/selftraining.py | # coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# 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
#
# Unless required by applicab... | 16,963 | 42.609254 | 119 | py |
transformers | transformers-main/examples/research_projects/self-training-text-classification/finetuning.py | # coding=utf-8
# Copyright 2022 The Google Research Authors.
#
# 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
#
# Unless required by applicab... | 34,604 | 41.616995 | 119 | py |
transformers | transformers-main/examples/research_projects/bertology/run_prune_gpt.py | #!/usr/bin/env python3
""" This script is adapted from the Bertology pruning code (https://github.com/huggingface/transformers/blob/783d7d2629e97c5f0c5f9ef01b8c66410275c204/examples/research_projects/bertology/run_bertology.py)
to prune GPT-like models. The author is @altsoph.
"""
import argparse
import logging
import... | 15,491 | 38.520408 | 204 | py |
transformers | transformers-main/examples/research_projects/bertology/run_bertology.py | #!/usr/bin/env python3
# Copyright 2018 CMU 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
#
# Unless requir... | 18,594 | 40.048565 | 118 | py |
transformers | transformers-main/examples/research_projects/rag/use_own_knowledge_dataset.py | import logging
import os
from dataclasses import dataclass, field
from functools import partial
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import List, Optional
import faiss
import torch
from datasets import Features, Sequence, Value, load_dataset
from transformers import (
DPRCo... | 8,256 | 38.507177 | 144 | py |
transformers | transformers-main/examples/research_projects/rag/utils_rag.py | import itertools
import json
import linecache
import os
import pickle
import re
import socket
import string
from collections import Counter
from logging import getLogger
from pathlib import Path
from typing import Callable, Dict, Iterable, List
import git
import torch
from torch.utils.data import Dataset
from transfo... | 8,107 | 32.093878 | 118 | py |
transformers | transformers-main/examples/research_projects/rag/finetune_rag.py | """Finetuning script for RAG models. Adapted from examples.seq2seq.finetune.py"""
import argparse
import logging
import os
import sys
import time
from collections import defaultdict
from pathlib import Path
from typing import Any, Dict, List, Tuple
import numpy as np
import pytorch_lightning as pl
import torch
import... | 26,194 | 39.3 | 119 | py |
transformers | transformers-main/examples/research_projects/rag/distributed_pytorch_retriever.py | import logging
import os
from typing import List, Tuple
import numpy as np
import psutil
import torch
import torch.distributed as dist
from transformers import RagRetriever
logger = logging.getLogger(__name__)
class RagPyTorchDistributedRetriever(RagRetriever):
"""
A distributed retriever built on top of ... | 6,539 | 46.05036 | 155 | py |
transformers | transformers-main/examples/research_projects/rag/test_distributed_retriever.py | import json
import os
import shutil
import sys
import tempfile
import unittest
from unittest import TestCase
from unittest.mock import patch
import faiss
import numpy as np
from datasets import Dataset
from transformers import BartConfig, BartTokenizer, DPRConfig, DPRQuestionEncoderTokenizer, RagConfig
from transform... | 13,794 | 39.693215 | 118 | py |
transformers | transformers-main/examples/research_projects/rag/eval_rag.py | """ Evaluation script for RAG models."""
import argparse
import ast
import logging
import os
import sys
import pandas as pd
import torch
from tqdm import tqdm
from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration
from transformers import logging as trans... | 11,211 | 33.928349 | 119 | py |
transformers | transformers-main/examples/research_projects/rag/lightning_base.py | import argparse
import logging
import os
from pathlib import Path
from typing import Any, Dict
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info
from transformers import (
AdamW,
AutoConfig,
AutoModel,
AutoModelForPreTraining,
AutoModelForQuestionAnswering,
... | 15,639 | 37.617284 | 124 | py |
transformers | transformers-main/examples/research_projects/rag/callbacks_rag.py | import logging
from pathlib import Path
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
from pytorch_lightning.utilities import rank_zero_only
from utils_rag import save_json
def count_trainable_parameters(model):
model_paramet... | 4,442 | 36.974359 | 116 | py |
transformers | transformers-main/examples/research_projects/rag/_test_finetune_rag.py | import json
import logging
import os
import sys
from pathlib import Path
import finetune_rag
from transformers.file_utils import is_apex_available
from transformers.testing_utils import (
TestCasePlus,
execute_subprocess_async,
require_ray,
require_torch_gpu,
require_torch_multi_gpu,
)
logging.b... | 3,954 | 34.3125 | 85 | py |
transformers | transformers-main/examples/research_projects/pplm/run_pplm.py | #! /usr/bin/env python3
# coding=utf-8
# Copyright (c) 2019 Uber Technologies, 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.org/licenses/LICENSE-2.0
#
# Unless ... | 29,007 | 34.203883 | 182 | py |
transformers | transformers-main/examples/research_projects/pplm/run_pplm_discrim_train.py | #! /usr/bin/env python3
# coding=utf-8
# Copyright (c) 2019 Uber Technologies, 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.org/licenses/LICENSE-2.0
#
# Unless ... | 18,797 | 34.874046 | 117 | py |
transformers | transformers-main/examples/research_projects/pplm/pplm_classification_head.py | from torch import nn
class ClassificationHead(nn.Module):
"""Classification Head for transformer encoders"""
def __init__(self, class_size, embed_size):
super().__init__()
self.class_size = class_size
self.embed_size = embed_size
# self.mlp1 = nn.Linear(embed_size, embed_size... | 651 | 31.6 | 68 | py |
transformers | transformers-main/examples/research_projects/deebert/test_glue_deebert.py | import argparse
import logging
import sys
from unittest.mock import patch
import run_glue_deebert
from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
def get_setup_file():
parser = argparse... | 3,690 | 34.152381 | 109 | py |
transformers | transformers-main/examples/research_projects/deebert/run_glue_deebert.py | from __future__ import absolute_import, division, print_function
import argparse
import glob
import logging
import os
import random
import time
import numpy as np
import torch
from torch import nn
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
from torch.utils.data.distribute... | 31,739 | 42.125 | 150 | py |
transformers | transformers-main/examples/research_projects/deebert/src/modeling_highway_bert.py | import torch
from torch import nn
from torch.nn import CrossEntropyLoss, MSELoss
from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward
from transformers.models.bert.modeling_bert import (
BERT_INPUTS_DOCSTRING,
BERT_START_DOCSTRING,
BertEmbeddings,
BertLayer,
... | 17,702 | 43.2575 | 172 | py |
transformers | transformers-main/examples/research_projects/deebert/src/modeling_highway_roberta.py | from __future__ import absolute_import, division, print_function, unicode_literals
from torch import nn
from torch.nn import CrossEntropyLoss, MSELoss
from transformers import RobertaConfig
from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward
from transformers.models.roberta... | 6,789 | 42.806452 | 172 | py |
transformers | transformers-main/examples/research_projects/layoutlmv3/run_funsd_cord.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2022 The HuggingFace Team 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-... | 21,185 | 38.674157 | 118 | py |
transformers | transformers-main/examples/research_projects/lxmert/modeling_frcnn.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2 && Huggingface Co.
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... | 73,740 | 37.366805 | 152 | py |
transformers | transformers-main/examples/research_projects/lxmert/extracting_data.py | import getopt
import json
import os
# import numpy as np
import sys
from collections import OrderedDict
import datasets
import numpy as np
import torch
from modeling_frcnn import GeneralizedRCNN
from processing_image import Preprocess
from utils import Config
"""
USAGE:
``python extracting_data.py -i <img_dir> -o ... | 5,244 | 33.966667 | 109 | py |
transformers | transformers-main/examples/research_projects/lxmert/utils.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal, Huggingface team :)
Adapted From Facebook Inc, Detectron2
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://w... | 18,206 | 31.805405 | 122 | py |
transformers | transformers-main/examples/research_projects/lxmert/visualizing_image.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2
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/license... | 13,420 | 25.842 | 100 | py |
transformers | transformers-main/examples/research_projects/lxmert/processing_image.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2
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/license... | 5,747 | 37.066225 | 114 | py |
transformers | transformers-main/examples/research_projects/vqgan-clip/loaders.py | import importlib
import torch
import yaml
from omegaconf import OmegaConf
from taming.models.vqgan import VQModel
def load_config(config_path, display=False):
config = OmegaConf.load(config_path)
if display:
print(yaml.dump(OmegaConf.to_container(config)))
return config
def load_vqgan(device, c... | 2,230 | 28.746667 | 108 | py |
transformers | transformers-main/examples/research_projects/vqgan-clip/VQGAN_CLIP.py | import os
from glob import glob
import imageio
import torch
import torchvision
import wandb
from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan
from loaders import load_vqgan
from PIL import Image
from torch import nn
from transformers import CLIPModel, CLIPTokenizerFast
from uti... | 11,225 | 40.732342 | 136 | py |
transformers | transformers-main/examples/research_projects/vqgan-clip/img_processing.py | import numpy as np
import PIL
import torch
import torchvision.transforms as T
import torchvision.transforms.functional as TF
from PIL import Image
def preprocess(img, target_image_size=256):
s = min(img.size)
if s < target_image_size:
raise ValueError(f"min dim for image {s} < {target_image_size}")
... | 1,194 | 22.431373 | 72 | py |
transformers | transformers-main/examples/research_projects/vqgan-clip/utils.py | from datetime import datetime
import matplotlib.pyplot as plt
import torch
def freeze_module(module):
for param in module.parameters():
param.requires_grad = False
def get_device():
device = "cuda" if torch.cuda.is_available() else "cpu"
if torch.backends.mps.is_available() and torch.backends.m... | 969 | 25.944444 | 117 | py |
transformers | transformers-main/examples/research_projects/bertabs/modeling_bertabs.py | # MIT License
# Copyright (c) 2019 Yang Liu and the HuggingFace team
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, c... | 38,255 | 35.124646 | 114 | py |
transformers | transformers-main/examples/research_projects/bertabs/convert_bertabs_original_pytorch_checkpoint.py | # coding=utf-8
# Copyright 2018 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
#
# Unless required by applicable... | 6,523 | 34.075269 | 117 | py |
transformers | transformers-main/examples/research_projects/bertabs/utils_summarization.py | import os
from collections import deque
import torch
from torch.utils.data import Dataset
# ------------
# Data loading
# ------------
class CNNDMDataset(Dataset):
"""Abstracts the dataset used to train seq2seq models.
The class will process the documents that are located in the specified
folder. The ... | 5,753 | 33.25 | 106 | py |
transformers | transformers-main/examples/research_projects/bertabs/test_utils_summarization.py | # coding=utf-8
# Copyright 2019 HuggingFace 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 4,419 | 43.646465 | 99 | py |
transformers | transformers-main/examples/research_projects/bertabs/run_summarization.py | #! /usr/bin/python3
import argparse
import logging
import os
import sys
from collections import namedtuple
import torch
from modeling_bertabs import BertAbs, build_predictor
from torch.utils.data import DataLoader, SequentialSampler
from tqdm import tqdm
from transformers import BertTokenizer
from .utils_summarizati... | 10,202 | 28.318966 | 115 | py |
transformers | transformers-main/examples/research_projects/fsner/setup.py | import setuptools
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setuptools.setup(
name="fsner",
version="0.0.1",
author="msi sayef",
author_email="msi.sayef@gmail.com",
description="Few-shot Named Entity Recognition",
long_description=long_description,
... | 864 | 29.892857 | 97 | py |
transformers | transformers-main/examples/research_projects/fsner/src/fsner/tokenizer_utils.py | import torch
from transformers import AutoTokenizer
class FSNERTokenizerUtils(object):
def __init__(self, pretrained_model_name_or_path):
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path)
def tokenize(self, x):
"""
Wrapper function for tokenizing query and... | 3,989 | 37.737864 | 182 | py |
transformers | transformers-main/examples/research_projects/fsner/src/fsner/model.py | import torch
from transformers import AutoModel
class FSNERModel(torch.nn.Module):
"""
The FSNER model implements a few-shot named entity recognition method from the paper `Example-Based Named Entity Recognition <https://arxiv.org/abs/2008.10570>`__ by
Morteza Ziyadi, Yuting Sun, Abhishek Goswami, Jade H... | 3,100 | 37.283951 | 169 | py |
transformers | transformers-main/examples/research_projects/adversarial/run_hans.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... | 8,264 | 33.012346 | 117 | py |
transformers | transformers-main/examples/research_projects/adversarial/utils_hans.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... | 11,760 | 33.591176 | 118 | py |
transformers | transformers-main/examples/research_projects/robust-speech-event/run_speech_recognition_ctc_streaming.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2022 The HuggingFace Inc. team. 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 copy of the License at
#
# http://www.apache.org/licenses/LI... | 28,211 | 40.488235 | 145 | py |
transformers | transformers-main/examples/research_projects/robust-speech-event/run_speech_recognition_ctc_bnb.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. 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 copy of the License at
#
# http://www.apache.org/licenses/LI... | 31,562 | 39.413572 | 145 | py |
transformers | transformers-main/examples/research_projects/robust-speech-event/eval.py | #!/usr/bin/env python3
import argparse
import re
from typing import Dict
import torch
from datasets import Audio, Dataset, load_dataset, load_metric
from transformers import AutoFeatureExtractor, pipeline
def log_results(result: Dataset, args: Dict[str, str]):
"""DO NOT CHANGE. This function computes and logs t... | 4,711 | 33.394161 | 147 | py |
transformers | transformers-main/examples/research_projects/performer/run_mlm_performer.py | # coding=utf-8
# Copyright 2020 The HuggingFace Team 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... | 28,738 | 40.530347 | 119 | py |
transformers | transformers-main/examples/research_projects/performer/modeling_flax_performer.py | # coding=utf-8
# Copyright 2018 The Google Flax 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
... | 21,121 | 37.264493 | 120 | py |
transformers | transformers-main/examples/research_projects/performer/modeling_flax_performer_utils.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# 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
#
# Unless required by applicab... | 25,678 | 37.966616 | 119 | py |
transformers | transformers-main/examples/research_projects/information-gain-filtration/run_clm_igf.py | # Copyright 2022 - Intel Corp. All rights reserved.
# Authors: Mayank Kumar Raunak, Javier Turek, Nicole Beckage
"""
Implementation of a new method for fine-tuning transformer models that we call
Information Gain Filtration 'IGF' on WikiText data set and compared the results
with the standard fine-tuning method
Steps... | 15,491 | 33.735426 | 150 | py |
transformers | transformers-main/examples/research_projects/information-gain-filtration/igf/igf.py | # Copyright 2022 - Intel Corp. All rights reserved.
# Authors: Mayank Kumar Raunak, Javier Turek, Nicole Backage
import copy
import logging
import random
import joblib
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from tqdm import tqdm
from transformers import AdamW, G... | 14,499 | 33.772182 | 117 | py |
transformers | transformers-main/examples/research_projects/rag-end2end-retriever/use_own_knowledge_dataset.py | import logging
import os
from dataclasses import dataclass, field
from functools import partial
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import List, Optional
import faiss
import torch
from datasets import Features, Sequence, Value, load_dataset
from transformers import DPRContextE... | 6,991 | 38.727273 | 144 | py |
transformers | transformers-main/examples/research_projects/rag-end2end-retriever/utils_rag.py | import itertools
import json
import linecache
import os
import pickle
import re
import socket
import string
from collections import Counter
from logging import getLogger
from pathlib import Path
from typing import Callable, Dict, Iterable, List
import git
import torch
from torch.utils.data import Dataset
from transfo... | 8,107 | 32.093878 | 118 | py |
transformers | transformers-main/examples/research_projects/rag-end2end-retriever/finetune_rag.py | """Finetuning script for RAG models. Adapted from examples.seq2seq.finetune.py"""
import argparse
import copy
import json
import logging
import multiprocessing
import os
import random
import shutil
import sys
import time
from collections import defaultdict
from pathlib import Path
from typing import Any, Dict, List, T... | 33,679 | 40.27451 | 159 | py |
transformers | transformers-main/examples/research_projects/rag-end2end-retriever/eval_rag.py | """ Evaluation script for RAG models."""
import argparse
import ast
import logging
import os
import sys
import pandas as pd
import torch
from tqdm import tqdm
from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration
from transformers import logging as trans... | 11,211 | 33.928349 | 119 | py |
transformers | transformers-main/examples/research_projects/rag-end2end-retriever/lightning_base.py | import argparse
import logging
import os
from pathlib import Path
from typing import Any, Dict
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info
from transformers import (
AdamW,
AutoConfig,
AutoModel,
AutoModelForPreTraining,
AutoModelForQuestionAnswering,
... | 16,089 | 37.771084 | 124 | py |
transformers | transformers-main/examples/research_projects/rag-end2end-retriever/callbacks_rag.py | import logging
from pathlib import Path
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
from pytorch_lightning.utilities import rank_zero_only
from utils_rag import save_json
def count_trainable_parameters(model):
model_paramet... | 4,473 | 36.283333 | 116 | py |
transformers | transformers-main/examples/research_projects/movement-pruning/counts_parameters.py | # Copyright 2020-present, 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
#
# Unless required by applicable law o... | 3,465 | 34.731959 | 117 | py |
transformers | transformers-main/examples/research_projects/movement-pruning/masked_run_glue.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... | 40,722 | 41.243776 | 150 | py |
transformers | transformers-main/examples/research_projects/movement-pruning/bertarize.py | # Copyright 2020-present, 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
#
# Unless required by applicable law o... | 5,156 | 36.642336 | 140 | py |
transformers | transformers-main/examples/research_projects/movement-pruning/masked_run_squad.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... | 47,877 | 40.669278 | 126 | py |
transformers | transformers-main/examples/research_projects/movement-pruning/emmental/modeling_bert_masked.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... | 47,115 | 45.056696 | 152 | py |
transformers | transformers-main/examples/research_projects/movement-pruning/emmental/modules/masked_nn.py | # coding=utf-8
# Copyright 2020-present, 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
#
# Unless required by a... | 4,506 | 41.121495 | 105 | py |
transformers | transformers-main/examples/research_projects/movement-pruning/emmental/modules/binarizer.py | # coding=utf-8
# Copyright 2020-present, AllenAI Authors, University of Illinois Urbana-Champaign,
# Intel Nervana Systems 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 ... | 5,822 | 39.158621 | 175 | py |
transformers | transformers-main/examples/research_projects/visual_bert/modeling_frcnn.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2 && Huggingface Co.
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... | 73,740 | 37.366805 | 152 | py |
transformers | transformers-main/examples/research_projects/visual_bert/extracting_data.py | import getopt
import json
import os
# import numpy as np
import sys
from collections import OrderedDict
import datasets
import numpy as np
import torch
from modeling_frcnn import GeneralizedRCNN
from processing_image import Preprocess
from utils import Config
"""
USAGE:
``python extracting_data.py -i <img_dir> -o ... | 5,244 | 33.966667 | 109 | py |
transformers | transformers-main/examples/research_projects/visual_bert/utils.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal, Huggingface team :)
Adapted From Facebook Inc, Detectron2
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://w... | 18,206 | 31.805405 | 122 | py |
transformers | transformers-main/examples/research_projects/visual_bert/visualizing_image.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2
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/license... | 13,420 | 25.842 | 100 | py |
transformers | transformers-main/examples/research_projects/visual_bert/processing_image.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2
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/license... | 5,747 | 37.066225 | 114 | py |
transformers | transformers-main/examples/research_projects/zero-shot-distillation/distill_classifier.py | import logging
import os
import sys
from dataclasses import dataclass, field
from typing import List, Optional
import torch
from datasets import Dataset
from torch import nn
from tqdm.auto import tqdm
from transformers import (
AutoModelForSequenceClassification,
AutoTokenizer,
HfArgumentParser,
Train... | 12,184 | 34.943953 | 119 | py |
transformers | transformers-main/examples/research_projects/mm-imdb/run_mmimdb.py | # coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright (c) 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... | 23,942 | 40.495667 | 123 | py |
transformers | transformers-main/examples/research_projects/mm-imdb/utils_mmimdb.py | # coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright (c) 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... | 4,586 | 30.204082 | 119 | py |
transformers | transformers-main/examples/research_projects/decision_transformer/run_decision_transformer.py | import gym
import numpy as np
import torch
from mujoco_py import GlfwContext
from transformers import DecisionTransformerModel
GlfwContext(offscreen=True) # Create a window to init GLFW.
def get_action(model, states, actions, rewards, returns_to_go, timesteps):
# we don't care about the past rewards in this m... | 5,570 | 31.017241 | 112 | py |
transformers | transformers-main/examples/research_projects/seq2seq-distillation/callbacks.py | import logging
from pathlib import Path
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
from pytorch_lightning.utilities import rank_zero_only
from utils import save_json
def count_trainable_parameters(model):
model_parameters... | 4,431 | 36.880342 | 117 | py |
transformers | transformers-main/examples/research_projects/seq2seq-distillation/run_eval.py | #!/usr/bin/env python
import argparse
import datetime
import json
import time
import warnings
from logging import getLogger
from pathlib import Path
from typing import Dict, List
import torch
from tqdm import tqdm
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
from utils import calculate_bleu, calcula... | 6,551 | 38 | 189 | py |
transformers | transformers-main/examples/research_projects/seq2seq-distillation/_test_seq2seq_examples.py | import argparse
import logging
import os
import sys
import tempfile
from pathlib import Path
import lightning_base
import pytest
import pytorch_lightning as pl
import torch
from convert_pl_checkpoint_to_hf import convert_pl_to_hf
from distillation import distill_main
from finetune import SummarizationModule, main
from... | 16,660 | 36.440449 | 115 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.