repo_id
stringclasses
55 values
file_path
stringlengths
42
186
content
stringlengths
1
333k
__index_level_0__
int64
0
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/seq2seq-distillation/README.md
## Sequence to Sequence Training and Evaluation This directory contains examples for finetuning and evaluating transformers on summarization and translation tasks. Author: Sam Shleifer (https://github.com/sshleifer) ### Supported Architectures - `BartForConditionalGeneration` (and anything that inherits from it) - ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/seq2seq-distillation/train_distilbart_xsum.sh
#!/usr/bin/env bash export PYTHONPATH="../":"${PYTHONPATH}" python distillation.py \ --teacher facebook/bart-large-xsum --data_dir xsum \ --tokenizer_name facebook/bart-large-xsum \ --student_decoder_layers 6 --student_encoder_layers 12 \ --freeze_encoder --freeze_embeds \ --learning_rate=3e-4 \ --do_train ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/seq2seq-distillation/train_distilbart_cnn.sh
#!/usr/bin/env bash export PYTHONPATH="../":"${PYTHONPATH}" export BS=32 export GAS=1 python finetune.py \ --learning_rate=3e-5 \ --fp16 \ --gpus 1 \ --do_train \ --do_predict \ --val_check_interval 0.25 \ --n_val 500 \ --num_train_epochs 2 \ --freeze_encoder --freeze_embeds --data...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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 ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/pplm/requirements.txt
tensorboard scikit-learn seqeval psutil sacrebleu rouge-score tensorflow_datasets pytorch-lightning matplotlib git-python==1.0.3 faiss-cpu streamlit elasticsearch nltk pandas datasets >= 1.1.3 fire pytest conllu sentencepiece != 0.1.92 protobuf transformers==3.5.1
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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 ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/pplm/README.md
# Plug and Play Language Models: a Simple Approach to Controlled Text Generation Authors: [Sumanth Dathathri](https://dathath.github.io/), [Andrea Madotto](https://andreamad8.github.io/), Janice Lan, Jane Hung, Eric Frank, [Piero Molino](https://w4nderlu.st/), [Jason Yosinski](http://yosinski.com/), and [Rosanne Liu](...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/vqgan-clip/requirements.txt
einops gradio icecream imageio lpips matplotlib more_itertools numpy omegaconf opencv_python_headless Pillow pudb pytorch_lightning PyYAML requests scikit_image scipy setuptools streamlit taming-transformers torch torchvision tqdm transformers==4.26.0 tokenizers==0.13.2 typing_extensions wandb
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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}") ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/vqgan-clip/README.md
# Simple VQGAN CLIP Author: @ErwannMillon This is a very simple VQGAN-CLIP implementation that was built as a part of the <a href= "https://github.com/ErwannMillon/face-editor"> Face Editor project </a> . This simplified version allows you to generate or edit images using text with just three lines of code. For a mo...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/mm-imdb/README.md
## MM-IMDb Based on the script [`run_mmimdb.py`](https://github.com/huggingface/transformers/blob/main/examples/research_projects/mm-imdb/run_mmimdb.py). [MM-IMDb](http://lisi1.unal.edu.co/mmimdb/) is a Multimodal dataset with around 26,000 movies including images, plots and other metadata. ### Training on MM-IMDb ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/layoutlmv3/requirements.txt
datasets seqeval pillow
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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-...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/layoutlmv3/README.md
<!--- 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-2.0 Unless required by applicable law or ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/bertabs/configuration_bertabs.py
# coding=utf-8 # Copyright 2019 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 copy of the License at # # http://www.a...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/bertabs/requirements.txt
transformers == 3.5.1 # For ROUGE nltk py-rouge
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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 ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/bertabs/README.md
# Text Summarization with Pretrained Encoders This folder contains part of the code necessary to reproduce the results on abstractive summarization from the article [Text Summarization with Pretrained Encoders](https://arxiv.org/pdf/1908.08345.pdf) by [Yang Liu](https://nlp-yang.github.io/) and [Mirella Lapata](https:...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/fsner/requirements.txt
transformers>=4.9.2
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/fsner/pyproject.toml
[build-system] requires = [ "setuptools>=57.4.0", "wheel>=0.37.0", "transformers>=4.9.2" ] build-backend = "setuptools.build_meta"
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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, ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/fsner/README.md
<p align="center"> <img src="http://sayef.tech:8082/uploads/FSNER-LOGO-2.png" alt="FSNER LOGO"> </p> <p align="center"> Implemented by <a href="https://huggingface.co/sayef"> sayef </a>. </p> ## Overview The FSNER model was proposed in [Example-Based Named Entity Recognition](https://arxiv.org/abs/2008.10570) by ...
0
mavonic_private_repos/transformers/examples/research_projects/fsner/src
mavonic_private_repos/transformers/examples/research_projects/fsner/src/fsner/__init__.py
from .model import FSNERModel from .tokenizer_utils import FSNERTokenizerUtils __all__ = ["FSNERModel", "FSNERTokenizerUtils"]
0
mavonic_private_repos/transformers/examples/research_projects/fsner/src
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects/fsner/src
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/luke/run_luke_ner_no_trainer.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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/luke/luke_utils.py
import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBase def padding_tensor(seq...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/luke/README.md
# Token classification ## PyTorch version, no Trainer Fine-tuning (m)LUKE for token classification task such as Named Entity Recognition (NER), Parts-of-speech tagging (POS) or phrase extraction (CHUNKS). You can easily customize it to your needs if you need extra processing on your datasets. It will either run on a...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/ort-infer-benchmark.py
import os import time import numpy as np import onnxruntime as ort os.environ["ORT_TENSORRT_INT8_ENABLE"] = "1" os.environ["ORT_TENSORRT_INT8_USE_NATIVE_CALIBRATION_TABLE"] = "0" os.environ["ORT_TENSORRT_ENGINE_CACHE_ENABLE"] = "1" sess_opt = ort.SessionOptions() sess_opt.graph_optimization_level = ort.GraphOptimiz...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/Dockerfile
# coding=utf-8 # Copyright 2021 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/trainer_quant_qa.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team All rights reserved. # Copyright 2021 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 copy of the License at # # htt...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/quant_trainer.py
# coding=utf-8 # Copyright 2021 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/evaluate-hf-trt-qa.py
# coding=utf-8 # Copyright 2021 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/run_quant_qa.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Team All rights reserved. # Copyright 2021 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 copy of the ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/README.md
<!--- Copyright 2021 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 copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agr...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/quantization-qdqbert/utils_qa.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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/requirements.txt
torch>=1.4.0 -e git+https://github.com/huggingface/transformers.git@352d5472b0c1dec0f420d606d16747d851b4bda8#egg=transformers knockknock>=0.1.8.1 h5py>=2.10.0 numpy>=1.18.2 scipy>=1.4.1
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/Saving_PruneBERT.ipynb
# Includes import h5py import os import json from collections import OrderedDict from scipy import sparse import numpy as np import torch from torch import nn from transformers import * os.chdir("../../")# Load fine-pruned model and quantize the model model = BertForQuestionAnswering.from_pretrained("huggingface/...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/README.md
# Movement Pruning: Adaptive Sparsity by Fine-Tuning Author: @VictorSanh *Magnitude pruning is a widely used strategy for reducing model size in pure supervised learning; however, it is less effective in the transfer learning regime that has become standard for state-of-the-art natural language processing application...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects/movement-pruning
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/emmental/configuration_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...
0
mavonic_private_repos/transformers/examples/research_projects/movement-pruning
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects/movement-pruning
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/emmental/__init__.py
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
0
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/emmental
mavonic_private_repos/transformers/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 ...
0
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/emmental
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/emmental/modules/__init__.py
from .binarizer import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer from .masked_nn import MaskedLinear
0
mavonic_private_repos/transformers/examples/research_projects/movement-pruning/emmental
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects/onnx
mavonic_private_repos/transformers/examples/research_projects/onnx/summarization/requirements.txt
torch >= 1.10
0
mavonic_private_repos/transformers/examples/research_projects/onnx
mavonic_private_repos/transformers/examples/research_projects/onnx/summarization/run_onnx_exporter.py
#!/usr/bin/env python # coding=utf-8 # Copyright The HuggingFace Team and 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.ap...
0
mavonic_private_repos/transformers/examples/research_projects/onnx
mavonic_private_repos/transformers/examples/research_projects/onnx/summarization/README.md
<!--- 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 applicable law or a...
0
mavonic_private_repos/transformers/examples/research_projects/onnx/summarization
mavonic_private_repos/transformers/examples/research_projects/onnx/summarization/bart_onnx/generation_onnx.py
import copy import itertools from typing import List, Optional, Tuple import torch import torch.nn.functional as F from transformers import BartConfig from transformers.generation import GenerationMixin def _convert_past_list_to_tuple(past_key_values): """ In Bart model, the type of past_key_values is tuple...
0
mavonic_private_repos/transformers/examples/research_projects/onnx/summarization
mavonic_private_repos/transformers/examples/research_projects/onnx/summarization/bart_onnx/reduce_onnx_size.py
""" Code to remove duplicate initializers to reduce ONNX model size. """ import os import numpy import onnx def _is_equal_tensor_proto(a, b): name_a = a.name name_b = b.name a.name = "" b.name = "" res = a == b a.name = name_a b.name = name_b return res def _node_replace_input_...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/decision_transformer/requirements.txt
absl-py==1.0.0 aiohttp==3.9.0 aiosignal==1.2.0 alembic==1.7.7 appdirs==1.4.4 APScheduler==3.9.1 arrow==1.2.2 asttokens==2.0.5 astunparse==1.6.3 async-timeout==4.0.2 attrs==21.4.0 audioread==2.1.9 autopage==0.5.0 backcall==0.2.0 backoff==1.11.1 backports.zoneinfo==0.2.1 binaryornot==0.4.4 black==24.3.0 boto3==1.16.34 bo...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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 ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/performer/sanity_script.sh
TOKENIZERS_PARALLELISM=true python run_mlm_performer.py --output_dir experiments --dataset_name wikipedia --dataset_config_name 20200501.simple --model_name_or_path bert-base-cased --tokenizer_name bert-base-cased --do_train --overwrite_output_dir --per_device_train_batch_size 4 --learning_rate 5e-4 --warmup_steps 100...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/performer/full_script.sh
TOKENIZERS_PARALLELISM=true python run_mlm_performer.py --output_dir experiments --dataset_name wikipedia --dataset_config_name 20200501.en --model_name_or_path bert-large-cased --tokenizer_name bert-large-cased --do_train --overwrite_output_dir --per_device_train_batch_size 4 --learning_rate 5e-4 --warmup_steps 100 -...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/performer/README.md
# Performer fine-tuning Example authors: @TevenLeScao, @Patrickvonplaten Paper authors: Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, David Belanger, Lucy Colwell, Adrian Weller ## Requirements `datase...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience/run_glue_with_pabee.py
# coding=utf-8 # Copyright 2020 The Google AI Language Team Authors, The HuggingFace Inc. team and Microsoft Corporation. # 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....
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience/requirements.txt
transformers == 3.5.1
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience/test_run_glue_with_pabee.py
import argparse import logging import sys from unittest.mock import patch import run_glue_with_pabee from transformers.testing_utils import TestCasePlus logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger() def get_setup_file(): parser = argparse.ArgumentParser() parser.add_argument("-f")...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience/README.md
# Patience-based Early Exit Patience-based Early Exit (PABEE) is a plug-and-play inference method for pretrained language models. We have already implemented it on BERT and ALBERT. Basically, you can make your LM faster and more robust with PABEE. It can even improve the performance of ALBERT on GLUE. The only sacrifi...
0
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience/pabee/modeling_pabee_albert.py
# coding=utf-8 # Copyright 2020 Google AI, Google Brain, the HuggingFace Inc. team and Microsoft Corporation. # # 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/lic...
0
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience
mavonic_private_repos/transformers/examples/research_projects/bert-loses-patience/pabee/modeling_pabee_bert.py
# coding=utf-8 # Copyright 2020 The Google AI Language Team Authors, The HuggingFace Inc. team and Microsoft Corporation. # 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....
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/codeparrot/requirements.txt
transformers==4.19.0 datasets==1.16.0 wandb==0.12.0 tensorboard==2.6.0 torch==1.13.1 huggingface-hub==0.1.0 git+https://github.com/huggingface/accelerate.git@3c45b6f760ad8745be9ebc9bbb26f5b04dea4abe datasketch==1.5.7 dpu_utils
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/codeparrot/README.md
# CodeParrot 🦜 <p align="center"> <img src="https://huggingface.co/datasets/lvwerra/repo-images/raw/main/code-highlighting-streamlit.png" alt="drawing" width="350"/> </p> ## What is this about? This is an open-source effort to train and evaluate code generation models. CodeParrot 🦜 is a GPT-2 model trained from ...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/examples/requirements.txt
datasets==2.3.2 transformers==4.21.1 wandb==0.13.1 evaluate==0.2.2 scikit-learn==1.1.2
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/examples/README.md
# Examples In this folder we showcase some examples to use code models for downstream tasks. ## Complexity prediction In this task we want to predict the complexity of Java programs in [CodeComplex](https://huggingface.co/datasets/codeparrot/codecomplex) dataset. Using Hugging Face `trainer`, we finetuned [multilingua...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/examples/train_complexity_predictor.py
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, TrainingArguments, ...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts/pretokenizing.py
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def tokenize(example): output = {} output["input_ids"] = tokenizer(example["content"], truncation=False)["input_ids"] output["ratio...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts/minhash_deduplication.py
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm import ...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts/preprocessing.py
import gzip import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from huggingface_hub.utils import insecure_hashlib from minhash_deduplication import deduplicate_datase...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts/bpe_training.py
from arguments import TokenizerTrainingArguments from datasets import load_dataset from tqdm import tqdm from transformers import AutoTokenizer, HfArgumentParser from transformers.models.gpt2.tokenization_gpt2 import bytes_to_unicode # Iterator for Training def batch_iterator(batch_size=10): for _ in tqdm(range(...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts/arguments.py
from dataclasses import dataclass, field from typing import Optional @dataclass class TrainingArguments: """ Configuration for training model. """ model_ckpt: Optional[str] = field( default="codeparrot/codeparrot", metadata={"help": "Model name or path of model to be trained."} ) save...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts/initialize_model.py
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration parser = HfArgumentParser(InitializationArguments) args = parser.parse_args() # Load codeparrot tokenizer trained for Python code tokenization tokenizer = AutoToke...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/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 ...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts
mavonic_private_repos/transformers/examples/research_projects/codeparrot/scripts/tests/test_deduplicate.py
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def get_dataset(): data_dict = { "repo_name": ["test_repo1", "test_repo2", "test_repo3"], "path": ["test_1.py", "test_2.py", "unit_test.py"], "content"...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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, ...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/rag-end2end-retriever/requirements.txt
faiss-cpu >= 1.7.2 datasets psutil >= 5.9.1 torch >= 1.11.0 pytorch-lightning == 1.6.4 nvidia-ml-py3 == 7.352.0 ray >= 1.13.0
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/rag-end2end-retriever/finetune_rag_ray_end2end.sh
# Sample script to finetune RAG using Ray for distributed retrieval. # Add parent directory to python path to access lightning_base.py export PYTHONPATH="../":"${PYTHONPATH}" #creates the custom knowlegebase python use_own_knowledge_dataset.py \ --csv_path /DIR/SQUAD-KB/squad-kb.csv \ --output_dir /DIR/SQUA...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/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...
0
mavonic_private_repos/transformers/examples/research_projects
mavonic_private_repos/transformers/examples/research_projects/rag-end2end-retriever/kb_encode_utils.py
import os from functools import partial from glob import glob import faiss from datasets import Features, Sequence, Value, concatenate_datasets, load_dataset, load_from_disk from transformers import DPRContextEncoder, DPRContextEncoderTokenizerFast def split_text(text, n=100, character=" "): """Split the text e...
0