repo_id
stringlengths
15
86
file_path
stringlengths
28
180
content
stringlengths
1
1.75M
__index_level_0__
int64
0
0
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/test_rag_new_features.sh
export PYTHONPATH="../":"${PYTHONPATH}" python use_own_knowledge_dataset.py ray start --head python finetune_rag.py \ --model_name_or_path facebook/rag-token-base \ --model_type rag_token \ --context_encoder_name facebook/dpr-ctx_encoder-multiset-base \ --fp16 \ --gpus 1 \ --profile \ --e...
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/test_finetune.sh
# Add parent directory to python path to access lightning_base.py export PYTHONPATH="../":"${PYTHONPATH}" #creates the custom knowlegebase python use_own_knowledge_dataset.py # Start a single-node Ray cluster. ray start --head # A sample finetuning run, you need to specify data_dir, output_dir and model_name_or_pat...
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/dummy-kb/my_knowledge_dataset.csv
Aaron Aaron Aaron ( or ; "Ahärôn") is a prophet, high priest, and the brother of Moses in the Abrahamic religions. Knowledge of Aaron, along with his brother Moses, comes exclusively from religious texts, such as the Bible and Quran. The Hebrew Bible relates that, unlike Moses, who grew up in the Egyptian royal court, ...
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/dummy-train-data/train.target
to a snake Moses' assistant Egyptian royal court let his rod turn in to a snake The Pokémon Company Nintendo world's top-selling toy brand, the top-selling trading card game over 20 seasons to a snake Moses' assistant Egyptian royal court let his rod turn in to a snake The Pokémon Company Nintendo world's top-selling...
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/dummy-train-data/val.source
What does Moses' rod turn into ? Who is Aron? Where did Moses grow up ? What happens at the command of the Moses ? Who manages the Pokémon ? Who owned the Pokémon trademark ? What else include in Pokémon franchise ? How many seasons in Pokémon animme series ?
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/dummy-train-data/val.target
to a snake Moses' assistant Egyptian royal court let his rod turn in to a snake The Pokémon Company Nintendo world's top-selling toy brand, the top-selling trading card game over 20 seasons
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/dummy-train-data/test.target
to a snake Moses' assistant Egyptian royal court let his rod turn in to a snake The Pokémon Company Nintendo world's top-selling toy brand, the top-selling trading card game over 20 seasons
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/dummy-train-data/train.source
What does Moses' rod turn into ? Who is Aron? Where did Moses grow up ? What happens at the command of the Moses ? Who manages the Pokémon ? Who owned the Pokémon trademark ? What else include in Pokémon franchise ? How many seasons in Pokémon animme series ? What does Moses' rod turn into ? Who is Aron? Where did Mose...
0
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run
hf_public_repos/transformers/examples/research_projects/rag-end2end-retriever/test_run/dummy-train-data/test.source
What does Moses' rod turn into ? Who is Aron? Where did Moses grow up ? What happens at the command of the Moses ? Who manages the Pokémon ? Who owned the Pokémon trademark ? What else include in Pokémon franchise ? How many seasons in Pokémon animme series ?
0
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/information-gain-filtration/requirements.txt
matplotlib numpy>=1.17.2 joblib>=0.13.2 scipy torch>=1.10.1 transformers>=3.5
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/information-gain-filtration/README.md
# Information Gain Filtration(IGF) Authors @Tuko @mraunak This folder contains the code how to implement IGF for finetuning on GPT-2. ## What is IGF? Here we present a general fine-tuning method that we call information gain filtration for improving the overall training efficiency and final performance of language...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects/information-gain-filtration
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/requirements.txt
transformers datasets torch>=1.5.0 torchaudio jiwer==2.2.0 lang-trans==0.6.0 librosa==0.8.0
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/run_common_voice.py
#!/usr/bin/env python3 import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from tr...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/finetune_base_timit_asr.sh
#!/usr/bin/env bash python run_asr.py \ --output_dir="./wav2vec2-base-timit-asr" \ --num_train_epochs="30" \ --per_device_train_batch_size="20" \ --per_device_eval_batch_size="20" \ --evaluation_strategy="steps" \ --save_steps="500" \ --eval_steps="100" \ --logging_steps="50" \ --learning_rate="5e-4" \ --warmup_steps="...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/README.md
**NOTE**: This example is outdated and is not longer actively maintained. Please follow the new instructions of fine-tuning Wav2Vec2 [here](https://github.com/huggingface/transformers/blob/main/examples/pytorch/speech-recognition/README.md) ## Fine-tuning Wav2Vec2 The `run_asr.py` script allows one to fine-tune pret...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/alignment.py
# Parts of the code are adapted from the snippets provided in the TorchAudio Wav2Vec forced alignment tutorial. # The full tutorial can be found here: https://pytorch.org/audio/stable/tutorials/forced_alignment_tutorial.html import argparse import os from dataclasses import dataclass import torch import torchaudio fr...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/test_wav2vec2_deepspeed.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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/run_pretrain.py
#!/usr/bin/env python3 import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, ...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/finetune_large_lv60_100.sh
#!/usr/bin/env bash python run_asr.py \ --output_dir="./wav2vec2-large-lv60-100h" \ --num_train_epochs="30" \ --per_device_train_batch_size="16" \ --per_device_eval_batch_size="16" \ --evaluation_strategy="steps" \ --save_total_limit="3" \ --save_steps="500" \ --eval_steps="100" \ --logging_steps="50" \ --learning_rate...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/run_asr.py
#!/usr/bin/env python3 import logging import pathlib import re import sys from dataclasses import dataclass, field from typing import Any, Callable, Dict, List, Optional, Set, Union import datasets import librosa import numpy as np import torch from lang_trans import arabic from packaging import version from torch imp...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/finetune_large_xlsr_53_arabic_speech_corpus.sh
#!/usr/bin/env bash python run_asr.py \ --output_dir="./wav2vec2-large-xlsr-53-arabic-speech-corpus" \ --num_train_epochs="50" \ --per_device_train_batch_size="1" \ --per_device_eval_batch_size="1" \ --gradient_accumulation_steps="8" \ --evaluation_strategy="steps" \ --save_steps="500" \ --eval_steps="100" \ --logging_...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/finetune_wav2vec2_xlsr_turkish.sh
#!/usr/bin/env bash python run_common_voice.py \ --model_name_or_path="facebook/wav2vec2-large-xlsr-53" \ --dataset_config_name="tr" \ --output_dir=./wav2vec2-large-xlsr-turkish-demo \ --overwrite_output_dir \ --num_train_epochs="5" \ --per_device_train_batch_size="16" \ --evaluation_strateg...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/FINE_TUNE_XLSR_WAV2VEC2.md
# Fine-Tuning week of XLSR-Wav2Vec2 on 60 languages 🌍 Welcome to the fine-tuning week! The goal of this week is to have state-of-the-art automatic speech recognition (ASR) models in as many languages as possible. The fine-tuning week ends on Friday, the 26th March at midnight PST time. Participants are encouraged to...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/ds_config_wav2vec2_zero2.json
{ "fp16": { "enabled": "auto", "loss_scale": 0, "loss_scale_window": 1000, "initial_scale_power": 16, "hysteresis": 2, "min_loss_scale": 1 }, "optimizer": { "type": "AdamW", "params": { "lr": "auto", "betas": "auto", ...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/ds_config_wav2vec2_zero3.json
{ "fp16": { "enabled": "auto", "loss_scale": 0, "loss_scale_window": 1000, "initial_scale_power": 16, "hysteresis": 2, "min_loss_scale": 1 }, "optimizer": { "type": "AdamW", "params": { "lr": "auto", "betas": "auto", ...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/finetune_large_lv60_timit_asr.sh
#!/usr/bin/env bash python run_asr.py \ --output_dir="./wav2vec2-large-lv60-timit-asr" \ --num_train_epochs="30" \ --per_device_train_batch_size="2" \ --per_device_eval_batch_size="2" \ --gradient_accumulation_steps="4" \ --evaluation_strategy="steps" \ --save_steps="500" \ --eval_steps="100" \ --logging_steps="50" \ -...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/run_alignment.sh
#!/usr/bin/env bash python alignment.py \ --model_name="arijitx/wav2vec2-xls-r-300m-bengali" \ --wav_dir="./wavs" \ --text_file="script.txt" \ --input_wavs_sr=48000 \ --output_dir="./out_alignment" \ --cuda
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/wav2vec2/finetune_base_100.sh
#!/usr/bin/env bash python run_asr.py \ --output_dir="./wav2vec2-base-100h" \ --num_train_epochs="30" \ --per_device_train_batch_size="32" \ --per_device_eval_batch_size="32" \ --evaluation_strategy="steps" \ --save_total_limit="3" \ --save_steps="500" \ --eval_steps="100" \ --logging_steps="50" \ --learning_rate="5e-4...
0
hf_public_repos/transformers/examples/research_projects/wav2vec2
hf_public_repos/transformers/examples/research_projects/wav2vec2/vocab/buckwalter.json
{ "<pad>": 0, "<s>": 1, "</s>": 2, "<unk>": 3, "/": 4, "'": 5, "|": 6, ">": 7, "&": 8, "<": 9, "}": 10, "A": 11, "b": 12, "p": 13, "t": 14, "v": 15, "j": 16, "H": 17, "x": 18, "d": 19, "*": 20, "r": 21, "z": 22, "s": 23, ...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/decision_transformer/requirements.txt
absl-py==1.0.0 aiohttp==3.8.5 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==22.1.0 boto3==1.16.34 bo...
0
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/layoutlmv3/requirements.txt
datasets seqeval pillow
0
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/mlm_wwm/requirements.txt
datasets >= 1.1.3 sentencepiece != 0.1.92 protobuf ltp
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/mlm_wwm/README.md
<!--- 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 applicable law or ...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/mlm_wwm/run_chinese_ref.py
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def _is_chinese_char(cp): """Checks whether CP is the codepoint of a CJK character.""" # This defines a "chinese character" as anything in the CJK Unicode block: #...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/mlm_wwm/run_mlm_wwm.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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/jax-projects/README.md
# Flax/JAX community week 🤗 Welcome to the Flax/JAX community week! The goal of this week is to make compute-intensive NLP and CV projects (like pre-training BERT, GPT2, CLIP, ViT) practicable for a wider audience of engineers and researchers. To do so, we will try to teach **you** how to effectively use JAX/Flax o...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/jax-projects/HOW_TO_PROPOSE_PROJECT.md
# How to propose a Flax/JAX + Transformers project Great that you've opened this document! While we at 🤗 are proposing a couple of projects, we strongly believe that the community can come up with much more **creative**, **fun**, and **impactful** projects on their own. This being said, we are really looking forw...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/big_bird/requirements.txt
git+https://github.com/huggingface/transformers@main datasets sentencepiece wandb flax jsonlines
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/big_bird/README.md
Author: [@vasudevgupta7](https://github.com/thevasudevgupta/) ## Intro In this project, we fine-tuned [**BigBird**](https://arxiv.org/abs/2007.14062) on [**natural-questions**](https://huggingface.co/datasets/natural_questions) dataset for **question-answering** task on long documents. **BigBird**, is a **sparse-att...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/big_bird/prepare_natural_questions.py
import os import jsonlines import numpy as np from tqdm import tqdm DOC_STRIDE = 2048 MAX_LENGTH = 4096 SEED = 42 PROCESS_TRAIN = os.environ.pop("PROCESS_TRAIN", "false") CATEGORY_MAPPING = {"null": 0, "short": 1, "long": 2, "yes": 3, "no": 4} def _get_single_answer(example): def choose_first(answer, is_long_a...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/big_bird/bigbird_flax.py
import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import from_bytes, to_bytes from...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/big_bird/sweep_flax.yaml
command: - python3 - train.py method: random parameters: lr: values: [4e-5, 3e-5] warmup_steps: values: [20000, 15000, 10000, 5000] weight_decay: distribution: normal mu: 1e-2 sigma: 2e-3 metric: ...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/big_bird/evaluate.py
import jax import jax.numpy as jnp from bigbird_flax import FlaxBigBirdForNaturalQuestions from datasets import load_from_disk from transformers import BigBirdTokenizerFast CATEGORY_MAPPING = {0: "null", 1: "short", 2: "long", 3: "yes", 4: "no"} PUNCTUATION_SET_TO_EXCLUDE = set("".join(["‘", "’", "´", "`", ".", ",",...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/big_bird/train.py
import os from dataclasses import replace import jax import wandb from bigbird_flax import Args, DataCollator, FlaxBigBirdForNaturalQuestions, Trainer, build_tx, train_step, val_step from datasets import load_dataset from flax import jax_utils from transformers import BigBirdTokenizerFast if __name__ == "__main__":...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/dataset-streaming/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 ...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/dataset-streaming/run_mlm_flax_stream.py
#!/usr/bin/env python # coding=utf-8 # 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-...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/hybrid_clip/requirements.txt
jax>=0.2.8 jaxlib>=0.1.59 flax>=0.3.5 optax>=0.0.8 -f https://download.pytorch.org/whl/torch_stable.html torch==1.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html torchvision==0.10.0+cpu
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/hybrid_clip/configuration_hybrid_clip.py
import copy from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging logger = logging.get_logger(__name__) class HybridCLIPConfig(PretrainedConfig): r""" :class:`HybridCLIPConfig` is the configuration class to store the configuration of a :class:`~HybridCLIPM...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/hybrid_clip/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 ...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/hybrid_clip/modeling_hybrid_clip.py
# coding=utf-8 # 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 requir...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/hybrid_clip/run_hybrid_clip.py
#!/usr/bin/env python # coding=utf-8 # 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-...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/model_parallel/run_clm_mp.py
#!/usr/bin/env python # coding=utf-8 # 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-...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/model_parallel/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 ...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/model_parallel/partitions.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The Google Research Authors and 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://...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/wav2vec2/README.md
# Wav2Vec2 Contrastive Loss PreTraining examples The following example showcases how to pretrain a wav2vec2 model using the JAX/Flax backend. Pretraining Wav2Vec2 is rather complex, so it is highly recommended to read the [official paper](https://arxiv.org/abs/2006.11477). JAX/Flax allows you to trace pure functions...
0
hf_public_repos/transformers/examples/research_projects/jax-projects
hf_public_repos/transformers/examples/research_projects/jax-projects/wav2vec2/run_wav2vec2_pretrain_flax.py
#!/usr/bin/env python3 import logging import sys import time from dataclasses import field from pathlib import Path from typing import Dict, List, Optional, Union import flax import jax import jax.numpy as jnp import librosa import numpy as np import optax from datasets import DatasetDict, load_dataset from flax impor...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/fsner/requirements.txt
transformers>=4.9.2
0
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects/fsner/src
hf_public_repos/transformers/examples/research_projects/fsner/src/fsner/__init__.py
from .model import FSNERModel from .tokenizer_utils import FSNERTokenizerUtils __all__ = ["FSNERModel", "FSNERTokenizerUtils"]
0
hf_public_repos/transformers/examples/research_projects/fsner/src
hf_public_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
hf_public_repos/transformers/examples/research_projects/fsner/src
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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 ...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/lxmert/requirements.txt
appdirs==1.4.3 argon2-cffi==20.1.0 async-generator==1.10 attrs==20.2.0 backcall==0.2.0 CacheControl==0.12.6 certifi==2023.7.22 cffi==1.14.2 chardet==3.0.4 click==7.1.2 colorama==0.4.3 contextlib2==0.6.0 cycler==0.10.0 datasets==1.0.0 decorator==4.4.2 defusedxml==0.6.0 dill==0.3.2 distlib==0.3.0 distro==1.4.0 entrypoint...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/lxmert/README.md
# LXMERT DEMO 1. make a virtualenv: ``virtualenv venv`` and activate ``source venv/bin/activate`` 2. install reqs: ``pip install -r ./requirements.txt`` 3. usage is as shown in demo.ipynb
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/lxmert/demo.ipynb
# %pip install-r requirements.txtfrom IPython.display import clear_output, Image, display import PIL.Image import io import json import torch import numpy as np from processing_image import Preprocess from visualizing_image import SingleImageViz from modeling_frcnn import GeneralizedRCNN from utils import Config import...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/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...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/zero-shot-distillation/README.md
# Zero-shot classifier distillation Author: @joeddav This script provides a way to improve the speed and memory performance of a zero-shot classifier by training a more efficient student model from the zero-shot teacher's predictions over an unlabeled dataset. The zero-shot classification pipeline uses a model pre-...
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/xtreme-s/requirements.txt
datasets >= 1.18.0 torch >= 1.5 torchaudio librosa jiwer
0
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/xtreme-s/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
hf_public_repos/transformers/examples/research_projects
hf_public_repos/transformers/examples/research_projects/xtreme-s/run_xtreme_s.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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples/research_projects
hf_public_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
hf_public_repos/transformers/examples
hf_public_repos/transformers/examples/legacy/README.md
<!--- 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 applicable law or ...
0
hf_public_repos/transformers/examples
hf_public_repos/transformers/examples/legacy/run_chinese_ref.py
#!/usr/bin/env python import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _is_chinese_char(cp): """Checks whether CP is the codepoint of a CJK character.""" # This defines a "chinese character" as anything in the CJK Unicode block: # https...
0